Skip to content

Commit 37a1c4b

Browse files
author
Dimitry Kh
committed
t8n stress test, workflow and evmone t8n fix
1 parent 116eb5d commit 37a1c4b

File tree

4 files changed

+181
-12
lines changed

4 files changed

+181
-12
lines changed

.github/workflows/fill_with_t8n.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,25 @@ jobs:
2222
uv sync --no-progress
2323
uv run python --version
2424
25+
- name: Verify EEST t8n fill
26+
run: |
27+
uv run fill tests/frontier/examples/test_t8n_structures.py
28+
2529
- name: Build EVMONE EVM
2630
uses: ./.github/actions/build-evm-client/evmone
2731
id: evm-builder2
2832
with:
2933
targets: "evmone-t8n"
3034

35+
- name: Verify EVMONE t8n fill
36+
run: |
37+
uv run fill tests/frontier/examples/test_t8n_structures.py --evm-bin=evmone-t8n
38+
3139
- name: Build GO EVM
3240
uses: ./.github/actions/build-evm-client/geth
3341

34-
- name: Verify EEST t8n fill
35-
run: |
36-
uv run fill tests/frontier/opcodes/test_push.py::test_push
37-
3842
- name: Verify GETH t8n fill
3943
run: |
40-
uv run fill tests/frontier/opcodes/test_push.py::test_push --evm-bin evm
44+
uv run fill tests/frontier/examples/test_t8n_structures.py --evm-bin=evm
45+
4146
42-
- name: Verify EVMONE t8n fill
43-
run: |
44-
uv run fill tests/frontier/opcodes/test_push.py::test_push --evm-bin evmone-t8n

src/ethereum_clis/clis/geth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def __init__(
172172
self.binary = binary
173173
self.trace = trace
174174
self.exception_mapper = exception_mapper if exception_mapper else GethExceptionMapper()
175+
self._info_metadata: Optional[Dict[str, Any]] = {}
175176

176177
def _run_command(self, command: List[str]) -> subprocess.CompletedProcess:
177178
try:

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)
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
"""Test T8N compatibility."""
2+
3+
import pytest
4+
5+
from ethereum_test_forks import Berlin, Byzantium, Cancun, Fork, London, Paris, Prague
6+
from ethereum_test_tools import (
7+
AccessList,
8+
Account,
9+
Alloc,
10+
AuthorizationTuple,
11+
Block,
12+
BlockchainTestFiller,
13+
Environment,
14+
Storage,
15+
Transaction,
16+
add_kzg_version,
17+
)
18+
from ethereum_test_tools.vm.opcode import Opcodes as Op
19+
20+
from ...cancun.eip4844_blobs.spec import Spec as BlobSpec
21+
22+
23+
@pytest.mark.valid_from("Frontier")
24+
def test_t8n_structures(blockchain_test: BlockchainTestFiller, pre: Alloc, fork: Fork):
25+
"""Feed t8n with all kinds of possible input."""
26+
env = Environment()
27+
sender = pre.fund_eoa()
28+
storage_1 = Storage()
29+
storage_2 = Storage()
30+
31+
code_account_1 = pre.deploy_contract(
32+
code=Op.SSTORE(storage_1.store_next(1, "blockhash_0_is_set"), Op.GT(Op.BLOCKHASH(0), 0))
33+
+ Op.SSTORE(storage_1.store_next(0, "blockhash_1"), Op.BLOCKHASH(1))
34+
+ Op.SSTORE(
35+
storage_1.store_next(1 if fork < Paris else 0, "difficulty_1_is_near_20000"),
36+
Op.AND(Op.GT(Op.PREVRANDAO(), 0x19990), Op.LT(Op.PREVRANDAO(), 0x20100)),
37+
)
38+
)
39+
code_account_2 = pre.deploy_contract(
40+
code=Op.SSTORE(storage_2.store_next(1, "blockhash_1_is_set"), Op.GT(Op.BLOCKHASH(1), 0))
41+
+ Op.SSTORE(
42+
storage_2.store_next(1 if fork < Paris else 0, "difficulty_2_is_near_20000"),
43+
Op.AND(Op.GT(Op.PREVRANDAO(), 0x19990), Op.LT(Op.PREVRANDAO(), 0x20100)),
44+
)
45+
)
46+
47+
tx_1 = Transaction(
48+
gas_limit=100_000, to=code_account_1, data=b"", sender=sender, protected=fork >= Byzantium
49+
)
50+
if fork < Berlin:
51+
# Feed legacy transaction
52+
tx_2 = Transaction(
53+
gas_limit=100_000,
54+
to=code_account_2,
55+
data=b"",
56+
sender=sender,
57+
protected=fork >= Byzantium,
58+
)
59+
elif fork < London:
60+
# Feed access list transaction
61+
tx_2 = Transaction(
62+
gas_limit=100_000,
63+
to=code_account_2,
64+
data=b"",
65+
sender=sender,
66+
protected=fork >= Byzantium,
67+
access_list=[
68+
AccessList(
69+
address=0x1234,
70+
storage_keys=[0, 1],
71+
)
72+
],
73+
)
74+
elif fork < Cancun:
75+
# Feed base fee transaction
76+
tx_2 = Transaction(
77+
to=code_account_2,
78+
data=b"",
79+
sender=sender,
80+
protected=fork >= Byzantium,
81+
gas_limit=100_000,
82+
max_priority_fee_per_gas=5,
83+
max_fee_per_gas=10,
84+
access_list=[
85+
AccessList(
86+
address=0x1234,
87+
storage_keys=[0, 1],
88+
)
89+
],
90+
)
91+
elif fork < Prague:
92+
# Feed blob transaction
93+
tx_2 = Transaction(
94+
to=code_account_2,
95+
data=b"",
96+
sender=sender,
97+
protected=fork >= Byzantium,
98+
gas_limit=100_000,
99+
max_priority_fee_per_gas=5,
100+
max_fee_per_gas=10,
101+
max_fee_per_blob_gas=30,
102+
blob_versioned_hashes=add_kzg_version([1], BlobSpec.BLOB_COMMITMENT_VERSION_KZG),
103+
access_list=[
104+
AccessList(
105+
address=0x1234,
106+
storage_keys=[0, 1],
107+
)
108+
],
109+
)
110+
else:
111+
# Feed set code transaction
112+
tx_2 = Transaction(
113+
to=sender,
114+
data=b"",
115+
sender=sender,
116+
protected=fork >= Byzantium,
117+
gas_limit=100_000,
118+
max_priority_fee_per_gas=5,
119+
max_fee_per_gas=10,
120+
nonce=1,
121+
access_list=[
122+
AccessList(
123+
address=0x1234,
124+
storage_keys=[0, 1],
125+
)
126+
],
127+
authorization_list=[
128+
AuthorizationTuple(
129+
address=code_account_2,
130+
nonce=2,
131+
signer=sender,
132+
),
133+
],
134+
)
135+
136+
block_1 = Block(
137+
txs=[tx_1],
138+
expected_post_state={
139+
code_account_1: Account(
140+
storage=storage_1,
141+
),
142+
},
143+
)
144+
145+
block_2 = Block(
146+
txs=[tx_2],
147+
expected_post_state={
148+
code_account_2: Account(
149+
storage=storage_2,
150+
),
151+
}
152+
if fork < Prague
153+
else {
154+
sender: Account(
155+
storage=storage_2,
156+
),
157+
},
158+
)
159+
160+
blockchain_test(
161+
genesis_environment=env,
162+
pre=pre,
163+
post=block_1.expected_post_state,
164+
blocks=[block_1, block_2],
165+
)

0 commit comments

Comments
 (0)