-
Notifications
You must be signed in to change notification settings - Fork 55
Description
System information
Erigon version: erigon version 1.4.3-dev-b00927fe
OS & Version: Linux/
Commit hash: b00927fe
Erigon Command (with flags/config):
- erigon
- --chain=bsc
- --datadir=/home/erigon/persistence/data
- --http.addr=0.0.0.0
- --rpc.accessList=/home/erigon/acl-config/acl.json
- --rpc.batch.limit=1000
- --rpc.txfeecap=100
- --http.api=eth,erigon,web3,net,debug,txpool,trace
- --http.vhosts=*
- --http.corsdomain=null
- --http
- --ws
- --db.pagesize=16384
- --ethash.dagdir=/home/erigon/persistence/dag
- --maxpeers=32
- --identity=nd-786-726-458
- --private.api.addr=0.0.0.0:9090
- --private.api.ratelimit=31872
- --rpc.returndata.limit=1100000
- --metrics
- --metrics.addr=0.0.0.0
- --healthcheck
- --port=30303
- --db.size.limit=5TB
- --p2p.protocol=67,68
- --rpc.batch.limit=1000
- --rpc.returndata.limit=1100000
- --http.timeouts.read=300s
- --bsc.blobSidecars.no-pruning=true
- --prune.mode=archive
- --no-downloader
- --bootnodes=...
- --staticpeers=...
image: ghcr.io/node-real/bsc-erigon:v1.4.3
Chain/Network: BSC Mainnet
Expected behaviour
Return a proper error message when the block cannot be found
Actual behaviour
Panic occurs because block is nil
The eth_callMany RPC method crashes with a nil pointer dereference panic when attempting to call on a block that doesn't exist.
Error Log
[EROR] [12-27|11:42:03.803] RPC method eth_callMany crashed: runtime error: invalid memory address or nil pointer dereference
[service.go:222 panic.go:792 panic.go:262 signal_unix.go:925 block.go:1327 eth_callMany.go:144 value.go:584 value.go:368 service.go:227 handler.go:529 handler.go:479 handler.go:420 handler.go:240 handler.go:333 asm_amd64.s:1700]
Likely Root Cause
In rpc/jsonrpc/eth_callMany.go, the api.blockWithSenders() method can return a nil block without returning an error when the requested block is not found. The code only checks for errors but doesn't validate that the block pointer is non-nil before attempting to access it
Problematic code (lines 130-144):
block, err := api.blockWithSenders(ctx, tx, hash, blockNum)
if err != nil {
return nil, err
}
// Missing nil check here!
if transactionIndex == -1 {
transactionIndex = len(block.Transactions()) // Panic occurs here
}
When block.Transactions() is called on a nil pointer, it triggers a panic in execution/types/block.go:1327
Impact
RPC service crashes instead of returning a proper error response
Affects any customer calling eth_callMany with a non-existent block number
Proposed Fix
Add a nil check after retrieving the block:
block, err := api.blockWithSenders(ctx, tx, hash, blockNum)
if err != nil {
return nil, err
}
if block == nil {
return nil, fmt.Errorf("block not found for number %d", blockNum)
}