From 3d18f0364e3824a2dc9b9d7c0fba36ac9ecc2cae Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Wed, 12 Jun 2024 22:34:00 -0600 Subject: [PATCH] fix(tests): Remove `TestAddress` usage on EOF tests (#626) * fix(tests): EOF - EIP-3540 - fix TestAddress usage * fix(tests): EOF - EIP-3540 - section order test exception fix * fix(tests): remove outdated code+comments --- .../eip3540_eof_v1/test_calls.py | 5 +- .../eip3540_eof_v1/test_code_validation.py | 105 ------------------ .../eip3540_eof_v1/test_section_order.py | 4 +- 3 files changed, 3 insertions(+), 111 deletions(-) diff --git a/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_calls.py b/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_calls.py index d413cc68f4..6ac51fed4a 100644 --- a/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_calls.py +++ b/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_calls.py @@ -13,7 +13,6 @@ Environment, StateTestFiller, Storage, - TestAddress, Transaction, ) from ethereum_test_tools.eof.v1 import Container, Section @@ -109,7 +108,7 @@ def test_legacy_calls_eof_sstore( if opcode == Op.CALL: destination_storage[slot_caller] = calling_contract_address elif opcode == Op.DELEGATECALL: - calling_storage[slot_caller] = TestAddress + calling_storage[slot_caller] = sender elif opcode == Op.CALLCODE: calling_storage[slot_caller] = calling_contract_address elif opcode == Op.STATICCALL: @@ -248,7 +247,7 @@ def test_eof_calls_eof_sstore( if opcode == Op.EXTCALL: destination_storage[slot_caller] = calling_contract_address elif opcode == Op.EXTDELEGATECALL: - calling_storage[slot_caller] = TestAddress + calling_storage[slot_caller] = sender elif opcode == Op.EXTSTATICCALL: calling_storage[slot_call_result] = value_eof_call_reverted diff --git a/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_code_validation.py b/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_code_validation.py index 1cb17fec36..127dd46985 100644 --- a/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_code_validation.py +++ b/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_code_validation.py @@ -156,108 +156,3 @@ def test_legacy_initcode_invalid_eof_v1_contract( data=bytes(container), expect_exception=container.validity_error, ) - - -""" -@test_from(EOF_FORK_NAME) -def test_legacy_initcode_invalid_eof_v1_contract(_): - Test creating various types of invalid EOF V1 contracts using legacy - initcode, a contract creating transaction, - and the CREATE opcode. - tx_created_contract_address = compute_create_address(TestAddress, 0) - create_opcode_created_contract_address = compute_create_address(0x100, 0) - - env = Environment() - - pre = { - TestAddress: Account( - balance=1000000000000000000000, - nonce=0, - ), - Address(0x100): Account( - code=create_initcode_from_calldata, - ), - Address(0x200): Account( - code=create2_initcode_from_calldata, - ), - } - - post = { - Address(0x100): Account( - storage={ - 0: 1, - } - ), - tx_created_contract_address: Account.NONEXISTENT, - create_opcode_created_contract_address: Account.NONEXISTENT, - } - - tx_create_contract = Transaction( - nonce=0, - to=None, - gas_limit=100000000, - gas_price=10, - protected=False, - ) - tx_create_opcode = Transaction( - nonce=1, - to=Address(0x100), - gas_limit=100000000, - gas_price=10, - protected=False, - ) - tx_create2_opcode = Transaction( - nonce=2, - to=Address(0x200), - gas_limit=100000000, - gas_price=10, - protected=False, - ) - - for container in ALL_INVALID: - # print(container.name + ": " + bytes(container).hex()) - if container.validity_error == "": - print( - "WARN: Invalid container " - + f"`{container.name}` without validity error" - ) - legacy_initcode = Initcode(deploy_code=container) - tx_create_contract.data = legacy_initcode - tx_create_opcode.data = legacy_initcode - tx_create2_opcode.data = legacy_initcode - create2_opcode_created_contract_address = compute_create2_address( - 0x200, 0, bytes(legacy_initcode) - ) - post[create2_opcode_created_contract_address] = Account.NONEXISTENT - yield StateTest( - env=env, - pre=pre, - post=post, - txs=[ - tx_create_contract, - tx_create_opcode, - tx_create2_opcode, - ], - name=container.name - if container.name is not None - else "unknown_container", - ) - del post[create2_opcode_created_contract_address] - """ - - -# TODO: EOF cannot create legacy code: -# Tx -> EOF-initcode -> Legacy return (Fail) -# EOF contract CREATE -> EOF-initcode -> Legacy return (Fail) -# EOF contract CREATE2 -> EOF-initcode -> Legacy return (Fail) -# -# Tx -> Legacy-initcode -> Legacy return (Pass) -# EOF contract CREATE -> Legacy-initcode -> Legacy return (Fail) -# EOF contract CREATE2 -> Legacy-initcode -> Legacy return (Fail) -# -# Tx -> Legacy-initcode -> EOF return (Pass) -# EOF contract CREATE -> Legacy-initcode -> EOF return (Fail) -# EOF contract CREATE2 -> Legacy-initcode -> EOF return (Fail) -# TODO: Create empty contract from EOF -# TODO: No new opcodes in legacy code -# TODO: General EOF initcode validation diff --git a/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_order.py b/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_order.py index caf09789fb..3f9cb32c84 100644 --- a/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_order.py +++ b/tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_section_order.py @@ -109,9 +109,7 @@ def get_expected_code_exception( case (SectionKind.DATA, SectionTest.MISSING, CasePosition.BODY): return ( "ef000101000402000100030400010000800001305000", - # Eofparse tool cannot automatically discern between a deployed eof contract - # and a init container, which allows truncated data, so no exception - None, + EOFException.TOPLEVEL_CONTAINER_TRUNCATED, ) case (SectionKind.DATA, SectionTest.MISSING, CasePosition.BODY_AND_HEADER): return "ef000101000402000100030000800001305000", EOFException.MISSING_DATA_SECTION