Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Test fixtures for use by clients are available for each release on the [Github r

#### `fill`

- ✨ Allow command to customize `--chain-id` used for filling ([#2016](https://github.com/ethereum/execution-specs/pull/2016)).

#### `consume`

#### `execute`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from execution_testing.specs import BaseTest
from execution_testing.specs.base import OpMode
from execution_testing.test_types import EnvironmentDefaults
from execution_testing.test_types.chain_config_types import ChainConfigDefaults
from execution_testing.tools.utility.versioning import (
generate_github_url,
get_current_commit_hash_or_tag,
Expand Down Expand Up @@ -457,6 +458,14 @@ def pytest_addoption(parser: pytest.Parser) -> None:
"intended for regular CLI use."
),
)
evm_group.addoption(
"--chain-id",
action="store",
dest="chain_id",
type=str,
default=None,
help=("Specify the chain ID for the test filling."),
)
evm_group.addoption(
"--traces",
action="store_true",
Expand Down Expand Up @@ -777,6 +786,16 @@ def pytest_configure(config: pytest.Config) -> None:
f"<code>{command_line_args}</code>"
)

chain_id = config.getoption("chain_id")

if chain_id is None:
# Try to get the chain ID from the environment variable
chain_id = os.environ.get("CHAIN_ID")

# write to config
if chain_id is not None:
ChainConfigDefaults.chain_id = chain_id


@pytest.hookimpl(trylast=True)
def pytest_report_header(config: pytest.Config) -> List[str]:
Expand Down
6 changes: 5 additions & 1 deletion packages/testing/src/execution_testing/specs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
BlockAccessList,
BlockAccessListExpectation,
)
from execution_testing.test_types.chain_config_types import ChainConfigDefaults

from .base import BaseTest, OpMode, verify_result
from .debugging import print_traces
Expand Down Expand Up @@ -477,7 +478,10 @@ class BlockchainTest(BaseTest):
post: Alloc
blocks: List[Block]
genesis_environment: Environment = Field(default_factory=Environment)
chain_id: int = 1
chain_id: int = Field(
default_factory=lambda: ChainConfigDefaults.chain_id,
validate_default=True,
)
exclude_full_post_state_in_output: bool = False
"""
Exclude the post state from the fixture output. In this case, the state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, raw: Any, fork: Any) -> None:

def json_to_chain_id(self) -> U64:
"""Get chain ID for the transaction."""
return U64(1)
return hex_to_u64(self.raw.get("chainId", "0x01"))

def json_to_nonce(self) -> U256:
"""Get the nonce for the transaction."""
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def sign_transaction(self, json_tx: Any) -> None:
if t8n.fork.has_signing_hash_155:
if protected:
signing_hash = t8n.fork.signing_hash_155(
tx_decoded, U64(1)
tx_decoded, self.t8n.chain_id
)
v_addend = U256(37) # Assuming chain_id = 1
v_addend = U256(36) + U256(self.t8n.chain_id)
else:
signing_hash = t8n.fork.signing_hash_pre155(tx_decoded)
v_addend = U256(27)
Expand Down
Loading