Skip to content

Commit

Permalink
feat: minor polycli enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
IdrisHanafi committed Nov 29, 2023
1 parent 1b893ca commit d67f263
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/loadtest/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type (
ShouldProduceSummary *bool
SummaryOutputMode *string
LegacyTransactionMode *bool
SendOnly *bool
RecallLength *uint64

// Computed
Expand Down Expand Up @@ -220,6 +221,7 @@ func initFlags() {
ltp.BatchSize = LoadtestCmd.PersistentFlags().Uint64("batch-size", 999, "Number of batches to perform at a time for receipt fetching. Default is 999 requests at a time.")
ltp.SummaryOutputMode = LoadtestCmd.PersistentFlags().String("output-mode", "text", "Format mode for summary output (json | text)")
ltp.LegacyTransactionMode = LoadtestCmd.PersistentFlags().Bool("legacy", false, "Send a legacy transaction instead of an EIP1559 transaction.")
ltp.SendOnly = LoadtestCmd.PersistentFlags().Bool("send-only", false, "Send transactions and load without waiting for it to be mined.")

// Local flags.
ltp.Modes = LoadtestCmd.Flags().StringSliceP("mode", "m", []string{"t"}, `The testing mode to use. It can be multiple like: "t,c,d,f"
Expand Down
6 changes: 5 additions & 1 deletion cmd/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {
inputLoadTestParams.CurrentGasTipCap = gasTipCap
}

*inputLoadTestParams.PrivateKey = strings.TrimPrefix(*inputLoadTestParams.PrivateKey, "0x")
privateKey, err := ethcrypto.HexToECDSA(*inputLoadTestParams.PrivateKey)
if err != nil {
log.Error().Err(err).Msg("Couldn't process the hex private key")
Expand All @@ -164,7 +165,6 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {
return err
}
log.Trace().Uint64("blocknumber", blockNumber).Msg("Current Block Number")

ethAddress := ethcrypto.PubkeyToAddress(privateKey.PublicKey)

nonce, err := c.NonceAt(ctx, ethAddress, bigBlockNumber)
Expand Down Expand Up @@ -310,6 +310,10 @@ func initNonce(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Client) err

func completeLoadTest(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Client) error {
log.Debug().Uint64("startNonce", startNonce).Uint64("lastNonce", currentNonce).Msg("Finished main load test loop")
if *inputLoadTestParams.SendOnly {
log.Info().Msgf("Send only mode enabled: finished sending %d transactions.", currentNonce-startNonce)
return nil
}
log.Debug().Msg("Waiting for remaining transactions to be completed and mined")

var err error
Expand Down
1 change: 1 addition & 0 deletions doc/polycli_loadtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ The codebase has a contract that used for load testing. It's written in Yul and
-r, --rpc-url string The RPC endpoint url (default "http://localhost:8545")
--seed int A seed for generating random values and addresses (default 123456)
--send-amount string The amount of wei that we'll send every transaction (default "0x38D7EA4C68000")
--send-only Send transactions and load without waiting for it to be mined.
--steady-state-tx-pool-size uint When using adaptive rate limiting, this value sets the target queue size. If the queue is smaller than this value, we'll speed up. If the queue is smaller than this value, we'll back off. (default 1000)
--summarize Should we produce an execution summary after the load test has finished. If you're running a large load test, this can take a long time
-t, --time-limit int Maximum number of seconds to spend for benchmarking. Use this to benchmark within a fixed total amount of time. Per default there is no time limit. (default -1)
Expand Down
1 change: 1 addition & 0 deletions doc/polycli_loadtest_uniswapv3.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The command also inherits flags from parent commands.
-r, --rpc-url string The RPC endpoint url (default "http://localhost:8545")
--seed int A seed for generating random values and addresses (default 123456)
--send-amount string The amount of wei that we'll send every transaction (default "0x38D7EA4C68000")
--send-only Send transactions and load without waiting for it to be mined.
--steady-state-tx-pool-size uint When using adaptive rate limiting, this value sets the target queue size. If the queue is smaller than this value, we'll speed up. If the queue is smaller than this value, we'll back off. (default 1000)
--summarize Should we produce an execution summary after the load test has finished. If you're running a large load test, this can take a long time
-t, --time-limit int Maximum number of seconds to spend for benchmarking. Use this to benchmark within a fixed total amount of time. Per default there is no time limit. (default -1)
Expand Down

0 comments on commit d67f263

Please sign in to comment.