Skip to content
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

Merged
merged 5 commits into from
Nov 5, 2019
Merged

Draft EIP: BEGINDATA opcode #2327

merged 5 commits into from
Nov 5, 2019

Conversation

MrChico
Copy link
Member

@MrChico MrChico commented Oct 28, 2019

Waiting for EIP number to be assigned. Will post link to discussions after having opened this PR.

@MrChico
Copy link
Member Author

MrChico commented Oct 28, 2019

EIPS/eip-2327.md Outdated Show resolved Hide resolved
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
EIPS/eip-2327.md Outdated Show resolved Hide resolved
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.
Copy link
Member

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`.
Copy link
Member

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`.
Copy link
Member

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`.
Copy link
Member

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.

Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

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).

@axic axic mentioned this pull request Nov 4, 2019
@axic axic added the type: Core label Nov 4, 2019
@MrChico MrChico force-pushed the master branch 2 times, most recently from e4571da to 832f229 Compare November 5, 2019 13:34
Copy link
Member

@axic axic left a 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.

@axic axic merged commit a8d19c5 into ethereum:master Nov 5, 2019
@MrChico
Copy link
Member Author

MrChico commented Nov 5, 2019

Thanks @axic for the review

ilanolkies pushed a commit to ilanolkies/EIPs that referenced this pull request Nov 12, 2019
* 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
MadeofTin pushed a commit to MadeofTin/EIPs that referenced this pull request Nov 13, 2019
* 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
tkstanczak pushed a commit to tkstanczak/EIPs that referenced this pull request Nov 7, 2020
* 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
Arachnid pushed a commit to Arachnid/EIPs that referenced this pull request Mar 6, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants