Skip to content

Commit

Permalink
chore: convert polycli loadtest --send-amount flag from wei in hex …
Browse files Browse the repository at this point in the history
…format to eth in float format
  • Loading branch information
leovct committed Nov 28, 2023
1 parent bc31249 commit b14f642
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
8 changes: 4 additions & 4 deletions cmd/loadtest/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package loadtest
import (
"crypto/ecdsa"
_ "embed"
"fmt"
"errors"
"math/big"
"math/rand"
"sync"
Expand Down Expand Up @@ -47,7 +47,7 @@ type (
ChainID *uint64
PrivateKey *string
ToAddress *string
HexSendAmount *string
SendAmountInEth *float64
RateLimit *float64
AdaptiveRateLimit *bool
SteadyStateTxPoolSize *uint64
Expand Down Expand Up @@ -179,7 +179,7 @@ func checkLoadtestFlags() error {
}

if ltp.AdaptiveBackoffFactor != nil && *ltp.AdaptiveBackoffFactor <= 0.0 {
return fmt.Errorf("the backoff factor needs to be non-zero positive")
return errors.New("the backoff factor needs to be non-zero positive")
}

return nil
Expand All @@ -204,7 +204,7 @@ func initFlags() {
ltp.ToRandom = LoadtestCmd.PersistentFlags().Bool("to-random", false, "When doing a transfer test, should we send to random addresses rather than DEADBEEFx5")
ltp.CallOnly = LoadtestCmd.PersistentFlags().Bool("call-only", false, "When using this mode, rather than sending a transaction, we'll just call. This mode is incompatible with adaptive rate limiting, summarization, and a few other features.")
ltp.CallOnlyLatestBlock = LoadtestCmd.PersistentFlags().Bool("call-only-latest", false, "When using call only mode with recall, should we execute on the latest block or on the original block")
ltp.HexSendAmount = LoadtestCmd.PersistentFlags().String("send-amount", "0x38D7EA4C68000", "The amount of wei that we'll send every transaction")
ltp.SendAmountInEth = LoadtestCmd.PersistentFlags().Float64("eth-send-amount", 0.001, "The amount of wei that we'll send every transaction")
ltp.RateLimit = LoadtestCmd.PersistentFlags().Float64("rate-limit", 4, "An overall limit to the number of requests per second. Give a number less than zero to remove this limit all together")
ltp.AdaptiveRateLimit = LoadtestCmd.PersistentFlags().Bool("adaptive-rate-limit", false, "Enable AIMD-style congestion control to automatically adjust request rate")
ltp.SteadyStateTxPoolSize = LoadtestCmd.PersistentFlags().Uint64("steady-state-tx-pool-size", 1000, "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.")
Expand Down
6 changes: 1 addition & 5 deletions cmd/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {

toAddr := ethcommon.HexToAddress(*inputLoadTestParams.ToAddress)

amt, err := util.HexToBigInt(*inputLoadTestParams.HexSendAmount)
if err != nil {
log.Error().Err(err).Msg("Couldn't parse send amount")
return err
}
amt := util.EthToWei(*inputLoadTestParams.SendAmountInEth)

header, err := c.HeaderByNumber(ctx, nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion doc/polycli_loadtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ The codebase has a contract that used for load testing. It's written in Yul and
-c, --concurrency int Number of requests to perform concurrently. Default is one request at a time. (default 1)
--erc20-address string The address of a pre-deployed ERC20 contract
--erc721-address string The address of a pre-deployed ERC721 contract
--eth-send-amount float The amount of wei that we'll send every transaction (default 0.001)
--force-contract-deploy Some load test modes don't require a contract deployment. Set this flag to true to force contract deployments. This will still respect the --lt-address flags.
-f, --function --mode f A specific function to be called if running with --mode f or a specific precompiled contract when running with `--mode a` (default 1)
--gas-limit uint In environments where the gas limit can't be computed on the fly, we can specify it manually. This can also be used to avoid eth_estimateGas
Expand Down Expand Up @@ -144,7 +145,6 @@ The codebase has a contract that used for load testing. It's written in Yul and
-n, --requests int Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results. (default 1)
-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")
--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
2 changes: 1 addition & 1 deletion doc/polycli_loadtest_uniswapv3.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The command also inherits flags from parent commands.
--chain-id uint The chain id for the transactions.
-c, --concurrency int Number of requests to perform concurrently. Default is one request at a time. (default 1)
--config string config file (default is $HOME/.polygon-cli.yaml)
--eth-send-amount float The amount of wei that we'll send every transaction (default 0.001)
--gas-limit uint In environments where the gas limit can't be computed on the fly, we can specify it manually. This can also be used to avoid eth_estimateGas
--gas-price uint In environments where the gas price can't be determined automatically, we can specify it manually
-i, --iterations uint If we're making contract calls, this controls how many times the contract will execute the instruction in a loop. If we are making ERC721 Mints, this indicates the minting batch size (default 1)
Expand All @@ -98,7 +99,6 @@ The command also inherits flags from parent commands.
-n, --requests int Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results. (default 1)
-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")
--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 b14f642

Please sign in to comment.