Skip to content

Commit

Permalink
Fix eth_feeHistory gasUsedRatio
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Tristan-Wilson committed May 2, 2024
1 parent 39a2d17 commit ec50381
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec50381

Please sign in to comment.