Skip to content

Commit 0abd182

Browse files
committed
rename multi-account flags from addresses to accounts
1 parent 8a8bd53 commit 0abd182

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

cmd/loadtest/account.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func NewAccountPool(ctx context.Context, client *ethclient.Client, fundingPrivat
143143
// Debug log for when fundingAmount==0.
144144
if fundingAmount.Cmp(big.NewInt(0)) == 0 {
145145
log.Debug().
146-
Msg("address-funding-amount is zero - account funding disabled")
146+
Msg("account-funding-amount is zero - account funding disabled")
147147
}
148148

149149
return &AccountPool{
@@ -383,7 +383,7 @@ func (ap *AccountPool) FundAccounts(ctx context.Context) error {
383383
}
384384
balance, err := ap.client.BalanceAt(ctx, tops.From, nil)
385385
if err != nil {
386-
log.Error().Err(err).Msg("Unable to get funding address balance")
386+
log.Error().Err(err).Msg("Unable to get funding account balance")
387387
}
388388

389389
totalBalanceNeeded := new(big.Int).Mul(ap.fundingAmount, big.NewInt(int64(len(ap.accounts))))
@@ -484,7 +484,7 @@ func (ap *AccountPool) ReturnFunds(ctx context.Context) error {
484484
defer ap.mu.Unlock()
485485

486486
log.Debug().
487-
Msg("Returning funds from sending addresses to funding address")
487+
Msg("Returning funds from sending accounts to funding account")
488488

489489
ethTransferGas := big.NewInt(21000)
490490
err := ap.clientRateLimiter.Wait(ctx)
@@ -513,7 +513,7 @@ func (ap *AccountPool) ReturnFunds(ctx context.Context) error {
513513
}
514514
balanceBefore, err := ap.client.BalanceAt(ctx, fundingAddress, nil)
515515
if err != nil {
516-
log.Error().Err(err).Msg("Unable to get funding address balance")
516+
log.Error().Err(err).Msg("Unable to get funding account balance")
517517
return err
518518
}
519519
log.Debug().
@@ -687,7 +687,7 @@ func (ap *AccountPool) ReturnFunds(ctx context.Context) error {
687687
}
688688
balanceAfter, err := ap.client.BalanceAt(ctx, fundingAddress, nil)
689689
if err != nil {
690-
log.Error().Err(err).Msg("Unable to get funding address balance")
690+
log.Error().Err(err).Msg("Unable to get funding account balance")
691691
return err
692692
}
693693

cmd/loadtest/app.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ type (
7979
BlobFeeCap *uint64
8080
StartNonce *uint64
8181
GasPriceMultiplier *float64
82-
SendingAddressCount *uint64
83-
AddressFundingAmount *big.Int
84-
PreFundSendingAddresses *bool
82+
SendingAccountsCount *uint64
83+
AccountFundingAmount *big.Int
84+
PreFundSendingAccounts *bool
8585
KeepFundsAfterTest *bool
86-
SendingAddressesFile *string
86+
SendingAccountsFile *string
8787
Proxy *string
8888

8989
// Computed
@@ -160,8 +160,8 @@ var (
160160
0xF0, 0x0D, 0xBA, 0xBE,
161161
}
162162

163-
randSrc *rand.Rand
164-
defaultFunding = new(big.Int).SetUint64(0) // 1 ETH
163+
randSrc *rand.Rand
164+
defaultAccountFundingAmount = new(big.Int).SetUint64(0) // 1 ETH
165165
)
166166

167167
// LoadtestCmd represents the loadtest command
@@ -241,12 +241,12 @@ func initFlags() {
241241
ltp.LegacyTransactionMode = LoadtestCmd.PersistentFlags().Bool("legacy", false, "Send a legacy transaction instead of an EIP1559 transaction.")
242242
ltp.FireAndForget = LoadtestCmd.PersistentFlags().Bool("fire-and-forget", false, "Send transactions and load without waiting for it to be mined.")
243243
ltp.BlobFeeCap = LoadtestCmd.Flags().Uint64("blob-fee-cap", 100000, "The blob fee cap, or the maximum blob fee per chunk, in Gwei.")
244-
ltp.SendingAddressCount = LoadtestCmd.Flags().Uint64("sending-address-count", 1, "The number of sending addresses to use. This is useful for avoiding pool account queue.")
245-
ltp.AddressFundingAmount = defaultFunding
246-
LoadtestCmd.Flags().Var(&flag_loader.BigIntValue{Val: ltp.AddressFundingAmount}, "address-funding-amount", "The amount in wei to fund the sending addresses with. Set to 0 to disable account funding (useful for eth-call-only mode or pre-funded addresses).")
247-
ltp.PreFundSendingAddresses = LoadtestCmd.Flags().Bool("pre-fund-sending-addresses", false, "If set to true, the sending addresses will be funded at the start of the execution, otherwise all addresses will be funded when used for the first time.")
248-
ltp.KeepFundsAfterTest = LoadtestCmd.Flags().Bool("keep-funds-after-test", false, "If set to true, the funded amount will be kept in the sending addresses. Otherwise, the funded amount will be refunded back to the account used to fund the account.")
249-
ltp.SendingAddressesFile = LoadtestCmd.Flags().String("sending-addresses-file", "", "The file containing the sending addresses private keys, one per line. This is useful for avoiding pool account queue but also to keep the same sending addresses for different execution cycles.")
244+
ltp.SendingAccountsCount = LoadtestCmd.Flags().Uint64("sending-accounts-count", 1, "The number of sending accounts to use. This is useful for avoiding pool account queue.")
245+
ltp.AccountFundingAmount = defaultAccountFundingAmount
246+
LoadtestCmd.Flags().Var(&flag_loader.BigIntValue{Val: ltp.AccountFundingAmount}, "account-funding-amount", "The amount in wei to fund the sending accounts with. Set to 0 to disable account funding (useful for eth-call-only mode or pre-funded accounts).")
247+
ltp.PreFundSendingAccounts = LoadtestCmd.Flags().Bool("pre-fund-sending-accounts", false, "If set to true, the sending accounts will be funded at the start of the execution, otherwise all accounts will be funded when used for the first time.")
248+
ltp.KeepFundsAfterTest = LoadtestCmd.Flags().Bool("keep-funds-after-test", false, "If set to true, the funded amount will be kept in the sending accounts. Otherwise, the funded amount will be refunded back to the account used to fund the account.")
249+
ltp.SendingAccountsFile = LoadtestCmd.Flags().String("sending-accounts-file", "", "The file containing the sending accounts private keys, one per line. This is useful for avoiding pool account queue but also to keep the same sending accounts for different execution cycles.")
250250

251251
// Local flags.
252252
ltp.Modes = LoadtestCmd.Flags().StringSliceP("mode", "m", []string{"t"}, `The testing mode to use. It can be multiple like: "d,t"

cmd/loadtest/loadtest.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -302,22 +302,22 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {
302302

303303
randSrc = rand.New(rand.NewSource(*inputLoadTestParams.Seed))
304304

305-
sendingAddressCount := *inputLoadTestParams.SendingAddressCount
306-
preFundSendingAddresses := *inputLoadTestParams.PreFundSendingAddresses
307-
fundingAmount := inputLoadTestParams.AddressFundingAmount
308-
sendingAddressesFile := *inputLoadTestParams.SendingAddressesFile
305+
sendingAccountsCount := *inputLoadTestParams.SendingAccountsCount
306+
preFundSendingAccounts := *inputLoadTestParams.PreFundSendingAccounts
307+
fundingAmount := inputLoadTestParams.AccountFundingAmount
308+
sendingAccountsFile := *inputLoadTestParams.SendingAccountsFile
309309
accountPool, err = NewAccountPool(ctx, c, privateKey, fundingAmount)
310310
if err != nil {
311311
log.Error().Err(err).Msg("Unable to create account pool")
312312
return fmt.Errorf("unable to create account pool. %w", err)
313313
}
314314

315-
if len(sendingAddressesFile) > 0 {
315+
if len(sendingAccountsFile) > 0 {
316316
log.Trace().
317-
Str("sendingAddressFile", sendingAddressesFile).
317+
Str("sendingAccountsFile", sendingAccountsFile).
318318
Msg("Adding accounts from file to the account pool")
319319

320-
privateKeys, iErr := readPrivateKeysFromFile(sendingAddressesFile)
320+
privateKeys, iErr := readPrivateKeysFromFile(sendingAccountsFile)
321321
if iErr != nil {
322322
log.Error().
323323
Err(iErr).
@@ -326,25 +326,25 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {
326326
}
327327
if len(privateKeys) == 0 && *inputLoadTestParams.StartNonce > 0 {
328328
log.Fatal().
329-
Str("sendingAddressFile", sendingAddressesFile).
329+
Str("sendingAccountsFile", sendingAccountsFile).
330330
Msg("nonce can't be set while using multiple sending accounts")
331331
}
332332

333333
err = accountPool.AddN(ctx, privateKeys...)
334-
} else if sendingAddressCount > 1 {
334+
} else if sendingAccountsCount > 1 {
335335
log.Trace().
336-
Uint64("sendingAddressCount", sendingAddressCount).
336+
Uint64("sendingAccountsCount", sendingAccountsCount).
337337
Msg("Adding random accounts to the account pool")
338338

339339
if *inputLoadTestParams.StartNonce > 0 {
340340
log.Fatal().
341-
Uint64("sendingAddressCount", sendingAddressCount).
341+
Uint64("sendingAccountsCount", sendingAccountsCount).
342342
Msg("nonce can't be set while using multiple sending accounts")
343343
}
344-
err = accountPool.AddRandomN(ctx, sendingAddressCount)
344+
err = accountPool.AddRandomN(ctx, sendingAccountsCount)
345345
} else {
346346
log.Trace().
347-
Uint64("sendingAddressCount", sendingAddressCount).
347+
Uint64("sendingAccountsCount", sendingAccountsCount).
348348
Msg("Using the same account for all transactions")
349349
var nonce *uint64
350350
if *inputLoadTestParams.StartNonce > 0 {
@@ -358,40 +358,40 @@ func initializeLoadTestParams(ctx context.Context, c *ethclient.Client) error {
358358
return fmt.Errorf("unable to set account pool. %w", err)
359359
}
360360

361-
// Only call FundAccounts() to prefund addresses if preFundSendingAddresses enabled and sendingAddressCount > 1.
362-
// For single addresses, it will not be prefunded.
363-
if preFundSendingAddresses && sendingAddressCount > 1 {
364-
// Check if we need to auto-set funding amount for multiple addresses or pre-funding
365-
if inputLoadTestParams.AddressFundingAmount.Cmp(new(big.Int)) > 0 {
361+
// Only call FundAccounts() to pre fund accounts if preFundSendingAccounts enabled and sendingAAccountsCount > 1.
362+
// For single account, it will not be prefunded.
363+
if preFundSendingAccounts && sendingAccountsCount > 1 {
364+
// Check if we need to auto-set funding amount for multiple accounts or pre-funding
365+
if inputLoadTestParams.AccountFundingAmount.Cmp(new(big.Int)) > 0 {
366366
err := accountPool.FundAccounts(ctx)
367367
if err != nil {
368-
log.Error().Err(err).Msg("Unable to fund sending addresses")
368+
log.Error().Err(err).Msg("Unable to fund sending accounts")
369369
iErr := accountPool.ReturnFunds(ctx)
370370
if iErr != nil {
371371
log.Error().
372372
Err(iErr).
373-
Msg("There was an issue returning the funds from the sending addresses back to the funding address")
374-
return fmt.Errorf("unable to return funds from sending addresses. %w", iErr)
373+
Msg("There was an issue returning the funds from the sending accounts back to the funding account")
374+
return fmt.Errorf("unable to return funds from sending accounts. %w", iErr)
375375
}
376-
return fmt.Errorf("unable to fund sending addresses. %w", err)
376+
return fmt.Errorf("unable to fund sending accounts. %w", err)
377377
}
378378
} else if !*inputLoadTestParams.EthCallOnly {
379-
// When using multiple sending addresses and not using --eth-call-only and --address-funding-amount <= 0, we need to make sure the addresses get funded
379+
// When using multiple sending accounts and not using --eth-call-only and --account-funding-amount <= 0, we need to make sure the accounts get funded
380380
// Set default funding to 1 ETH (1000000000000000000 wei)
381381
defaultFunding := new(big.Int).SetUint64(1000000000000000000)
382-
inputLoadTestParams.AddressFundingAmount = defaultFunding
382+
inputLoadTestParams.AccountFundingAmount = defaultFunding
383383
log.Debug().
384-
Msg("Multiple sending addresses detected with pre-funding enabled with zero funding amount - auto-setting funding amount to 1 ETH")
384+
Msg("Multiple sending accounts detected with pre-funding enabled with zero funding amount - auto-setting funding amount to 1 ETH")
385385
}
386386
}
387387

388388
return nil
389389
}
390390

391-
func readPrivateKeysFromFile(sendingAddressesFile string) ([]*ecdsa.PrivateKey, error) {
392-
file, err := os.Open(sendingAddressesFile)
391+
func readPrivateKeysFromFile(sendingAccountsFile string) ([]*ecdsa.PrivateKey, error) {
392+
file, err := os.Open(sendingAccountsFile)
393393
if err != nil {
394-
return nil, fmt.Errorf("unable to open sending addresses file: %w", err)
394+
return nil, fmt.Errorf("unable to open sending accounts file: %w", err)
395395
}
396396
defer file.Close()
397397

@@ -411,7 +411,7 @@ func readPrivateKeysFromFile(sendingAddressesFile string) ([]*ecdsa.PrivateKey,
411411
}
412412

413413
if err := scanner.Err(); err != nil {
414-
return nil, fmt.Errorf("error reading sending address file: %w", err)
414+
return nil, fmt.Errorf("error reading sending accounts file: %w", err)
415415
}
416416

417417
return privateKeys, nil
@@ -453,7 +453,7 @@ func completeLoadTest(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Clie
453453
if err != nil {
454454
log.Error().
455455
Err(err).
456-
Msg("There was an issue returning the funds from the sending addresses back to the funding address")
456+
Msg("There was an issue returning the funds from the sending accounts back to the funding account")
457457
}
458458

459459
if *inputLoadTestParams.ShouldProduceSummary {

doc/load-testing-guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ The loadtest command provided by `polycli` send all the transactions with the sa
153153
the test requires multiple accounts to be used in order to avoid the pool queue limits, the `polycli` supports
154154
multi-account by setting the following flags:
155155

156-
- `sending-address-count`: defines the number of accounts that will be created to send the test txs
157-
- `address-funding-amount`: defines the amount that will be funded to each sending account that will be created
158-
- `pre-fund-sending-addresses`: if set to true, the sending addresses will be funded at the start of the execution of
156+
- `sending-accounts-count`: defines the number of accounts that will be created to send the test txs
157+
- `account-funding-amount`: defines the amount that will be funded to each sending account that will be created
158+
- `pre-fund-sending-accounts`: if set to true, the sending account will be funded at the start of the execution of
159159
the load test, funding all the created accounts concurrently, otherwise all sending accounts will be funded only when
160160
used for the first time.
161161
- `keep-funded-amount`: by default, at the final of the load test execution, all the funds funded to the sending
162162
accounts that were created during the execution will be returned to the funding account, which is the account set in the
163163
`--private-key` flag. In case you want the funded funds to remain in the created accounts, set it to `true`
164-
- `sending-addresses-file`: defines the path to a file containing a list of private keys to be used by the load test.
164+
- `sending-accounts-file`: defines the path to a file containing a list of private keys to be used by the load test.
165165
Instead of creating new accounts, the test will use only the accounts defined in the file with the private keys as the
166166
accounts that will send the test txs
167167

doc/polycli_loadtest.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ The codebase has a contract that used for load testing. It's written in Solidity
7979
## Flags
8080

8181
```bash
82+
--account-funding-amount big.Int The amount in wei to fund the sending accounts with. Set to 0 to disable account funding (useful for eth-call-only mode or pre-funded accounts).
8283
--adaptive-backoff-factor float When using adaptive rate limiting, this flag controls our multiplicative decrease value. (default 2)
8384
--adaptive-cycle-duration-seconds uint When using adaptive rate limiting, this flag controls how often we check the queue size and adjust the rates (default 10)
8485
--adaptive-rate-limit Enable AIMD-style congestion control to automatically adjust request rate
8586
--adaptive-rate-limit-increment uint When using adaptive rate limiting, this flag controls the size of the additive increases. (default 50)
8687
--adaptive-target-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)
87-
--address-funding-amount big.Int The amount in wei to fund the sending addresses with. Set to 0 to disable account funding (useful for eth-call-only mode or pre-funded addresses).
8888
--batch-size uint Number of batches to perform at a time for receipt fetching. Default is 999 requests at a time. (default 999)
8989
--blob-fee-cap uint The blob fee cap, or the maximum blob fee per chunk, in Gwei. (default 100000)
9090
--calldata string The hex encoded calldata passed in. The format is function signature + arguments encoded together. This must be paired up with --mode contract-call and --contract-address
@@ -105,7 +105,7 @@ The codebase has a contract that used for load testing. It's written in Solidity
105105
--gas-price-multiplier float A multiplier to increase or decrease the gas price (default 1)
106106
-h, --help help for loadtest
107107
--inscription-content string The inscription content that will be encoded as calldata. This must be paired up with --mode inscription (default "data:,{\"p\":\"erc-20\",\"op\":\"mint\",\"tick\":\"TEST\",\"amt\":\"1\"}")
108-
--keep-funds-after-test If set to true, the funded amount will be kept in the sending addresses. Otherwise, the funded amount will be refunded back to the account used to fund the account.
108+
--keep-funds-after-test If set to true, the funded amount will be kept in the sending accounts. Otherwise, the funded amount will be refunded back to the account used to fund the account.
109109
--legacy Send a legacy transaction instead of an EIP1559 transaction.
110110
--loadtest-contract-address string The address of a pre-deployed load test contract
111111
-m, --mode strings The testing mode to use. It can be multiple like: "d,t"
@@ -124,7 +124,7 @@ The codebase has a contract that used for load testing. It's written in Solidity
124124
v3, uniswapv3 - Perform UniswapV3 swaps (default [t])
125125
--nonce uint Use this flag to manually set the starting nonce
126126
--output-mode string Format mode for summary output (json | text) (default "text")
127-
--pre-fund-sending-addresses If set to true, the sending addresses will be funded at the start of the execution, otherwise all addresses will be funded when used for the first time.
127+
--pre-fund-sending-accounts If set to true, the sending accounts will be funded at the start of the execution, otherwise all accounts will be funded when used for the first time.
128128
--priority-gas-price uint Specify Gas Tip Price in the case of EIP-1559
129129
--private-key string The hex encoded private key that we'll use to send transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa")
130130
--proxy string Use the proxy specified
@@ -134,8 +134,8 @@ The codebase has a contract that used for load testing. It's written in Solidity
134134
-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)
135135
-r, --rpc-url string The RPC endpoint url (default "http://localhost:8545")
136136
--seed int A seed for generating random values and addresses (default 123456)
137-
--sending-address-count uint The number of sending addresses to use. This is useful for avoiding pool account queue. (default 1)
138-
--sending-addresses-file string The file containing the sending addresses private keys, one per line. This is useful for avoiding pool account queue but also to keep the same sending addresses for different execution cycles.
137+
--sending-accounts-count uint The number of sending accounts to use. This is useful for avoiding pool account queue. (default 1)
138+
--sending-accounts-file string The file containing the sending accounts private keys, one per line. This is useful for avoiding pool account queue but also to keep the same sending accounts for different execution cycles.
139139
--store-data-size uint If we're in store mode, this controls how many bytes we'll try to store in our contract (default 1024)
140140
--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
141141
-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)

0 commit comments

Comments
 (0)