Commit 20df7459 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

l2geth: docall protect nil block (#736)

* l2geth: protect nil in eth_call

* chore: add changeset
parent d32d9155
---
'@eth-optimism/l2geth': patch
---
Protect a possible `nil` reference in `eth_call` when the blockchain is empty
......@@ -937,6 +937,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
if err != nil {
return nil, 0, false, err
}
if block != nil {
txs := block.Transactions()
if header.Number.Uint64() != 0 {
if len(txs) != 1 {
......@@ -946,6 +947,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
blockNumber = tx.L1BlockNumber()
timestamp = new(big.Int).SetUint64(tx.L1Timestamp())
}
}
msg, err = core.EncodeSimulatedMessage(msg, timestamp, blockNumber, executionManager, stateManager)
if err != nil {
return nil, 0, false, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment