Skip to content

Commit 9a50767

Browse files
danceratopzfelix314159
authored andcommitted
fix(types): ensure Environment fields have even byte length (ethereum#1268)
* fix(types): ensure `Environment` fields have even byte length This is requried by `evmone-t8n`. * docs: update changelog
1 parent 74e8cc4 commit 9a50767

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ Test fixtures for use by clients are available for each release on the [Github r
1616
- 🔀 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)).
1717
- ✨ 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)).
1818
- ✨ Allow `fill --collect-only` without the need for existence of the folder `./fixtures'
19-
- ✨ 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).
19+
- ✨ 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)).
2020
- ✨ 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)).
2121
- ✨ 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)).
2222
- 🐞 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)).
23+
- 🐞 Zero-pad `Environment` fields passed to `t8n` tools as required by `evmone-t8n` ([#1268](https://github.com/ethereum/execution-spec-tests/pull/1268)).
2324

2425
### 📋 Misc
2526

src/ethereum_test_types/tests/test_types.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ def test_account_merge(
442442
Environment(),
443443
{
444444
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
445-
"currentGasLimit": "0x16345785d8a0000",
446-
"currentNumber": "0x1",
447-
"currentTimestamp": "0x3e8",
445+
"currentGasLimit": "0x016345785d8a0000",
446+
"currentNumber": "0x01",
447+
"currentTimestamp": "0x03e8",
448448
"blockHashes": {},
449449
"ommers": [],
450450
"parentUncleHash": (
@@ -475,17 +475,17 @@ def test_account_merge(
475475
),
476476
{
477477
"currentCoinbase": "0x0000000000000000000000000000000000001234",
478-
"currentGasLimit": "0x16345785d8a0000",
479-
"currentNumber": "0x1",
480-
"currentTimestamp": "0x3e8",
481-
"currentDifficulty": "0x5",
482-
"currentRandom": "0x6",
483-
"currentBaseFee": "0x7",
484-
"parentDifficulty": "0x8",
485-
"parentTimestamp": "0x9",
486-
"parentBaseFee": "0xa",
487-
"parentGasUsed": "0xb",
488-
"parentGasLimit": "0xc",
478+
"currentGasLimit": "0x016345785d8a0000",
479+
"currentNumber": "0x01",
480+
"currentTimestamp": "0x03e8",
481+
"currentDifficulty": "0x05",
482+
"currentRandom": "0x06",
483+
"currentBaseFee": "0x07",
484+
"parentDifficulty": "0x08",
485+
"parentTimestamp": "0x09",
486+
"parentBaseFee": "0x0a",
487+
"parentGasUsed": "0x0b",
488+
"parentGasLimit": "0x0c",
489489
"parentUncleHash": (
490490
"0x000000000000000000000000000000000000000000000000000000000000000d"
491491
),
@@ -497,8 +497,8 @@ def test_account_merge(
497497
"amount": "0x2",
498498
},
499499
],
500-
"parentBlobGasUsed": "0xe",
501-
"parentExcessBlobGas": "0xf",
500+
"parentBlobGasUsed": "0x0e",
501+
"parentExcessBlobGas": "0x0f",
502502
"currentBlobGasUsed": "0x10",
503503
"currentExcessBlobGas": "0x11",
504504
"blockHashes": {

src/ethereum_test_types/types.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
StorageRootType,
4343
TestAddress,
4444
TestPrivateKey,
45+
ZeroPaddedHexNumber,
4546
)
4647
from ethereum_test_base_types import Alloc as BaseAlloc
4748
from ethereum_test_base_types.conversions import (
@@ -352,16 +353,16 @@ class EnvironmentGeneric(CamelModel, Generic[NumberBoundTypeVar]):
352353
parent_gas_limit: NumberBoundTypeVar | None = Field(None)
353354

354355

355-
class Environment(EnvironmentGeneric[HexNumber]):
356+
class Environment(EnvironmentGeneric[ZeroPaddedHexNumber]):
356357
"""
357358
Structure used to keep track of the context in which a block
358359
must be executed.
359360
"""
360361

361-
blob_gas_used: HexNumber | None = Field(None, alias="currentBlobGasUsed")
362+
blob_gas_used: ZeroPaddedHexNumber | None = Field(None, alias="currentBlobGasUsed")
362363
parent_ommers_hash: Hash = Field(Hash(EmptyOmmersRoot), alias="parentUncleHash")
363-
parent_blob_gas_used: HexNumber | None = Field(None)
364-
parent_excess_blob_gas: HexNumber | None = Field(None)
364+
parent_blob_gas_used: ZeroPaddedHexNumber | None = Field(None)
365+
parent_excess_blob_gas: ZeroPaddedHexNumber | None = Field(None)
365366
parent_beacon_block_root: Hash | None = Field(None)
366367

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

0 commit comments

Comments
 (0)