diff --git a/eth/api_backend.go b/eth/api_backend.go index 75b039dbe1..e582e25c63 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -187,6 +187,10 @@ func (b *EthAPIBackend) Pending() (*types.Block, types.Receipts, *state.StateDB) } func (b *EthAPIBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) { + // CHANGE(taiko): always use the latest block number for pending state. + if b.ChainConfig().Taiko && number == rpc.PendingBlockNumber { + number = rpc.LatestBlockNumber + } // Pending state is only known by the miner if number == rpc.PendingBlockNumber { block, _, state := b.eth.miner.Pending() diff --git a/eth/api_debug.go b/eth/api_debug.go index d5e4dda140..4ab3781742 100644 --- a/eth/api_debug.go +++ b/eth/api_debug.go @@ -52,6 +52,10 @@ func (api *DebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) { OnlyWithAddresses: true, Max: AccountRangeMaxResults, // Sanity limit over RPC } + // CHANGE(taiko): always use the latest block number for pending state. + if api.eth.blockchain.Config().Taiko && blockNr == rpc.PendingBlockNumber { + blockNr = rpc.LatestBlockNumber + } if blockNr == rpc.PendingBlockNumber { // If we're dumping the pending state, we need to request // both the pending block as well as the pending state from @@ -138,6 +142,10 @@ func (api *DebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start hex var err error if number, ok := blockNrOrHash.Number(); ok { + // CHANGE(taiko): always use the latest block number for pending state. + if api.eth.blockchain.Config().Taiko && number == rpc.PendingBlockNumber { + number = rpc.LatestBlockNumber + } if number == rpc.PendingBlockNumber { // If we're dumping the pending state, we need to request // both the pending block as well as the pending state from