-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new(tests): EOF - EIP-7620: EOFCREATE and RETURNDATA tests (#532)
* EOFCREATE and RETURNDATA tests Tests covering EOFCREATE and RETURNDATA, ported from evmone Signed-off-by: Danno Ferrin <[email protected]> * fix imports Signed-off-by: Danno Ferrin <[email protected]> * review requested changes add canary value Signed-off-by: Danno Ferrin <[email protected]> * reviewer change requests Change all magic numbers for storage into variables. Signed-off-by: Danno Ferrin <[email protected]> * code formatting Signed-off-by: Danno Ferrin <[email protected]> * fix(fw): minor nit * refactor(tests): EIP-7620: fixes --------- Signed-off-by: Danno Ferrin <[email protected]> Co-authored-by: Mario Vega <[email protected]>
- Loading branch information
Showing
13 changed files
with
1,328 additions
and
25 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 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
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
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
14 changes: 14 additions & 0 deletions
14
tests/prague/eip7692_eof_v1/eip7620_eof_create/__init__.py
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,14 @@ | ||
""" | ||
EOFCREATE, RETURNCONTRACT, and container tests | ||
evmone tests not ported | ||
create_tx_with_eof_initcode - This calls it invalid, it is now the way to add EOF contacts to state | ||
eofcreate_extcall_returncontract - per the new initcode mode tests you cannot have RETURNCONTRACT | ||
in a deployed contract | ||
eofcreate_dataloadn_referring_to_auxdata - covered by | ||
tests.prague.eip7480_data_section.test_data_opcodes.test_data_section_succeed | ||
eofcreate_initcontainer_return - RETURN is banned in initcode containers | ||
eofcreate_initcontainer_stop - STOP is banned in initcode containers | ||
All TXCREATE tests - TXCREATE has been removed from Prague | ||
""" |
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,88 @@ | ||
""" | ||
A collection of contracts used in 7620 EOF tests | ||
""" | ||
import itertools | ||
|
||
from ethereum_test_tools import Address | ||
from ethereum_test_tools import Opcodes as Op | ||
from ethereum_test_tools import Transaction | ||
from ethereum_test_tools.eof.v1 import Container, Section | ||
from ethereum_test_tools.eof.v1.constants import NON_RETURNING_SECTION | ||
|
||
"""Storage addresses for common testing fields""" | ||
_slot = itertools.count() | ||
next(_slot) # don't use slot 0 | ||
slot_code_worked = next(_slot) | ||
slot_code_should_fail = next(_slot) | ||
slot_create_address = next(_slot) | ||
slot_calldata = next(_slot) | ||
slot_call_result = next(_slot) | ||
slot_returndata = next(_slot) | ||
slot_returndata_size = next(_slot) | ||
|
||
slot_last_slot = next(_slot) | ||
|
||
value_code_worked = 0x2015 | ||
value_canary_should_not_change = 0x2019 | ||
value_canary_to_be_overwritten = 0x2009 | ||
value_create_failed = 0 | ||
value_call_result_success = 0 | ||
|
||
smallest_runtime_subcontainer = Container( | ||
name="Runtime Subcontainer", | ||
sections=[ | ||
Section.Code( | ||
code=Op.STOP, code_inputs=0, code_outputs=NON_RETURNING_SECTION, max_stack_height=0 | ||
) | ||
], | ||
) | ||
|
||
smallest_initcode_subcontainer = Container( | ||
name="Initcode Subcontainer", | ||
sections=[ | ||
Section.Code( | ||
code=Op.RETURNCONTRACT[0](0, 0), | ||
code_inputs=0, | ||
code_outputs=NON_RETURNING_SECTION, | ||
max_stack_height=2, | ||
), | ||
Section.Container(container=smallest_runtime_subcontainer), | ||
], | ||
) | ||
|
||
|
||
def fixed_address(index: int) -> Address: | ||
""" | ||
Returns an determinstic address for testing | ||
Parameters | ||
---------- | ||
index - how foar off of the initial to create the address | ||
Returns | ||
------- | ||
An address, unique per index and human friendly for testing | ||
""" | ||
return Address(0x7E570000 + index) | ||
|
||
|
||
default_address = fixed_address(0) | ||
|
||
|
||
def simple_transaction( | ||
target: Address = default_address, payload: bytes = b"", gas_limit: int = 10_000_000 | ||
): | ||
""" | ||
Creates a simple transaction | ||
Parameters | ||
---------- | ||
target the target address, defaults to 0x100 | ||
payload the payload, defauls to empty | ||
Returns | ||
------- | ||
a transaction instance that can be passed into state_tests | ||
""" | ||
return Transaction( | ||
nonce=1, to=target, gas_limit=gas_limit, gas_price=10, protected=False, data=payload | ||
) |
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,5 @@ | ||
""" | ||
EOF V1 Constants used throughout all tests | ||
""" | ||
|
||
EOF_FORK_NAME = "Prague" |
Oops, something went wrong.