Skip to content

Commit

Permalink
Filter by total gas rather than GasUsed
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Feb 26, 2025
1 parent 05221e1 commit 2636147
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion eth/gasprice/fee_info_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,17 @@ func (f *feeInfoProvider) addHeader(ctx context.Context, header *types.Header) (
timestamp: header.Time,
baseFee: header.BaseFee,
}

totalGasUsed := new(big.Int).SetUint64(header.GasUsed)
if header.ExtDataGasUsed != nil {
totalGasUsed.Add(totalGasUsed, header.ExtDataGasUsed)
}
minGasUsed := new(big.Int).SetUint64(f.minGasUsed)

// Don't bias the estimate with blocks containing a limited number of transactions paying to
// expedite block production.
var err error
if f.minGasUsed <= header.GasUsed {
if minGasUsed.Cmp(totalGasUsed) <= 0 {
// Compute minimum required tip to be included in previous block
//
// NOTE: Using this approach, we will never recommend that the caller
Expand Down
10 changes: 10 additions & 0 deletions eth/gasprice/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,13 @@ func TestSuggestTipCapMaxBlocksSecondsLookback(t *testing.T) {
expectedTip: big.NewInt(92_212_529_424),
}, timeCrunchOracleConfig())
}

func TestSuggestTipCapIncludesExtraDataGas(t *testing.T) {
applyGasPriceTest(t, suggestTipCapTest{
chainConfig: params.TestChainConfig,
numBlocks: 20,
extDataGasUsage: DefaultMinGasUsed,
genBlock: testGenBlock(t, 100_000, 1),
expectedTip: big.NewInt(83_603_561_239),
}, timeCrunchOracleConfig())
}

0 comments on commit 2636147

Please sign in to comment.