celo-org / op-geth

GNU Lesser General Public License v3.0
0 stars 0 forks source link

`eth_estimateGas` RPC method returns error for pending block #136

Closed ezdac closed 3 weeks ago

ezdac commented 1 month ago

Expected behaviour

eth_estimateGas should return a gas estimation value also when the "pending" block is specified as call argument.

Actual behaviour

eth_estimateGas returns an error:

retrieve state for block hash 0x314235fb94d1dc505b1afca64ff99d59464585b8286ae5a090cfd808bcb6c40d: header for hash 
not found

Backtrace

Encountered in a CI run of an end-to-end test of celo-org/optimism that is using the recent version of celo-org/op-geth

WARN [05-29|11:08:09.400] Served eth_estimateGas                   reqid=9 duration="62.229µs"  err="retrieve state for block hash 0x314235fb94d1dc505b1afca64ff99d59464585b8286ae5a090cfd808bcb6c40d: header for hash not found"
    l2_proposer.go:153: 
                Error Trace:    /root/project/op-e2e/actions/l2_proposer.go:153
                                                        /root/project/op-e2e/actions/l2_proposer.go:260
                                                        /root/project/op-e2e/actions/l2_proposer_test.go:100
                                                        /root/project/op-e2e/actions/l2_proposer_test.go:41
                Error:          Received unexpected error:
                                retrieve state for block hash 0x314235fb94d1dc505b1afca64ff99d59464585b8286ae5a090cfd808bcb6c40d: header for hash not found
                Test:           TestProposerBatchType/RunProposerTest_SpanBatch

Problem source

The getter methods for exchange rates in the celoapi query their state based only on the block-header hash from the state-db: https://github.com/celo-org/op-geth/blob/1cc16d181fac85fc42635a85543f1e2e8124f057/internal/celoapi/backend.go#L62-L67

When the pending block-state is queried in the RPC method upstream, the block-header hash is calculated in an ad-hoc fashion by querying the state from the miner https://github.com/celo-org/op-geth/blob/1cc16d181fac85fc42635a85543f1e2e8124f057/eth/api_backend.go#L193-L195 This block is not retrievable by hash by the state-db.

lvpeschke commented 3 weeks ago

End of weekly commitment check-in: @ezdac can you provide a status update?