@@ -12,6 +12,7 @@ import (
1212 "syscall"
1313 "time"
1414
15+ "github.com/ethereum/go-ethereum/ethclient"
1516 "github.com/prometheus/client_golang/prometheus/promhttp"
1617 "github.com/spf13/cobra"
1718 "go.opentelemetry.io/otel"
@@ -66,6 +67,7 @@ func init() {
6667 rootCmd .Flags ().Bool ("ramp-up" , false , "Ramp up loadtest" )
6768 rootCmd .Flags ().String ("report-path" , "" , "Path to save the report" )
6869 rootCmd .Flags ().String ("txs-dir" , "" , "Path to save the transactions" )
70+ rootCmd .Flags ().Uint64 ("target-gas" , 10_000_000 , "Target gas per block" )
6971
7072 // Initialize Viper with proper error handling
7173 if err := config .InitializeViper (rootCmd ); err != nil {
@@ -228,7 +230,18 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
228230 // Create dispatcher
229231 var dispatcher * sender.Dispatcher
230232 if settings .TxsDir != "" {
231- writer := sender .NewTxsWriter (10_000_000 , settings .TxsDir )
233+ // get latest height
234+ ethclient , err := ethclient .Dial (cfg .Endpoints [0 ])
235+ if err != nil {
236+ return fmt .Errorf ("failed to create ethclient: %w" , err )
237+ }
238+ latestHeight , err := ethclient .BlockNumber (ctx )
239+ if err != nil {
240+ return fmt .Errorf ("failed to get latest height: %w" , err )
241+ }
242+ writerHeight := latestHeight + 10 // some buffer
243+ log .Printf ("🔍 Latest height: %d, writer start height: %d" , latestHeight , writerHeight )
244+ writer := sender .NewTxsWriter (settings .TargetGas , settings .TxsDir , writerHeight , 100 )
232245 dispatcher = sender .NewDispatcher (gen , writer )
233246 } else {
234247 dispatcher = sender .NewDispatcher (gen , snd )
0 commit comments