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

Add TestMode.ContractCall #10354

Closed
wants to merge 167 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
293d078
Debug CircleCi
jcortejoso May 3, 2023
92fece7
Force worflow failure
jcortejoso May 3, 2023
1ba698b
GitHub actions migration wip
jcortejoso May 5, 2023
f0d041d
Changed default shell
jcortejoso May 5, 2023
6da8441
debug
jcortejoso May 5, 2023
4cc6e1a
debug
jcortejoso May 5, 2023
1bf5c97
debug
jcortejoso May 5, 2023
8652445
debug
jcortejoso May 5, 2023
92e8dac
debug
jcortejoso May 5, 2023
932e38a
debug
jcortejoso May 5, 2023
a898ecb
debug
jcortejoso May 5, 2023
b865f59
debug
jcortejoso May 5, 2023
d16e121
debug
jcortejoso May 5, 2023
056ce97
debug
jcortejoso May 5, 2023
a2529ee
debug
jcortejoso May 5, 2023
e2020ff
debug
jcortejoso May 5, 2023
9c1b342
debug
jcortejoso May 5, 2023
4f251fb
debug
jcortejoso May 5, 2023
5e9e52e
debug
jcortejoso May 5, 2023
8d4da7e
debug
jcortejoso May 5, 2023
dfdd818
debug
jcortejoso May 5, 2023
9e69e59
debug
jcortejoso May 5, 2023
635dc24
debug
jcortejoso May 5, 2023
8386759
debug
jcortejoso May 5, 2023
b39a960
refactored node cache
jcortejoso May 5, 2023
7ebe0f3
refactored node cache
jcortejoso May 5, 2023
42a1d68
refactored node cache
jcortejoso May 5, 2023
abd5f84
refactored node cache
jcortejoso May 5, 2023
39537d8
refactored node cache
jcortejoso May 5, 2023
9aa9b95
refactored node cache
jcortejoso May 5, 2023
4ef70b0
refactored node cache
jcortejoso May 5, 2023
daf9491
refactored node cache
jcortejoso May 5, 2023
b56e42e
refactored node cache
jcortejoso May 5, 2023
adac02e
refactored node cache
jcortejoso May 5, 2023
25996ce
Added wallet test
jcortejoso May 8, 2023
97909c3
Debug
jcortejoso May 8, 2023
d2dca58
debug
jcortejoso May 8, 2023
96a35cc
debug
jcortejoso May 8, 2023
d5792a0
Disable tmate
jcortejoso May 9, 2023
71d6114
debug
jcortejoso May 9, 2023
11d820f
Merge branch 'master' of github.com:celo-org/celo-monorepo into jcort…
jcortejoso May 9, 2023
2e0ec01
Caching subpackage node_modules
jcortejoso May 9, 2023
89778f9
debug
jcortejoso May 9, 2023
1e41baf
testing cache
jcortejoso May 9, 2023
d1b9139
Testing caching the whole packages folder
jcortejoso May 9, 2023
62db5ff
Disable debug
jcortejoso May 9, 2023
7159457
Testing composite action
jcortejoso May 9, 2023
e6fcf13
Fix composite action
jcortejoso May 9, 2023
23ccf98
debug
jcortejoso May 9, 2023
c85be18
Test composite action
jcortejoso May 9, 2023
8f461f4
Composite action fixes
jcortejoso May 9, 2023
2cdd7b6
Running new tests
jcortejoso May 9, 2023
c40cc3e
debug wallet tests
jcortejoso May 9, 2023
5ccbe01
debug wallet
jcortejoso May 9, 2023
6a57fb8
Test matrix
jcortejoso May 9, 2023
89ffa42
Running more tests
jcortejoso May 9, 2023
2024197
More tests
jcortejoso May 9, 2023
e73fb02
Merge branch 'master' of https://github.com/celo-org/celo-monorepo in…
jcortejoso May 9, 2023
83f5b9f
Switch to protocol restore cache
jcortejoso May 9, 2023
e77a0a6
Debug prepare protocol test
jcortejoso May 10, 2023
7e55f96
Debug
jcortejoso May 10, 2023
95ace94
Bump cache version
jcortejoso May 10, 2023
18092fc
Debug cache
jcortejoso May 10, 2023
b80bc29
Merge branch 'jcortejoso/circleci-github-actions' of github.com:celo-…
jcortejoso May 10, 2023
4b53eff
WIP
jcortejoso May 10, 2023
4f4899f
fix
jcortejoso May 10, 2023
e80184f
wip
jcortejoso May 10, 2023
4ae55bc
test
jcortejoso May 10, 2023
b906dee
debug
jcortejoso May 10, 2023
922e7cb
debug
jcortejoso May 10, 2023
1e6a16f
More tests
jcortejoso May 10, 2023
684e680
debug
jcortejoso May 10, 2023
21ac38c
debug
jcortejoso May 10, 2023
4739f33
debug
jcortejoso May 10, 2023
567fcef
debug
jcortejoso May 10, 2023
cfda63b
debug
jcortejoso May 10, 2023
fea5a44
wip
jcortejoso May 10, 2023
fbebf77
Using relative path
jcortejoso May 10, 2023
3641453
debug
jcortejoso May 10, 2023
1075ffd
Fixed sdk package installs
jcortejoso May 10, 2023
c37c0b7
debug
jcortejoso May 10, 2023
a5ff83d
Testing partial cache
jcortejoso May 10, 2023
5ad9b50
wip
jcortejoso May 10, 2023
bfb3a54
debug
jcortejoso May 10, 2023
797da7f
debug
jcortejoso May 10, 2023
7ecfb4e
debug
jcortejoso May 10, 2023
a43f101
Including dist/ in node cache
jcortejoso May 10, 2023
ffab3dc
debug
jcortejoso May 10, 2023
85b9c77
debug
jcortejoso May 10, 2023
798dbc7
debug
jcortejoso May 10, 2023
cdb957a
debug
jcortejoso May 10, 2023
0aa2ed5
more cache
jcortejoso May 10, 2023
d45b478
more debug
jcortejoso May 10, 2023
6567264
more cache, ever
jcortejoso May 10, 2023
ee1e2c0
Fixing tests
jcortejoso May 10, 2023
73b4788
Contractkit specific cache
jcortejoso May 11, 2023
9355277
Do not debug
jcortejoso May 11, 2023
2214022
Update contract reference to fix tests on other envs (github actions)
jcortejoso May 11, 2023
75bd44b
Split node cache in two
jcortejoso May 11, 2023
1aeb256
Fix cache
jcortejoso May 11, 2023
ceb11ce
Debug e2e
jcortejoso May 11, 2023
fd8ff33
Job dependencies
jcortejoso May 11, 2023
fe9d2ae
Do not fail-fast on matrix jobs
jcortejoso May 11, 2023
0f49aa5
Typos and format.
jcortejoso May 11, 2023
80c7378
Fix go path
jcortejoso May 11, 2023
d89f31b
Cache everything!
jcortejoso May 11, 2023
2728ff9
Fixing tests
jcortejoso May 11, 2023
76a85e6
More tests
jcortejoso May 11, 2023
2546b7b
Certora tests
jcortejoso May 11, 2023
8b3f212
Testing with no java package manager
jcortejoso May 11, 2023
f7899d0
Debug certora
jcortejoso May 12, 2023
80f20fa
debug
jcortejoso May 12, 2023
d68113b
debug
jcortejoso May 12, 2023
21d704f
debug
jcortejoso May 12, 2023
9daf439
quotes
jcortejoso May 12, 2023
990675e
debug
jcortejoso May 12, 2023
1bf7f05
debug
jcortejoso May 12, 2023
b321cf5
Debug
jcortejoso May 12, 2023
fb50260
debug
jcortejoso May 12, 2023
b634bf1
debug
jcortejoso May 12, 2023
1cf95d5
debug
jcortejoso May 12, 2023
76124c2
debug
jcortejoso May 12, 2023
101f672
debug
jcortejoso May 12, 2023
ecf9b77
Force triggering everything
jcortejoso May 12, 2023
2860727
debug
jcortejoso May 12, 2023
a457d85
debug
jcortejoso May 12, 2023
6b400df
debug
jcortejoso May 12, 2023
9281377
Added npm scheduled job
jcortejoso May 12, 2023
1fbef2b
force execution npm install
jcortejoso May 12, 2023
3170b9b
Changed container
jcortejoso May 12, 2023
cc5245c
Bumped node version
jcortejoso May 12, 2023
7708690
Fix dependencies
jcortejoso May 12, 2023
a652450
Fix celocli command
jcortejoso May 12, 2023
e4294e6
Undo changes
jcortejoso May 12, 2023
87c873f
Fail if cache missed
jcortejoso May 12, 2023
7fd940d
format
jcortejoso May 12, 2023
ae2a665
Upload cron protocol-test-with-coverage
jcortejoso May 12, 2023
0f632ac
Undo change
jcortejoso May 12, 2023
2565a08
Flake-tracker refactor to support GitHub worflows
jcortejoso May 12, 2023
561abf9
Retry commands
jcortejoso May 12, 2023
c5bd850
Merge branch 'master' into jcortejoso/circleci-github-actions
jcortejoso May 16, 2023
21d2900
Merge branch 'master' into jcortejoso/circleci-github-actions
jcortejoso May 18, 2023
2935e6e
Merge branch 'master' into jcortejoso/circleci-github-actions
jcortejoso May 22, 2023
f30f93f
Testing with celo-blockchain release branch
jcortejoso May 24, 2023
3f2594a
Increase mocha timeout
jcortejoso May 24, 2023
70dccf9
Disable mocha timeouts
jcortejoso May 24, 2023
b1207b2
Merge branch 'master' into jcortejoso/circleci-github-actions
jcortejoso May 24, 2023
e9ed4c2
Increase action retry timeout
jcortejoso May 24, 2023
eca6218
Merge branch 'jcortejoso/circleci-github-actions' of https://github.c…
jcortejoso May 24, 2023
d89b681
Merge branch 'jcortejoso/circleci-github-actions' of github.com:celo-…
jcortejoso May 24, 2023
8f06fff
Fix flake-tracker when run out from CI
jcortejoso May 24, 2023
ca01410
Fix flake-tracker when run out from CI
jcortejoso May 24, 2023
0fc14c6
Review improvements
jcortejoso May 26, 2023
fde4ee3
More review driven improvements
jcortejoso May 30, 2023
e8ad3de
CiJob -> ciJob
jcortejoso May 30, 2023
0e4ea18
Test coverage workflow
jcortejoso May 31, 2023
f0b1af1
Final changes
jcortejoso May 31, 2023
c2f853f
Merge branch 'master' into jcortejoso/circleci-github-actions
jcortejoso May 31, 2023
e05ec3f
Fix linter
jcortejoso Jun 1, 2023
f7eab28
Add TestMode.ContractCall
Jun 2, 2023
b4583b2
Load test gas size changes
jcortejoso Jun 2, 2023
b4d70a8
Merge branch 'eelanagaraj/patch-celotool-loadtest' of github.com:celo…
jcortejoso Jun 2, 2023
97f71d6
Zero out transfer value and fix logging
Jun 2, 2023
6a56519
Merge branch 'eelanagaraj/patch-celotool-loadtest' of github.com:celo…
jcortejoso Jun 2, 2023
f939855
Added gasPrice limit and gasSize parameters
jcortejoso Jun 5, 2023
db07900
Reduce base threads and refactor signing and unlocking
Jun 7, 2023
d918c04
Merge branch 'temp-jcortejoso-loadtest-changes-Jun2023' into eelanaga…
jcortejoso Jun 8, 2023
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
53 changes: 44 additions & 9 deletions packages/celotool/src/cmds/geth/simulate_client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/* tslint:disable no-console */
import { AccountType, generateAddress } from 'src/lib/generate_utils'
import { getIndexForLoadTestThread, simulateClient, TestMode } from 'src/lib/geth'
import BigNumber from 'bignumber.js'
import { AccountType, generateAddress, generatePrivateKey } from 'src/lib/generate_utils'
import {
MAX_LOADTEST_THREAD_COUNT,
TestMode,
getIndexForLoadTestThread,
simulateClient,
} from 'src/lib/geth'
import * as yargs from 'yargs'
export const command = 'simulate-client'

