diff --git a/tests/cancun/eip4788_beacon_root/common.py b/tests/cancun/eip4788_beacon_root/common.py index 077b6ab5c8..6c5273b461 100644 --- a/tests/cancun/eip4788_beacon_root/common.py +++ b/tests/cancun/eip4788_beacon_root/common.py @@ -37,7 +37,7 @@ def expected_storage( valid_input: bool, ) -> Storage: """ - Derives the expected storage for a given beacon root precompile call + 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 @@ -45,7 +45,7 @@ def expected_storage( # 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 precompile call is successful + # beacon root contract call is successful storage[0] = 1 storage[1] = beacon_root storage[2] = 32 diff --git a/tests/cancun/eip4788_beacon_root/conftest.py b/tests/cancun/eip4788_beacon_root/conftest.py index 25e6d5aff0..1c74f359ff 100644 --- a/tests/cancun/eip4788_beacon_root/conftest.py +++ b/tests/cancun/eip4788_beacon_root/conftest.py @@ -77,15 +77,15 @@ def caller_address() -> str: # noqa: D103 @pytest.fixture -def precompile_call_account(call_type: Op, call_value: int, call_gas: int) -> Account: +def contract_call_account(call_type: Op, call_value: int, call_gas: int) -> Account: """ - Code to call the beacon root precompile. + Code to call the beacon root contract. """ args_start, args_length, return_start, return_length = 0x20, Op.CALLDATASIZE, 0x00, 0x20 - precompile_call_code = Op.CALLDATACOPY(args_start, 0x00, args_length) + contract_call_code = Op.CALLDATACOPY(args_start, 0x00, args_length) if call_type == Op.CALL or call_type == Op.CALLCODE: - precompile_call_code += Op.SSTORE( - 0x00, # store the result of the precompile call in storage[0] + contract_call_code += Op.SSTORE( + 0x00, # store the result of the contract call in storage[0] call_type( call_gas, BEACON_ROOT_CONTRACT_ADDRESS, @@ -98,7 +98,7 @@ def precompile_call_account(call_type: Op, call_value: int, call_gas: int) -> Ac ) elif call_type == Op.DELEGATECALL or call_type == Op.STATICCALL: # delegatecall and staticcall use one less argument - precompile_call_code += Op.SSTORE( + contract_call_code += Op.SSTORE( 0x00, call_type( call_gas, @@ -109,12 +109,12 @@ def precompile_call_account(call_type: Op, call_value: int, call_gas: int) -> Ac return_length, ), ) - precompile_call_code += ( - Op.SSTORE( # Save the return value of the precompile call + contract_call_code += ( + Op.SSTORE( # Save the return value of the contract call 0x01, Op.MLOAD(return_start), ) - + Op.SSTORE( # Save the length of the return value of the precompile call + + Op.SSTORE( # Save the length of the return value of the contract call 0x02, Op.RETURNDATASIZE, ) @@ -130,7 +130,7 @@ def precompile_call_account(call_type: Op, call_value: int, call_gas: int) -> Ac ) return Account( nonce=0, - code=precompile_call_code, + code=contract_call_code, balance=0x10**10, ) @@ -138,7 +138,7 @@ def precompile_call_account(call_type: Op, call_value: int, call_gas: int) -> Ac @pytest.fixture def valid_call() -> bool: """ - Validity of beacon root precompile call: defaults to True. + Validity of beacon root contract call: defaults to True. """ return True @@ -146,7 +146,7 @@ def valid_call() -> bool: @pytest.fixture def valid_input() -> bool: """ - Validity of timestamp input to precompile call: defaults to True. + Validity of timestamp input to contract call: defaults to True. """ return True @@ -161,20 +161,20 @@ def system_address_balance() -> int: @pytest.fixture def pre( - precompile_call_account: Account, + contract_call_account: Account, system_address_balance: int, caller_address: str, ) -> Dict: """ Prepares the pre state of all test cases, by setting the balance of the - source account of all test transactions, and the precompile caller account. + source account of all test transactions, and the contract caller account. """ return { TestAddress: Account( nonce=0, balance=0x10**10, ), - caller_address: precompile_call_account, + caller_address: contract_call_account, SYSTEM_ADDRESS: Account( nonce=0, balance=system_address_balance, @@ -198,7 +198,7 @@ def auto_access_list() -> bool: @pytest.fixture def access_list(auto_access_list: bool, timestamp: int) -> List[AccessList]: """ - Access list included in the transaction to call the beacon root precompile. + Access list included in the transaction to call the beacon root contract. """ if auto_access_list: return [ @@ -216,7 +216,7 @@ def access_list(auto_access_list: bool, timestamp: int) -> List[AccessList]: @pytest.fixture def tx_data(timestamp: int) -> bytes: """ - Data included in the transaction to call the beacon root precompile. + Data included in the transaction to call the beacon root contract. """ return to_hash_bytes(timestamp) @@ -240,7 +240,7 @@ def tx( call_beacon_root_contract: bool, ) -> Transaction: """ - Prepares transaction to call the beacon root precompile caller account. + Prepares transaction to call the beacon root contract caller account. """ to = BEACON_ROOT_CONTRACT_ADDRESS if call_beacon_root_contract else tx_to_address kwargs: Dict = { @@ -280,7 +280,7 @@ def post( call_beacon_root_contract: bool, ) -> Dict: """ - Prepares the expected post state for a single precompile call based upon the success or + Prepares the expected post state for a single contract call based upon the success or failure of the call, and the validity of the timestamp input. """ storage = 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 27823e1236..3e654ebdd8 100644 --- a/tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py +++ b/tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py @@ -59,7 +59,7 @@ ], ) @pytest.mark.valid_from("Cancun") -def test_beacon_root_precompile_calls( +def test_beacon_root_contract_calls( state_test: StateTestFiller, env: Environment, pre: Dict, @@ -67,7 +67,7 @@ def test_beacon_root_precompile_calls( post: Dict, ): """ - Tests the beacon root precompile call using various call contexts: + Tests the beacon root contract call using various call contexts: - `CALL` - `DELEGATECALL` - `CALLCODE` @@ -77,7 +77,7 @@ def test_beacon_root_precompile_calls( - extra gas (valid call) - insufficient gas (invalid call) - The expected result is that the precompile call will be executed if the gas amount is met + The expected result is that the contract call will be executed if the gas amount is met and return the correct`parent_beacon_block_root`. Otherwise the call will be invalid, and not be executed. This is highlighted within storage by storing the return value of each call context. @@ -114,7 +114,7 @@ def test_beacon_root_precompile_calls( ], ) @pytest.mark.valid_from("Cancun") -def test_beacon_root_precompile_timestamps( +def test_beacon_root_contract_timestamps( state_test: StateTestFiller, env: Environment, pre: Dict, @@ -122,9 +122,9 @@ def test_beacon_root_precompile_timestamps( post: Dict, ): """ - Tests the beacon root precompile call across for various valid and invalid timestamps. + Tests the beacon root contract call across for various valid and invalid timestamps. - The expected result is that the precompile call will return the correct + The expected result is that the contract call will return the correct `parent_beacon_block_root` for a valid input timestamp and return the zero'd 32 bytes value for an invalid input timestamp. """ @@ -157,7 +157,7 @@ def test_calldata_lengths( post: Dict, ): """ - Tests the beacon root precompile call using multiple invalid input lengths. + Tests the beacon root contract call using multiple invalid input lengths. """ state_test( env=env, @@ -187,9 +187,9 @@ def test_beacon_root_equal_to_timestamp( post: Dict, ): """ - Tests the beacon root precompile call where the beacon root is equal to the timestamp. + Tests the beacon root contract call where the beacon root is equal to the timestamp. - The expected result is that the precompile call will return the `parent_beacon_block_root`, + The expected result is that the contract call will return the `parent_beacon_block_root`, as all timestamps used are valid. """ state_test( @@ -212,8 +212,7 @@ def test_tx_to_beacon_root_contract( post: Dict, ): """ - Tests the beacon root precompile call using a transaction to the precompile contract, using - different transaction types and data lengths. + Tests the beacon root contract using a transaction with different types and data lengths. """ state_test( env=env, 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 bc8522f593..1a919c5c65 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 @@ -128,7 +128,7 @@ def test_multi_block_beacon_root_timestamp_calls( ): """ Tests multiple blocks where each block writes a timestamp to storage and contains one - transaction that calls the beacon root precompile multiple times. + 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 `HISTORICAL_ROOTS_MODULUS` or not.