Skip to content

fix(types): ensure Environment fields have even byte length #1268

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

Merged
merged 2 commits into from
Feb 27, 2025
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
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Test fixtures for use by clients are available for each release on the [Github r
- 🔀 Refactor `ethereum_test_fixtures` and `ethereum_clis` to create `FixtureConsumer` and `FixtureConsumerTool` classes which abstract away the consumption process used by `consume direct` ([#935](https://github.com/ethereum/execution-spec-tests/pull/935)).
- ✨ Allow `consume direct --collect-only` without specifying a fixture consumer binary on the command-line ([#1237](https://github.com/ethereum/execution-spec-tests/pull/1237)).
- ✨ Allow `fill --collect-only` without the need for existence of the folder `./fixtures'
- ✨ Report the (resolved) fixture tarball URL and local fixture cache directory when `consume`'s `--input` flag is a release spec or URL [#1239](https://github.com/ethereum/execution-spec-tests/pull/1239).
- ✨ Report the (resolved) fixture tarball URL and local fixture cache directory when `consume`'s `--input` flag is a release spec or URL ([#1239](https://github.com/ethereum/execution-spec-tests/pull/1239)).
- ✨ EOF Container validation tests (`eof_test`) now generate container deployment state tests, by wrapping the EOF container in an init-container and sending a deploy transaction ([#783](https://github.com/ethereum/execution-spec-tests/pull/783), [#1233](https://github.com/ethereum/execution-spec-tests/pull/1233)).
- ✨ Use regexes for Hive's `--sim.limit` argument and don't use xdist if `--sim.parallelism==1` in the `eest/consume-rlp` and `eest/consume-rlp` simulators ([#1220](https://github.com/ethereum/execution-spec-tests/pull/1220)).
- 🐞 Register generated test markers, e.g., `blockchain_test_from_state_test`, to prevent test session warnings ([#1238](https://github.com/ethereum/execution-spec-tests/pull/1238), [#1245](https://github.com/ethereum/execution-spec-tests/pull/1245)).
- 🐞 Zero-pad `Environment` fields passed to `t8n` tools as required by `evmone-t8n` ([#1268](https://github.com/ethereum/execution-spec-tests/pull/1268)).

### 📋 Misc

Expand Down
32 changes: 16 additions & 16 deletions src/ethereum_test_types/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ def test_account_merge(
Environment(),
{
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentGasLimit": "0x16345785d8a0000",
"currentNumber": "0x1",
"currentTimestamp": "0x3e8",
"currentGasLimit": "0x016345785d8a0000",
"currentNumber": "0x01",
"currentTimestamp": "0x03e8",
"blockHashes": {},
"ommers": [],
"parentUncleHash": (
Expand Down Expand Up @@ -475,17 +475,17 @@ def test_account_merge(
),
{
"currentCoinbase": "0x0000000000000000000000000000000000001234",
"currentGasLimit": "0x16345785d8a0000",
"currentNumber": "0x1",
"currentTimestamp": "0x3e8",
"currentDifficulty": "0x5",
"currentRandom": "0x6",
"currentBaseFee": "0x7",
"parentDifficulty": "0x8",
"parentTimestamp": "0x9",
"parentBaseFee": "0xa",
"parentGasUsed": "0xb",
"parentGasLimit": "0xc",
"currentGasLimit": "0x016345785d8a0000",
"currentNumber": "0x01",
"currentTimestamp": "0x03e8",
"currentDifficulty": "0x05",
"currentRandom": "0x06",
"currentBaseFee": "0x07",
"parentDifficulty": "0x08",
"parentTimestamp": "0x09",
"parentBaseFee": "0x0a",
"parentGasUsed": "0x0b",
"parentGasLimit": "0x0c",
"parentUncleHash": (
"0x000000000000000000000000000000000000000000000000000000000000000d"
),
Expand All @@ -497,8 +497,8 @@ def test_account_merge(
"amount": "0x2",
},
],
"parentBlobGasUsed": "0xe",
"parentExcessBlobGas": "0xf",
"parentBlobGasUsed": "0x0e",
"parentExcessBlobGas": "0x0f",
"currentBlobGasUsed": "0x10",
"currentExcessBlobGas": "0x11",
"blockHashes": {
Expand Down
9 changes: 5 additions & 4 deletions src/ethereum_test_types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
StorageRootType,
TestAddress,
TestPrivateKey,
ZeroPaddedHexNumber,
)
from ethereum_test_base_types import Alloc as BaseAlloc
from ethereum_test_base_types.conversions import (
Expand Down Expand Up @@ -352,16 +353,16 @@ class EnvironmentGeneric(CamelModel, Generic[NumberBoundTypeVar]):
parent_gas_limit: NumberBoundTypeVar | None = Field(None)


class Environment(EnvironmentGeneric[HexNumber]):
class Environment(EnvironmentGeneric[ZeroPaddedHexNumber]):
"""
Structure used to keep track of the context in which a block
must be executed.
"""

blob_gas_used: HexNumber | None = Field(None, alias="currentBlobGasUsed")
blob_gas_used: ZeroPaddedHexNumber | None = Field(None, alias="currentBlobGasUsed")
parent_ommers_hash: Hash = Field(Hash(EmptyOmmersRoot), alias="parentUncleHash")
parent_blob_gas_used: HexNumber | None = Field(None)
parent_excess_blob_gas: HexNumber | None = Field(None)
parent_blob_gas_used: ZeroPaddedHexNumber | None = Field(None)
parent_excess_blob_gas: ZeroPaddedHexNumber | None = Field(None)
parent_beacon_block_root: Hash | None = Field(None)

block_hashes: Dict[Number, Hash] = Field(default_factory=dict)
Expand Down