Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmd/loadtest/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ var uniswapCfg = &config.UniswapV3Config{}
// gasManagerCfg holds gas manager configuration.
var gasManagerCfg = &config.GasManagerConfig{}

// preconfCfg holds preconf tracking configuration.
var preconfCfg = &config.PreconfConfig{}

// LoadtestCmd represents the loadtest command.
var LoadtestCmd = &cobra.Command{
Use: "loadtest",
Expand All @@ -60,6 +63,8 @@ var LoadtestCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
// Attach gas manager config.
cfg.GasManager = gasManagerCfg
// Attach preconf config.
cfg.Preconf = preconfCfg
return loadtest.Run(cmd.Context(), cfg)
},
}
Expand All @@ -78,6 +83,7 @@ var uniswapv3Cmd = &cobra.Command{
cfg.Modes = []string{"v3"}
cfg.UniswapV3 = uniswapCfg
cfg.GasManager = gasManagerCfg
cfg.Preconf = preconfCfg

return loadtest.Run(cmd.Context(), cfg)
},
Expand Down Expand Up @@ -121,8 +127,11 @@ func initPersistentFlags() {
pf.BoolVar(&cfg.LegacyTxMode, "legacy", false, "send a legacy transaction instead of an EIP1559 transaction")
pf.BoolVar(&cfg.FireAndForget, "fire-and-forget", false, "send transactions and load without waiting for it to be mined")
pf.BoolVar(&cfg.FireAndForget, "send-only", false, "alias for --fire-and-forget")
pf.BoolVar(&cfg.CheckForPreconf, "check-preconf", false, "check for preconf status after sending tx")
pf.StringVar(&cfg.PreconfStatsFile, "preconf-stats-file", "", "path for preconf stats JSON output, updated every 2 seconds")
pf.BoolVar(&preconfCfg.Enabled, "check-preconf", false, "check for preconf status after sending tx")
pf.StringVar(&preconfCfg.StatsFile, "preconf-stats-file", "", "path for preconf stats JSON output, updated every 2 seconds")
pf.IntVar(&preconfCfg.BatchSize, "preconf-batch-size", 50, "transactions per batch RPC call for preconf tracking")
pf.DurationVar(&preconfCfg.PollInterval, "preconf-poll-interval", 100*time.Millisecond, "interval between batch polls for preconf tracking")
pf.DurationVar(&preconfCfg.Timeout, "preconf-timeout", time.Minute, "timeout for tracking each transaction")

initGasManagerFlags()
}
Expand Down
3 changes: 3 additions & 0 deletions doc/polycli_loadtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ The codebase has a contract that used for load testing. It's written in Solidity
--output-mode string format mode for summary output (json | text) (default "text")
--output-raw-tx-only output raw signed transaction hex without sending (works with most modes except RPC and UniswapV3)
--pre-fund-sending-accounts fund all sending accounts at start instead of on first use
--preconf-batch-size int transactions per batch RPC call for preconf tracking (default 100)
--preconf-poll-interval duration interval between batch polls for preconf tracking (default 500ms)
--preconf-stats-file string path for preconf stats JSON output, updated every 2 seconds
--preconf-timeout duration timeout for tracking each transaction (default 1m0s)
--priority-gas-price uint gas tip price for EIP-1559 transactions
--private-key string hex encoded private key to use for sending transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa")
--proxy string use the proxy specified
Expand Down
3 changes: 3 additions & 0 deletions doc/polycli_loadtest_uniswapv3.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ The command also inherits flags from parent commands.
--nonce uint use this flag to manually set the starting nonce
--output-mode string format mode for summary output (json | text) (default "text")
--output-raw-tx-only output raw signed transaction hex without sending (works with most modes except RPC and UniswapV3)
--preconf-batch-size int transactions per batch RPC call for preconf tracking (default 100)
--preconf-poll-interval duration interval between batch polls for preconf tracking (default 500ms)
--preconf-stats-file string path for preconf stats JSON output, updated every 2 seconds
--preconf-timeout duration timeout for tracking each transaction (default 1m0s)
--pretty-logs output logs in pretty format instead of JSON (default true)
--priority-gas-price uint gas tip price for EIP-1559 transactions
--private-key string hex encoded private key to use for sending transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa")
Expand Down
21 changes: 16 additions & 5 deletions loadtest/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"math/big"
"time"

"github.com/0xPolygon/polygon-cli/loadtest/uniswapv3"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -51,11 +52,9 @@ type Config struct {
ToAddress string
EthAmountInWei uint64
RandomRecipients bool
LegacyTxMode bool
FireAndForget bool
CheckForPreconf bool
PreconfStatsFile string
WaitForReceipt bool
LegacyTxMode bool
FireAndForget bool
WaitForReceipt bool
ReceiptRetryMax uint
ReceiptRetryDelay uint // initial delay in milliseconds
OutputRawTxOnly bool
Expand Down Expand Up @@ -117,6 +116,9 @@ type Config struct {
// Gas manager config (optional, for gas oscillation features)
GasManager *GasManagerConfig

// Preconf tracking config
Preconf *PreconfConfig

// Computed fields (populated during initialization)
CurrentGasPrice *big.Int
CurrentGasTipCap *big.Int
Expand Down Expand Up @@ -147,6 +149,15 @@ type GasManagerConfig struct {
DynamicGasPricesVariation float64 // ±percentage variation for dynamic
}

// PreconfConfig holds preconf tracking configuration.
type PreconfConfig struct {
Enabled bool // enable preconf tracking
StatsFile string // path for stats JSON output
BatchSize int // number of transactions per batch RPC call
PollInterval time.Duration // interval between batch polls
Timeout time.Duration // timeout for tracking each transaction
}

// UniswapV3Config holds UniswapV3-specific configuration.
type UniswapV3Config struct {
// Pre-deployed contract addresses (as hex strings).
Expand Down
Loading
Loading