Skip to content

Commit

Permalink
watch gas and fee
Browse files Browse the repository at this point in the history
  • Loading branch information
jmederosalvarado committed Oct 19, 2022
1 parent 250f511 commit a4321c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cmd/livefuzzer/block_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}
}
8 changes: 6 additions & 2 deletions cmd/livefuzzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
)

var (
delay = time.Second
verbose = false
address = "http://127.0.0.1:8545"
txPerAccount = 1000
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit a4321c6

Please sign in to comment.