Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion contracts/internal/host-chain/utils/deployCreateX.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import chalk from "chalk";
import * as fs from "fs"
import * as path from "path"
import { TransactionReceipt } from "ethers";
import type { HardhatRuntimeEnvironment } from "hardhat/types";
import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";

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

async function waitForReceiptWithIndexRetry(txHash: string, hre: HardhatRuntimeEnvironment): Promise<TransactionReceipt> {
for (;;) {
try {
const receipt = await hre.ethers.provider.getTransactionReceipt(txHash);
if (receipt) {
return receipt;
}
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
// Local geth can briefly reject receipt lookups while its tx indexer warms up
// right after startup. Retrying here avoids failing the entire deployer on boot.
if (!message.includes("transaction indexing is in progress")) {
throw error;
}
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}

export const deployCreateX = async function (hre: HardhatRuntimeEnvironment, signer: HardhatEthersSigner): Promise<boolean> {
const { ethers } = hre;

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

const receipt = await txResponse.wait();
const receipt = await waitForReceiptWithIndexRetry(txResponse.hash, hre);
if (receipt?.contractAddress !== proxyTransactionDetails.address) {
console.log(
"Failed to deploy createX contract, resulting address",
Expand Down
8 changes: 7 additions & 1 deletion contracts/internal/host-chain/utils/fund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ export async function fundAccount(
): Promise<any> {
if ((await hre.ethers.provider.getBalance(signer.address)).toString() === "0") {
if (hre.network.name === "localfhenixk8s") {
await getFunds(signer.address, "http://hostchain:3000");
// Local CoFHE hostchain now relies on prefunded genesis accounts instead of
// the old faucet service, so a zero balance here means the hostchain state
// was initialized from the wrong image/genesis and deployment cannot proceed.
throw new Error(
`Account ${signer.address} has zero balance on localfhenixk8s. ` +
"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."
);
} else if (hre.network.name === "localfhenix") {
await hre.fhenixjs.getFunds(signer.address);
console.log(
Expand Down
Loading