From 805980dd183b962cd5595a357a9e9f83e450d08f Mon Sep 17 00:00:00 2001 From: spencer Date: Tue, 19 Sep 2023 17:44:40 -0400 Subject: [PATCH] tests/cancun/eip_4788: Update predeploy address(0xbEAC02..7d7a), add additional tests (#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 Co-authored-by: danceratopz --- src/ethereum_test_forks/forks/forks.py | 8 +- tests/cancun/eip4788_beacon_root/common.py | 53 --------- tests/cancun/eip4788_beacon_root/conftest.py | 24 ++-- tests/cancun/eip4788_beacon_root/spec.py | 78 +++++++++++++ .../test_beacon_root_contract.py | 84 ++++++++++++-- .../test_blocks_beacon_root_contract.py | 106 +++++++++--------- whitelist.txt | 1 + 7 files changed, 220 insertions(+), 134 deletions(-) delete mode 100644 tests/cancun/eip4788_beacon_root/common.py create mode 100644 tests/cancun/eip4788_beacon_root/spec.py diff --git a/src/ethereum_test_forks/forks/forks.py b/src/ethereum_test_forks/forks/forks.py index b943677536..ca9de82dcb 100644 --- a/src/ethereum_test_forks/forks/forks.py +++ b/src/ethereum_test_forks/forks/forks.py @@ -365,11 +365,11 @@ def pre_allocation(cls, block_number: int = 0, timestamp: int = 0) -> Mapping: Cancun requires pre-allocation of the beacon root contract for EIP-4788 """ new_allocation = { - 0xBEAC00DDB15F3B6D645C48263DC93862413A222D: { + 0xBEAC020008AFF7331C0A389CB2AAB67597567D7A: { "nonce": 1, - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604457602036146024575f5f" - "fd5b620180005f350680545f35146037575f5ffd5b6201800001545f5260205ff35b620180004206" - "4281555f359062018000015500", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5f" + "fd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f" + "5ffd5b62001fff42064281555f359062001fff015500", } } return new_allocation | super(Cancun, cls).pre_allocation(block_number, timestamp) diff --git a/tests/cancun/eip4788_beacon_root/common.py b/tests/cancun/eip4788_beacon_root/common.py deleted file mode 100644 index faedbbdb47..0000000000 --- a/tests/cancun/eip4788_beacon_root/common.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -Common constants, classes & functions local to EIP-4788 tests. -""" - -from ethereum_test_tools import Storage - -REF_SPEC_4788_GIT_PATH = "EIPS/eip-4788.md" -REF_SPEC_4788_VERSION = "e7608fe8ac8a60934ca874f5aab7d5c1f4ff7782" - -BEACON_ROOT_CONTRACT_ADDRESS = 0xBEAC00DDB15F3B6D645C48263DC93862413A222D -BEACON_ROOT_CONTRACT_CALL_GAS = 100_000 -HISTORY_BUFFER_LENGTH = 98_304 -SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE - -FORK_TIMESTAMP = 15_000 # ShanghaiToCancun timestamp - - -def timestamp_index(timestamp: int) -> int: - """ - Derive the timestamp index into the timestamp ring buffer. - """ - return timestamp % HISTORY_BUFFER_LENGTH - - -def root_index(timestamp: int) -> int: - """ - Derive the root index into the root ring buffer. - """ - return timestamp_index(timestamp) + HISTORY_BUFFER_LENGTH - - -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 diff --git a/tests/cancun/eip4788_beacon_root/conftest.py b/tests/cancun/eip4788_beacon_root/conftest.py index 5baeeaa0dc..b6fb6d4255 100644 --- a/tests/cancun/eip4788_beacon_root/conftest.py +++ b/tests/cancun/eip4788_beacon_root/conftest.py @@ -20,13 +20,7 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -from .common import ( - BEACON_ROOT_CONTRACT_ADDRESS, - BEACON_ROOT_CONTRACT_CALL_GAS, - HISTORY_BUFFER_LENGTH, - SYSTEM_ADDRESS, - expected_storage, -) +from .spec import Spec, SpecHelpers BLOB_COMMITMENT_VERSION_KZG = 1 @@ -88,7 +82,7 @@ def call_value() -> int: # noqa: D103 @pytest.fixture def call_gas() -> int: # noqa: D103 - return BEACON_ROOT_CONTRACT_CALL_GAS + return Spec.BEACON_ROOTS_CALL_GAS @pytest.fixture @@ -108,7 +102,7 @@ def contract_call_account(call_type: Op, call_value: int, call_gas: int) -> Acco 0x00, # store the result of the contract call in storage[0] call_type( call_gas, - BEACON_ROOT_CONTRACT_ADDRESS, + Spec.BEACON_ROOTS_ADDRESS, call_value, args_start, args_length, @@ -122,7 +116,7 @@ def contract_call_account(call_type: Op, call_value: int, call_gas: int) -> Acco 0x00, call_type( call_gas, - BEACON_ROOT_CONTRACT_ADDRESS, + Spec.BEACON_ROOTS_ADDRESS, args_start, args_length, return_start, @@ -197,7 +191,7 @@ def pre( caller_address: contract_call_account, } if system_address_balance > 0: - pre_alloc[to_address(SYSTEM_ADDRESS)] = Account( + pre_alloc[to_address(Spec.SYSTEM_ADDRESS)] = Account( nonce=0, balance=system_address_balance, ) @@ -225,10 +219,10 @@ def access_list(auto_access_list: bool, timestamp: int) -> List[AccessList]: if auto_access_list: return [ AccessList( - address=BEACON_ROOT_CONTRACT_ADDRESS, + address=Spec.BEACON_ROOTS_ADDRESS, storage_keys=[ timestamp, - timestamp + HISTORY_BUFFER_LENGTH, + timestamp + Spec.HISTORY_BUFFER_LENGTH, ], ), ] @@ -264,7 +258,7 @@ def tx( """ Prepares transaction to call the beacon root contract caller account. """ - to = BEACON_ROOT_CONTRACT_ADDRESS if call_beacon_root_contract else tx_to_address + to = Spec.BEACON_ROOTS_ADDRESS if call_beacon_root_contract else tx_to_address kwargs: Dict = { "ty": tx_type, "nonce": 0, @@ -307,7 +301,7 @@ def post( """ storage = Storage() if not call_beacon_root_contract: - storage = expected_storage( + storage = SpecHelpers.expected_storage( beacon_root=beacon_root, valid_call=valid_call, valid_input=valid_input, diff --git a/tests/cancun/eip4788_beacon_root/spec.py b/tests/cancun/eip4788_beacon_root/spec.py new file mode 100644 index 0000000000..739f09fe73 --- /dev/null +++ b/tests/cancun/eip4788_beacon_root/spec.py @@ -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 diff --git a/tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py b/tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py index 3e654ebdd8..02aa434500 100644 --- a/tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py +++ b/tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py @@ -27,22 +27,29 @@ import pytest -from ethereum_test_tools import Environment, StateTestFiller, Transaction +from ethereum_test_tools import ( + Account, + Environment, + StateTestFiller, + Storage, + Transaction, + to_address, +) from ethereum_test_tools.vm.opcode import Opcodes as Op -from .common import BEACON_ROOT_CONTRACT_CALL_GAS, REF_SPEC_4788_GIT_PATH, REF_SPEC_4788_VERSION +from .spec import Spec, ref_spec_4788 -REFERENCE_SPEC_GIT_PATH = REF_SPEC_4788_GIT_PATH -REFERENCE_SPEC_VERSION = REF_SPEC_4788_VERSION +REFERENCE_SPEC_GIT_PATH = ref_spec_4788.git_path +REFERENCE_SPEC_VERSION = ref_spec_4788.version @pytest.mark.parametrize( "call_gas, valid_call", [ - pytest.param(BEACON_ROOT_CONTRACT_CALL_GAS, True), - pytest.param(BEACON_ROOT_CONTRACT_CALL_GAS + 1, True), + pytest.param(Spec.BEACON_ROOTS_CALL_GAS, True), + pytest.param(Spec.BEACON_ROOTS_CALL_GAS + 1, True), pytest.param( - BEACON_ROOT_CONTRACT_CALL_GAS - 1, + Spec.BEACON_ROOTS_CALL_GAS - 1, False, marks=pytest.mark.xfail(reason="gas calculation is incorrect"), # TODO ), @@ -220,3 +227,66 @@ def test_tx_to_beacon_root_contract( txs=[tx], post=post, ) + + +@pytest.mark.parametrize( + "tx_data", + [ + pytest.param(int.to_bytes(0, length=32, byteorder="big"), id="zero_calldata"), + ], +) +@pytest.mark.parametrize("valid_call,valid_input", [(False, False)]) +@pytest.mark.parametrize("timestamp", [12]) +@pytest.mark.valid_from("Cancun") +def test_invalid_beacon_root_calldata_value( + state_test: StateTestFiller, + env: Environment, + pre: Dict, + tx: Transaction, + post: Dict, +): + """ + Tests the beacon root contract call using invalid input values: + - zero calldata. + + Contract should revert. + """ + state_test( + env=env, + pre=pre, + txs=[tx], + post=post, + ) + + +@pytest.mark.parametrize("timestamp", [12]) +@pytest.mark.valid_from("Cancun") +def test_beacon_root_selfdestruct( + state_test: StateTestFiller, + env: Environment, + pre: Dict, + tx: Transaction, + post: Dict, +): + """ + Tests that self destructing the beacon root address transfers actors balance correctly. + """ + # self destruct actor + pre[to_address(0x1337)] = Account( + code=Op.SELFDESTRUCT(Spec.BEACON_ROOTS_ADDRESS), + balance=0xBA1, + ) + # self destruct caller + pre[to_address(0xCC)] = Account( + code=Op.CALL(100000, Op.PUSH20(to_address(0x1337)), 0, 0, 0, 0, 0) + + Op.SSTORE(0, Op.BALANCE(Spec.BEACON_ROOTS_ADDRESS)), + ) + post[to_address(0xCC)] = Account( + storage=Storage({0: 0xBA1}), + ) + state_test( + env=env, + pre=pre, + txs=[tx, Transaction(nonce=1, to=to_address(0xCC), gas_limit=100000, gas_price=10)], + post=post, + ) diff --git a/tests/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py b/tests/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py index 7d68504e29..32b45ba07b 100644 --- a/tests/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py +++ b/tests/cancun/eip4788_beacon_root/test_blocks_beacon_root_contract.py @@ -42,16 +42,10 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -from .common import ( - BEACON_ROOT_CONTRACT_ADDRESS, - HISTORY_BUFFER_LENGTH, - REF_SPEC_4788_GIT_PATH, - REF_SPEC_4788_VERSION, - SYSTEM_ADDRESS, -) +from .spec import Spec, ref_spec_4788 -REFERENCE_SPEC_GIT_PATH = REF_SPEC_4788_GIT_PATH -REFERENCE_SPEC_VERSION = REF_SPEC_4788_VERSION +REFERENCE_SPEC_GIT_PATH = ref_spec_4788.git_path +REFERENCE_SPEC_VERSION = ref_spec_4788.version @pytest.mark.parametrize( @@ -59,7 +53,7 @@ [ pytest.param( count( - start=HISTORY_BUFFER_LENGTH - 5, + start=Spec.HISTORY_BUFFER_LENGTH - 5, step=1, ), id="buffer_wraparound", @@ -67,28 +61,28 @@ pytest.param( count( start=12, - step=HISTORY_BUFFER_LENGTH, + step=Spec.HISTORY_BUFFER_LENGTH, ), id="buffer_wraparound_overwrite", ), pytest.param( count( start=2**32, - step=HISTORY_BUFFER_LENGTH, + step=Spec.HISTORY_BUFFER_LENGTH, ), id="buffer_wraparound_overwrite_high_timestamp", ), pytest.param( count( start=5, - step=HISTORY_BUFFER_LENGTH - 1, + step=Spec.HISTORY_BUFFER_LENGTH - 1, ), id="buffer_wraparound_no_overwrite", ), pytest.param( count( - start=HISTORY_BUFFER_LENGTH - 3, - step=HISTORY_BUFFER_LENGTH + 1, + start=Spec.HISTORY_BUFFER_LENGTH - 3, + step=Spec.HISTORY_BUFFER_LENGTH + 1, ), id="buffer_wraparound_no_overwrite_2", ), @@ -110,7 +104,7 @@ def test_multi_block_beacon_root_timestamp_calls( transaction that calls the beacon root contract multiple times. The blocks might overwrite the historical roots buffer, or not, depending on the `timestamps`, - and whether they increment in multiples of `HISTORY_BUFFER_LENGTH` or not. + and whether they increment in multiples of `Spec.HISTORY_BUFFER_LENGTH` or not. By default, the beacon roots are the keccak of the block number. @@ -133,7 +127,7 @@ def test_multi_block_beacon_root_timestamp_calls( all_timestamps: List[int] = [] for timestamp, beacon_root, i in zip(timestamps, beacon_roots, range(block_count)): - timestamp_index = timestamp % HISTORY_BUFFER_LENGTH + timestamp_index = timestamp % Spec.HISTORY_BUFFER_LENGTH timestamps_storage[timestamp_index] = timestamp roots_storage[timestamp_index] = beacon_root @@ -152,13 +146,13 @@ def test_multi_block_beacon_root_timestamp_calls( current_call_account_code += Op.MSTORE(0, t) call_valid = ( timestamp_index in timestamps_storage - and timestamps_storage[t % HISTORY_BUFFER_LENGTH] == t + and timestamps_storage[t % Spec.HISTORY_BUFFER_LENGTH] == t ) current_call_account_code += Op.SSTORE( current_call_account_expected_storage.store_next(0x01 if call_valid else 0x00), Op.CALL( call_gas, - BEACON_ROOT_CONTRACT_ADDRESS, + Spec.BEACON_ROOTS_ADDRESS, call_value, 0x00, 0x20, @@ -169,7 +163,7 @@ def test_multi_block_beacon_root_timestamp_calls( current_call_account_code += Op.SSTORE( current_call_account_expected_storage.store_next( - roots_storage[t % HISTORY_BUFFER_LENGTH] if call_valid else 0x00 + roots_storage[t % Spec.HISTORY_BUFFER_LENGTH] if call_valid else 0x00 ), Op.MLOAD(0x20), ) @@ -194,13 +188,13 @@ def test_multi_block_beacon_root_timestamp_calls( withdrawals=[ # Also withdraw to the beacon root contract and the system address Withdrawal( - address=BEACON_ROOT_CONTRACT_ADDRESS, + address=Spec.BEACON_ROOTS_ADDRESS, amount=1, index=next(withdraw_index), validator=0, ), Withdrawal( - address=SYSTEM_ADDRESS, + address=Spec.SYSTEM_ADDRESS, amount=1, index=next(withdraw_index), validator=1, @@ -252,7 +246,7 @@ def test_beacon_root_transition( timestamps_in_beacon_root_contract: List[int] = [] for timestamp, beacon_root, i in zip(timestamps, beacon_roots, range(block_count)): - timestamp_index = timestamp % HISTORY_BUFFER_LENGTH + timestamp_index = timestamp % Spec.HISTORY_BUFFER_LENGTH transitioned = fork.header_beacon_root_required(i, timestamp) if transitioned: @@ -277,13 +271,13 @@ def test_beacon_root_transition( call_valid = ( t in timestamps_in_beacon_root_contract and timestamp_index in timestamps_storage - and timestamps_storage[t % HISTORY_BUFFER_LENGTH] == t + and timestamps_storage[t % Spec.HISTORY_BUFFER_LENGTH] == t ) current_call_account_code += Op.SSTORE( current_call_account_expected_storage.store_next(0x01 if call_valid else 0x00), Op.CALL( call_gas, - BEACON_ROOT_CONTRACT_ADDRESS, + Spec.BEACON_ROOTS_ADDRESS, call_value, 0x00, 0x20, @@ -294,7 +288,7 @@ def test_beacon_root_transition( current_call_account_code += Op.SSTORE( current_call_account_expected_storage.store_next( - roots_storage[t % HISTORY_BUFFER_LENGTH] if call_valid else 0x00 + roots_storage[t % Spec.HISTORY_BUFFER_LENGTH] if call_valid else 0x00 ), Op.MLOAD(0x20), ) @@ -319,13 +313,13 @@ def test_beacon_root_transition( withdrawals=[ # Also withdraw to the beacon root contract and the system address Withdrawal( - address=BEACON_ROOT_CONTRACT_ADDRESS, + address=Spec.BEACON_ROOTS_ADDRESS, amount=1, index=next(withdraw_index), validator=0, ), Withdrawal( - address=SYSTEM_ADDRESS, + address=Spec.SYSTEM_ADDRESS, amount=1, index=next(withdraw_index), validator=1, @@ -365,13 +359,13 @@ def test_no_beacon_root_contract_at_transition( withdrawals=[ # Also withdraw to the beacon root contract and the system address Withdrawal( - address=BEACON_ROOT_CONTRACT_ADDRESS, + address=Spec.BEACON_ROOTS_ADDRESS, amount=1, index=0, validator=0, ), Withdrawal( - address=SYSTEM_ADDRESS, + address=Spec.SYSTEM_ADDRESS, amount=1, index=1, validator=1, @@ -379,16 +373,16 @@ def test_no_beacon_root_contract_at_transition( ], ) ] - pre[BEACON_ROOT_CONTRACT_ADDRESS] = Account( + pre[Spec.BEACON_ROOTS_ADDRESS] = Account( code=b"", # Remove the code that is automatically allocated on Cancun fork nonce=0, balance=0, ) post = { - BEACON_ROOT_CONTRACT_ADDRESS: Account( + Spec.BEACON_ROOTS_ADDRESS: Account( storage={ - timestamp % HISTORY_BUFFER_LENGTH: 0, - (timestamp % HISTORY_BUFFER_LENGTH) + HISTORY_BUFFER_LENGTH: 0, + timestamp % Spec.HISTORY_BUFFER_LENGTH: 0, + (timestamp % Spec.HISTORY_BUFFER_LENGTH) + Spec.HISTORY_BUFFER_LENGTH: 0, }, code=b"", nonce=0, @@ -429,27 +423,29 @@ def test_beacon_root_contract_deploy( code deployed and its functionality after Cancun. """ assert fork.header_beacon_root_required(1, timestamp) + tx_gas_limit = 0x3D090 + tx_gas_price = 0xE8D4A51000 + deployer_required_balance = tx_gas_limit * tx_gas_price deploy_tx = Transaction( ty=0, nonce=0, to=None, - gas_limit=0x27EAC, - gas_price=0xE8D4A51000, + gas_limit=tx_gas_limit, + gas_price=tx_gas_price, value=0, data=bytes.fromhex( - "60588060095f395ff33373fffffffffffffffffffffffffffffffffffffffe146044576020361460" - "24575f5ffd5b620180005f350680545f35146037575f5ffd5b6201800001545f5260205ff35b6201" - "800042064281555f359062018000015500" + "60618060095f395ff33373fffffffffffffffffffffffffffffffffffffffe14604d576020361460" + "24575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f526020" + "5ff35b5f5ffd5b62001fff42064281555f359062001fff015500" ), v=0x1B, r=0x539, - s=0x133700F3A77843802897DB, + s=0x1337005F06A8B6A0A0B1F4, protected=False, ).with_signature_and_sender() deployer_address = deploy_tx.sender assert deployer_address is not None - deployer_required_balance = 0x27EAC * 0xE8D4A51000 - + assert deployer_address == int.to_bytes(Spec.BEACON_ROOTS_DEPLOYER_ADDRESS, 20, "big") blocks: List[Block] = [] beacon_root_contract_storage: Dict = {} @@ -465,13 +461,13 @@ def test_beacon_root_contract_deploy( withdrawals=[ # Also withdraw to the beacon root contract and the system address Withdrawal( - address=BEACON_ROOT_CONTRACT_ADDRESS, + address=Spec.BEACON_ROOTS_ADDRESS, amount=1, index=0, validator=0, ), Withdrawal( - address=SYSTEM_ADDRESS, + address=Spec.SYSTEM_ADDRESS, amount=1, index=1, validator=1, @@ -479,9 +475,9 @@ def test_beacon_root_contract_deploy( ], ) ) - beacon_root_contract_storage[current_timestamp % HISTORY_BUFFER_LENGTH] = 0 + beacon_root_contract_storage[current_timestamp % Spec.HISTORY_BUFFER_LENGTH] = 0 beacon_root_contract_storage[ - (current_timestamp % HISTORY_BUFFER_LENGTH) + HISTORY_BUFFER_LENGTH + (current_timestamp % Spec.HISTORY_BUFFER_LENGTH) + Spec.HISTORY_BUFFER_LENGTH ] = 0 elif i == 1: blocks.append( @@ -492,13 +488,13 @@ def test_beacon_root_contract_deploy( withdrawals=[ # Also withdraw to the beacon root contract and the system address Withdrawal( - address=BEACON_ROOT_CONTRACT_ADDRESS, + address=Spec.BEACON_ROOTS_ADDRESS, amount=1, index=2, validator=0, ), Withdrawal( - address=SYSTEM_ADDRESS, + address=Spec.SYSTEM_ADDRESS, amount=1, index=3, validator=1, @@ -507,16 +503,16 @@ def test_beacon_root_contract_deploy( ), ) beacon_root_contract_storage[ - current_timestamp % HISTORY_BUFFER_LENGTH + current_timestamp % Spec.HISTORY_BUFFER_LENGTH ] = current_timestamp beacon_root_contract_storage[ - (current_timestamp % HISTORY_BUFFER_LENGTH) + HISTORY_BUFFER_LENGTH + (current_timestamp % Spec.HISTORY_BUFFER_LENGTH) + Spec.HISTORY_BUFFER_LENGTH ] = beacon_root else: assert False, "This test should only have two blocks" - expected_code = fork.pre_allocation(1, timestamp)[BEACON_ROOT_CONTRACT_ADDRESS]["code"] - pre[BEACON_ROOT_CONTRACT_ADDRESS] = Account( + expected_code = fork.pre_allocation(1, timestamp)[Spec.BEACON_ROOTS_ADDRESS]["code"] + pre[Spec.BEACON_ROOTS_ADDRESS] = Account( code=b"", # Remove the code that is automatically allocated on Cancun fork nonce=0, balance=0, @@ -525,20 +521,20 @@ def test_beacon_root_contract_deploy( balance=deployer_required_balance, ) - post[BEACON_ROOT_CONTRACT_ADDRESS] = Account( + post[Spec.BEACON_ROOTS_ADDRESS] = Account( storage=beacon_root_contract_storage, code=expected_code, nonce=1, balance=int(2e9), ) - post[SYSTEM_ADDRESS] = Account( + post[Spec.SYSTEM_ADDRESS] = Account( storage={}, code=b"", nonce=0, balance=int(2e9), ) post[deployer_address] = Account( - balance=91366000000000000, # It doesn't consume all the balance :( + balance=175916000000000000, # It doesn't consume all the balance :( nonce=1, ) blockchain_test( diff --git a/whitelist.txt b/whitelist.txt index 0a3679a80a..6d844cef0d 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -484,3 +484,4 @@ mcopy precompile precompiles deployer +0x