1

I have a vyper contract, as such:

@external
def add_two(my_number: uint256) -> uint256:
    two: uint256 = 123456
    return my_number + two

When you compile this (with 0.3.6), a piece of the opcode output that looks like so:

PUSH3 0x1E240 
PUSH1 0x40 
MSTORE 

0x1E240 is the hex for 123456, and 0x40 will be our offset in memory when we call MSTORE, so this is the section of the opcodes responsible for the two: uint256 = 123456 piece of the vyper, and storing that value to memory.

My question though, is why didn't vyper use PUSH 0x20 instead of 0x40? I checked the rest of the code, and the first 32 bytes of memory is never written to with MSTORE or read from with MLOAD.

So why does vyper add an extra 32 bytes?

1 Answer 1

0

Vyper reserves the first two slots in memory for mainly keccak operations.

Just an implementation detail.

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.