Skip to content

Commit a6504e8

Browse files
authored
accomodate faster local deploy (#65)
1 parent c1c1c3a commit a6504e8

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

contracts/internal/host-chain/utils/deployCreateX.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import chalk from "chalk";
22
import * as fs from "fs"
33
import * as path from "path"
4+
import { TransactionReceipt } from "ethers";
45
import type { HardhatRuntimeEnvironment } from "hardhat/types";
56
import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
67

@@ -16,6 +17,25 @@ export const isAlreadyDeployed = async function (hre: HardhatRuntimeEnvironment,
1617
return code !== "0x";
1718
}
1819

20+
async function waitForReceiptWithIndexRetry(txHash: string, hre: HardhatRuntimeEnvironment): Promise<TransactionReceipt> {
21+
for (;;) {
22+
try {
23+
const receipt = await hre.ethers.provider.getTransactionReceipt(txHash);
24+
if (receipt) {
25+
return receipt;
26+
}
27+
} catch (error) {
28+
const message = error instanceof Error ? error.message : String(error);
29+
// Local geth can briefly reject receipt lookups while its tx indexer warms up
30+
// right after startup. Retrying here avoids failing the entire deployer on boot.
31+
if (!message.includes("transaction indexing is in progress")) {
32+
throw error;
33+
}
34+
}
35+
await new Promise((resolve) => setTimeout(resolve, 1000));
36+
}
37+
}
38+
1939
export const deployCreateX = async function (hre: HardhatRuntimeEnvironment, signer: HardhatEthersSigner): Promise<boolean> {
2040
const { ethers } = hre;
2141

@@ -47,7 +67,7 @@ export const deployCreateX = async function (hre: HardhatRuntimeEnvironment, sig
4767
// deploy proxy contract
4868
const txResponse = await ethers.provider.broadcastTransaction(transaction);
4969

50-
const receipt = await txResponse.wait();
70+
const receipt = await waitForReceiptWithIndexRetry(txResponse.hash, hre);
5171
if (receipt?.contractAddress !== proxyTransactionDetails.address) {
5272
console.log(
5373
"Failed to deploy createX contract, resulting address",

contracts/internal/host-chain/utils/fund.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ export async function fundAccount(
2323
): Promise<any> {
2424
if ((await hre.ethers.provider.getBalance(signer.address)).toString() === "0") {
2525
if (hre.network.name === "localfhenixk8s") {
26-
await getFunds(signer.address, "http://hostchain:3000");
26+
// Local CoFHE hostchain now relies on prefunded genesis accounts instead of
27+
// the old faucet service, so a zero balance here means the hostchain state
28+
// was initialized from the wrong image/genesis and deployment cannot proceed.
29+
throw new Error(
30+
`Account ${signer.address} has zero balance on localfhenixk8s. ` +
31+
"This devnet no longer exposes hostchain:3000/faucet; rebuild the hostchain image and wipe the hostchain/beacon volumes so the prefunded genesis accounts are applied."
32+
);
2733
} else if (hre.network.name === "localfhenix") {
2834
await hre.fhenixjs.getFunds(signer.address);
2935
console.log(

0 commit comments

Comments
 (0)