From ec50381e827ac90dc1ea6b844c8d21e75f270141 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 2 May 2024 14:49:59 +0100 Subject: [PATCH] Fix eth_feeHistory gasUsedRatio The intent for eth_feeHistory for Arbitrum is to return the ratio of gas used per second / the target gas per second. The logic for calculating this gets the receipts for each tx in a block and gets the cumulative gas used, but it was using the wrong hash to look up the receipts (it should be the block hash and not the receipts hash). Note: the current implementation returns 1.0 for gasUsedRatio for the blocks at the beginning of the window specified by eth_feeHistory's blockCount and newestBlock if the prior block has the same timestamp as the first block in the window (ie time has not ticked over). --- arbitrum/apibackend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 29615f8e26..7db8008a8e 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -282,7 +282,7 @@ func (a *APIBackend) FeeHistory( currentTimestampGasUsed = 0 } - receipts := a.BlockChain().GetReceiptsByHash(header.ReceiptHash) + receipts := a.BlockChain().GetReceiptsByHash(header.Hash()) for _, receipt := range receipts { if receipt.GasUsed > receipt.GasUsedForL1 { currentTimestampGasUsed += receipt.GasUsed - receipt.GasUsedForL1