diff --git a/converted-ethereum-tests.txt b/converted-ethereum-tests.txt index fa95fc194b3..977be678507 100644 --- a/converted-ethereum-tests.txt +++ b/converted-ethereum-tests.txt @@ -10,8 +10,18 @@ GeneralStateTests/stCreate2/call_then_create2_successful_then_returndatasize.jso EOFTests/EIP3540/validInvalid.json EOFTests/EIP3670/validInvalid.json +EOFTests/EIP4200/validInvalid.json EOFTests/efValidation/EOF1_embedded_container_.json EOFTests/efValidation/EOF1_eofcreate_valid_.json +EOFTests/efValidation/EOF1_valid_rjump_.json +EOFTests/efValidation/EOF1_valid_rjumpi_.json +EOFTests/efValidation/EOF1_valid_rjumpv_.json +EOFTests/efValidation/EOF1_rjump_truncated_.json +EOFTests/efValidation/EOF1_rjumpi_truncated_.json +EOFTests/efValidation/EOF1_rjumpv_truncated_.json +EOFTests/efValidation/EOF1_rjump_invalid_destination_.json +EOFTests/efValidation/EOF1_rjumpi_invalid_destination_.json +EOFTests/efValidation/EOF1_rjumpv_invalid_destination_.json EOFTests/efValidation/EOF1_section_order_.json EOFTests/efValidation/EOF1_truncated_section_.json EOFTests/efValidation/EOF1_undefined_opcodes_.json diff --git a/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py b/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py index f089fbf02fc..c723d7add44 100644 --- a/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py +++ b/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py @@ -40,17 +40,13 @@ def test_rjump_positive_negative( ): """EOF1V4200_0001 (Valid) EOF code containing RJUMP (Positive, Negative).""" eof_state_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH0 - + Op.RJUMPI[3] - + Op.RJUMP[7] - + Op.SSTORE(slot_code_worked, value_code_worked) - + Op.STOP - + Op.RJUMP[-10], - ) - ], + data=Container.Code( + Op.PUSH0 + + Op.RJUMPI[3] + + Op.RJUMP[7] + + Op.SSTORE(slot_code_worked, value_code_worked) + + Op.STOP + + Op.RJUMP[-10], ), container_post=Account(storage={slot_code_worked: value_code_worked}), ) @@ -61,12 +57,8 @@ def test_rjump_zero( ): """EOF1V4200_0002 (Valid) EOF code containing RJUMP (Zero).""" eof_state_test( - data=Container( - sections=[ - Section.Code( - code=Op.RJUMP[0] + Op.SSTORE(slot_code_worked, value_code_worked) + Op.STOP, - ) - ], + data=Container.Code( + Op.RJUMP[0] + Op.SSTORE(slot_code_worked, value_code_worked) + Op.STOP, ), container_post=Account(storage={slot_code_worked: value_code_worked}), ) @@ -77,20 +69,14 @@ def test_rjump_maxes( ): """EOF1V4200_0003 EOF with RJUMP containing the max positive and negative offset (32767).""" eof_state_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH0 - + Op.RJUMPI[ - RJUMP_LEN - ] # The push/jumpi is to allow the NOOPs to be forward referenced - + Op.RJUMP[0x7FFF] - + Op.NOOP * (0x7FFF - 7) - + Op.SSTORE(slot_code_worked, value_code_worked) - + Op.STOP - + Op.RJUMP[0x8000], - ) - ], + data=Container.Code( + Op.PUSH0 + + Op.RJUMPI[RJUMP_LEN] # The push/jumpi is to allow the NOOPs to be forward referenced + + Op.RJUMP[0x7FFF] + + Op.NOOP * (0x7FFF - 7) + + Op.SSTORE(slot_code_worked, value_code_worked) + + Op.STOP + + Op.RJUMP[0x8000], ), container_post=Account(storage={slot_code_worked: value_code_worked}), ) @@ -110,7 +96,7 @@ def test_rjump_max_bytecode_size( + (Op.NOOP * noop_count) + Op.STOP ) - container = Container.Code(code=code) + container = Container.Code(code) assert len(container) == MAX_BYTECODE_SIZE eof_test(data=container) @@ -120,9 +106,7 @@ def test_rjump_truncated_rjump( ): """EOF1I4200_0001 (Invalid) EOF code containing truncated RJUMP.""" eof_test( - data=Container( - sections=[Section.Code(code=Op.RJUMP)], - ), + data=Container.Code(Op.RJUMP), expect_exception=EOFException.TRUNCATED_INSTRUCTION, ) @@ -132,26 +116,22 @@ def test_rjump_truncated_rjump_2( ): """EOF1I4200_0002 (Invalid) EOF code containing truncated RJUMP.""" eof_test( - data=Container( - sections=[Section.Code(code=Op.RJUMP + Op.STOP)], - ), + data=Container.Code(Op.RJUMP + Op.STOP), expect_exception=EOFException.TRUNCATED_INSTRUCTION, ) +@pytest.mark.parametrize("offset", [-5, -13]) def test_rjump_into_header( eof_test: EOFTestFiller, + offset: int, ): """ EOF1I4200_0003 (Invalid) EOF code containing RJUMP with target outside code bounds (Jumping into header). """ eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[-5]), - ], - ), + data=Container.Code(Op.RJUMP[offset]), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -164,11 +144,7 @@ def test_rjump_before_header( (Jumping before code begin). """ eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[-23]), - ], - ), + data=Container.Code(Op.RJUMP[-23]), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -183,7 +159,7 @@ def test_rjump_into_data( eof_test( data=Container( sections=[ - Section.Code(code=Op.RJUMP[2]), + Section.Code(Op.RJUMP[2]), Section.Data(data=b"\xaa\xbb\xcc"), ], ), @@ -230,11 +206,7 @@ def test_rjump_after_container( (Jumping after code end). """ eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[2]), - ], - ), + data=Container.Code(Op.RJUMP[2]), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -247,11 +219,7 @@ def test_rjump_to_code_end( (Jumping to code end). """ eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[1] + Op.STOP), - ], - ), + data=Container.Code(Op.RJUMP[1] + Op.STOP), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -263,11 +231,7 @@ def test_rjump_into_self_data_portion( ): """EOF1I4200_0008 (Invalid) EOF code containing RJUMP with target self RJUMP immediate.""" eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[-offset] + Op.STOP), - ], - ), + data=Container.Code(Op.RJUMP[-offset] + Op.STOP), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -280,11 +244,7 @@ def test_rjump_into_self_remaining_code( unreachable code. """ eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[-len(Op.RJUMP[0])] + Op.STOP), - ], - ), + data=Container.Code(Op.RJUMP[-len(Op.RJUMP[0])] + Op.STOP), expect_exception=EOFException.UNREACHABLE_INSTRUCTIONS, ) @@ -294,11 +254,7 @@ def test_rjump_into_self( ): """EOF code containing RJUMP with target self RJUMP.""" eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[-len(Op.RJUMP[0])]), - ], - ), + data=Container.Code(Op.RJUMP[-len(Op.RJUMP[0])]), ) @@ -307,11 +263,7 @@ def test_rjump_into_self_pre_code( ): """EOF code containing RJUMP with target self RJUMP with non-zero stack before RJUMP.""" eof_test( - data=Container( - sections=[ - Section.Code(code=Op.PUSH1(0) + Op.RJUMP[-len(Op.RJUMP[0])]), - ], - ), + data=Container.Code(Op.PUSH1(0) + Op.RJUMP[-len(Op.RJUMP[0])]), ) @@ -320,11 +272,7 @@ def test_rjump_into_stack_height_diff( ): """EOF code containing RJUMP with target instruction that causes stack height difference.""" eof_test( - data=Container( - sections=[ - Section.Code(code=Op.PUSH1(0) + Op.RJUMP[-(len(Op.RJUMP[0]) + len(Op.PUSH1(0)))]), - ], - ), + data=Container.Code(Op.PUSH1(0) + Op.RJUMP[-(len(Op.RJUMP[0]) + len(Op.PUSH1(0)))]), expect_exception=EOFException.STACK_HEIGHT_MISMATCH, ) @@ -334,13 +282,7 @@ def test_rjump_into_stack_height_diff_2( ): """EOF code containing RJUMP with target instruction that cause stack height difference.""" eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH1(0) + Op.POP + Op.RJUMP[-(len(Op.RJUMP[0]) + len(Op.POP))] - ), - ], - ), + data=Container.Code(Op.PUSH1(0) + Op.POP + Op.RJUMP[-(len(Op.RJUMP[0]) + len(Op.POP))]), expect_exception=EOFException.STACK_HEIGHT_MISMATCH, ) @@ -350,17 +292,13 @@ def test_rjump_into_stack_underflow( ): """EOF code containing RJUMP with target instruction that cause stack underflow.""" eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.ORIGIN - + Op.RJUMPI[len(Op.RJUMP[0])] - + Op.RJUMP[len(Op.STOP)] - + Op.STOP - + Op.POP - + Op.STOP - ), - ], + data=Container.Code( + Op.ORIGIN + + Op.RJUMPI[len(Op.RJUMP[0])] + + Op.RJUMP[len(Op.STOP)] + + Op.STOP + + Op.POP + + Op.STOP ), expect_exception=EOFException.STACK_UNDERFLOW, ) @@ -371,11 +309,7 @@ def test_rjump_into_rjump( ): """EOF1I4200_0009 (Invalid) EOF code containing RJUMP with target other RJUMP immediate.""" eof_test( - data=Container( - sections=[ - Section.Code(code=Op.RJUMP[1] + Op.RJUMP[0]), - ], - ), + data=Container.Code(Op.RJUMP[1] + Op.RJUMP[0]), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -385,13 +319,7 @@ def test_rjump_into_rjumpi( ): """EOF1I4200_0010 (Invalid) EOF code containing RJUMP with target RJUMPI immediate.""" eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.RJUMP[5] + Op.STOP + Op.PUSH1(1) + Op.RJUMPI[-6] + Op.STOP, - ) - ], - ), + data=Container.Code(Op.RJUMP[5] + Op.STOP + Op.PUSH1(1) + Op.RJUMPI[-6] + Op.STOP), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -403,11 +331,7 @@ def test_rjump_into_push_1(eof_test: EOFTestFiller, jump: JumpDirection): Op.PUSH1[1] + Op.RJUMP[-4] if jump == JumpDirection.BACKWARD else Op.RJUMP[1] + Op.PUSH1[1] ) + Op.STOP eof_test( - data=Container( - sections=[ - Section.Code(code=code), - ], - ), + data=Container.Code(code), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -469,11 +393,7 @@ def test_rjump_into_push_n( offset = -4 if data_portion_end else -4 - data_portion_length + 1 code = opcode[0] + Op.RJUMP[offset] eof_test( - data=Container( - sections=[ - Section.Code(code=code), - ], - ), + data=Container.Code(code), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -493,16 +413,12 @@ def test_rjump_into_rjumpv( invalid_destination = 4 + (2 * target_rjumpv_table_size) if data_portion_end else 4 target_jump_table = [0 for _ in range(target_rjumpv_table_size)] eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.RJUMP[invalid_destination] - + Op.STOP - + Op.PUSH1(1) - + Op.RJUMPV[target_jump_table] - + Op.STOP, - ) - ], + data=Container.Code( + Op.RJUMP[invalid_destination] + + Op.STOP + + Op.PUSH1(1) + + Op.RJUMPV[target_jump_table] + + Op.STOP, ), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -540,17 +456,8 @@ def test_rjump_into_dupn( ): """EOF code containing RJUMP with target DUPN immediate.""" eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH1(1) - + Op.PUSH1(1) - + Op.RJUMP[1] - + Op.DUPN[1] - + Op.SSTORE - + Op.STOP, - ), - ], + data=Container.Code( + Op.PUSH1(1) + Op.PUSH1(1) + Op.RJUMP[1] + Op.DUPN[1] + Op.SSTORE + Op.STOP, ), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -561,17 +468,8 @@ def test_rjump_into_swapn( ): """EOF code containing RJUMP with target SWAPN immediate.""" eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH1(1) - + Op.PUSH1(1) - + Op.RJUMP[1] - + Op.SWAPN[1] - + Op.SSTORE - + Op.STOP, - ), - ], + data=Container.Code( + Op.PUSH1(1) + Op.PUSH1(1) + Op.RJUMP[1] + Op.SWAPN[1] + Op.SSTORE + Op.STOP, ), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -582,18 +480,14 @@ def test_rjump_into_exchange( ): """EOF code containing RJUMP with target EXCHANGE immediate.""" eof_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH1(1) - + Op.PUSH1(2) - + Op.PUSH1(3) - + Op.RJUMP[1] - + Op.EXCHANGE[0x00] - + Op.SSTORE - + Op.STOP, - ), - ], + data=Container.Code( + Op.PUSH1(1) + + Op.PUSH1(2) + + Op.PUSH1(3) + + Op.RJUMP[1] + + Op.EXCHANGE[0x00] + + Op.SSTORE + + Op.STOP, ), expect_exception=EOFException.INVALID_RJUMP_DESTINATION, ) @@ -607,7 +501,7 @@ def test_rjump_into_eofcreate( data=Container( sections=[ Section.Code( - code=Op.RJUMP[1] + Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP, + code=Op.PUSH0 * 4 + Op.RJUMP[1] + Op.EOFCREATE[0] + Op.STOP, ), Section.Container( container=Container( @@ -616,11 +510,7 @@ def test_rjump_into_eofcreate( code=Op.RETURNCONTRACT[0](0, 0), ), Section.Container( - container=Container( - sections=[ - Section.Code(code=Op.STOP), - ] - ) + container=Container.Code(code=Op.STOP), ), ] ) @@ -645,14 +535,10 @@ def test_rjump_into_returncontract( container=Container( sections=[ Section.Code( - code=Op.RJUMP[5] + Op.RETURNCONTRACT[0](0, 0), + code=Op.PUSH0 * 2 + Op.RJUMP[1] + Op.RETURNCONTRACT[0], ), Section.Container( - container=Container( - sections=[ - Section.Code(code=Op.STOP), - ] - ) + container=Container.Code(code=Op.STOP), ), ] ) diff --git a/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py b/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py index 7a9f1e54d57..427ddb226f4 100644 --- a/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py +++ b/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py @@ -48,19 +48,15 @@ def test_rjumpi_condition_forwards( env = Environment() sender = pre.fund_eoa(10**18) contract_address = pre.deploy_contract( - code=Container( - sections=[ - Section.Code( - code=Op.PUSH1(0) - + Op.CALLDATALOAD - + Op.RJUMPI[6] - + Op.SSTORE(slot_conditional_result, value_calldata_false) - + Op.STOP - + Op.SSTORE(slot_conditional_result, value_calldata_true) - + Op.STOP, - ) - ] - ), + code=Container.Code( + Op.PUSH1(0) + + Op.CALLDATALOAD + + Op.RJUMPI[6] + + Op.SSTORE(slot_conditional_result, value_calldata_false) + + Op.STOP + + Op.SSTORE(slot_conditional_result, value_calldata_true) + + Op.STOP, + ) ) tx = Transaction( to=contract_address, @@ -93,20 +89,16 @@ def test_rjumpi_condition_backwards( env = Environment() sender = pre.fund_eoa(10**18) contract_address = pre.deploy_contract( - code=Container( - sections=[ - Section.Code( - code=Op.PUSH1(1) - + Op.RJUMPI[6] - + Op.SSTORE(slot_conditional_result, value_calldata_true) - + Op.STOP - + Op.PUSH0 - + Op.CALLDATALOAD - + Op.RJUMPI[-11] - + Op.SSTORE(slot_conditional_result, value_calldata_false) - + Op.STOP, - ) - ] + code=Container.Code( + Op.PUSH1(1) + + Op.RJUMPI[6] + + Op.SSTORE(slot_conditional_result, value_calldata_true) + + Op.STOP + + Op.PUSH0 + + Op.CALLDATALOAD + + Op.RJUMPI[-11] + + Op.SSTORE(slot_conditional_result, value_calldata_false) + + Op.STOP, ) ) tx = Transaction( @@ -316,8 +308,10 @@ def test_rjumpi_truncated_2( ) +@pytest.mark.parametrize("offset", [-7, -15]) def test_rjumpi_into_header( eof_test: EOFTestFiller, + offset: int, ): """ EOF1I4200_0016 (Invalid) EOF code containing RJUMPI with target outside code bounds @@ -327,7 +321,7 @@ def test_rjumpi_into_header( data=Container( sections=[ Section.Code( - code=Op.PUSH1(1) + Op.RJUMPI[-7] + Op.STOP, + code=Op.PUSH1(1) + Op.RJUMPI[offset] + Op.STOP, ) ], ), @@ -747,12 +741,12 @@ def test_rjumpi_into_exchange( def test_rjumpi_into_eofcreate( eof_test: EOFTestFiller, ): - """EOF code containing RJUMP with target EOFCREATE immediate.""" + """EOF code containing RJUMPI with target EOFCREATE immediate.""" eof_test( data=Container( sections=[ Section.Code( - code=Op.PUSH0 + Op.RJUMPI[9] + Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP, + code=Op.PUSH0 * 5 + Op.RJUMPI[1] + Op.EOFCREATE[0] + Op.STOP, ), Section.Container( container=Container( @@ -761,11 +755,7 @@ def test_rjumpi_into_eofcreate( code=Op.RETURNCONTRACT[0](0, 0), ), Section.Container( - container=Container( - sections=[ - Section.Code(code=Op.STOP), - ] - ) + container=Container.Code(code=Op.STOP), ), ] ) @@ -779,7 +769,7 @@ def test_rjumpi_into_eofcreate( def test_rjumpi_into_returncontract( eof_test: EOFTestFiller, ): - """EOF code containing RJUMP with target RETURNCONTRACT immediate.""" + """EOF code containing RJUMPI with target RETURNCONTRACT immediate.""" eof_test( data=Container( sections=[ @@ -790,14 +780,10 @@ def test_rjumpi_into_returncontract( container=Container( sections=[ Section.Code( - code=Op.PUSH0 + Op.RJUMPI[5] + Op.RETURNCONTRACT[0](0, 0), + code=Op.PUSH0 * 3 + Op.RJUMPI[1] + Op.RETURNCONTRACT[0], ), Section.Container( - container=Container( - sections=[ - Section.Code(code=Op.STOP), - ] - ) + container=Container.Code(code=Op.STOP), ), ] ) diff --git a/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py b/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py index f30f7c0c858..b89b5c3f24d 100644 --- a/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py +++ b/tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py @@ -191,75 +191,20 @@ def test_rjumpv_size_3( ) +@pytest.mark.parametrize( + "target", + [0, 1, 100, 254, 255, 256], +) def test_rjumpv_full_table( eof_state_test: EOFStateTestFiller, + target: int, ): - """EOF1V4200_0012 (Valid) EOF with RJUMPV table size 256 (Target 0).""" - eof_state_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH1(0) - + Op.RJUMPV[range(256)] - + Op.NOOP * 256 - + Op.SSTORE(slot_code_worked, value_code_worked) - + Op.STOP, - ) - ], - ), - container_post=Account(storage={slot_code_worked: value_code_worked}), - ) - - -def test_rjumpv_full_table_mid( - eof_state_test: EOFStateTestFiller, -): - """EOF1V4200_0013 (Valid) EOF with RJUMPV table size 256 (Target 100).""" + """EOF1V4200_0012/13/14/15 (Valid) EOF with RJUMPV table size 256 (target parameterized).""" eof_state_test( data=Container( sections=[ Section.Code( - code=Op.PUSH1(100) - + Op.RJUMPV[range(256)] - + Op.NOOP * 256 - + Op.SSTORE(slot_code_worked, value_code_worked) - + Op.STOP, - ) - ], - ), - container_post=Account(storage={slot_code_worked: value_code_worked}), - ) - - -def test_rjumpv_full_table_end( - eof_state_test: EOFStateTestFiller, -): - """EOF1V4200_0014 (Valid) EOF with RJUMPV table size 256 (Target 254).""" - eof_state_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH1(254) - + Op.RJUMPV[range(256)] - + Op.NOOP * 256 - + Op.SSTORE(slot_code_worked, value_code_worked) - + Op.STOP, - ) - ], - ), - container_post=Account(storage={slot_code_worked: value_code_worked}), - ) - - -def test_rjumpv_full_table_last( - eof_state_test: EOFStateTestFiller, -): - """EOF1V4200_0015 (Valid) EOF with RJUMPV table size 256 (Target 256).""" - eof_state_test( - data=Container( - sections=[ - Section.Code( - code=Op.PUSH2(256) + code=Op.PUSH2[target] + Op.RJUMPV[range(256)] + Op.NOOP * 256 + Op.SSTORE(slot_code_worked, value_code_worked) @@ -320,7 +265,7 @@ def test_rjumpv_truncated( branches: int, byte_count_last_branch: int, ): - """EOF1I4200_0028/29/30/31 (Invalid) EOF code containing truncated RJUMPV.""" + """EOF1I4200_0028/29/30 (Invalid) EOF code containing truncated RJUMPV.""" rjumpv_bytes = int.to_bytes(branches - 1, 1, "big") rjumpv_bytes += b"\0" * ((2 * (branches - 1)) + byte_count_last_branch) @@ -362,6 +307,7 @@ def test_rjumpv_into_header( ) +@pytest.mark.parametrize("offset", [-13, -23]) @pytest.mark.parametrize( "table_size,invalid_index", [ @@ -374,12 +320,13 @@ def test_rjumpv_before_container( eof_test: EOFTestFiller, table_size: int, invalid_index: int, + offset: int, ): """ EOF1I4200_0032 (Invalid) EOF code containing RJUMPV with target outside code bounds (Jumping to before code begin). """ - invalid_destination = -13 - (2 * table_size) + invalid_destination = offset - (2 * table_size) jump_table = [0 for _ in range(table_size)] jump_table[invalid_index] = invalid_destination eof_test( @@ -1051,18 +998,15 @@ def test_rjumpv_into_eofcreate( table_size: int, invalid_index: int, ): - """EOF code containing RJUMP with target EOFCREATE immediate.""" - invalid_destination = 9 + """EOF code containing RJUMPV with target EOFCREATE immediate.""" + invalid_destination = 1 jump_table = [0 for _ in range(table_size)] jump_table[invalid_index] = invalid_destination eof_test( data=Container( sections=[ Section.Code( - code=Op.PUSH1(0) - + Op.RJUMPV[jump_table] - + Op.EOFCREATE[0](0, 0, 0, 0) - + Op.STOP, + code=Op.PUSH0 * 5 + Op.RJUMPV[jump_table] + Op.EOFCREATE[0] + Op.STOP, ), Section.Container( container=Container( @@ -1071,11 +1015,7 @@ def test_rjumpv_into_eofcreate( code=Op.RETURNCONTRACT[0](0, 0), ), Section.Container( - container=Container( - sections=[ - Section.Code(code=Op.STOP), - ] - ) + container=Container.Code(Op.STOP), ), ] ) @@ -1099,8 +1039,8 @@ def test_rjumpv_into_returncontract( table_size: int, invalid_index: int, ): - """EOF code containing RJUMP with target RETURNCONTRACT immediate.""" - invalid_destination = 5 + """EOF code containing RJUMPV with target RETURNCONTRACT immediate.""" + invalid_destination = 1 jump_table = [0 for _ in range(table_size)] jump_table[invalid_index] = invalid_destination eof_test( @@ -1113,16 +1053,10 @@ def test_rjumpv_into_returncontract( container=Container( sections=[ Section.Code( - code=Op.PUSH1(0) - + Op.RJUMPV[jump_table] - + Op.RETURNCONTRACT[0](0, 0), + code=Op.PUSH0 * 3 + Op.RJUMPV[jump_table] + Op.RETURNCONTRACT[0], ), Section.Container( - container=Container( - sections=[ - Section.Code(code=Op.STOP), - ] - ) + container=Container.Code(Op.STOP), ), ] ) diff --git a/tests/osaka/eip7692_eof_v1/eof_tracker.md b/tests/osaka/eip7692_eof_v1/eof_tracker.md index efacca1499c..d6f4f3a67ae 100644 --- a/tests/osaka/eip7692_eof_v1/eof_tracker.md +++ b/tests/osaka/eip7692_eof_v1/eof_tracker.md @@ -107,31 +107,31 @@ ### Validation -- [ ] Valid RJUMP with various offsets (ethereum/tests: src/EOFTestsFiller/efValidation/EOF1_valid_rjump_Copier.json src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) -- [ ] Valid RJUMP with maximum offset (ethereum/tests: src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) -- [ ] Valid RJUMP with minimum offset -- [ ] Valid RJUMPI with various offsets (ethereum/tests: src/EOFTestsFiller/efValidation/EOF1_valid_rjumpi_Copier.json src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) -- [ ] Valid RJUMPI with maximum offset (ethereum/offset: src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) -- [ ] Valid RJUMPI with minimum offset -- [ ] Valid RJUMPV with various number of offsets and various offsets (ethereum/tests: src/EOFTestsFiller/efValidation/EOF1_valid_rjumpv_Copier.json src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) -- [ ] Valid RJUMPV with table size 256 (ethereum/tests: src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) -- [ ] Valid RJUMPV containing maximum offset (ethereum/tests: src/EOFTestsFiller/EIP4200/validInvalidFiller.yml) +- [x] Valid RJUMP with various offsets ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_positive_negative`](./eip4200_relative_jumps/test_rjump/test_rjump_positive_negative.md)) +- [x] Valid RJUMP with maximum offset ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_maxes`](./eip4200_relative_jumps/test_rjump/test_rjump_maxes.md)) +- [x] Valid RJUMP with minimum offset ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_maxes`](./eip4200_relative_jumps/test_rjump/test_rjump_maxes.md)) +- [x] Valid RJUMPI with various offsets ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_forwards`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_forwards.md)) +- [x] Valid RJUMPI with maximum offset ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_max_forward`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_max_forward.md)) +- [x] Valid RJUMPI with minimum offset ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_max_backward`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_max_backward.md)) +- [x] Valid RJUMPV with various number of offsets and various offsets ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_forwards`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_forwards.md)) +- [x] Valid RJUMPV with table size 256 ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_full_table`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_full_table.md)) +- [x] Valid RJUMPV containing maximum offset ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_max_forwards`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_max_forwards.md)) - [ ] Valid RJUMPV containing minimum offset -- [ ] Truncated before RJUMP immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjump_truncated_Copier.json) -- [ ] Truncated RJUMP immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjump_truncated_Copier.json) -- [ ] RJUMP out of container bounds (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjump_invalid_destination_Copier.json) -- [ ] RJUMP out of section bounds (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjump_invalid_destination_Copier.json) -- [ ] RJUMP into immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjump_invalid_destination_Copier.json) -- [ ] Truncated before RJUMPI immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpi_truncated_Copier.json) -- [ ] Truncated RJUMPI immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpi_truncated_Copier.json) -- [ ] RJUMPI out of container bounds (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpi_invalid_destination_Copier.json) -- [ ] RJUMPI out of section bounds (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpi_invalid_destination_Copier.json) -- [ ] RJUMPI into immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpi_invalid_destination_Copier.json) -- [ ] Truncated before RJUMPV immediate -- [ ] Truncated RJUMPV immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpv_truncated_Copier.json) -- [ ] RJUMPV out of container bounds (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpv_invalid_destination_Copier.json) -- [ ] RJUMPV out of section bounds (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpv_invalid_destination_Copier.json) -- [ ] RJUMPV into immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_rjumpv_invalid_destination_Copier.json) +- [x] Truncated before RJUMP immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_truncated_rjump`](./eip4200_relative_jumps/test_rjump/test_rjump_truncated_rjump.md)) +- [x] Truncated RJUMP immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_truncated_rjump_2`](./eip4200_relative_jumps/test_rjump/test_rjump_truncated_rjump_2.md)) +- [x] RJUMP out of container bounds ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_after_container`](./eip4200_relative_jumps/test_rjump/test_rjump_after_container.md)) +- [x] RJUMP out of section bounds ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_into_data`](./eip4200_relative_jumps/test_rjump/test_rjump_into_data.md)) +- [x] RJUMP into immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py::test_rjump_into_push_1`](./eip4200_relative_jumps/test_rjump/test_rjump_into_push_1.md)) +- [x] Truncated before RJUMPI immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_truncated`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_truncated.md)) +- [x] Truncated RJUMPI immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_truncated_2`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_truncated_2.md)) +- [x] RJUMPI out of container bounds ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_after_container`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_after_container.md)) +- [x] RJUMPI out of section bounds ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_into_data`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_into_data.md)) +- [x] RJUMPI into immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_into_push_1`](./eip4200_relative_jumps/test_rjumpi/test_rjumpi_into_push_1.md)) +- [x] Truncated before RJUMPV immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_truncated_empty`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_truncated_empty.md)) +- [x] Truncated RJUMPV immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_truncated`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_truncated.md)) +- [x] RJUMPV out of container bounds ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_after_container`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_after_container.md)) +- [x] RJUMPV out of section bounds ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_data`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_into_data.md)) +- [x] RJUMPV into immediate ([`tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_push_1`](./eip4200_relative_jumps/test_rjumpv/test_rjumpv_into_push_1.md)) ### Execution