wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.21k stars 298 forks source link

Getting `nonce has already been used` with `deterministicDeployment` #544

Open leopaul36 opened 7 months ago

leopaul36 commented 7 months ago

Hello,

I am trying to deploy safe-contracts which uses deterministicDeployment in its scripts on an Avalanche Subnet EVM.

The deployment fails at stage deploying create2 deployer contract with the following stack trace:

$ C:\Users\leo\dev\gnosis-safe\safe-smart-account\node_modules\.bin\hardhat --network dexalotTestnet deploy
Nothing to compile
sending eth to create2 contract deployer address (0x3fab184622dc19b6109349b94811493bf2a45362) (tx: 0x67dcc04a0943ec80a34f4d3eadb6a5e257d60035af3af4754e
564866f25b1708)...
deploying create2 deployer contract (at 0x4e59b44847b379578588920ca78fbf26c0b4956c) using deterministic deployment (https://github.com/Arachnid/determi
nistic-deployment-proxy)An unexpected error occurred:

Error: ERROR processing C:\Users\leo\dev\gnosis-safe\safe-smart-account\src\deploy\deploy_accessors.ts:
Error: nonce has already been used (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="sendTransaction", transaction="0xf8a5
8085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360160008160208237803582823
4f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a0222222222222222222222222222222222222
2222222222222222222222222222", code=NONCE_EXPIRED, version=providers/5.4.5)
    at Logger.makeError (C:\Users\leo\dev\gnosis-safe\safe-smart-account\node_modules\hardhat-deploy\node_modules\@ethersproject\logger\src.ts\index.
ts:225:28)

It is worth mentioning that a previous attempt at deploying the contracts failed on the network on which I want to deploy the Safe contracts (see transaction) so indeed, the deployer address' 0x3fab184622dc19b6109349b94811493bf2a45362 nonce 0 has already been used.

Is there a way to setup the nonce using deterministicDeployment?

Thanks

wighawag commented 7 months ago

That's a weird one, It means the blockchain you are trying to deploy do not support the factory used by hardhat-deploy

You can configure a different factory : https://github.com/wighawag/hardhat-deploy?tab=readme-ov-file#4-deterministicdeployment-ability-to-specify-a-deployment-factory

leopaul36 commented 7 months ago

@wighawag after investigating more, I came across this issue which is really similar: https://github.com/safe-global/safe-singleton-factory/issues/408

So it turns out that the 1st attempt at deployer contract creation failed because the deployer address 0x3fab184622dc19b6109349b94811493bf2a45362 was not allowed to create smart contract on this chain.

Now that nonce 0 has been used, I guess we're a bit stuck here...

wighawag commented 7 months ago

yes, you would need a different factory

executionreverted commented 1 month ago

i had same issue. forgot to allow my contract. now nonce 0 is gone. maybe a simple feature can be added to plugin to check if a chain has IAllowList precompile (means its avax l1) and check it has right to deploy first?

executionreverted commented 1 month ago

is there a way to disable deterministic deployment, or is there an easy way to create new factory parameters for deterministicDeployment

wighawag commented 1 month ago

@executionreverted see this comment : https://github.com/wighawag/hardhat-deploy/issues/544#issuecomment-2082227768

you can setup your own deterministic deployment parameters