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:
Steven Allen 2023-10-27 07:37:51 -07:00 committed by GitHub
parent 420f33017e
commit 3f00691f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -733,10 +733,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++