Skip to content

Commit 3b89417

Browse files
committed
chore(forks|tests): temp squashed commit for release.
1 parent 72d848d commit 3b89417

File tree

8 files changed

+551
-4
lines changed

8 files changed

+551
-4
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Users can select any of the artifacts depending on their testing needs for their
7575
-[EIP-7934](https://eips.ethereum.org/EIPS/eip-7934): Add test cases for the block RLP max limit of 10MiB ([#1730](https://github.com/ethereum/execution-spec-tests/pull/1730)).
7676
-[EIP-7939](https://eips.ethereum.org/EIPS/eip-7939) Add count leading zeros (CLZ) opcode tests for Osaka ([#1733](https://github.com/ethereum/execution-spec-tests/pull/1733)).
7777
-[EIP-7918](https://eips.ethereum.org/EIPS/eip-7918): Blob base fee bounded by execution cost test cases (initial), includes some adjustments to [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) tests ([#1685](https://github.com/ethereum/execution-spec-tests/pull/1685)).
78+
-[EIP-7907](https://eips.ethereum.org/EIPS/eip-7907): Initial meter contract code size and increase limit tests cases ([#1777](https://github.com/ethereum/execution-spec-tests/pull/1777)).
79+
- 🔀 [EIP-3860](https://eips.ethereum.org/EIPS/eip-3860) tests cases updated for [EIP-7907](https://eips.ethereum.org/EIPS/eip-7907) ([#1777](https://github.com/ethereum/execution-spec-tests/pull/1777)).
7880

7981
## [v4.5.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v4.5.0) - 2025-05-14
8082

src/ethereum_test_tools/code/generators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class CodeGasMeasure(Bytecode):
149149
To be considered when subtracting the value of the previous GAS operation,
150150
and to be popped at the end of the execution.
151151
"""
152-
sstore_key: int | Bytes
152+
sstore_key: int | Bytes | Bytecode
153153
"""
154154
Storage key to save the gas used.
155155
"""
@@ -160,7 +160,7 @@ def __new__(
160160
code: Bytecode,
161161
overhead_cost: int = 0,
162162
extra_stack_items: int = 0,
163-
sstore_key: int | Bytes = 0,
163+
sstore_key: int | Bytes | Bytecode = 0,
164164
stop: bool = True,
165165
):
166166
"""Assemble the bytecode that measures gas usage."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Cross-client EIP-7907 Tests."""
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""Fixtures for EIP-7907 meter contract code size tests."""
2+
3+
import pytest
4+
5+
from ethereum_test_forks import Fork
6+
from ethereum_test_tools import (
7+
Address,
8+
Alloc,
9+
Bytecode,
10+
)
11+
from ethereum_test_tools.vm.opcode import Opcodes as Op
12+
from ethereum_test_types import Environment
13+
14+
from .helpers import create_large_contract
15+
16+
17+
@pytest.fixture
18+
def env() -> Environment:
19+
"""Environment fixture with sufficient gas limit for large contract tests."""
20+
return Environment(gas_limit=30_000_000)
21+
22+
23+
@pytest.fixture
24+
def large_contract_code() -> Bytecode:
25+
"""Return the default large contract code."""
26+
return Op.STOP
27+
28+
29+
@pytest.fixture
30+
def large_contract_size(fork: Fork) -> int:
31+
"""Return the minimum contract size that triggers the large contract access gas."""
32+
large_contract_size = fork.large_contract_size()
33+
if large_contract_size is None:
34+
return fork.max_code_size()
35+
else:
36+
return large_contract_size + 1
37+
38+
39+
@pytest.fixture
40+
def large_contract_bytecode(
41+
large_contract_size: int,
42+
large_contract_code: Bytecode | None,
43+
) -> bytes:
44+
"""Return the default large contract code."""
45+
return create_large_contract(size=large_contract_size, prefix=large_contract_code)
46+
47+
48+
@pytest.fixture
49+
def large_contract_address(
50+
pre: Alloc,
51+
large_contract_bytecode: bytes,
52+
) -> Address:
53+
"""Create a large contract address."""
54+
return pre.deploy_contract(large_contract_bytecode)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Helper functions for the EIP-7907 meter contract code size tests."""
2+
3+
from ethereum_test_tools import Bytecode
4+
5+
6+
def create_large_contract(
7+
*,
8+
size: int,
9+
padding_byte: bytes = b"\0",
10+
prefix: Bytecode | None = None,
11+
) -> bytes:
12+
"""Create a large contract with the given size and prefix."""
13+
if prefix is None:
14+
prefix = Bytecode()
15+
return bytes(prefix + padding_byte * (size - len(prefix)))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Defines EIP-7907 specification constants and functions."""
2+
3+
from dataclasses import dataclass
4+
5+
6+
@dataclass(frozen=True)
7+
class ReferenceSpec:
8+
"""Defines the reference spec version and git path."""
9+
10+
git_path: str
11+
version: str
12+
13+
14+
ref_spec_7907 = ReferenceSpec("EIPS/eip-7907.md", "d758026fc3bd5ac21b652e73d244dee803b1fe44")
15+
16+
17+
@dataclass(frozen=True)
18+
class Spec:
19+
"""
20+
Reference constants from EIP-7907 specification.
21+
22+
Note: Tests should use fork methods for actual values, not these constants directly.
23+
"""
24+
25+
MAX_CODE_SIZE = 0x40000
26+
MAX_INIT_CODE_SIZE = 0x80000
27+
LARGE_CONTRACT_THRESHOLD = 0x6000
28+
GAS_INIT_CODE_WORD_COST = 2

0 commit comments

Comments
 (0)