2

Here’s my whole program. The reasoning behind it is the larger is the program on Ethereum, the more it costs money to load it (as the gas cost is per byte and quite high).

CALLER
CALLDATASIZE
ISZERO
PUSH1 0x07
JUMPI
PUSH3 0x5b6000
SSTORE

So I’m jumping into PUSH3 0x5b6000 but if we disassemble 0x5b6000 then it means

JUMPDEST
PUSH1 0x00

So since the evm opcode encoding is fully variable length (and all instructions being one byte long beside PUSHxx) and I’m jumping into a JUMPDEST, why does this transaction fails?

Where is it specified in the yellow paper that going to a JUMPDEST isn’t the only requirement for a valid jump destination?

user2284570
  • 2,891
  • 3
  • 26
  • 74
  • **Please notice that there’s no program or tools for assembly a program completely written in Ethereum assembly.** It needs to be done completely by hand using an hex editor. – user2284570 Oct 18 '20 at 13:25
  • Why the downvote? – user2284570 Oct 18 '20 at 13:39
  • Note that this sort of jumping to the middle of instructions, while more common by the "masters" of the past, makes it incredibly hard for anyone to understand what's happening. However, the typical things to ask apply. Have you tried running it in a debugger? – Thomas Jager Oct 18 '20 at 14:55
  • @ThomasJager then it behave as in the question’s transaction link described it which is `invalid jump destination` without telling why it’s invalid. Please note that on Ethereum fees are very high compared to traditional cloud computing which is the reasoning behind having programs as short as possible. – user2284570 Oct 18 '20 at 15:22
  • It might be worth it to migrate this question to the [Ethereum StackExchange](https://ethereum.stackexchange.com). – Paul Razvan Berg Sep 03 '21 at 16:52

1 Answers1

2

I am not sure about which version of the yellow paper was available when this question was originally asked, but here is an excerpt from page 13 of the Istanbul version:

9.4.3. Jump Destination Validity. We previously used D as the function to determine the set of valid jump destinations given the code that is being run. We define this as any position in the code occupied by a JUMPDEST instruction.

All such positions must be on valid instruction boundaries, rather than sitting in the data portion of PUSH operations and must appear within the explicitly defined portion of the code (rather than in the implicitly defined STOP operations that trail it).

And here is the geth source location for the code that implements an anasysis for this.

raugfer
  • 1,844
  • 19
  • 19