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

feat(fw,tests): EIP-6110, EIP-7002, EIP-7251, EIP-7702: Pectra Devnet-4 updates #832

Merged
merged 35 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
19c0048
fix(forks): Update 7002, 7251 contracts
marioevz Oct 9, 2024
9d36738
feat(forks): Add 7685 methods
marioevz Oct 9, 2024
cf90af0
fix(fw): Remove requests from block body, add as parameters for new p…
marioevz Oct 9, 2024
6a3e1e0
refactor(tests): Refactor requests usages, add more 7685 tests
marioevz Oct 9, 2024
45a4e86
feat(tests): EIP-7702, #8929 changes - Incomplete
marioevz Oct 10, 2024
ee83f0d
Update tests/prague/eip7702_set_code_tx/spec.py
marioevz Oct 10, 2024
849a73d
feat(exceptions): Add invalid authorization format exception
marioevz Oct 10, 2024
09bb0b7
new(tests): EIP 7702: chain id/nonce overflow tests
marioevz Oct 10, 2024
654c31b
new(tests): EIP 7702: delegation clearing test
marioevz Oct 10, 2024
47d894e
new(tests): EIP 7702: delegation clearing on failure test
marioevz Oct 10, 2024
60c51e3
new(tests): EIP 7702: fixup
marioevz Oct 10, 2024
9f3831d
new(tests): EIP 7702: test deployting a delegation-like contract
marioevz Oct 10, 2024
70c00c0
fix(tests): EIP 7702: remove `test_set_code_to_zero_address`
marioevz Oct 10, 2024
38c1d0d
new(tests): EIP 7702: add `test_signature_s_out_of_range`
marioevz Oct 10, 2024
84f7437
fix(forks): EIP-7002,7251 contracts
marioevz Oct 10, 2024
3f6b4ce
new(tests): EIP-7002: withdrawal request during fork
marioevz Oct 11, 2024
c27f5c4
fix(tests): EIP-7002: fixup
marioevz Oct 11, 2024
db09530
fix(tests): EIP-7002: fixup
marioevz Oct 11, 2024
5aee890
new(tests): EIP-7251: consolidation requests during fork
marioevz Oct 11, 2024
1b90ae4
fix(tests): tox
marioevz Oct 11, 2024
f329265
github: Add devnet-4 configs
marioevz Oct 12, 2024
a0a6b41
fix(github): feature devnet-4
marioevz Oct 12, 2024
3021227
fix(tests): EIP-6110 conftest
marioevz Oct 13, 2024
52ff39d
fix(github): feature
marioevz Oct 13, 2024
e0420fa
fix(specs): Propagate `block.requests` to the Engine API params
marioevz Oct 14, 2024
c937f10
fix(tests): Fix override requests comparison for empty list
marioevz Oct 14, 2024
782cb06
fix(tox): whitelist
marioevz Oct 14, 2024
b7c7c29
fix(tests): EIP-7702: note in `test_tx_validity_nonce`
marioevz Oct 15, 2024
16e226b
new(tests): EIP-7702: Add invalid `v` (27, 28) for auth tuple test
marioevz Oct 24, 2024
d86c9f2
chore(hive): update hive client config file in test summary
danceratopz Oct 23, 2024
e03a7df
fix(plugins/execute): Requests
marioevz Oct 24, 2024
889c9d4
fix(rpc): Support `engine_getPayloadV4`
marioevz Oct 24, 2024
f729ff5
fix(plugins/execute): Support `engine_getPayloadV4`
marioevz Oct 24, 2024
17db052
fix(tests): EIP-7702: test id
marioevz Oct 24, 2024
a7f0eca
fix(tests): EIP-7702: execute marks
marioevz Oct 24, 2024
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
6 changes: 5 additions & 1 deletion .github/configs/evm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ eip7692-osaka:
pectra-devnet-3:
impl: ethjs
repo: ethereumjs/ethereumjs-monorepo
ref: t8ntool
ref: t8ntool
pectra-devnet-4:
impl: ethjs
repo: ethereumjs/ethereumjs-monorepo
ref: 7702-devnet-4-plus-t8ntool
6 changes: 5 additions & 1 deletion .github/configs/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ eip7692-osaka:
solc: 0.8.21
pectra-devnet-3:
evm-type: pectra-devnet-3
fill-params: --fork=Prague -m "not slow and not 2537" ./tests/prague/
fill-params: --fork=Prague -m "not slow" ./tests/prague/
solc: 0.8.21
pectra-devnet-4:
evm-type: pectra-devnet-4
fill-params: --fork=Prague -m "not slow and not eip_version_check" ./tests/prague/
solc: 0.8.21
15 changes: 3 additions & 12 deletions src/ethereum_clis/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
from pydantic import Field

