-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
9.4.3. Jump Destination Validity - "code" means data accessible by Program Counter or even non-executable data? #840
Comments
I don't see what is unclear here. Consider the code as The example code from the ropsten tx you linked: Even though the second Clients have implemented the distinction between "code" versus "data after PUSH" from genesis, it's nothing new. It is most definitely intended. The intention is to provide code which "mutates" by offsetting the execution by jumping into pushdata, and suddenly executing sequences that behave differently because of it. |
I understand your narrative. In short: The EVM is intended as a simple, unopinionated (therefore flexible) base layer with the rules of a stack machine. The stack machine rules are applied opcode by opcode. But in this above case, you add additional rules outside the concerns of the stack machine, even before the bytecode is run. Something that is intended as unexecutable data now can become code, because it contains something that is parsed like a
|
@holiman, since you have not answered, it compelled me to do a little bit of digging. And I found https://github.com/ethereum/EIPs/blob/3ca4f87938f0295a06fa07eb530b4f3cd7774fcd/EIPS/eip-3540.md, which says exactly what I say above:
Hence, our colleagues @axic, @gumb0, @chfast know very well that while code is data, not all data is code. This is very good. |
Well, I didn't answer, because I didn't know what the argument was. Are you arguing for 1. Something to be clarified in YP?2. Something to be changed in Ethereum?Your first post seemed like you saw implementations doing something wrong (ethereumjs), and I just chimed in why there's nothing wrong with what they're doing, and nothing misunderstood. I agree with the EOF eip and the separate code and data. ( nevertheless, immediate data (following push) will still be in the code-section )What is it you want to achieve?
|
@holiman
Of course, I would prefer 2). The main reason is: it is harder for the EVM to verify itself if you impose a pre-execution analysis. And it may even be a non-breaking change to fix this. |
That would require a hard-fork though. So the YP cannot be changed here.
|
Consider the following assembly code:
This translates to
0x601461000e60003960146000f3006100065600005b63eeeeeeee60005260206000f3
. If this contract is deployed and it receives a transaction/call, it returns0x00000000000000000000000000000000000000000000000000000000eeeeeeee
. An example of this execution was ran at https://ropsten.etherscan.io/tx/0x6c300851fc63bb91829041acddd49c440720ca095061f4d164e53e9abce4d781.Consider that we change the above bytecode by replacing the 2nd
stop
instruction withPUSH4
(0x63
). We obtain0x601461000e60003960146000f3006100065600635b63eeeeeeee60005260206000f3
. If this contract is deployed and it receives a transaction/call, it reverts withInvalid JUMP destination
: https://ropsten.etherscan.io/tx/0x81c674bb22b7171f1f0bd3ee98b09c35ef5e9874c7fc232821eb1b9542a363c0. This happens even though the0x63
(PUSH4
) instruction is never reachable, therefore not executable.This behavior is not obvious, not even from the description of the Yellow Paper and I doubt it is the intended behavior. Nonetheless, clients are implementing it https://github.com/ethereumjs/ethereumjs-monorepo/blob/93c4c4ad182d4b4be54b6346aab70f615fb21bb8/packages/vm/src/evm/interpreter.ts#L263-L283.
The text was updated successfully, but these errors were encountered: