Skip to content

Commit dfbf34e

Browse files
authored
Merge pull request #509 from Dstack-TEE/fix/deploy-nonce-race
fix: wait for RPC nonce sync between multi-step deployments
2 parents 16c6533 + 8660c66 commit dfbf34e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

kms/auth-eth/hardhat.config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,19 @@ task("kms:deploy", "Deploy the DstackKms contract")
108108
await appContractImpl.waitForDeployment();
109109
appImplementation = await appContractImpl.getAddress();
110110
console.log("✅ DstackApp implementation deployed to:", appImplementation);
111+
112+
// Wait for RPC nonce to catch up (public RPCs may return stale nonce)
113+
const tx = appContractImpl.deploymentTransaction();
114+
if (tx) {
115+
const expectedNonce = tx.nonce + 1;
116+
for (let i = 0; i < 10; i++) {
117+
const latestNonce = await ethers.provider.getTransactionCount(deployerAddress, "latest");
118+
if (latestNonce >= expectedNonce) break;
119+
await new Promise(r => setTimeout(r, 1500));
120+
}
121+
}
111122
}
112-
123+
113124
if (appImplementation !== ethers.ZeroAddress) {
114125
console.log("Setting DstackApp implementation during initialization:", appImplementation);
115126
}

0 commit comments

Comments
 (0)