fix: api: compute gasUsedRatio based on max gas in the tipset (#11354)
We were computing this based on the max block gas, but this is incorrect. The new value isn't entirely correct either (we should probably compute an average of the gas used in each block in the tipset?), but it's good enough. fixes #10515
This commit is contained in:
parent
56b0348e87
commit
3a74a2422a
@ -825,10 +825,11 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth
|
||||
}
|
||||
|
||||
rewards, totalGasUsed := calculateRewardsAndGasUsed(rewardPercentiles, txGasRewards)
|
||||
maxGas := build.BlockGasLimit * int64(len(ts.Blocks()))
|
||||
|
||||
// arrays should be reversed at the end
|
||||
baseFeeArray = append(baseFeeArray, ethtypes.EthBigInt(basefee))
|
||||
gasUsedRatioArray = append(gasUsedRatioArray, float64(totalGasUsed)/float64(build.BlockGasLimit))
|
||||
gasUsedRatioArray = append(gasUsedRatioArray, float64(totalGasUsed)/float64(maxGas))
|
||||
rewardsArray = append(rewardsArray, rewards)
|
||||
oldestBlkHeight = uint64(ts.Height())
|
||||
blocksIncluded++
|
||||
|
Loading…
Reference in New Issue
Block a user