Skip to content

Commit 8e6b949

Browse files
committed
cancun/tests: Merge 4788 proof changes to all cancun tests & 4788 fixes.
2 parents 8428811 + e080725 commit 8e6b949

19 files changed

+78
-23
lines changed

src/ethereum_test_tools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Fixture,
1616
FixtureEngineNewPayload,
1717
Header,
18+
HistoryStorageAddress,
1819
JSONEncoder,
1920
Storage,
2021
TestAddress,
@@ -63,6 +64,7 @@
6364
"Fixture",
6465
"FixtureEngineNewPayload",
6566
"Header",
67+
"HistoryStorageAddress",
6668
"Initcode",
6769
"JSONEncoder",
6870
"Opcode",

src/ethereum_test_tools/common/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
BeaconRoot,
88
EmptyTrieRoot,
99
EngineAPIError,
10+
HistoryStorageAddress,
1011
TestAddress,
1112
TestAddress2,
1213
TestPrivateKey,
@@ -75,6 +76,7 @@
7576
"Hash",
7677
"Header",
7778
"HeaderNonce",
79+
"HistoryStorageAddress",
7880
"JSONEncoder",
7981
"Number",
8082
"Storage",

src/ethereum_test_tools/common/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
EmptyNonce = bytes([0] * 8)
2121
ZeroAddress = bytes([0] * 20)
2222

23+
HistoryStorageAddress = "0x000000000000000000000000000000000000000b"
2324
BeaconRoot = bytes.fromhex("3e97e493f9123f7455a3be1b388db32876beea7d165a3b63528d8f9a38b7249f")
2425

2526

src/ethereum_test_tools/spec/blockchain_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def make_genesis(
9494
if env.withdrawals is not None
9595
else None
9696
),
97+
beacon_root=Hash.or_none(env.beacon_root),
9798
)
9899

99100
genesis_rlp, genesis.hash = genesis.build(

src/ethereum_test_tools/spec/state_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
State test filler.
33
"""
4+
from copy import copy
45
from dataclasses import dataclass
56
from typing import Any, Callable, Dict, Generator, List, Mapping, Optional, Tuple, Type
67

@@ -57,7 +58,13 @@ def make_genesis(
5758
"""
5859
Create a genesis block from the state test definition.
5960
"""
60-
env = self.env.set_fork_requirements(fork)
61+
env = copy(self.env)
62+
63+
# Remove fields that should not be present in the genesis block.
64+
env.withdrawals = None
65+
env.beacon_root = None
66+
67+
env = env.set_fork_requirements(fork)
6168

6269
genesis = FixtureHeader(
6370
parent_hash=Hash(0),
@@ -93,6 +100,7 @@ def make_genesis(
93100
if env.withdrawals is not None
94101
else None
95102
),
103+
beacon_root=Hash.or_none(env.beacon_root),
96104
)
97105

98106
genesis_rlp, genesis.hash = genesis.build(

tests/cancun/eip4788_beacon_root/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ethereum_test_tools import (
99
Account,
1010
Environment,
11+
HistoryStorageAddress,
1112
TestAddress,
1213
Transaction,
1314
to_address,
@@ -127,6 +128,7 @@ def pre(
127128
source account of all test transactions, and the precompile caller account.
128129
"""
129130
return {
131+
HistoryStorageAddress: Account(balance=1),
130132
TestAddress: Account(
131133
nonce=0,
132134
balance=0x10**10,

tests/cancun/eip4788_beacon_root/test_beacon_root_precompile.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ def test_beacon_root_equal_to_timestamp(
184184
[
185185
12, # twelve
186186
2**32, # arbitrary
187-
2**64 - 2, # near-max
188-
2**64 - 1, # max
189187
],
190188
)
191189
@pytest.mark.valid_from("Cancun")
@@ -226,11 +224,12 @@ def test_beacon_root_timestamp_collisions(
226224
txs=[
227225
tx.with_fields(
228226
nonce=i,
229-
to=to_address(0x100),
227+
to=to_address(0x100 + i),
230228
data=to_hash_bytes(timestamp),
231229
)
232230
],
233231
beacon_root=DEFAULT_BEACON_ROOT_HASH,
232+
timestamp=timestamp,
234233
)
235234
)
236235
post[to_address(0x100 + i)] = Account(
@@ -243,7 +242,6 @@ def test_beacon_root_timestamp_collisions(
243242
)
244243

245244
blockchain_test(
246-
genesis_environment=env,
247245
pre=pre,
248246
blocks=blocks,
249247
post=post,

tests/cancun/eip4844_blobs/test_blob_txs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121

2222
import pytest
2323

24-
from ethereum_test_tools import Account, Block, BlockchainTestFiller, Environment, Header
24+
from ethereum_test_tools import (
25+
Account,
26+
Block,
27+
BlockchainTestFiller,
28+
Environment,
29+
Header,
30+
HistoryStorageAddress,
31+
)
2532
from ethereum_test_tools import Opcodes as Op
2633
from ethereum_test_tools import (
2734
Storage,
@@ -295,6 +302,7 @@ def pre( # noqa: D103
295302
blocks.
296303
"""
297304
return {
305+
HistoryStorageAddress: Account(balance=1),
298306
TestAddress: Account(balance=total_account_minimum_balance + account_balance_modifier),
299307
}
300308

tests/cancun/eip4844_blobs/test_blob_txs_full.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
BlockchainTestFiller,
1515
Environment,
1616
Header,
17+
HistoryStorageAddress,
1718
TestAddress,
1819
Transaction,
1920
to_address,
@@ -226,6 +227,7 @@ def pre() -> Dict:
226227
source account of all test transactions.
227228
"""
228229
return {
230+
HistoryStorageAddress: Account(balance=1),
229231
TestAddress: Account(balance=10**40),
230232
}
231233

tests/cancun/eip4844_blobs/test_blobhash_opcode.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
Block,
2727
BlockchainTestFiller,
2828
CodeGasMeasure,
29+
HistoryStorageAddress,
2930
TestAddress,
3031
Transaction,
3132
to_address,
@@ -44,7 +45,10 @@
4445

4546
@pytest.fixture
4647
def pre(): # noqa: D103
47-
return {TestAddress: Account(balance=10000000000000000000000)}
48+
return {
49+
HistoryStorageAddress: Account(balance=1),
50+
TestAddress: Account(balance=10000000000000000000000),
51+
}
4852

4953

5054
@pytest.fixture

0 commit comments

Comments
 (0)