-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Draft EIP: BEGINDATA opcode #2327
Conversation
Discussions-to: https://ethereum-magicians.org/t/new-opcode-begindata/3727 |
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
EIPS/eip-2327.md
Outdated
|
||
## Motivation | ||
<!--The motivation is critical for EIPs that want to change the Ethereum protocol. It should clearly explain why the existing protocol specification is inadequate to address the problem that the EIP solves. EIP submissions without sufficient motivation may be rejected outright.--> | ||
The `BEGINDATA` opcode has been suggested before as part of the EIP `Subroutines and Static Jumps for the EVM` [EIP-615](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-615.md) as a way to determine the position of jumptables in contract bytecode. It is here introduced in its own right in order to exclude data from the JUMPDEST analysis of contracts, making it impossible to jump to data. This makes it easier for static analysis tools to analyse contracts, allows disassemblers, chain explorers and debuggers to not display data as a mess of INVALID opcodes and may even provide a marginal improvement in performance. Additionally, it paves the way for suggestions such as [EIP 1712](https://github.com/ethereum/EIPs/pull/1712) to disallow unused opcodes, jumptables [EIP-615](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-615.md) and speculative proposals to disallow for deployment of contracts with stack usage violations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the canonical URL (https://eips.ethereum.org/EIPS/eip-XX) whenever possible.
EIPS/eip-2327.md
Outdated
## Rationale | ||
<!--The rationale fleshes out the specification by describing what motivated the design and why particular design decisions were made. It should describe alternate designs that were considered and related work, e.g. how the feature is supported in other languages. The rationale may also provide evidence of consensus within the community, and should discuss important objections or concerns raised during discussion.--> | ||
The byte `0xb6` was chosen to align with [EIP-615](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-615.md). | ||
The choice to STOP if `BEGINDATA` is encountered is somewhat arbitrary. An alternative would be to `THROW`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no such thing as "throw" defined anywhere.
EIPS/eip-2327.md
Outdated
## Rationale | ||
<!--The rationale fleshes out the specification by describing what motivated the design and why particular design decisions were made. It should describe alternate designs that were considered and related work, e.g. how the feature is supported in other languages. The rationale may also provide evidence of consensus within the community, and should discuss important objections or concerns raised during discussion.--> | ||
The byte `0xb6` was chosen to align with [EIP-615](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-615.md). | ||
The choice to STOP if `BEGINDATA` is encountered is somewhat arbitrary. An alternative would be to `THROW`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may make it nicer to read if all JUMPDEST and STOP opcodes are escaped.
EIPS/eip-2327.md
Outdated
## Test Cases | ||
<!--Test cases for an implementation are mandatory for EIPs that are affecting consensus changes. Other EIPs can choose to include links to test cases if applicable.--> | ||
Test cases should include: | ||
1) A contract which jumps to a destination `X`, where `X` has a pc value higher than the `BEGINDATA` opcode, and the byte at `X` is `0x5b`. This should fail with a `BAD_JUMPDEST`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use BAD_JUMPDEST or BAD_JUMP_DESTINATION consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Albeit there is no such error clearly defined in EVM semantics, I'd still opt to keep that in the EIP (for now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am referring to the status codes as defined by EVMC https://evmc.ethereum.org/group__EVMC.html#ga4c0be97f333c050ff45321fcaa34d920. Even if they haven't been universally accepted, they do provide the most systematic treatment of exceptions I'm aware of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware of them and glad to see them utilised, they haven't been referenced yet (apart from #2003).
e4571da
to
832f229
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is sound enough for a draft.
Thanks @axic for the review |
* Draft EIP: BEGINDATA opcode * EIP-BEGINDATA: Add discussions-to link * use eip number 2327 * Update EIPS/eip-2327.md Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com> * eip-2327: Update formatting and clarify CODECOPY behaviour
* Draft EIP: BEGINDATA opcode * EIP-BEGINDATA: Add discussions-to link * use eip number 2327 * Update EIPS/eip-2327.md Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com> * eip-2327: Update formatting and clarify CODECOPY behaviour
* Draft EIP: BEGINDATA opcode * EIP-BEGINDATA: Add discussions-to link * use eip number 2327 * Update EIPS/eip-2327.md Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com> * eip-2327: Update formatting and clarify CODECOPY behaviour
* Draft EIP: BEGINDATA opcode * EIP-BEGINDATA: Add discussions-to link * use eip number 2327 * Update EIPS/eip-2327.md Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com> * eip-2327: Update formatting and clarify CODECOPY behaviour
Waiting for EIP number to be assigned. Will post link to discussions after having opened this PR.