Skip to content

Commit 76a1993

Browse files
committed
Merge remote-tracking branch 'ds/master'
2 parents 6054b84 + 16c6533 commit 76a1993

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

kms/auth-eth/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ task("kms:add-device", "Add a device ID of an KMS instance")
196196
const kmsContract = await getKmsContract(ethers);
197197
const tx = await kmsContract.addKmsDevice(deviceId);
198198
await waitTx(tx);
199-
console.log("Device compose hash added successfully");
199+
console.log("Device ID added successfully");
200200
});
201201

202202
task("kms:remove-device", "Remove a device ID")

kms/auth-eth/lib/deployment-helpers.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,34 @@ export async function estimateDeploymentCost(
110110
}
111111

112112
/**
113-
* Verify contract deployment
113+
* Verify contract deployment with retry logic for public RPCs.
114+
*
115+
* Public RPC endpoints may return stale data immediately after a transaction
116+
* is mined, causing `getCode()` to return `'0x'` even though the contract was
117+
* deployed successfully. We retry a few times with exponential back-off
118+
* before giving up.
114119
*/
115120
export async function verifyDeployment(
116121
hre: HardhatRuntimeEnvironment,
117122
contractAddress: string,
118123
quiet: boolean = false
119124
) {
120-
// Verify that contract was deployed successfully
121-
const code = await hre.ethers.provider.getCode(contractAddress);
122-
if (code === '0x') {
123-
throw new Error('Contract deployment failed - no code at address');
125+
const maxRetries = 5;
126+
const baseDelayMs = 2000;
127+
128+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
129+
const code = await hre.ethers.provider.getCode(contractAddress);
130+
if (code !== '0x') {
131+
break;
132+
}
133+
if (attempt === maxRetries) {
134+
throw new Error('Contract deployment failed - no code at address after ' + maxRetries + ' attempts');
135+
}
136+
const delay = baseDelayMs * attempt;
137+
if (!quiet) {
138+
console.log(`Waiting for contract code at ${contractAddress} (attempt ${attempt}/${maxRetries}, next retry in ${delay}ms)...`);
139+
}
140+
await new Promise(resolve => setTimeout(resolve, delay));
124141
}
125142

126143
// Get implementation contract address

0 commit comments

Comments
 (0)