Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): Remove TestAddress usage on EOF tests #626

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
Environment,
StateTestFiller,
Storage,
TestAddress,
Transaction,
)
from ethereum_test_tools.eof.v1 import Container, Section
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
105 changes: 0 additions & 105 deletions tests/prague/eip7692_eof_v1/eip3540_eof_v1/test_code_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down