I'm trying to understand state storage, and by doing so (for the first time) looking at raw geth traces. I've hit a blocker, though, which is understanding where the arguments to PUSH instructions come from.

According to evm.codes PUSH1 takes an argument and puts it on the stack. For other opcodes, such as SHA3/KECCAK256, the arguments offset and size are taken from the stack, and then it reads from memory.

But where does PUSH1 get its argument from?

  • 2
    PUSH1 gets its argument from the code of the contract, at the offset which is located at the PC + 1 . It only takes 64 bytes. Where it encounters PUSH1, it increments the PC and reads the 64 bytes (from contract code)
    – Nulik
    Feb 7, 2023 at 17:20
  • Thank you! You should add that as an answer below so I can accept it Feb 8, 2023 at 19:11
  • @Nulik That's correct, except that I think it takes a 1-byte number from the contract code (hence the 1 in PUSH1) and pushes it on the stack as a 32-byte number. Jun 19, 2023 at 9:34

1 Answer 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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