I'm looking to add some logging code to Geth.

I have a vm created with a single geth node and private blockchain running. I've deployed a smart contract to it.

I want to initiate a transaction on smart contract function and in the geth codebase I want to add some logging code before and after the EVM executes the function.

I've been looking through the code base and am unsure of where the entry and exit points of the EVM are.


Short answer (others may be able to provide more detail):

I think first you'll need to work out which EVM opcodes equate to the function call. (You could probably start by writing a very simple contract and seeing what equates to what.)

Then the place to start your instrumentation would probably be in the EVM's main (interpreter) event loop, which is here.

(The structure of the EVM itself is defined in evm.go, the instruction set is defined in instructions.go, and the opcodes are defined in opcodes.go.)

The following two articles from the same series might also be of help:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.