1

When trying to load the 32 bytes of memory that follow a high offset (say 0x12345678), the RETURN and MLOAD opcodes give an out of gas error. Why is that ?

Example

PUSH1 0x20
PUSH4 0x12345678
RETURN

I would expect the result to be 0x0000...00 since the memory isn't initialized there but it appears that another operation is ran, which costs gas.

What exactly is going on here ?

1 Answer 1

1

Your RETURN code needs to access a very high memory index (very high in the context of Ethereum contracts), which costs too much gas. The higher the memory cell that's accessed, the more gas it costs: https://ethereum.stackexchange.com/a/62732/7598

Your Answer

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

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