@@ -237,12 +237,12 @@ func testGenBlock(t *testing.T, tip int64, numTx int) func(int, *core.BlockGen)
237237 b .SetCoinbase (common.Address {1 })
238238
239239 txTip := big .NewInt (tip * params .GWei )
240- signer := types .LatestSigner (params .TestChainConfig )
240+ signer := types .LatestSigner (params .TestFortunaChainConfig )
241241 baseFee := b .BaseFee ()
242242 feeCap := new (big.Int ).Add (baseFee , txTip )
243243 for j := 0 ; j < numTx ; j ++ {
244244 tx := types .NewTx (& types.DynamicFeeTx {
245- ChainID : params .TestChainConfig .ChainID ,
245+ ChainID : params .TestFortunaChainConfig .ChainID ,
246246 Nonce : b .TxNonce (addr ),
247247 To : & common.Address {},
248248 Gas : ethparams .TxGas ,
@@ -274,7 +274,7 @@ func TestSuggestTipCapNetworkUpgrades(t *testing.T) {
274274
275275func TestSuggestTipCapSimple (t * testing.T ) {
276276 applyGasPriceTest (t , suggestTipCapTest {
277- chainConfig : params .TestChainConfig ,
277+ chainConfig : params .TestFortunaChainConfig ,
278278 numBlocks : 3 ,
279279 genBlock : testGenBlock (t , 55 , 370 ),
280280 expectedTip : big .NewInt (1_287_001_288 ),
@@ -283,7 +283,7 @@ func TestSuggestTipCapSimple(t *testing.T) {
283283
284284func TestSuggestTipCapSimpleFloor (t * testing.T ) {
285285 applyGasPriceTest (t , suggestTipCapTest {
286- chainConfig : params .TestChainConfig ,
286+ chainConfig : params .TestFortunaChainConfig ,
287287 numBlocks : 1 ,
288288 genBlock : testGenBlock (t , 55 , 370 ),
289289 expectedTip : big .NewInt (643_500_644 ),
@@ -293,17 +293,17 @@ func TestSuggestTipCapSimpleFloor(t *testing.T) {
293293func TestSuggestTipCapSmallTips (t * testing.T ) {
294294 tip := big .NewInt (550 * params .GWei )
295295 applyGasPriceTest (t , suggestTipCapTest {
296- chainConfig : params .TestChainConfig ,
296+ chainConfig : params .TestFortunaChainConfig ,
297297 numBlocks : 3 ,
298298 genBlock : func (i int , b * core.BlockGen ) {
299299 b .SetCoinbase (common.Address {1 })
300300
301- signer := types .LatestSigner (params .TestChainConfig )
301+ signer := types .LatestSigner (params .TestFortunaChainConfig )
302302 baseFee := b .BaseFee ()
303303 feeCap := new (big.Int ).Add (baseFee , tip )
304304 for j := 0 ; j < 185 ; j ++ {
305305 tx := types .NewTx (& types.DynamicFeeTx {
306- ChainID : params .TestChainConfig .ChainID ,
306+ ChainID : params .TestFortunaChainConfig .ChainID ,
307307 Nonce : b .TxNonce (addr ),
308308 To : & common.Address {},
309309 Gas : ethparams .TxGas ,
@@ -317,7 +317,7 @@ func TestSuggestTipCapSmallTips(t *testing.T) {
317317 }
318318 b .AddTx (tx )
319319 tx = types .NewTx (& types.DynamicFeeTx {
320- ChainID : params .TestChainConfig .ChainID ,
320+ ChainID : params .TestFortunaChainConfig .ChainID ,
321321 Nonce : b .TxNonce (addr ),
322322 To : & common.Address {},
323323 Gas : ethparams .TxGas ,
@@ -336,7 +336,7 @@ func TestSuggestTipCapSmallTips(t *testing.T) {
336336
337337func TestSuggestTipCapMinGas (t * testing.T ) {
338338 applyGasPriceTest (t , suggestTipCapTest {
339- chainConfig : params .TestChainConfig ,
339+ chainConfig : params .TestFortunaChainConfig ,
340340 numBlocks : 3 ,
341341 genBlock : testGenBlock (t , 500 , 50 ),
342342 expectedTip : DefaultMinPrice ,
@@ -352,10 +352,10 @@ func TestSuggestGasPriceSubnetEVM(t *testing.T) {
352352 Percentile : 60 ,
353353 }
354354
355- backend := newTestBackend (t , params .TestChainConfig , 3 , func (i int , b * core.BlockGen ) {
355+ backend := newTestBackend (t , params .TestFortunaChainConfig , 3 , func (i int , b * core.BlockGen ) {
356356 b .SetCoinbase (common.Address {1 })
357357
358- signer := types .LatestSigner (params .TestChainConfig )
358+ signer := types .LatestSigner (params .TestFortunaChainConfig )
359359 gasPrice := big .NewInt (legacy .BaseFee )
360360 for j := 0 ; j < 50 ; j ++ {
361361 tx := types .NewTx (& types.LegacyTx {
@@ -379,18 +379,57 @@ func TestSuggestGasPriceSubnetEVM(t *testing.T) {
379379 require .NoError (t , err )
380380}
381381
382+ // NOTE: [Oracle.SuggestTipCap] does NOT simply return the "required" (minimum) tip.
383+ // The oracle computes a percentile of recent required tips (not observed on-chain tips)
384+ // within a time/blocks lookback window and applies a small floor (e.g., 1 wei in tests):
385+ //
386+ // suggested = max(floor, recent-required-percentile)
387+ //
388+ // After Granite, BlockGasCost is 0 and per-block required tips are 0, so the oracle
389+ // suggestion equals the floor (1 wei) in steady state, regardless of high on-chain tips.
390+ // The cases below exercise behavior across forks using the same percentile logic and floor.
382391func TestSuggestTipCapMaxBlocksLookback (t * testing.T ) {
392+ cases := []struct {
393+ chainConfig * params.ChainConfig
394+ expectedTip * big.Int
395+ }{
396+ // TODO: remove Fortuna case when we activate Granite
397+ {
398+ chainConfig : params .TestFortunaChainConfig ,
399+ expectedTip : big .NewInt (1 ),
400+ },
401+ {
402+ chainConfig : params .TestChainConfig ,
403+ expectedTip : big .NewInt (1 ),
404+ },
405+ }
406+ for _ , c := range cases {
407+ applyGasPriceTest (t , suggestTipCapTest {
408+ chainConfig : c .chainConfig ,
409+ numBlocks : 200 ,
410+ genBlock : testGenBlock (t , 550 , 80 ),
411+ expectedTip : c .expectedTip ,
412+ }, defaultOracleConfig ())
413+ }
414+ }
415+
416+ // Post-Granite, even very high observed tx tips should not affect SuggestTipCap, which
417+ // is computed from required tips. Since required tips are 0 in Granite, the returned
418+ // suggestion should be the floor (1 wei).
419+ func TestSuggestTipCapIgnoresObservedTipsPostGranite (t * testing.T ) {
383420 applyGasPriceTest (t , suggestTipCapTest {
384- chainConfig : params .TestChainConfig ,
421+ chainConfig : params .TestChainConfig , // Granite active in TestChainConfig
385422 numBlocks : 20 ,
386- genBlock : testGenBlock (t , 550 , 370 ),
387- expectedTip : big .NewInt (5_807_226_111 ),
423+ // Generate blocks with very high on-chain tips to ensure they wouldn't bias the result
424+ // if the oracle looked at observed tips. Expectation remains 1 wei.
425+ genBlock : testGenBlock (t , 100_000 , 80 ),
426+ expectedTip : big .NewInt (1 ),
388427 }, defaultOracleConfig ())
389428}
390429
391430func TestSuggestTipCapMaxBlocksSecondsLookback (t * testing.T ) {
392431 applyGasPriceTest (t , suggestTipCapTest {
393- chainConfig : params .TestChainConfig ,
432+ chainConfig : params .TestFortunaChainConfig ,
394433 numBlocks : 20 ,
395434 genBlock : testGenBlock (t , 550 , 370 ),
396435 expectedTip : big .NewInt (10_384_877_852 ),
@@ -407,14 +446,14 @@ func TestEstimateBaseFeeAfterFeeConfigUpdate(t *testing.T) {
407446 }
408447
409448 // create a chain config with fee manager enabled at genesis with [addr] as the admin
410- chainConfig := params .Copy (params .TestChainConfig )
449+ chainConfig := params .Copy (params .TestFortunaChainConfig )
411450 chainConfigExtra := params .GetExtra (& chainConfig )
412451 chainConfigExtra .GenesisPrecompiles = extras.Precompiles {
413452 feemanager .ConfigKey : feemanager .NewConfig (utils .NewUint64 (0 ), []common.Address {addr }, nil , nil , nil ),
414453 }
415454
416455 // create a fee config with higher MinBaseFee and prepare it for inclusion in a tx
417- signer := types .LatestSigner (params .TestChainConfig )
456+ signer := types .LatestSigner (params .TestFortunaChainConfig )
418457 highFeeConfig := chainConfigExtra .FeeConfig
419458 highFeeConfig .MinBaseFee = big .NewInt (28_000_000_000 )
420459 data , err := feemanager .PackSetFeeConfig (highFeeConfig )
0 commit comments