1
0
Fork 0
forked from forks/go-ethereum

eth/gasprice: fix eth_feeHistory blobGasUsedRatio divide zero (#31663)

The API `eth_feeHistory` returns
`{"jsonrpc":"2.0","id":1,"error":{"code":-32603,"message":"json:
unsupported value: NaN"}}`, when we query `eth_feeHistory` with a old
block that without a blob, or when the field
`config.blobSchedule.cancun.max` in genesis.config is 0 (that happens
for some projects fork geth but they don't have blob).

So here we specially handle the case when maxBlobGas == 0 to prevent
this issue from happening.
This commit is contained in:
Morty 2025-04-19 22:02:31 +08:00 committed by GitHub
parent 1296cdb748
commit bf6da20012
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,7 +108,9 @@ func (oracle *Oracle) processBlock(bf *blockFees, percentiles []float64) {
bf.results.gasUsedRatio = float64(bf.header.GasUsed) / float64(bf.header.GasLimit)
if blobGasUsed := bf.header.BlobGasUsed; blobGasUsed != nil {
maxBlobGas := eip4844.MaxBlobGasPerBlock(config, bf.header.Time)
bf.results.blobGasUsedRatio = float64(*blobGasUsed) / float64(maxBlobGas)
if maxBlobGas != 0 {
bf.results.blobGasUsedRatio = float64(*blobGasUsed) / float64(maxBlobGas)
}
}
if len(percentiles) == 0 {