Skip to content

Conversation

felix314159
Copy link
Collaborator

@felix314159 felix314159 commented Sep 30, 2025

🗒️ Description

If you run geth with
geth --dev --http -http.addr=localhost --http.port=8545
and then run
uv run execute remote -m blockchain_test --fork=frontier --rpc-endpoint=http://127.0.0.1:8545 --rpc-seed-key=b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291 --tx-wait-timeout 60 -vv -s tests/frontier/scenarios/test_scenarios.py::test_scenarios -k "ChainId" -vv -s --chain-id=1337
you can see that the passed chain-id is used (if you print it).

But why does it only work with ChainConfigDefaults.chain_id and not with ChainConfig.chain_id? The PR that introduces this uses the latter without problems.

Fixes #2095

🔗 Related Issues or PRs

N/A.

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

Comment on lines +433 to +434
# TODO: why attribute error when accessing ChainConfig.chain_id?
# only ChainConfigDefaults works
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because ChainConfig only can return the field once instantiated because it does not have a default like ChainConfigDefaults, and this is by design.

We have the chain_config fixture that is defined in src/pytest_plugins/shared/execute_fill.py, and contains the instance of ChainConfig that is valid for the current running test, so you can get the chain ID from there.

Example here:

def test_chainid(
state_test: StateTestFiller,
pre: Alloc,
chain_config: ChainConfig,
typed_transaction: Transaction,
):
"""Test CHAINID opcode."""
chain_id = chain_config.chain_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProgramChainid uses hardcoded chain_id instead of chain_id passed in through commandline arguments
2 participants