From 0d44ac39fe121736fb78003e3033def8ac7e20fc Mon Sep 17 00:00:00 2001 From: Karel Moravec Date: Mon, 11 Nov 2024 17:19:21 +0100 Subject: [PATCH] fix: for "Nonce Has Already Been Used" Issue During Deployment on Calibrationnet (#1186) --- .github/workflows/contracts-deployment-test.yaml | 6 +++--- contracts/tasks/deploy-registry.ts | 8 ++------ contracts/tasks/lib/deployments.ts | 6 ++++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/contracts-deployment-test.yaml b/.github/workflows/contracts-deployment-test.yaml index 7d7de2147..bc77985b2 100644 --- a/.github/workflows/contracts-deployment-test.yaml +++ b/.github/workflows/contracts-deployment-test.yaml @@ -1,4 +1,4 @@ -name: 'Contracts: Smoke test deployment' +name: "Contracts: Smoke test deployment" # This workflow is triggered from the main CI workflow. on: @@ -17,8 +17,8 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: '18.x' - cache: 'pnpm' + node-version: "18.x" + cache: "pnpm" - name: Install dependencies run: cd contracts && make deps diff --git a/contracts/tasks/deploy-registry.ts b/contracts/tasks/deploy-registry.ts index f087bd8b0..50ecb7507 100644 --- a/contracts/tasks/deploy-registry.ts +++ b/contracts/tasks/deploy-registry.ts @@ -97,12 +97,8 @@ task('deploy-registry') creationPrivileges: Number(mode), } - console.log(`Deploying SubnetRegistryDiamond...`) - const registry = await hre.deployments.deploy('SubnetRegistryDiamond', { - from: deployer, + Deployments.deploy(hre, deployer, { + name: 'SubnetRegistryDiamond', args: [registryFacets.asFacetCuts(), registryConstructorParams], - log: true, - waitConfirmations: 1, }) - console.log(`SubnetRegistryDiamond deployed at ${registry.address}`) }) diff --git a/contracts/tasks/lib/deployments.ts b/contracts/tasks/lib/deployments.ts index 4fbcb15b4..89eaacc47 100644 --- a/contracts/tasks/lib/deployments.ts +++ b/contracts/tasks/lib/deployments.ts @@ -68,16 +68,22 @@ export class Deployments { ...(contract.libraries || []), ) + // Manually managed nonce due to a Filecoin update, which requires specifying 'pending' with + // getTransactionCount to retrieve the latest nonce. + const nonce = await hre.ethers.provider.getTransactionCount(deployer, "pending"); + const result = await hre.deployments.deploy(contract.name, { from: deployer, log: true, args: contract.args, libraries: libraries.addresses, + nonce: nonce, waitConfirmations: 1, }) results[contract.name] = result console.log(`${contract.name} deployed at ${result.address}`) } + return new Deployments( await Deployments.resolveContracts(hre, Object.keys(results)), results,