reth
reth copied to clipboard
reth can panic if custom chainspec does not contain any hardforks
Ref #3201 this happens if config does not contain any hardforks and panics:
https://github.com/paradigmxyz/reth/blob/8eeba4dcc8f12ac17ac51af1d1cc8bd94c7d130d/crates/revm/revm-primitives/src/config.rs#L45-L45
Still can't run as a custom chain
I use custom.json like this:
{
"config": {
"chainId": 123456
},
"nonce": "0x42",
"timestamp": "0x0",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388",
"difficulty": "0x400000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"stateRoot": "",
"alloc": {
"0x6385892acb085eaa24b745a712c9e682d80ff681": {
"balance": "0xad78ebc5ac6200000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
then run node with this command:
reth node --chain ./custom.json --datadir ./newdir --auto-mine --http --http.api "admin,debug,eth,net,trace,txpool,web3,rpc" --disable-discovery
Now node starts and restarts without database read error, but produces other errors: on run:
2023-06-20T15:30:14.253349Z INFO reth::cli: Starting consensus engine
2023-06-20T15:30:15.253830Z WARN make_canonical{block_hash=0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3}: blockchain_tree: Block hash not found in block indices block_hash=0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3
2023-06-20T15:30:15.253891Z WARN consensus::engine: Error canonicalizing the head hash error=Execution(BlockHashNotFoundInChain { block_hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3 }) state=ForkchoiceState { head_block_hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3, safe_block_hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3, finalized_block_hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3 }
2023-06-20T15:30:15.254060Z INFO reth::node::events: Forkchoice updated head_block_hash=0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3 safe_block_hash=0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3 finalized_block_hash=0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3 status=Syncing
2023-06-20T15:30:15.254386Z INFO try_insert_validated_block{block=(1, 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3)}: blockchain_tree: return=Err(InsertBlockError { error: Execution(Validation(BlockPreMerge { hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3 })), hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3, number: 1, parent_hash: 0x4929a1061079421430b50de04704d8d3ef39458f8c16c2839ecfd067f8708ee1, num_txs: 0, .. })
2023-06-20T15:30:15.255283Z WARN consensus::engine: Bad block with header hash: 0x5d534cbfe605fddab9806d94a58ff02dd42ff297d63229c06f2d1739f40b33a3, invalid ancestor: Header { parent_hash: 0x4929a1061079421430b50de04704d8d3ef39458f8c16c2839ecfd067f8708ee1, ommers_hash: 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, beneficiary: 0x0000000000000000000000000000000000000000, state_root: 0xa1d71f9d73f5ffda21e25795538508aa0a819422ed76825508be4ba9c07bcb29, transactions_root: 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421, receipts_root: 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421, withdrawals_root: None, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, difficulty: 0x0000000000000000000000000000000000000000000000000000000000000002_U256, number: 1, gas_limit: 30000000, gas_used: 0, timestamp: 1687275015, mix_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, nonce: 0, base_fee_per_gas: None, extra_data: Bytes(0x) }
I can connect MM to the localhost and see initial 200eth balance on it. But when I try to press "send" button, nothing happens, and node produces this error:
thread 'tokio-runtime-worker' panicked at 'wrong configuration', crates/revm/revm-primitives/src/config.rs:45:9
Originally posted by @manylov in https://github.com/paradigmxyz/reth/issues/3201#issuecomment-1599035406
good catch
@manylov there's an issue because the chainspec does not contain any hardforks
"config": {
"chainId": 12345,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0
}
I think you also need to set "terminalTotalDifficulty": 0, in order to active Paris from the start
Tried with this cusom.json :
{
"config": {
"chainId": 12345,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"terminalTotalDifficulty": 0
},
"nonce": "0x42",
"timestamp": "0x0",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388",
"difficulty": "0x400000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"stateRoot": "",
"alloc": {
"9a4407Bf1Dc791383923cc0EA2706607c8E43eb1": {
"balance": "0xad78ebc5ac6200000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
now node produces this error:
INFO reth::cli: Starting consensus engine
2023-06-20T16:58:53.707906Z WARN make_canonical{block_hash=0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476}: blockchain_tree: Block hash not found in block indices block_hash=0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476
2023-06-20T16:58:53.707944Z WARN consensus::engine: Error canonicalizing the head hash error=Execution(BlockHashNotFoundInChain { block_hash: 0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476 }) state=ForkchoiceState { head_block_hash: 0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476, safe_block_hash: 0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476, finalized_block_hash: 0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476 }
2023-06-20T16:58:53.708040Z INFO reth::node::events: Forkchoice updated head_block_hash=0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476 safe_block_hash=0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476 finalized_block_hash=0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476 status=Syncing
2023-06-20T16:58:53.708354Z INFO try_insert_validated_block{block=(1, 0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476)}: blockchain_tree: return=Ok(Valid)
2023-06-20T16:58:53.708405Z INFO make_canonical{block_hash=0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476}: blockchain_tree: Committing new canonical chain: [(1, 0x682977ea825b5b8e9cd961df63d25d2b0c22e39d1335f0584cf5b254b7721476)]
I am not sure if there is some error here
With this setup, I am able to see initial balance and even have made transfer from initial wallet to the other wallet, although transaction is in "waiting" state
After few restarts, tx has been sent and eth transferred, here are logs with new errors:
2023-06-20T17:08:16.953661Z INFO reth::cli: Status connected_peers=0 latest_block=0
2023-06-20T17:08:17.952928Z WARN make_canonical{block_hash=0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18}: blockchain_tree: Block hash not found in block indices block_hash=0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18
2023-06-20T17:08:17.952970Z WARN consensus::engine: Error canonicalizing the head hash error=Execution(BlockHashNotFoundInChain { block_hash: 0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18 }) state=ForkchoiceState { head_block_hash: 0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18, safe_block_hash: 0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18, finalized_block_hash: 0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18 }
2023-06-20T17:08:17.953154Z INFO reth::node::events: Forkchoice updated head_block_hash=0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18 safe_block_hash=0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18 finalized_block_hash=0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18 status=Syncing
2023-06-20T17:08:17.953447Z INFO try_insert_validated_block{block=(3, 0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18)}: blockchain_tree: return=Ok(Valid)
2023-06-20T17:08:17.953506Z INFO make_canonical{block_hash=0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18}: blockchain_tree: Committing new canonical chain: [(3, 0xb8f21175dbca3e5fcacef5d815e7a2e436e9515cb699f8c5ca43631410595a18)]
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:140:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:140:40
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:140:40
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:140:40
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:140:40
thanks for reporting all of these and sorry for the inconvenience
Thank you for your fast fixes. I can not make eth transfer from one wallet to another. Tx is in waiting state anytime. It looks like auto-mine does not work. And I don't see any logs when send tx from MM.
cast block-number shows that on every restart new block added
After few restarts, attempt to send eth produced this error
2023-06-20T20:36:26.739136Z INFO reth::cli: Status connected_peers=0 latest_block=0
2023-06-20T20:36:27.739667Z WARN make_canonical{block_hash=0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff}: blockchain_tree: Block hash not found in block indices block_hash=0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff
2023-06-20T20:36:27.739714Z WARN consensus::engine: Error canonicalizing the head hash error=Execution(BlockHashNotFoundInChain { block_hash: 0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff }) state=ForkchoiceState { head_block_hash: 0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff, safe_block_hash: 0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff, finalized_block_hash: 0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff }
2023-06-20T20:36:27.739812Z INFO reth::node::events: Forkchoice updated head_block_hash=0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff safe_block_hash=0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff finalized_block_hash=0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff status=Syncing
2023-06-20T20:36:27.740196Z INFO try_insert_validated_block{block=(3, 0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff)}: blockchain_tree: return=Ok(Valid)
2023-06-20T20:36:27.740255Z INFO make_canonical{block_hash=0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff}: blockchain_tree: Committing new canonical chain: [(3, 0x8c1bf8615af09c3a9b37cf6f87cebc0e18c1ee30c331cc0d163c42d8f7aca0ff)]
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:151:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:151:45
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:151:45
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:151:45
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:151:45
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/maxim/learning/rust/reth/crates/rpc/rpc/src/eth/api/fees.rs:151:45
2023-06-20T20:36:56.740385Z INFO reth::cli: Status connected_peers=0 latest_block=0
2023-06-20T20:37:26.740176Z INFO reth::cli: Status connected_peers=0 latest_block=0
2023-06-20T20:37:56.740913Z INFO reth::cli: Status connected_peers=0 latest_block=0
fyi @onbjerg there's another one -.-
sorry the eth_feeHistory impl is flawed and is being worked on atm
Any update on this issue? I am also trying to run a auto-miner node with a custom genesis json. The eth_feeHistory seems to be fixed, the node is able to run even with the "Block hash not found in block indices block_hash" and "Error canonicalizing the head hash" warnings (mentioned two comments up). I am able to send a tx
❯ curl http://127.0.0.1:8545 \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf86e808502540be400825208942b5ad5c4795c026514f8317c7a215e218dccd6cf880de0b6b3a764000080820a96a00f6fe5f68d0727ebfff61366e08c681ffa1a8ae044e67bc583c3582ab77006fca05067cccf52537635dc30bee10785a0de31ce6df2c8943d7ff437ee59854f984c"],"id":1}'
{"jsonrpc":"2.0","result":"0x24feba64144876530eade5c98f1530388e34512164251dcb53ac1d75f99d418b","id":1}
but the transaction is not mined, I am still on the same block as before and tx is missing in db.
Is the auto-miner not working? Should I create a new issue for this?
I'm not really sure if a chainspec with no hardforks is even valid.
Is the auto-miner not working?
it likely has more bugs, because we only wrote this to perform hive tests, and haven't tested for local node yet.
Even with hardforks (copies for example from sepolia.json) does not work, so this is probably a new issue and not related to this one.
I understand a local node is not a priority, but I would find it super helpful. I tried debugging the auto-miner myself, but did not get far yet.
I could not reproduce any errors or panics with the provided commands or JSON specs. @pistomat If you're still encountering errors, please open a new issue.