Skip to content

Commit ce3a5b8

Browse files
committed
Update deployment scripts
1 parent ba01181 commit ce3a5b8

File tree

8 files changed

+61
-17
lines changed

8 files changed

+61
-17
lines changed

deploy/config/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const historicalDeployConfig: HistoricalDeployConfig = {
44
blockHeader:
55
"0x0000ec2480377962272e6ceefe662388c2323b08f1750e741d9900000000000000000000b8876bf9d189b5c88e4a7724032e0a1123e506fcfbbc785ac85f7546b4b63b4c12c9c468ac1102177c033abd",
66
blockHeight: 914431n,
7+
lastHistoryEpochStartTime: 1757050390n,
78
cumulativeWork: "0x0000000000000000000000000000000000000000e2290521afb0314879068960",
89
historyBlocksTreeRoot: "0xc6caf356aaf3a2e95ab3274f08f273097178644550d8f9b0354ef526d35a6bac",
910
proofBlocksCount: 914432n,

deploy/config/ethereum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const historicalDeployConfig: HistoricalDeployConfig = {
44
blockHeader:
55
"0x0000ec2480377962272e6ceefe662388c2323b08f1750e741d9900000000000000000000b8876bf9d189b5c88e4a7724032e0a1123e506fcfbbc785ac85f7546b4b63b4c12c9c468ac1102177c033abd",
66
blockHeight: 914431n,
7+
lastHistoryEpochStartTime: 1757050390n,
78
cumulativeWork: "0x0000000000000000000000000000000000000000e2290521afb0314879068960",
89
historyBlocksTreeRoot: "0xc6caf356aaf3a2e95ab3274f08f273097178644550d8f9b0354ef526d35a6bac",
910
proofBlocksCount: 914432n,

deploy/config/localhost.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const historicalDeployConfig: HistoricalDeployConfig = {
1111
blockHeader:
1212
"0x00a00220e968938e8359a569ee6572db4d84e0b4e082872d83a5010000000000000000009c9671154ec76af4d624d88a1359373f85b76328f4afe78a3e53c7be83bcf21396c3b268912b02178f54c573",
1313
blockHeight: 912383n,
14-
cumulativeWork: "0x0000000000000000000000000000000000000000de5f1bd9bd93c239552a585e",
14+
lastHistoryEpochStartTime: 1755895678n,
15+
cumulativeWork: "0x0000000000000000000000000000000000000000de5ea5e3576fb66c630a9540",
1516
historyBlocksTreeRoot: "0xd2fde3f66540b59b7b41411d875c0ecee424d70dce15d3685566c34ed66feae3",
1617
proofBlocksCount: 912384n,
1718
};

deploy/config/sepolia.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ export const deployConfig: DeployConfig = {
99

1010
export const historicalDeployConfig: HistoricalDeployConfig = {
1111
blockHeader:
12-
"0x0000ec2480377962272e6ceefe662388c2323b08f1750e741d9900000000000000000000b8876bf9d189b5c88e4a7724032e0a1123e506fcfbbc785ac85f7546b4b63b4c12c9c468ac1102177c033abd",
13-
blockHeight: 914431n,
14-
cumulativeWork: "0x0000000000000000000000000000000000000000e2290521afb0314879068960",
15-
historyBlocksTreeRoot: "0xc6caf356aaf3a2e95ab3274f08f273097178644550d8f9b0354ef526d35a6bac",
16-
proofBlocksCount: 914432n,
12+
"0x00a00220e968938e8359a569ee6572db4d84e0b4e082872d83a5010000000000000000009c9671154ec76af4d624d88a1359373f85b76328f4afe78a3e53c7be83bcf21396c3b268912b02178f54c573",
13+
blockHeight: 912383n,
14+
lastHistoryEpochStartTime: 1755895678n,
15+
cumulativeWork: "0x0000000000000000000000000000000000000000de5ea5e3576fb66c630a9540",
16+
historyBlocksTreeRoot: "0xd2fde3f66540b59b7b41411d875c0ecee424d70dce15d3685566c34ed66feae3",
17+
proofBlocksCount: 912384n,
1718
};

deploy/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type HistoricalDeployConfig = {
1010
blockHeader: string;
1111
blockHeight: BigNumberish;
1212
cumulativeWork: BigNumberish;
13+
lastHistoryEpochStartTime: BigNumberish;
1314
historyBlocksTreeRoot: string;
1415
proofBlocksCount: bigint;
1516
};

deploy/historical/1_HistoricalSPVGateway.migration.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
11
import { Deployer, Reporter } from "@solarity/hardhat-migrate";
22

3-
import { HistoryProofVerifier914432__factory, ICreateX__factory, HistoricalSPVGateway__factory } from "@ethers-v6";
3+
import { ICreateX__factory, HistoricalSPVGateway__factory } from "@ethers-v6";
44

55
import path from "path";
66
import { ethers } from "hardhat";
77
import { getHistoryProofFromFile, getHistoryProofPublicInputsFromFile } from "@/test/helpers";
88

99
import { getHistoricalConfig } from "../config/config";
1010
import { getGuardedSalt } from "../helpers/helpers";
11+
import { deployHistoryVerifier } from "./helpers";
1112

1213
export = async (deployer: Deployer) => {
1314
const config = await getHistoricalConfig();
1415

1516
const createXDeployer = await deployer.deployed(ICreateX__factory, "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed");
1617

17-
// zero address + 00 (cross-chain redeploy protection) + 0000 + ASCII(HPV914432)
18-
const historyVerifier914432Salt = `0x0000000000000000000000000000000000000000000000485056393134343332`;
19-
20-
await createXDeployer.deployCreate2(historyVerifier914432Salt, HistoryProofVerifier914432__factory.bytecode);
21-
22-
const historyVerifierAddress = await createXDeployer.computeCreate2Address(
23-
getGuardedSalt(historyVerifier914432Salt),
24-
ethers.keccak256(HistoryProofVerifier914432__factory.bytecode),
25-
);
18+
const historyVerifierAddress = await deployHistoryVerifier(deployer, config.proofBlocksCount);
2619

2720
const proofDirPath = path.join(__dirname, "./proofs", config.proofBlocksCount.toString());
2821

2922
const proof = getHistoryProofFromFile(proofDirPath);
3023
const publicInputs = getHistoryProofPublicInputsFromFile(proofDirPath);
3124

3225
const historicalSPVInitData = HistoricalSPVGateway__factory.createInterface().encodeFunctionData(
33-
"__HistoricalSPVGateway_init(bytes,uint64,uint256,bytes32,(address,bytes32[],bytes))",
26+
"__HistoricalSPVGateway_init(bytes,uint64,uint32,uint256,bytes32,(address,bytes32[],bytes))",
3427
[
3528
config.blockHeader,
3629
config.blockHeight,
30+
config.lastHistoryEpochStartTime,
3731
config.cumulativeWork,
3832
config.historyBlocksTreeRoot,
3933
{

deploy/historical/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./verifiers";
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { getGuardedSalt } from "@/deploy/helpers/helpers";
2+
import {
3+
ICreateX__factory,
4+
HistoryProofVerifier912384__factory,
5+
HistoryProofVerifier914432__factory,
6+
} from "@/generated-types/ethers";
7+
import { Deployer } from "@solarity/hardhat-migrate";
8+
import { ethers } from "hardhat";
9+
10+
export async function deployHistoryVerifier(deployer: Deployer, blocksCount: bigint): Promise<string> {
11+
const createXDeployer = await deployer.deployed(ICreateX__factory, "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed");
12+
13+
const verifierBytecode = getHistoryVerifierBytecode(blocksCount);
14+
const verifierSalt = getHistoryVerifierSalt(blocksCount);
15+
16+
const verifierAddress = await createXDeployer.computeCreate2Address(
17+
getGuardedSalt(verifierSalt),
18+
ethers.keccak256(verifierBytecode),
19+
);
20+
21+
if ((await ethers.provider.getCode(verifierAddress)) == "") {
22+
await createXDeployer.deployCreate2(verifierSalt, verifierBytecode);
23+
}
24+
25+
return verifierAddress;
26+
}
27+
28+
export function getHistoryVerifierBytecode(blocksCount: bigint): string {
29+
switch (blocksCount) {
30+
case 912384n:
31+
return HistoryProofVerifier912384__factory.bytecode;
32+
case 914432n:
33+
return HistoryProofVerifier914432__factory.bytecode;
34+
default:
35+
throw new Error("Unsupported blocks count!");
36+
}
37+
}
38+
39+
export function getHistoryVerifierSalt(blocksCount: bigint): string {
40+
const saltSuffix = ethers.hexlify(ethers.toUtf8Bytes(`HPV${blocksCount}`));
41+
42+
// zero address + 00 (cross-chain redeploy protection) + 0000 + ASCII(HPV + {blocksCount})
43+
return `${ethers.ZeroAddress}000000${saltSuffix.slice(2)}`;
44+
}

0 commit comments

Comments
 (0)