Open lebed2045 opened 2 years ago
you can provide nonce: "pending"
to the deploy option
But the way hardhat-deploy works to remain idempotent (if the script are designed for it) is to wait for the previous tx first and use latest
nonce
this line: await allContracts.suOracleAggregator.setOracleImplementation(mockOracleId, mockOracle.address);
is not waiting for the tx to be mined, it just wait for the tx to be broadcasted
Any update on how we can solve this error when calling contracts ? It seems really unpractical to code script with it right now ?
@Smajser12 what do you mean ?
I replied, you either have to wait for the tx to be mined with tx.wait() or use nonce:
pending` (but the latter will break hardhat-deploy replayability
Describe the bug hardhat-deploy can't be used together with regular hardchat smartcontact calls, it uses same nonce
To Reproduce
deploying "MockWBTC"nonce has already been used [ See: https://links.ethers.org/v5-errors-NONCE_EXPIRED ] (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="sendTransaction", transaction=undefined, code=NONCE_EXPIRED, version=providers/5.6.2) {"reason":"nonce has already been used","code":"NONCE_EXPIRED","error":{"name":"ProviderError","code":-32000,"_isProviderError":true},"method":"sendTransaction"} Error: nonce has already been used [ See: https://links.ethers.org/v5-errors-NONCE_EXPIRED ] (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="sendTransaction", transaction=undefined, code=NONCE_EXPIRED, version=providers/5.6.2) at Logger.makeError (/Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/logger/src.ts/index.ts:261:28) at Logger.throwError (/Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/logger/src.ts/index.ts:273:20) at checkError (/Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:88:16) at /Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:243:24 at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'nonce has already been used',
code: 'NONCE_EXPIRED',
error: ProviderError: nonce too low
at HttpProvider.request (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat/src/internal/core/providers/http.ts:49:19)
at LocalAccountsProvider.request (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat/src/internal/core/providers/accounts.ts:182:36)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5),
method: 'sendTransaction',
transaction: undefined
}
An unexpected error occurred:
Error: ERROR processing /Users/dmitry/stableunit-poc-v2/deploy/2_MockContracts.ts:
Error: nonce has already been used [ See: https://links.ethers.org/v5-errors-NONCE_EXPIRED ] (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="sendTransaction", transaction=undefined, code=NONCE_EXPIRED, version=providers/5.6.2)
at Logger.makeError (/Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
at Logger.throwError (/Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
at checkError (/Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:88:16)
at /Users/dmitry/stableunit-poc-v2/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:243:24
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at DeploymentsManager.executeDeployScripts (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1222:19)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async DeploymentsManager.runDeploy (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:5)
at async SimpleTaskDefinition.action (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat-deploy/src/index.ts:422:5)
at async Environment._runTaskDefinition (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
at async Environment.run (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14)
at async SimpleTaskDefinition.action (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat-deploy/src/index.ts:568:32)
at async Environment._runTaskDefinition (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
at async Environment.run (/Users/dmitry/stableunit-poc-v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14)
npm notice
npm notice New minor version of npm available! 8.5.5 -> 8.12.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.12.1
npm notice Run npm install -g npm@8.12.1 to update!
npm notice
Expected behavior it should be able to deploy and call function without problems.
versions
Additional context it works extremely inconsistent, add sleep(30 seconds) after hardhat-deploy and regular call and vice-versa sometimes help, but if you have lots of cases - one eventually fails.