-
Notifications
You must be signed in to change notification settings - Fork 6k
Add EIP: EOF - Prepare for Address Space Extension #8385
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
Changes from 2 commits
4714240
57e6676
aea42bc
58da873
dcb7e04
ba5bff8
9e33f75
9897f98
1216936
c2e241f
523d18c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| eip: TBD | ||
shemnon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| title: EOF - Prepare for Address Space Extension | ||
| description: Update EOF opcodes so addresses are not trimmed durring execution | ||
shemnon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| author: Danno Ferrin (@shemnon) | ||
| discussions-to: https://ethereum-magicians.org/t/eof-prepare-for-address-space-extension/19537 | ||
| status: Draft | ||
| type: Standards Track | ||
| category: Core | ||
| created: 2024-04-03 | ||
| requires: 3540, 3670, 7069 | ||
| --- | ||
|
|
||
| ## Abstract | ||
|
|
||
| Operations in the Legacy EVM trim off the top 12 bytes of an address operand before evaluation. This | ||
| EIP changes the handling of those opcodes within EOF so that no trimming occurs and the top twelve | ||
| bytes need to be zero or an exceptional halt is raised. | ||
|
|
||
| ## Motivation | ||
|
|
||
| There have been propsals to extend Ethereum Addresses from 160 bytes to 256, such as one that would | ||
| use the extra bits for state expiry (such ethereum magicians fourm topic "Increasing the addres | ||
shemnon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sisze from 20 to 32 bytes"). One issue ground this work to a halt: EVM opcodes that accept Addresses | ||
shemnon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| trim all but the lowest 20 bytes out fo the operand before processing. EVM Reference tests verify | ||
| this behavior in the 'stBadOpcode/invalidAddr.json' tests. | ||
|
|
||
| The EVM Object Framework presents an opportunity to remove this address masking in a backwards | ||
| compatible way, by baking it into the format definition from the start. | ||
|
|
||
| Most of the work is already in place. The following 5 operations have already been banned from | ||
| EOF: `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALLCODE`, and `SELFDESTRUCT`. Three call | ||
| operations, `CALL`, `DELEGATECALL`, and `STATICCALL` are being revamped | ||
| in [EIP-7069](./eip-7069.md). That leaves only one operation, `BALANCE`, to be changed. | ||
|
|
||
| When future uses of address space extension are specified it is expected that the exeptional halt | ||
| behavior will be modified. | ||
|
|
||
| ## Specification | ||
|
|
||
| The `BALANCE` operation, when invoked in code in an EOF container, will reauire the top 12 bytes of | ||
|
||
| the operand to be zero. | ||
|
|
||
| If `BALANCE` is invoked with any of the high 12 bytes set to a non-zero value the operation will | ||
| cause an exceptional halt. All gas in the current frame will be consumed on failure, no gas schedule | ||
| change is needed. | ||
|
|
||
| Any new operation with an address operand on the stack, or any operation that is un-banned from EOF | ||
| that has an address operand on the stack will have the same behavior as `BALANCE` when validating | ||
| the address operand. | ||
|
|
||
| ## Rationale | ||
|
|
||
| There are two alternative ways to handle accounts with high bits set. The specification calls for | ||
| exceptional halt, but the alternative was to treat the account as empty. The reason the "empty | ||
| account" approach was rejected is twofold: first the warm account list could be required to track | ||
| 256 bit accounts when an invalid address is accessed. Second, the `EXTCALL` series instructions | ||
| could still send balance to those addresses and such accounts would then hold an (inaccessble) | ||
| balance that would need to be reflected in the merkle trie. | ||
|
|
||
| Because the BALANCE operation already needs to check the warmed account list there is already a good | ||
| amount of processing that must go into the operation, so no change to the gas schedule are needed to | ||
| prevent abuse of the failures. Such incremental costs will be dominated by costs related to reverts | ||
| and address checking for valid accounts. | ||
|
|
||
| ## Backwards Compatibility | ||
|
|
||
| Only one operation shared between legacy and EOF is impacted. All other impacted operations are used | ||
| in only one mode. | ||
|
|
||
| ## Test Cases | ||
|
|
||
| Test cases similar to `invalidAddr.json` tests in the standard reference tests will need to be | ||
| written for the EOF tests, except they would check for halts on invalid addresses. | ||
|
|
||
| ## Reference Implementation | ||
|
|
||
| TBD | ||
|
|
||
| ## Security Considerations | ||
|
|
||
| This EIP only defines a revert behavior for previously stripped addresses. Compilers will need to be | ||
| aware of the need to mask addresses coming in from call data. Some of this is already present in | ||
| existing Solidity ABI standards but more care should be taken in examining the flow around `BALANCE` | ||
| and code for `EXTCALL` operations to ensure that compiled code strips the high bytes. | ||
|
|
||
| ## Copyright | ||
|
|
||
| Copyright and related rights waived via [CC0](../LICENSE.md). | ||
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 an option to leave EIP-7069 intact, and put this step as an expansion of EXT*CALL logic into the new EIP-7676. The advantage is decoupling EIPs and not leaving this step without its due motivation described in EIP-7069 (or worse, having to reference circularly the EIP-7676).
But I'm not strongly against laying this out like is done 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.
It's the scattering of call across only two EIPs that concerns me. For vanilla validation it's already across multiple, and the rules focus on the operations in those EIPs. But splitting operational steps across EIPs I am concerned will result in implementations overlooking the detail.