from ethereum_test_base_types import Address, Bloom, Bytes, CamelModel, Hash, HexNumber
from ethereum_test_types import (
Alloc,
ConsolidationRequest,
DepositRequest,
Environment,
Transaction,
WithdrawalRequest,
)
from ethereum_test_types import Alloc, Environment, Transaction


class TransactionLog(CamelModel):
Expand Down Expand Up @@ -94,10 +87,8 @@ class Result(CamelModel):
withdrawals_root: Hash | None = None
excess_blob_gas: HexNumber | None = Field(None, alias="currentExcessBlobGas")
blob_gas_used: HexNumber | None = None
requests_root: Hash | None = None
deposit_requests: List[DepositRequest] | None = None
withdrawal_requests: List[WithdrawalRequest] | None = None
consolidation_requests: List[ConsolidationRequest] | None = None
requests_hash: Hash | None = None
requests: List[Bytes] | None = None


class TransitionToolInput(CamelModel):
Expand Down
4 changes: 4 additions & 0 deletions src/ethereum_test_exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ class TransactionException(ExceptionBase):
"""
Transaction is a type 4 transaction and has an empty `to`.
"""
TYPE_4_INVALID_AUTHORIZATION_FORMAT = auto()
"""
Transaction is type 4, but contains an authorization that has an invalid format.
"""


@unique
Expand Down
96 changes: 23 additions & 73 deletions src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@
from ethereum_test_forks import Fork, Paris
from ethereum_test_types.types import (
AuthorizationTupleGeneric,
ConsolidationRequest,
ConsolidationRequestGeneric,
DepositRequest,
DepositRequestGeneric,
Requests,
Transaction,
TransactionFixtureConverter,
TransactionGeneric,
Withdrawal,
WithdrawalGeneric,
WithdrawalRequest,
WithdrawalRequestGeneric,
)

from .base import BaseFixture
Expand Down Expand Up @@ -117,7 +110,7 @@ class FixtureHeader(CamelModel):
parent_beacon_block_root: Annotated[Hash, HeaderForkRequirement("beacon_root")] | None = Field(
None
)
requests_root: Annotated[Hash, HeaderForkRequirement("requests")] | None = Field(None)
requests_hash: Annotated[Hash, HeaderForkRequirement("requests")] | None = Field(None)

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

Expand Down Expand Up @@ -210,17 +203,13 @@ class FixtureExecutionPayload(CamelModel):

transactions: List[Bytes]
withdrawals: List[Withdrawal] | None = None
deposit_requests: List[DepositRequest] | None = None
withdrawal_requests: List[WithdrawalRequest] | None = None
consolidation_requests: List[ConsolidationRequest] | None = None

