Skip to content

Commit db60338

Browse files
marioevzjochem-brouwerdanceratopz
authored
feat(fw,tests): EIP-6110, EIP-7002, EIP-7251, EIP-7702: Pectra Devnet-4 updates (#832)
* fix(forks): Update 7002, 7251 contracts * feat(forks): Add 7685 methods * fix(fw): Remove requests from block body, add as parameters for new payload * refactor(tests): Refactor requests usages, add more 7685 tests * feat(tests): EIP-7702, #8929 changes - Incomplete * Update tests/prague/eip7702_set_code_tx/spec.py Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com> * feat(exceptions): Add invalid authorization format exception * new(tests): EIP 7702: chain id/nonce overflow tests * new(tests): EIP 7702: delegation clearing test * new(tests): EIP 7702: delegation clearing on failure test * new(tests): EIP 7702: fixup * new(tests): EIP 7702: test deployting a delegation-like contract * fix(tests): EIP 7702: remove `test_set_code_to_zero_address` * new(tests): EIP 7702: add `test_signature_s_out_of_range` * fix(forks): EIP-7002,7251 contracts * new(tests): EIP-7002: withdrawal request during fork * fix(tests): EIP-7002: fixup * fix(tests): EIP-7002: fixup * new(tests): EIP-7251: consolidation requests during fork * fix(tests): tox * github: Add devnet-4 configs * fix(github): feature devnet-4 * fix(tests): EIP-6110 conftest * fix(github): feature * fix(specs): Propagate `block.requests` to the Engine API params * fix(tests): Fix override requests comparison for empty list * fix(tox): whitelist * fix(tests): EIP-7702: note in `test_tx_validity_nonce` * new(tests): EIP-7702: Add invalid `v` (27, 28) for auth tuple test * chore(hive): update hive client config file in test summary * fix(plugins/execute): Requests * fix(rpc): Support `engine_getPayloadV4` * fix(plugins/execute): Support `engine_getPayloadV4` * fix(tests): EIP-7702: test id * fix(tests): EIP-7702: execute marks --------- Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com> Co-authored-by: danceratopz <danceratopz@gmail.com>
1 parent 358a26f commit db60338

File tree

34 files changed

+1745
-750
lines changed

34 files changed

+1745
-750
lines changed

.github/configs/evm.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ eip7692-osaka:
1717
pectra-devnet-3:
1818
impl: ethjs
1919
repo: ethereumjs/ethereumjs-monorepo
20-
ref: t8ntool
20+
ref: t8ntool
21+
pectra-devnet-4:
22+
impl: ethjs
23+
repo: ethereumjs/ethereumjs-monorepo
24+
ref: 7702-devnet-4-plus-t8ntool

.github/configs/feature.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ eip7692-osaka:
2020
solc: 0.8.21
2121
pectra-devnet-3:
2222
evm-type: pectra-devnet-3
23-
fill-params: --fork=Prague -m "not slow and not 2537" ./tests/prague/
23+
fill-params: --fork=Prague -m "not slow" ./tests/prague/
24+
solc: 0.8.21
25+
pectra-devnet-4:
26+
evm-type: pectra-devnet-4
27+
fill-params: --fork=Prague -m "not slow and not eip_version_check" ./tests/prague/
2428
solc: 0.8.21

src/ethereum_clis/types.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
from pydantic import Field
88

99
from ethereum_test_base_types import Address, Bloom, Bytes, CamelModel, Hash, HexNumber
10-
from ethereum_test_types import (
11-
Alloc,
12-
ConsolidationRequest,
13-
DepositRequest,
14-
Environment,
15-
Transaction,
16-
WithdrawalRequest,
17-
)
10+
from ethereum_test_types import Alloc, Environment, Transaction
1811

1912

2013
class TransactionLog(CamelModel):
@@ -94,10 +87,8 @@ class Result(CamelModel):
9487
withdrawals_root: Hash | None = None
9588
excess_blob_gas: HexNumber | None = Field(None, alias="currentExcessBlobGas")
9689
blob_gas_used: HexNumber | None = None
97-
requests_root: Hash | None = None
98-
deposit_requests: List[DepositRequest] | None = None
99-
withdrawal_requests: List[WithdrawalRequest] | None = None
100-
consolidation_requests: List[ConsolidationRequest] | None = None
90+
requests_hash: Hash | None = None
91+
requests: List[Bytes] | None = None
10192

10293

10394
class TransitionToolInput(CamelModel):

src/ethereum_test_exceptions/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,10 @@ class TransactionException(ExceptionBase):
382382
"""
383383
Transaction is a type 4 transaction and has an empty `to`.
384384
"""
385+
TYPE_4_INVALID_AUTHORIZATION_FORMAT = auto()
386+
"""
387+
Transaction is type 4, but contains an authorization that has an invalid format.
388+
"""
385389

386390

387391
@unique

src/ethereum_test_fixtures/blockchain.py

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,11 @@
2626
from ethereum_test_forks import Fork, Paris
2727
from ethereum_test_types.types import (
2828
AuthorizationTupleGeneric,
29-
ConsolidationRequest,
30-
ConsolidationRequestGeneric,
31-
DepositRequest,
32-
DepositRequestGeneric,
33-
Requests,
3429
Transaction,
3530
TransactionFixtureConverter,
3631
TransactionGeneric,
3732
Withdrawal,
3833
WithdrawalGeneric,
39-
WithdrawalRequest,
40-
WithdrawalRequestGeneric,
4134
)
4235

4336
from .base import BaseFixture
@@ -117,7 +110,7 @@ class FixtureHeader(CamelModel):
117110
parent_beacon_block_root: Annotated[Hash, HeaderForkRequirement("beacon_root")] | None = Field(
118111
None
119112
)
120-
requests_root: Annotated[Hash, HeaderForkRequirement("requests")] | None = Field(None)
113+
requests_hash: Annotated[Hash, HeaderForkRequirement("requests")] | None = Field(None)
121114

122115
fork: Fork | None = Field(None, exclude=True)
123116

@@ -210,17 +203,13 @@ class FixtureExecutionPayload(CamelModel):
210203

211204
transactions: List[Bytes]
212205
withdrawals: List[Withdrawal] | None = None
213-
deposit_requests: List[DepositRequest] | None = None
214-
withdrawal_requests: List[WithdrawalRequest] | None = None
215-
consolidation_requests: List[ConsolidationRequest] | None = None
216206

217207
@classmethod
218208
def from_fixture_header(
219209
cls,
220210
header: FixtureHeader,
221211
transactions: List[Transaction],
222212
withdrawals: List[Withdrawal] | None,
223-
requests: Requests | None,
224213
) -> "FixtureExecutionPayload":
225214
"""
226215
Returns a FixtureExecutionPayload from a FixtureHeader, a list
@@ -230,20 +219,20 @@ def from_fixture_header(
230219
**header.model_dump(exclude={"rlp"}, exclude_none=True),
231220
transactions=[tx.rlp for tx in transactions],
232221
withdrawals=withdrawals,
233-
deposit_requests=requests.deposit_requests() if requests is not None else None,
234-
withdrawal_requests=requests.withdrawal_requests() if requests is not None else None,
235-
consolidation_requests=requests.consolidation_requests()
236-
if requests is not None
237-
else None,
238222
)
239223

240224

241225
EngineNewPayloadV1Parameters = Tuple[FixtureExecutionPayload]
242226
EngineNewPayloadV3Parameters = Tuple[FixtureExecutionPayload, List[Hash], Hash]
227+
EngineNewPayloadV4Parameters = Tuple[FixtureExecutionPayload, List[Hash], Hash, List[Bytes]]
243228

244229
# Important: We check EngineNewPayloadV3Parameters first as it has more fields, and pydantic
245230
# has a weird behavior when the smaller tuple is checked first.
246-
EngineNewPayloadParameters = Union[EngineNewPayloadV3Parameters, EngineNewPayloadV1Parameters]
231+
EngineNewPayloadParameters = Union[
232+
EngineNewPayloadV4Parameters,
233+
EngineNewPayloadV3Parameters,
234+
EngineNewPayloadV1Parameters,
235+
]
247236

248237

249238
class FixtureEngineNewPayload(CamelModel):
@@ -280,7 +269,7 @@ def from_fixture_header(
280269
header: FixtureHeader,
281270
transactions: List[Transaction],
282271
withdrawals: List[Withdrawal] | None,
283-
requests: Requests | None,
272+
requests: List[Bytes] | None,
284273
**kwargs,
285274
) -> "FixtureEngineNewPayload":
286275
"""
@@ -296,10 +285,21 @@ def from_fixture_header(
296285
header=header,
297286
transactions=transactions,
298287
withdrawals=withdrawals,
299-
requests=requests,
300288
)
301-
params: Tuple[FixtureExecutionPayload] | Tuple[FixtureExecutionPayload, List[Hash], Hash]
302-
if fork.engine_new_payload_blob_hashes(header.number, header.timestamp):
289+
params: EngineNewPayloadParameters
290+
if (
291+
fork.engine_new_payload_requests(header.number, header.timestamp)
292+
and requests is not None
293+
):
294+
parent_beacon_block_root = header.parent_beacon_block_root
295+
assert parent_beacon_block_root is not None
296+
params = (
297+
execution_payload,
298+
Transaction.list_blob_versioned_hashes(transactions),
299+
parent_beacon_block_root,
300+
requests,
301+
)
302+
elif fork.engine_new_payload_blob_hashes(header.number, header.timestamp):
303303
parent_beacon_block_root = header.parent_beacon_block_root
304304
assert parent_beacon_block_root is not None
305305
params = (
@@ -366,60 +366,13 @@ def from_withdrawal(cls, w: WithdrawalGeneric) -> "FixtureWithdrawal":
366366
return cls(**w.model_dump())
367367

368368

369-
class FixtureDepositRequest(DepositRequestGeneric[ZeroPaddedHexNumber]):
370-
"""
371-
Structure to represent a single deposit request to be processed by the beacon
372-
chain.
373-
"""
374-
375-
@classmethod
376-
def from_deposit_request(cls, d: DepositRequestGeneric) -> "FixtureDepositRequest":
377-
"""
378-
Returns a FixtureDepositRequest from a DepositRequest.
379-
"""
380-
return cls(**d.model_dump())
381-
382-
383-
class FixtureWithdrawalRequest(WithdrawalRequestGeneric[ZeroPaddedHexNumber]):
384-
"""
385-
Structure to represent a single withdrawal request to be processed by the beacon
386-
chain.
387-
"""
388-
389-
@classmethod
390-
def from_withdrawal_request(cls, d: WithdrawalRequestGeneric) -> "FixtureWithdrawalRequest":
391-
"""
392-
Returns a FixtureWithdrawalRequest from a WithdrawalRequest.
393-
"""
394-
return cls(**d.model_dump())
395-
396-
397-
class FixtureConsolidationRequest(ConsolidationRequestGeneric[ZeroPaddedHexNumber]):
398-
"""
399-
Structure to represent a single consolidation request to be processed by the beacon
400-
chain.
401-
"""
402-
403-
@classmethod
404-
def from_consolidation_request(
405-
cls, d: ConsolidationRequestGeneric
406-
) -> "FixtureConsolidationRequest":
407-
"""
408-
Returns a FixtureConsolidationRequest from a ConsolidationRequest.
409-
"""
410-
return cls(**d.model_dump())
411-
412-
413369
class FixtureBlockBase(CamelModel):
414370
"""Representation of an Ethereum block within a test Fixture without RLP bytes."""
415371

416372
header: FixtureHeader = Field(..., alias="blockHeader")
417373
txs: List[FixtureTransaction] = Field(default_factory=list, alias="transactions")
418374
ommers: List[FixtureHeader] = Field(default_factory=list, alias="uncleHeaders")
419375
withdrawals: List[FixtureWithdrawal] | None = None
420-
deposit_requests: List[FixtureDepositRequest] | None = None
421-
withdrawal_requests: List[FixtureWithdrawalRequest] | None = None
422-
consolidation_requests: List[FixtureConsolidationRequest] | None = None
423376

424377
@computed_field(alias="blocknumber") # type: ignore[misc]
425378
@cached_property
@@ -429,7 +382,7 @@ def block_number(self) -> Number:
429382
"""
430383
return Number(self.header.number)
431384

432-
def with_rlp(self, txs: List[Transaction], requests: Requests | None) -> "FixtureBlock":
385+
def with_rlp(self, txs: List[Transaction]) -> "FixtureBlock":
433386
"""
434387
Returns a FixtureBlock with the RLP bytes set.
435388
"""
@@ -442,9 +395,6 @@ def with_rlp(self, txs: List[Transaction], requests: Requests | None) -> "Fixtur
442395
if self.withdrawals is not None:
443396
block.append([w.to_serializable_list() for w in self.withdrawals])
444397

445-
if requests is not None:
446-
block.append(requests.to_serializable_list())
447-
448398
return FixtureBlock(
449399
**self.model_dump(),
450400
rlp=eth_rlp.encode(block),

0 commit comments

Comments
 (0)