Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contract-call mode #173

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion cmd/loadtest/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ cc, contract-call - call a contract method`)
ltp.RecallLength = LoadtestCmd.Flags().Uint64("recall-blocks", 50, "The number of blocks that we'll attempt to fetch for recall")
ltp.ContractAddress = LoadtestCmd.Flags().String("contract-address", "", "The address of the contract that will be used in `--mode contract-call`. This must be paired up with `--mode contract-call` and `--calldata`")
ltp.ContractCallData = LoadtestCmd.Flags().String("calldata", "", "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`")
ltp.ContractCallPayable = LoadtestCmd.Flags().Bool("contract-call-payable", false, "Use this flag if the `--function-sig` is a `payable` function, the value amount passed will be from `--eth-amount`. This must be paired up with `--mode contract-call` and `--contract-address`")
ltp.ContractCallPayable = LoadtestCmd.Flags().Bool("contract-call-payable", false, "Use this flag if the function is payable, the value amount passed will be from `--eth-amount`. This must be paired up with `--mode contract-call` and `--contract-address`")

inputLoadTestParams = *ltp

Expand Down
26 changes: 16 additions & 10 deletions cmd/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,16 +1276,22 @@ func loadTestContractCall(ctx context.Context, c *ethclient.Client, nonce uint64
log.Error().Err(err).Msg("Unable to decode calldata string")
return
}
estimateInput := ethereum.CallMsg{
From: *ltp.FromETHAddress,
To: to,
Value: amount,
Data: calldata,
}
tops.GasLimit, err = c.EstimateGas(ctx, estimateInput)
if err != nil {
log.Error().Err(err).Msg("Unable to estimate gas for transaction")
return

if tops.GasLimit == 0 {
estimateInput := ethereum.CallMsg{
From: tops.From,
To: to,
Value: amount,
GasPrice: tops.GasPrice,
GasTipCap: tops.GasTipCap,
GasFeeCap: tops.GasFeeCap,
Data: calldata,
}
tops.GasLimit, err = c.EstimateGas(ctx, estimateInput)
if err != nil {
log.Error().Err(err).Msg("Unable to estimate gas for transaction. Manually setting gas-limit might be required")
return
}
}

var tx *ethtypes.Transaction
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,7 +114,7 @@ The codebase has a contract that used for load testing. It's written in Yul and
--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)
--contract-address --mode contract-call The address of the contract that will be used in --mode contract-call. This must be paired up with `--mode contract-call` and `--calldata`
--contract-call-payable --function-sig Use this flag if the --function-sig is a `payable` function, the value amount passed will be from `--eth-amount`. This must be paired up with `--mode contract-call` and `--contract-address`
--contract-call-payable --eth-amount Use this flag if the function is payable, the value amount passed will be from --eth-amount. This must be paired up with `--mode contract-call` and `--contract-address`
--erc20-address string The address of a pre-deployed ERC20 contract
--erc721-address string The address of a pre-deployed ERC721 contract
--eth-amount float The amount of ether to send on every transaction (default 0.001)
Expand Down