@classmethod
def from_fixture_header(
cls,
header: FixtureHeader,
transactions: List[Transaction],
withdrawals: List[Withdrawal] | None,
requests: Requests | None,
) -> "FixtureExecutionPayload":
"""
Returns a FixtureExecutionPayload from a FixtureHeader, a list
Expand All @@ -230,20 +219,20 @@ def from_fixture_header(
**header.model_dump(exclude={"rlp"}, exclude_none=True),
transactions=[tx.rlp for tx in transactions],
withdrawals=withdrawals,
deposit_requests=requests.deposit_requests() if requests is not None else None,
withdrawal_requests=requests.withdrawal_requests() if requests is not None else None,
consolidation_requests=requests.consolidation_requests()
if requests is not None
else None,
)


EngineNewPayloadV1Parameters = Tuple[FixtureExecutionPayload]
EngineNewPayloadV3Parameters = Tuple[FixtureExecutionPayload, List[Hash], Hash]
EngineNewPayloadV4Parameters = Tuple[FixtureExecutionPayload, List[Hash], Hash, List[Bytes]]

# Important: We check EngineNewPayloadV3Parameters first as it has more fields, and pydantic
# has a weird behavior when the smaller tuple is checked first.
EngineNewPayloadParameters = Union[EngineNewPayloadV3Parameters, EngineNewPayloadV1Parameters]
EngineNewPayloadParameters = Union[
EngineNewPayloadV4Parameters,
EngineNewPayloadV3Parameters,
EngineNewPayloadV1Parameters,
]


class FixtureEngineNewPayload(CamelModel):
Expand Down Expand Up @@ -280,7 +269,7 @@ def from_fixture_header(
header: FixtureHeader,
transactions: List[Transaction],
withdrawals: List[Withdrawal] | None,
requests: Requests | None,
requests: List[Bytes] | None,
**kwargs,
) -> "FixtureEngineNewPayload":
"""
Expand All @@ -296,10 +285,21 @@ def from_fixture_header(
header=header,
transactions=transactions,
withdrawals=withdrawals,
requests=requests,
)
params: Tuple[FixtureExecutionPayload] | Tuple[FixtureExecutionPayload, List[Hash], Hash]
if fork.engine_new_payload_blob_hashes(header.number, header.timestamp):
params: EngineNewPayloadParameters
if (
fork.engine_new_payload_requests(header.number, header.timestamp)
and requests is not None
):
parent_beacon_block_root = header.parent_beacon_block_root
assert parent_beacon_block_root is not None
params = (
execution_payload,
Transaction.list_blob_versioned_hashes(transactions),
parent_beacon_block_root,
requests,
)
elif fork.engine_new_payload_blob_hashes(header.number, header.timestamp):
parent_beacon_block_root = header.parent_beacon_block_root
assert parent_beacon_block_root is not None
params = (
Expand Down Expand Up @@ -366,60 +366,13 @@ def from_withdrawal(cls, w: WithdrawalGeneric) -> "FixtureWithdrawal":
return cls(**w.model_dump())


class FixtureDepositRequest(DepositRequestGeneric[ZeroPaddedHexNumber]):
"""
Structure to represent a single deposit request to be processed by the beacon
chain.
"""

@classmethod
def from_deposit_request(cls, d: DepositRequestGeneric) -> "FixtureDepositRequest":
"""
Returns a FixtureDepositRequest from a DepositRequest.
"""
return cls(**d.model_dump())


class FixtureWithdrawalRequest(WithdrawalRequestGeneric[ZeroPaddedHexNumber]):
"""
Structure to represent a single withdrawal request to be processed by the beacon
chain.
"""

@classmethod
def from_withdrawal_request(cls, d: WithdrawalRequestGeneric) -> "FixtureWithdrawalRequest":
"""
Returns a FixtureWithdrawalRequest from a WithdrawalRequest.
"""
return cls(**d.model_dump())


class FixtureConsolidationRequest(ConsolidationRequestGeneric[ZeroPaddedHexNumber]):
"""
Structure to represent a single consolidation request to be processed by the beacon
chain.
"""

@classmethod
def from_consolidation_request(
cls, d: ConsolidationRequestGeneric
) -> "FixtureConsolidationRequest":
"""
Returns a FixtureConsolidationRequest from a ConsolidationRequest.
"""
return cls(**d.model_dump())


class FixtureBlockBase(CamelModel):
"""Representation of an Ethereum block within a test Fixture without RLP bytes."""

header: FixtureHeader = Field(..., alias="blockHeader")
txs: List[FixtureTransaction] = Field(default_factory=list, alias="transactions")
ommers: List[FixtureHeader] = Field(default_factory=list, alias="uncleHeaders")
withdrawals: List[FixtureWithdrawal] | None = None
deposit_requests: List[FixtureDepositRequest] | None = None
withdrawal_requests: List[FixtureWithdrawalRequest] | None = None
consolidation_requests: List[FixtureConsolidationRequest] | None = None

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

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

if requests is not None:
block.append(requests.to_serializable_list())

return FixtureBlock(
**self.model_dump(),
rlp=eth_rlp.encode(block),
Expand Down
Loading