Skip to content

Commit

Permalink
t8n stress test, workflow and evmone t8n fix
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Feb 26, 2025
1 parent 116eb5d commit 256b5c9
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 12 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/fill_with_t8n.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ jobs:
uv sync --no-progress
uv run python --version
- name: Verify EEST t8n fill
run: |
uv run fill tests/frontier/examples/test_t8n_structures.py
- name: Build EVMONE EVM
uses: ./.github/actions/build-evm-client/evmone
id: evm-builder2
with:
targets: "evmone-t8n"

- name: Verify EVMONE t8n fill
run: |
uv run fill tests/frontier/examples/test_t8n_structures.py --evm-bin=evmone-t8n
- name: Build GO EVM
uses: ./.github/actions/build-evm-client/geth

- name: Verify EEST t8n fill
run: |
uv run fill tests/frontier/opcodes/test_push.py::test_push
- name: Verify GETH t8n fill
run: |
uv run fill tests/frontier/opcodes/test_push.py::test_push --evm-bin evm
uv run fill tests/frontier/examples/test_t8n_structures.py --evm-bin=evm
- name: Verify EVMONE t8n fill
run: |
uv run fill tests/frontier/opcodes/test_push.py::test_push --evm-bin evmone-t8n
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
165 changes: 165 additions & 0 deletions tests/frontier/examples/test_t8n_structures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
"""Test T8N compatibility."""

import pytest

from ethereum_test_forks import Berlin, Byzantium, Cancun, Fork, London, Paris, Prague
from ethereum_test_tools import (
AccessList,
Account,
Alloc,
AuthorizationTuple,
Block,
BlockchainTestFiller,
Environment,
Storage,
Transaction,
add_kzg_version,
)
from ethereum_test_tools.vm.opcode import Opcodes as Op

from ...cancun.eip4844_blobs.spec import Spec as BlobSpec


@pytest.mark.valid_from("Frontier")
def test_t8n_structures(blockchain_test: BlockchainTestFiller, pre: Alloc, fork: Fork):
"""Feed t8n with all kinds of possible input."""
env = Environment()
sender = pre.fund_eoa()
storage_1 = Storage()
storage_2 = Storage()

code_account_1 = pre.deploy_contract(
code=Op.SSTORE(storage_1.store_next(1, "blockhash_0_is_set"), Op.GT(Op.BLOCKHASH(0), 0))
+ Op.SSTORE(storage_1.store_next(0, "blockhash_1"), Op.BLOCKHASH(1))
+ Op.SSTORE(
storage_1.store_next(1 if fork < Paris else 0, "difficulty_1_is_near_20000"),
Op.AND(Op.GT(Op.PREVRANDAO(), 0x19990), Op.LT(Op.PREVRANDAO(), 0x20100)),
)
)
code_account_2 = pre.deploy_contract(
code=Op.SSTORE(storage_2.store_next(1, "blockhash_1_is_set"), Op.GT(Op.BLOCKHASH(1), 0))
+ Op.SSTORE(
storage_2.store_next(1 if fork < Paris else 0, "difficulty_2_is_near_20000"),
Op.AND(Op.GT(Op.PREVRANDAO(), 0x19990), Op.LT(Op.PREVRANDAO(), 0x20100)),
)
)

tx_1 = Transaction(
gas_limit=100_000, to=code_account_1, data=b"", sender=sender, protected=fork >= Byzantium
)
if fork < Berlin:
# Feed legacy transaction
tx_2 = Transaction(
gas_limit=100_000,
to=code_account_2,
data=b"",
sender=sender,
protected=fork >= Byzantium,
)
elif fork < London:
# Feed access list transaction
tx_2 = Transaction(
gas_limit=100_000,
to=code_account_2,
data=b"",
sender=sender,
protected=fork >= Byzantium,
access_list=[
AccessList(
address=0x1234,
storage_keys=[0, 1],
)
],
)
elif fork < Cancun:
# Feed base fee transaction
tx_2 = Transaction(
to=code_account_2,
data=b"",
sender=sender,
protected=fork >= Byzantium,
gas_limit=100_000,
max_priority_fee_per_gas=5,
max_fee_per_gas=10,
access_list=[
AccessList(
address=0x1234,
storage_keys=[0, 1],
)
],
)
elif fork < Prague:
# Feed blob transaction
tx_2 = Transaction(
to=code_account_2,
data=b"",
sender=sender,
protected=fork >= Byzantium,
gas_limit=100_000,
max_priority_fee_per_gas=5,
max_fee_per_gas=10,
max_fee_per_blob_gas=30,
blob_versioned_hashes=add_kzg_version([1], BlobSpec.BLOB_COMMITMENT_VERSION_KZG),
access_list=[
AccessList(
address=0x1234,
storage_keys=[0, 1],
)
],
)
else:
# Feed set code transaction
tx_2 = Transaction(
to=sender,
data=b"",
sender=sender,
protected=fork >= Byzantium,
gas_limit=100_000,
max_priority_fee_per_gas=5,
max_fee_per_gas=10,
nonce=1,
access_list=[
AccessList(
address=0x1234,
storage_keys=[0, 1],
)
],
authorization_list=[
AuthorizationTuple(
address=code_account_2,
nonce=2,
signer=sender,
),
],
)

block_1 = Block(
txs=[tx_1],
expected_post_state={
code_account_1: Account(
storage=storage_1,
),
},
)

block_2 = Block(
txs=[tx_2],
expected_post_state={
code_account_2: Account(
storage=storage_2,
),
}
if fork < Prague
else {
sender: Account(
storage=storage_2,
),
},
)

blockchain_test(
genesis_environment=env,
pre=pre,
post=block_1.expected_post_state,
blocks=[block_1, block_2],
)

0 comments on commit 256b5c9

Please # to comment.