@@ -336,6 +336,8 @@ func GetGasPrice(gasConfig *config.Gas, client *ethclient.Client, timeout time.D
336336//
337337// For type 2 transaction on i-th attempt,
338338// the multipliers are increased by i, and caps are increased by 11% per attempt.
339+ //
340+ // Any unset values will be set to default.
339341func GasConfigForAttempt (cfg * config.Gas , attempt int ) * config.Gas {
340342 switch cfg .TxType {
341343 case 0 :
@@ -352,63 +354,26 @@ func GasConfigForAttempt(cfg *config.Gas, attempt int) *config.Gas {
352354 GasPriceMultiplier : max (1.0 , cfg .GasPriceMultiplier ) * float32 (retryMultiplier ),
353355 GasPriceFixed : cfg .GasPriceFixed ,
354356 }
355- case 2 :
357+ default : // type 2 and invalid types
356358 attemptBig := big .NewInt (int64 (attempt ))
357359
358- maxPriorityMultiplier := new (big.Int )
359- if cfg .MaxPriorityMultiplier != nil && cfg .MaxPriorityMultiplier .Cmp (common .Big0 ) == 1 {
360- maxPriorityMultiplier .Set (cfg .MaxPriorityMultiplier )
361- maxPriorityMultiplier .Add (maxPriorityMultiplier , attemptBig )
362- } else {
363- maxPriorityMultiplier .SetInt64 (defaultTipMultiplier + int64 (attempt ))
364- }
365-
366- baseFeeMultiplier := new (big.Int )
367- if cfg .BaseFeeMultiplier != nil && cfg .BaseFeeMultiplier .Cmp (common .Big0 ) == 1 {
368- baseFeeMultiplier .Set (cfg .BaseFeeMultiplier )
369- baseFeeMultiplier .Add (baseFeeMultiplier , attemptBig )
370- } else {
371- baseFeeMultiplier .Add (config .DefaultBaseFeeMultiplier , attemptBig )
372- }
373-
374- maxMaxPriorityFee := new (big.Int )
375- if cfg .MaximalMaxPriorityFee != nil && cfg .MaximalMaxPriorityFee .Cmp (common .Big0 ) == 1 {
376- maxMaxPriorityFee .Set (cfg .MaximalMaxPriorityFee )
377- } else {
378- maxMaxPriorityFee .Set (config .DefaultMaximalMaxPriorityFee )
379- }
360+ c := cfg .CopyAndDefault ()
380361
381- minMaxPriorityFee := new (big.Int )
382- if cfg .MinimalMaxPriorityFee != nil && cfg .MinimalMaxPriorityFee .Cmp (common .Big0 ) == 1 {
383- minMaxPriorityFee .Set (cfg .MinimalMaxPriorityFee )
384- } else {
385- minMaxPriorityFee .Set (config .DefaultMinimalMaxPriorityFee )
386- }
362+ c .MaxPriorityMultiplier .Add (c .MaxPriorityMultiplier , attemptBig )
363+ c .BaseFeeMultiplier .Add (c .BaseFeeMultiplier , attemptBig )
387364
388365 // Increase caps by 11% per retry
389366 if attempt > 0 {
390367 multiplier := new (big.Int ).Exp (big .NewInt (multiplierBumpTimes100 ), attemptBig , nil )
391368 normalizer := new (big.Int ).Exp (big .NewInt (normalizer ), attemptBig , nil )
392369
393- maxMaxPriorityFee . Mul (maxMaxPriorityFee , multiplier )
394- maxMaxPriorityFee . Div (maxMaxPriorityFee , normalizer )
370+ c . MaximalMaxPriorityFee . Mul (c . MaximalMaxPriorityFee , multiplier )
371+ c . MaximalMaxPriorityFee . Div (c . MaximalMaxPriorityFee , normalizer )
395372
396- minMaxPriorityFee . Mul (minMaxPriorityFee , multiplier )
397- minMaxPriorityFee . Div (minMaxPriorityFee , normalizer )
373+ c . MinimalMaxPriorityFee . Mul (c . MinimalMaxPriorityFee , multiplier )
374+ c . MinimalMaxPriorityFee . Div (c . MinimalMaxPriorityFee , normalizer )
398375 }
399376
400- return & config.Gas {
401- TxType : 2 ,
402- GasLimit : cfg .GasLimit ,
403-
404- BaseFeeMultiplier : baseFeeMultiplier ,
405- MaxPriorityMultiplier : maxPriorityMultiplier ,
406- MaximalMaxPriorityFee : maxMaxPriorityFee ,
407- MinimalMaxPriorityFee : minMaxPriorityFee ,
408-
409- BaseFeePerGasCap : cfg .BaseFeePerGasCap ,
410- }
411- default :
412- return cfg
377+ return c
413378 }
414379}
0 commit comments