Expand All @@ -13,8 +19,12 @@ interface SimulateClientArgv extends yargs.Argv {
index: number
mnemonic: string
recipientIndex: number
contractAddress: string
contractData: string
clientCount: number
reuseClient: boolean
maxGasPrice: number
totalTxGas: number
testMode: string
}

Expand Down Expand Up @@ -47,25 +57,47 @@ export const builder = () => {
'Index of the load test account to send transactions to. Used to generate account address',
default: 0,
})
.options('contract-address', {
type: 'string',
description: `Contract Address to send to when using test mode: ${TestMode.ContractCall}`,
default: '',
})
.options('contract-data', {
type: 'string',
description: `Data to send to when using test mode: ${TestMode.ContractCall}`,
default: '',
})
.options('mnemonic', {
type: 'string',
description: 'Mnemonic used to generate account addresses',
demand: 'A mnemonic must be provided',
})
.options('client-count', {
type: 'number',
description: 'Number of clients to simulate',
description: `Number of clients to simulate, must not exceed ${MAX_LOADTEST_THREAD_COUNT}`,
default: 1,
})
.check((argv) => argv['client-count'] <= MAX_LOADTEST_THREAD_COUNT)
.options('reuse-client', {
type: 'boolean',
description: 'Use the same client for all the threads/accounts',
default: false,
})
.options('max-gas-price', {
type: 'number',
description: 'Max gasPrice to use for transactions',
default: 0,
})
.options('total-tx-gas', {
type: 'number',
description: 'Gas Target when using data transfers',
default: 500000,
})
.options('test-mode', {
type: 'string',
description: 'Load test mode: mixed transaction types, big calldatas, or simple transfers',
choices: [TestMode.Mixed, TestMode.Data, TestMode.Transfer],
description:
'Load test mode: mixed transaction types, big calldatas, simple transfers, or contract calls',
choices: [TestMode.Mixed, TestMode.Data, TestMode.Transfer, TestMode.ContractCall],
default: TestMode.Mixed,
})
}
Expand All @@ -74,7 +106,7 @@ export const handler = async (argv: SimulateClientArgv) => {
for (let thread = 0; thread < argv.clientCount; thread++) {
const senderIndex = getIndexForLoadTestThread(argv.index, thread)
const recipientIndex = getIndexForLoadTestThread(argv.recipientIndex, thread)
const senderAddress = generateAddress(
const senderPK = generatePrivateKey(
argv.mnemonic,
AccountType.LOAD_TESTING_ACCOUNT,
senderIndex
Expand All @@ -88,23 +120,26 @@ export const handler = async (argv: SimulateClientArgv) => {
const web3ProviderPort = argv.reuseClient ? 8545 : 8545 + thread

console.log(
`Account for sender index ${argv.index} thread ${thread}, final index ${senderIndex}: ${senderAddress}`
`PK for sender index ${argv.index} thread ${thread}, final index ${senderIndex}: ${senderPK}`
)
console.log(
`Account for recipient index ${argv.recipientIndex} thread ${thread}, final index ${recipientIndex}: ${recipientAddress}`
)
console.log(`web3ProviderPort for thread ${thread}: ${web3ProviderPort}`)

// tslint:disable-next-line: no-floating-promises
simulateClient(
senderAddress,
senderPK,
recipientAddress,
argv.contractAddress,
argv.contractData,
argv.delay,
argv.blockscoutUrl,
argv.blockscoutMeasurePercent,
argv.index,
argv.testMode as TestMode,
thread,
new BigNumber(argv.maxGasPrice),
argv.totalTxGas,
`http://localhost:${web3ProviderPort}`
)
}
Expand Down
160 changes: 88 additions & 72 deletions packages/celotool/src/lib/geth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import { convertToContractDecimals } from './contract-utils'
import { envVar, fetchEnv, isVmBased } from './env-utils'
import {
AccountType,
Validator,
generateGenesis,
generateGenesisWithMigrations,
generatePrivateKey,
privateKeyToAddress,
privateKeyToPublicKey,
Validator,
} from './generate_utils'
import { retrieveClusterIPAddress, retrieveIPAddress } from './helm_deploy'
import { GethInstanceConfig } from './interfaces/geth-instance-config'
Expand Down Expand Up @@ -78,6 +79,7 @@ export const LOG_TAG_TRANSACTION_VALIDATION_ERROR = 'validate_transaction_error'
// for log messages which show time needed to receive the receipt after
// the transaction has been sent
export const LOG_TAG_TX_TIME_MEASUREMENT = 'tx_time_measurement'
export const MAX_LOADTEST_THREAD_COUNT = 100

export const getEnodeAddress = (nodeId: string, ipAddress: string, port: number) => {
return `enode://${nodeId}@${ipAddress}:${port}`
Expand Down Expand Up @@ -548,28 +550,31 @@ export enum TestMode {
Mixed = 'mixed',
Data = 'data',
Transfer = 'transfer',
ContractCall = 'contract-call',
}

export const simulateClient = async (
senderAddress: string,
senderPK: string,
recipientAddress: string,
contractAddress: string,
contractData: string,
txPeriodMs: number, // time between new transactions in ms
blockscoutUrl: string,
blockscoutMeasurePercent: number, // percent of time in range [0, 100] to measure blockscout for a tx
index: number,
testMode: TestMode,
thread: number,
maxGasPrice: BigNumber = new BigNumber(0),
totalTxGas: number = 500000, // aim for half million gas txs
web3Provider: string = 'http://localhost:8545'
) => {
// Assume the node is accessible via localhost with senderAddress unlocked
const kit = newKitFromWeb3(new Web3(web3Provider))
const password = fetchEnv('PASSWORD')

let lastNonce: number = -1
let lastTx: string = ''
let lastGasPriceMinimum: BigNumber = new BigNumber(0)
let nonce: number = 0
let unlockNeeded: boolean = true
let recipientAddressFinal: string = recipientAddress
const useRandomRecipient = fetchEnv(envVar.LOAD_TEST_USE_RANDOM_RECIPIENT)

Expand All @@ -580,7 +585,8 @@ export const simulateClient = async (
)
await sleep(sleepTime)
}
kit.defaultAccount = senderAddress
kit.addAccount(senderPK)
kit.defaultAccount = privateKeyToAddress(senderPK)

// sleep a random amount of time in the range [0, txPeriodMs) before starting so
// that if multiple simulations are started at the same time, they don't all
Expand All @@ -589,21 +595,34 @@ export const simulateClient = async (
console.info(`Sleeping for ${randomSleep} ms`)
await sleep(randomSleep)

const intrinsicGas = 21000
// const totalTxGas = 500000 // aim for half million gas txs
const calldataGas = totalTxGas - intrinsicGas
const calldataSize = calldataGas / 4 // 119750 < tx pool size limit (128k)
let dataStr = testMode === TestMode.Data ? getBigData(calldataSize) : undefined // aim for half million gas txs
// Also running below the 128kb limit from the tx pool
let transferAmount = LOAD_TEST_TRANSFER_WEI

if (testMode === TestMode.ContractCall) {
if (!contractData || !contractAddress) {
throw new Error('Contract address and data must be provided for TestMode.ContractCall')
}
dataStr = contractData
recipientAddressFinal = contractAddress
transferAmount = new BigNumber(0)
}

const baseLogMessage: any = {
loadTestID: index,
threadID: thread,
sender: senderAddress,
sender: kit.defaultAccount,
recipient: recipientAddressFinal,
feeCurrency: '',
txHash: '',
}

while (true) {
const sendTransactionTime = Date.now()
if (unlockNeeded) {
await unlock(kit, kit.defaultAccount, password, 9223372036)
unlockNeeded = false
}
const txConf = await getTxConf(testMode)
baseLogMessage.tokenName = txConf.tokenName

Expand Down Expand Up @@ -631,6 +650,9 @@ export const simulateClient = async (
)
nonce = nonceResult.nonce
gasPrice = nonceResult.newPrice
if (maxGasPrice.isGreaterThan(0)) {
gasPrice = BigNumber.min(gasPrice, maxGasPrice)
}
lastGasPriceMinimum = gasPrice
txOptions = {
gasPrice: gasPrice.toString(),
Expand All @@ -644,19 +666,21 @@ export const simulateClient = async (
...baseLogMessage,
})
}
const intrinsicGas = 21000
const totalTxGas = 500000 // aim for half million gas txs
const calldataGas = totalTxGas - intrinsicGas
const calldataSize = calldataGas / 4 // 119750 < tx pool size limit (128k)
const dataStr = testMode === TestMode.Data ? getBigData(calldataSize) : undefined // aim for half million gas txs
// Also running below the 128kb limit from the tx pool

if (testMode === TestMode.ContractCall) {
if (!contractData || !contractAddress) {
throw new Error('Contract address and data must be provided for TestMode.ContractCall')
}
dataStr = contractData
recipientAddressFinal = contractAddress
}

await txConf
.transferFn(
kit,
senderAddress,
kit.defaultAccount,
recipientAddressFinal,
LOAD_TEST_TRANSFER_WEI,
transferAmount,
dataStr,
txOptions
)
Expand All @@ -665,7 +689,7 @@ export const simulateClient = async (
lastNonce = (await kit.web3.eth.getTransaction(lastTx)).nonce
await onLoadTestTxResult(
kit,
senderAddress,
kit.defaultAccount!,
txResult,
sendTransactionTime,
baseLogMessage,
Expand All @@ -674,9 +698,12 @@ export const simulateClient = async (
)
})
.catch((error: any) => {
if (catchNeedUnlock(error, baseLogMessage)) {
unlockNeeded = true
}
console.error('Load test transaction failed with error:', error)
tracerLog({
tag: LOG_TAG_TRANSACTION_ERROR,
error: error.toString(),
...baseLogMessage,
})
})
if (sendTransactionTime + txPeriodMs > Date.now()) {
await sleep(sendTransactionTime + txPeriodMs - Date.now())
Expand All @@ -689,32 +716,40 @@ const getBigData = (size: number) => {
}

const getTxConf = async (testMode: TestMode) => {
if (testMode === TestMode.Data) {
return {
feeCurrencyGold: true,
tokenName: 'cGLD.L',
transferFn: transferCalldata,
}
}
if (testMode === TestMode.Transfer) {
return {
feeCurrencyGold: true,
tokenName: 'cGLD',
transferFn: transferCeloGold,
}
}

// randomly choose which token to use
const useGold = Boolean(Math.round(Math.random()))
const _transferFn = useGold ? transferCeloGold : transferCeloDollars
const _tokenName = useGold ? 'cGLD' : 'cUSD'

// randomly choose which gas currency to use
const _feeCurrencyGold = Boolean(Math.round(Math.random()))
return {
feeCurrencyGold: _feeCurrencyGold,
tokenName: _tokenName,
transferFn: _transferFn,
switch (testMode) {
case TestMode.Data:
return {
feeCurrencyGold: true,
tokenName: 'cGLD.L',
transferFn: transferCalldata,
}
case TestMode.Transfer:
return {
feeCurrencyGold: true,
tokenName: 'cGLD',
transferFn: transferCeloGold,
}
case TestMode.Mixed:
// randomly choose which token to use
const useGold = Boolean(Math.round(Math.random()))
const _transferFn = useGold ? transferCeloGold : transferCeloDollars
const _tokenName = useGold ? 'cGLD' : 'cUSD'

// randomly choose which gas currency to use
const _feeCurrencyGold = Boolean(Math.round(Math.random()))
return {
feeCurrencyGold: _feeCurrencyGold,
tokenName: _tokenName,
transferFn: _transferFn,
}
case TestMode.ContractCall:
return {
feeCurrencyGold: true,
tokenName: 'contract', // For logging
transferFn: transferCalldata,
}
default:
throw new Error(`Unimplemented TestMode: ${testMode}`)
}
}

Expand Down Expand Up @@ -745,27 +780,6 @@ const getNonce = async (
}
}

// Catch errors from the transfer Fn, and returns if an account unlock
// is needed.
const catchNeedUnlock = (error: any, baseLogMessage: any) => {
let unlockNeeded = false
if (
typeof error === 'string' &&
error.includes('Error: authentication needed: password or unlock')
) {
console.warn('Load test transaction failed with locked account:', error)
unlockNeeded = true
} else {
console.error('Load test transaction failed with error:', error)
tracerLog({
tag: LOG_TAG_TRANSACTION_ERROR,
error: error.toString(),
...baseLogMessage,
})
}
return unlockNeeded
}

const getFeeCurrency = async (kit: ContractKit, feeCurrencyGold: boolean, baseLogMessage: any) => {
try {
return feeCurrencyGold ? '' : await kit.registry.addressFor(CeloContract.StableToken)
Expand Down Expand Up @@ -845,9 +859,11 @@ export const onLoadTestTxResult = async (
* @param thread the thread number inside the pod
*/
export function getIndexForLoadTestThread(pod: number, thread: number) {
// max number of threads to avoid overlap is [0, base)
const base = 10000
return pod * base + thread
if (thread > MAX_LOADTEST_THREAD_COUNT) {
throw new Error(`thread count must be smaller than ${MAX_LOADTEST_THREAD_COUNT}`)
}
// max number of threads to avoid overlap is [0, MAX_LOADTEST_THREAD_COUNT)
return pod * MAX_LOADTEST_THREAD_COUNT + thread
}

/**
Expand Down