diff --git a/cmd/livefuzzer/block_watcher.go b/cmd/livefuzzer/block_watcher.go index 98626ba..a611e4c 100644 --- a/cmd/livefuzzer/block_watcher.go +++ b/cmd/livefuzzer/block_watcher.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/params" ) var ( @@ -72,4 +73,10 @@ func processNewBlock(chainid *big.Int, block *types.Block) { } fmt.Printf("Included %v transaction in block %v - block gas usage was %v percent\n", txCount, block.NumberU64(), 100*block.GasUsed()/block.GasLimit()) }() + + if lastBaseFee.Cmp(new(big.Int).Mul(big.NewInt(1000), big.NewInt(params.GWei))) > 0 { + delay *= 2 + } else if lastGasUsage < 70 { + delay /= 2 + } } diff --git a/cmd/livefuzzer/main.go b/cmd/livefuzzer/main.go index b5885fb..bfb226c 100644 --- a/cmd/livefuzzer/main.go +++ b/cmd/livefuzzer/main.go @@ -26,6 +26,7 @@ import ( ) var ( + delay = time.Second verbose = false address = "http://127.0.0.1:8545" txPerAccount = 1000 @@ -177,10 +178,13 @@ func SendBaikalTransactions(client *rpc.Client, key *ecdsa.PrivateKey, f *filler panic(err) } if err = backend.SendTransaction(context.Background(), signedTx); err != nil { - fmt.Printf("Could not send tx{sender: %v, nonce: %v}: %v\n", sender.Hex(), tx.Nonce(), err) + if verbose { + fmt.Printf("Could not send tx{sender: %v, nonce: %v}: %v\n", sender.Hex(), tx.Nonce(), err) + } + time.Sleep(time.Second) continue } - time.Sleep(time.Second) + time.Sleep(delay) } }