forked from ethereum/execution-spec-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/cancun/eip_4788: Update predeploy address(0xbEAC02..7d7a), add …
…additional tests (ethereum#297) * tests/cancun/eip_4788: Update naming to match spec. * tests/cancun/eip_4788: Update history buffer length. * tests/cancun/eip_4788: Add todo for remaining values to update. * tests/cancun/eip_4788: Add test for zero calldata value. * forks: Latest Beacon Root Update to 0xBEA...BCA * tests/cancun: Latest Beacon Root Update to 0xBEA...BCA * refactor: wrap specification params in a Spec class * tests/cancun/eip_4788|src/forks: final beacon root address update. * tests/cancun/eip_4788: add small self-destruct test. * tests/cancun/eip-4788: deployer address in spec --------- Co-authored-by: Mario Vega <[email protected]> Co-authored-by: danceratopz <[email protected]>
- Loading branch information
1 parent
789de47
commit 805980d
Showing
7 changed files
with
220 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
""" | ||
Defines EIP-4788 specification constants and functions. | ||
""" | ||
from dataclasses import dataclass | ||
|
||
from ethereum_test_tools import Storage | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ReferenceSpec: | ||
""" | ||
Defines the reference spec version and git path. | ||
""" | ||
|
||
git_path: str | ||
version: str | ||
|
||
|
||
ref_spec_4788 = ReferenceSpec("EIPS/eip-4788.md", "e7608fe8ac8a60934ca874f5aab7d5c1f4ff7782") | ||
|
||
|
||
# Constants | ||
@dataclass(frozen=True) | ||
class Spec: | ||
""" | ||
Parameters from the EIP-4788 specifications as defined at | ||
https://eips.ethereum.org/EIPS/eip-4788#specification | ||
""" | ||
|
||
BEACON_ROOTS_ADDRESS = 0xBEAC020008AFF7331C0A389CB2AAB67597567D7A | ||
BEACON_ROOTS_CALL_GAS = 100_000 | ||
BEACON_ROOTS_DEPLOYER_ADDRESS = 0x4F6DA9BA1CC8C37D9CE52311D4BAFFC43BA42D0E | ||
HISTORY_BUFFER_LENGTH = 8_191 | ||
SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE | ||
FORK_TIMESTAMP = 15_000 # ShanghaiToCancun timestamp | ||
|
||
|
||
@dataclass(frozen=True) | ||
class SpecHelpers: | ||
""" | ||
Helper functions closely related to the EIP-4788 specification. | ||
""" | ||
|
||
def timestamp_index(self, timestamp: int) -> int: | ||
""" | ||
Derive the timestamp index into the timestamp ring buffer. | ||
""" | ||
return timestamp % Spec.HISTORY_BUFFER_LENGTH | ||
|
||
def root_index(self, timestamp: int) -> int: | ||
""" | ||
Derive the root index into the root ring buffer. | ||
""" | ||
return self.timestamp_index(timestamp) + Spec.HISTORY_BUFFER_LENGTH | ||
|
||
@staticmethod | ||
def expected_storage( | ||
*, | ||
beacon_root: bytes, | ||
valid_call: bool, | ||
valid_input: bool, | ||
) -> Storage: | ||
""" | ||
Derives the expected storage for a given beacon root contract call | ||
dependent on: | ||
- success or failure of the call | ||
- validity of the timestamp input used within the call | ||
""" | ||
# By default assume the call is unsuccessful and all keys are zero | ||
storage = Storage({k: 0 for k in range(4)}) | ||
if valid_call and valid_input: | ||
# beacon root contract call is successful | ||
storage[0] = 1 | ||
storage[1] = beacon_root | ||
storage[2] = 32 | ||
storage[3] = beacon_root | ||
|
||
return storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.