Skip to content

Commit d2b5148

Browse files
pdobaczmarioevz
andauthored
fix(tests,fw): Remove EIP-7698 EOF creation txs (#1451)
* fix(tests): Remove/Move EIP-7698 tests * fix(fw): add EOF_CREATION_TRANSACTION exception * fix(tests): EIP-7069 to not use EOF creation tx * fix(fw): eof_state_test not to use EOF creation tx * fix(fw): ...test_from_eof_test not to use EOF creation tx * fix(docs): misc remove mentions of EOF creation tx * fix(tests): allow variants of validation exceptions * review comments * Mark `test_legacy_create_tx_eof_initcode` with `xfail` * changelog --------- Co-authored-by: Mario Vega <[email protected]>
1 parent cb4ccde commit d2b5148

File tree

15 files changed

+383
-358
lines changed

15 files changed

+383
-358
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ This feature can be disabled by using `--disable-strict-exception-matching` for
5353
-[EIP-7251](https://eips.ethereum.org/EIPS/eip-7251): Remove pytest skips for consolidation request cases ([#1449](https://github.com/ethereum/execution-spec-tests/pull/1449)).
5454
-[EIP-7002](https://eips.ethereum.org/EIPS/eip-7002), [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251): Add cases to verify behavior of contracts missing at fork ([#1394](https://github.com/ethereum/execution-spec-tests/pull/1394)).
5555
-[EIP-7002](https://eips.ethereum.org/EIPS/eip-7002), [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251): Add cases to verify behavior of system contract errors invalidating a block ([#1394](https://github.com/ethereum/execution-spec-tests/pull/1394)).
56+
- 🔀 Remove [EIP-7698](https://eips.ethereum.org/EIPS/eip-7698): EIP has been removed and the tests related to it have also been removed, while preserving a subset of the tests to verify that functionality is removed in clients ([#1451](https://github.com/ethereum/execution-spec-tests/pull/1451)).
5657

5758
### 📋 Misc
5859

src/ethereum_clis/clis/evmone.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class EvmoneExceptionMapper(ExceptionMapper):
8080
),
8181
TransactionException.NONCE_MISMATCH_TOO_LOW: "nonce too low",
8282
TransactionException.NONCE_MISMATCH_TOO_HIGH: "nonce too high",
83+
TransactionException.EOF_CREATION_TRANSACTION: "EOF initcode in creation transaction",
8384
# TODO EVMONE needs to differentiate when the section is missing in the header or body
8485
EOFException.MISSING_STOP_OPCODE: "err: no_terminating_instruction",
8586
EOFException.MISSING_CODE_HEADER: "err: code_section_missing",

src/ethereum_test_exceptions/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ class TransactionException(ExceptionBase):
327327
"""
328328
Transaction's initcode for a contract-creating transaction is too large.
329329
"""
330+
EOF_CREATION_TRANSACTION = auto()
331+
"""
332+
Creation transaction (to: nil) contains EOF initcode
333+
"""
330334
TYPE_3_TX_PRE_FORK = auto()
331335
"""
332336
Transaction type 3 included before activation fork.

src/ethereum_test_specs/eof.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from ethereum_test_forks import Fork
3030
from ethereum_test_types import EOA, Alloc, Environment, Transaction
3131
from ethereum_test_types.eof.v1 import Container, ContainerKind, Section, SectionKind
32+
from ethereum_test_types.helpers import compute_eofcreate_address
3233
from ethereum_test_vm import Opcodes as Op
3334

3435
from .base import BaseTest
@@ -384,6 +385,7 @@ def generate_eof_contract_create_transaction(self) -> Transaction:
384385
"""Generate a transaction that creates a contract."""
385386
assert self.sender is not None, "sender must be set to generate a StateTest."
386387
assert self.post is not None, "post must be set to generate a StateTest."
388+
assert self.pre is not None, "pre must be set to generate a StateTest."
387389

388390
initcode: Container
389391
deployed_container: Container | Bytes | None = None
@@ -420,17 +422,23 @@ def generate_eof_contract_create_transaction(self) -> Transaction:
420422
)
421423
deployed_container = self.container
422424

425+
factory_address = self.pre.deploy_contract(
426+
Op.TXCREATE(tx_initcode_hash=initcode.hash) + Op.STOP
427+
)
428+
423429
tx = Transaction(
424430
sender=self.sender,
425-
to=None,
431+
to=factory_address,
426432
gas_limit=10_000_000,
427-
data=initcode,
433+
max_priority_fee_per_gas=10,
434+
max_fee_per_gas=10,
435+
initcodes=[initcode],
428436
)
429437

430438
if self.expect_exception is not None or deployed_container is None:
431-
self.post[tx.created_contract] = None
439+
self.post[compute_eofcreate_address(factory_address, 0)] = None
432440
else:
433-
self.post[tx.created_contract] = Account(
441+
self.post[compute_eofcreate_address(factory_address, 0)] = Account(
434442
code=deployed_container,
435443
)
436444
return tx
@@ -548,26 +556,39 @@ def model_post_init(self, __context):
548556
if self.post is None:
549557
self.post = Alloc()
550558

551-
if self.expect_exception is not None: # Invalid EOF
552-
self.to = None # Make EIP-7698 create transaction
553-
self.data = Bytes(
554-
bytes(self.container) + self.data
555-
) # by concatenating container and tx data.
559+
if self.expect_exception is not None and self.container_kind == ContainerKind.RUNTIME:
560+
# Invalid EOF runtime code
561+
initcode = Container.Init(deploy_container=self.container)
562+
self.to = self.pre.deploy_contract(
563+
Op.TXCREATE(tx_initcode_hash=initcode.hash) + Op.STOP
564+
)
565+
self.initcodes = [initcode]
566+
567+
# Run transaction model validation
568+
Transaction.model_post_init(self, __context)
569+
570+
self.post[compute_eofcreate_address(self.to, 0)] = None # Expect failure.
571+
elif self.expect_exception is not None and self.container_kind == ContainerKind.INITCODE:
572+
# Invalid EOF initcode
573+
self.to = self.pre.deploy_contract(
574+
Op.TXCREATE(tx_initcode_hash=self.container.hash) + Op.STOP
575+
)
576+
self.initcodes = [self.container]
556577

557578
# Run transaction model validation
558579
Transaction.model_post_init(self, __context)
559580

560-
self.post[self.created_contract] = None # Expect failure.
581+
self.post[compute_eofcreate_address(self.to, 0)] = None # Expect failure.
561582
elif self.container_kind == ContainerKind.INITCODE:
562-
self.to = None # Make EIP-7698 create transaction
563-
self.data = Bytes(
564-
bytes(self.container) + self.data
565-
) # by concatenating container and tx data.
583+
self.to = self.pre.deploy_contract(
584+
Op.TXCREATE(tx_initcode_hash=self.container.hash) + Op.STOP
585+
)
586+
self.initcodes = [self.container]
566587

567588
# Run transaction model validation
568589
Transaction.model_post_init(self, __context)
569590

570-
self.post[self.created_contract] = self.container_post # Successful.
591+
self.post[compute_eofcreate_address(self.to, 0)] = self.container_post
571592
else:
572593
self.to = self.pre.deploy_contract(code=self.container)
573594

tests/osaka/eip7692_eof_v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* [EIP-7069: Revamped CALL instructions](https://eips.ethereum.org/EIPS/eip-7069).
1313
* [EIP-7480: EOF - Data section access instructions](https://eips.ethereum.org/EIPS/eip-7480).
1414
* [EIP-7620: EOF Contract Creation](https://eips.ethereum.org/EIPS/eip-7620).
15-
* [EIP-7698: EOF - Creation transaction](https://eips.ethereum.org/EIPS/eip-7698).
15+
* [EIP-7873: EOF - TXCREATE and InitcodeTransaction type](https://eips.ethereum.org/EIPS/eip-7873).
1616
1717
## Devnet Specifications
1818

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,10 @@ def test_valid_containers(
426426
# EOF code containing type section size (Size 1)
427427
name="EOF1I4750_0003",
428428
raw_bytes="ef00010100010200010001ff00000000800000fe",
429-
validity_error=EOFException.INVALID_TYPE_SECTION_SIZE,
429+
validity_error=[
430+
EOFException.INVALID_TYPE_SECTION_SIZE,
431+
EOFException.INVALID_SECTION_BODIES_SIZE,
432+
],
430433
),
431434
Container(
432435
# EOF code containing type section size (Size 8 - 1 Code section)

tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_size.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def __str__(self) -> str:
7171
id="type_size_zero",
7272
),
7373
pytest.param(
74-
SectionKind.TYPE, SectionSize.UNDERSIZE, EOFException.INVALID_TYPE_SECTION_SIZE
74+
SectionKind.TYPE,
75+
SectionSize.UNDERSIZE,
76+
[EOFException.INVALID_SECTION_BODIES_SIZE, EOFException.INVALID_TYPE_SECTION_SIZE],
77+
id="type_size_undersize",
7578
),
7679
pytest.param(
7780
SectionKind.TYPE, SectionSize.OVERSIZE, EOFException.INVALID_SECTION_BODIES_SIZE

tests/osaka/eip7692_eof_v1/eip7069_extcall/test_calls.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
StateTestFiller,
1515
Storage,
1616
Transaction,
17-
compute_create_address,
1817
)
1918
from ethereum_test_tools.vm.opcode import Opcodes as Op
2019
from ethereum_test_types.eof.v1 import Container, Section
20+
from ethereum_test_types.helpers import compute_eofcreate_address
2121
from ethereum_test_vm.bytecode import Bytecode
2222
from ethereum_test_vm.evm_types import EVMCodeType
2323

@@ -1168,13 +1168,18 @@ def test_extdelegate_call_targets(
11681168
Section.Container(Container.Code(Op.STOP)),
11691169
]
11701170
)
1171+
initcode_hash = caller_contract.hash
1172+
factory_address = pre.deploy_contract(
1173+
code=Op.TXCREATE(tx_initcode_hash=initcode_hash) + Op.STOP,
1174+
)
11711175
tx = Transaction(
11721176
sender=sender,
1173-
to=None,
1177+
to=factory_address,
11741178
data=caller_contract,
11751179
gas_limit=4_000_000,
1180+
initcodes=[caller_contract],
11761181
)
1177-
calling_contract_address = tx.created_contract
1182+
calling_contract_address = compute_eofcreate_address(factory_address, 0)
11781183
else:
11791184
# Normal call from existing contract
11801185
caller_contract = Container.Code(
@@ -1196,14 +1201,9 @@ def test_extdelegate_call_targets(
11961201
if target_account_type == TargetAccountType.EOF_CONTRACT_INVALID
11971202
else EXTCALL_REVERT,
11981203
}
1199-
storage_address = (
1200-
compute_create_address(address=sender, nonce=0)
1201-
if call_from_initcode
1202-
else calling_contract_address
1203-
)
12041204

12051205
post = {
1206-
storage_address: Account(storage=calling_storage),
1206+
calling_contract_address: Account(storage=calling_storage),
12071207
}
12081208

12091209
state_test(

tests/osaka/eip7692_eof_v1/eip7698_eof_creation_tx/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/osaka/eip7692_eof_v1/eip7698_eof_creation_tx/helpers.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)