@@ -284,21 +284,44 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {
284284 * inputLoadTestParams .ChainID = chainID .Uint64 ()
285285 }
286286 inputLoadTestParams .CurrentBaseFee = header .BaseFee
287+ inputLoadTestParams .MaxFeePerGas = header .BaseFee
287288 go func (c * ethclient.Client , lbn uint64 ) {
288289 latestBlockNumber := lbn
289290 for {
291+ loopInterval := time .Second
292+
290293 iHeader , iErr := c .HeaderByNumber (ctx , nil )
291- if iErr == nil {
292- if iHeader .Number .Uint64 () > latestBlockNumber {
293- inputLoadTestParams .CurrentBaseFee = iHeader .BaseFee
294- latestBlockNumber = iHeader .Number .Uint64 ()
295- log .Trace ().
296- Uint64 ("latestBlockNumber" , latestBlockNumber ).
297- Str ("baseFee" , iHeader .BaseFee .String ()).
298- Msg ("Base fee updated" )
299- }
294+ if iErr != nil {
295+ time .Sleep (loopInterval )
296+ continue
297+ }
298+
299+ if latestBlockNumber >= iHeader .Number .Uint64 () {
300+ time .Sleep (loopInterval )
301+ continue
302+ }
303+
304+ feeHistory , iErr := c .FeeHistory (ctx , 5 , nil , []float64 {0.5 })
305+ if iErr != nil {
306+ time .Sleep (loopInterval )
307+ continue
300308 }
301- time .Sleep (time .Second )
309+
310+ priorityFee := feeHistory .Reward [len (feeHistory .Reward )- 1 ][0 ] // 50th percentile of most recent block
311+ baseFee := feeHistory .BaseFee [len (feeHistory .BaseFee )- 1 ] // base fee of next block
312+ inputLoadTestParams .MaxFeePerGas .Mul (big .NewInt (2 ), priorityFee )
313+ inputLoadTestParams .MaxFeePerGas .Add (inputLoadTestParams .MaxFeePerGas , baseFee )
314+ inputLoadTestParams .CurrentBaseFee = baseFee
315+
316+ latestBlockNumber = iHeader .Number .Uint64 ()
317+ log .Trace ().
318+ Uint64 ("latestBlockNumber" , latestBlockNumber ).
319+ Str ("priorityFee" , priorityFee .String ()).
320+ Str ("baseFee" , baseFee .String ()).
321+ Str ("maxFee" , inputLoadTestParams .MaxFeePerGas .String ()).
322+ Msg ("fees updated" )
323+
324+ time .Sleep (loopInterval )
302325 }
303326 }(c , header .Number .Uint64 ())
304327
@@ -1857,7 +1880,7 @@ func configureTransactOpts(ctx context.Context, c *ethclient.Client, tops *bind.
18571880
18581881 tops .GasPrice = nil
18591882 tops .GasTipCap = gasTipCap
1860- tops .GasFeeCap = ltp .CurrentBaseFee
1883+ tops .GasFeeCap = ltp .MaxFeePerGas
18611884
18621885 if ltp .ForcePriorityGasPrice != nil && * ltp .ForcePriorityGasPrice != 0 {
18631886 tops .GasTipCap = big .NewInt (0 ).SetUint64 (* ltp .ForcePriorityGasPrice )
0 commit comments