Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb committed Oct 29, 2024
2 parents ccf6718 + d20b3c4 commit f4a5831
Show file tree
Hide file tree
Showing 38 changed files with 1,911 additions and 776 deletions.
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
6 changes: 2 additions & 4 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ jobs:
mkdir -p fixtures/eof_tests
echo "uv run fill $files --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1"
uv run fill $files --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1
cat filloutput.log
uv run fill $files --until=Cancun --evm-bin evmone-t8n > >(tee -a filloutput.log) 2> >(tee -a filloutput.log >&2)
if grep -q "FAILURES" filloutput.log; then
echo "Error: failed to generate .py tests."
Expand Down Expand Up @@ -235,8 +234,7 @@ jobs:
if [ -n "$files_fixed" ]; then
echo "uv run fill $files_fixed --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1"
uv run fill $files_fixed --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1
cat filloutput.log
uv run fill $files_fixed --until=Cancun --evm-bin evmone-t8n > >(tee -a filloutput.log) 2> >(tee -a filloutput.log >&2)
if grep -q "FAILURES" filloutput.log; then
echo "Error: failed to generate .py tests from before the PR."
Expand Down
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

0 comments on commit f4a5831

Please sign in to comment.