-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Component
Anvil
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge Version: 1.0.0-nightly Commit SHA: 7e903eb Build Timestamp: 2025-03-12T06:02:03.811377000Z (1741759323) Build Profile: maxperf
What version of Foundryup are you on?
foundryup installed - forge Version: 1.0.0-nightly Commit SHA: 7e903eb Build Timestamp: 2025-03-12T06:02:03.811377000Z (1741759323) Build Profile: maxperf
foundryup: installed - cast Version: 1.0.0-nightly Commit SHA: 7e903eb Build Timestamp: 2025-03-12T06:02:03.811377000Z (1741759323) Build Profile: maxperf
foundryup: installed - anvil Version: 1.0.0-nightly Commit SHA: 7e903eb Build Timestamp: 2025-03-12T06:02:03.811377000Z (1741759323) Build Profile: maxperf
foundryup: installed - chisel Version: 1.0.0-nightly Commit SHA: 7e903eb Build Timestamp: 2025-03-12T06:02:03.811377000Z (1741759323) Build Profile: maxperf
What command(s) is the bug in?
No response
Operating System
macOS (Apple Silicon)
Describe the bug
Base command:
echo '{ "nonce": "0xc0ffee", "timestamp": "0x0", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x80000000", "difficulty": "0x20000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase": "0x0000000000000000000000000000000000000000", "number": "0x0", "gasUsed": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"}' > test-genesis.json && anvil --init ./test-genesis.json
This command works as expected and the chain id is displayed correctly in the initial message;
Chain ID
1
If we pass a chain_id option, things get more interesting:
echo '{ "nonce": "0xc0ffee", "timestamp": "0x0", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x80000000", "difficulty": "0x20000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase": "0x0000000000000000000000000000000000000000", "number": "0x0", "gasUsed": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"}' > test-genesis.json && anvil --init ./test-genesis.json --chain-id 100200300
Chain id from the initial message:
Chain ID
100200300
However, if you do an RPC call to the node, it will respond with chain id 1:
curl --location 'http://localhost:8545/' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1337,
"method": "eth_chainId",
"params": []
}'
{"jsonrpc":"2.0","id":1337,"result":"0x1"}
From what I tested, the node always uses the chain id from the genesis.json file (and defaults to 1 if not specified) and ignores the --chain_id option. This is different from other options, such as --timestamp which takes precedence over what's specified in the genesis file
Metadata
Metadata
Assignees
Labels
Type
Projects
Status