From 09a23b0e93d4382a078a129202e56cdbe4301b11 Mon Sep 17 00:00:00 2001 From: Mikolaj Jakobiak Date: Mon, 2 Sep 2024 15:31:14 +0100 Subject: [PATCH 1/4] added eth sepolia to world chain sepolia connection --- hardhat.config.ts | 4 ++ package.json | 3 +- script/Deploy_11155111_to_4801.sh | 30 +++++++++ script/Deploy_11155111_to_4801_part1.ts | 76 +++++++++++++++++++++ script/Deploy_11155111_to_4801_part2.ts | 87 +++++++++++++++++++++++++ script/Deploy_11155111_to_4801_part3.ts | 39 +++++++++++ 6 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 script/Deploy_11155111_to_4801.sh create mode 100644 script/Deploy_11155111_to_4801_part1.ts create mode 100644 script/Deploy_11155111_to_4801_part2.ts create mode 100644 script/Deploy_11155111_to_4801_part3.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index ddbdc39..d8299a0 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -78,6 +78,10 @@ const config: HardhatUserConfig = { url: process.env.ARBITRUM_SEPOLIA_RPC, accounts: [process.env.ARBITRUM_PRIVATE_KEY as string], }, + worldChainSepolia: { + url: process.env.WORLD_CHAIN_SEPOLIA_RPC, + accounts: [process.env.WORLD_CHAIN_PRIVATE_KEY as string], + }, }, }; export default config; diff --git a/package.json b/package.json index 9374485..ad42026 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "deploy:11155111_to_11155111": "npx hardhat run script/Deploy_11155111_to_11155111.ts --network sepolia", "deploy:11155111_to_11155420": "bash script/Deploy_11155111_to_11155420.sh", "deploy:11155111_to_421614": "bash script/Deploy_11155111_to_421614.sh", + "deploy:11155111_to_4801": "bash script/Deploy_11155111_to_4801.sh", "verify:11155111_to_300": "bash script/Verify_11155111_to_300.sh", "verify:11155111_to_11155111": "bash script/Verify_11155111_to_11155111.sh", "verify:11155111_to_11155420": "bash script/Verify_11155111_to_11155420.sh", @@ -41,4 +42,4 @@ "typescript": "^5.5.4", "zksync-ethers": "^6.11.2" } -} \ No newline at end of file +} diff --git a/script/Deploy_11155111_to_4801.sh b/script/Deploy_11155111_to_4801.sh new file mode 100644 index 0000000..f00f215 --- /dev/null +++ b/script/Deploy_11155111_to_4801.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +source .env +while IFS= read -r line; do + echo "$line" + + if [[ "$line" =~ ^Deployed\ OpMessagesInbox\ at:\ (0x[0-9A-Fa-f]+)$ ]]; then + DEPLOYED_L2_INBOX="${BASH_REMATCH[1]}" + fi +done < <(npx hardhat run script/Deploy_11155111_to_4801_part1.ts --network worldChainSepolia) + +if [ -z "$DEPLOYED_L2_INBOX" ]; then + echo "Didn't find deployment address of OpMessagesInbox" + exit 1 +fi + +while IFS= read -r line; do + echo "$line" + + if [[ "$line" =~ ^Deployed\ L1ToOptimismMessagesSender\ at:\ (0x[0-9A-Fa-f]+)$ ]]; then + DEPLOYED_L1_OUTBOX="${BASH_REMATCH[1]}" + fi +done < <(DEPLOYED_L2_INBOX=$DEPLOYED_L2_INBOX npx hardhat run script/Deploy_11155111_to_4801_part2.ts --network sepolia) + +if [ -z "$DEPLOYED_L1_OUTBOX" ]; then + echo "Didn't find deployment address of L1ToOptimismMessagesSender" + exit 1 +fi + +DEPLOYED_L2_INBOX=$DEPLOYED_L2_INBOX DEPLOYED_L1_OUTBOX=$DEPLOYED_L1_OUTBOX npx hardhat run script/Deploy_11155111_to_4801_part3.ts --network worldChainSepolia diff --git a/script/Deploy_11155111_to_4801_part1.ts b/script/Deploy_11155111_to_4801_part1.ts new file mode 100644 index 0000000..4fe901d --- /dev/null +++ b/script/Deploy_11155111_to_4801_part1.ts @@ -0,0 +1,76 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const PRIVATE_KEY = process.env.WORLD_CHAIN_PRIVATE_KEY || ""; +const CHAINID = process.env.L1_SEPOLIA_CHAINID || ""; + +if (!PRIVATE_KEY) { + throw new Error("WORLD_CHAIN_PRIVATE_KEY is not set in .env"); +} +if (!CHAINID) { + throw new Error("L1_SEPOLIA_CHAINID is not set in .env"); +} + +export async function main() { + // deploy OpMessagesInbox + const OpMessagesInbox = + await hre.ethers.getContractFactory("OpMessagesInbox"); + const opMessagesInbox = await OpMessagesInbox.deploy(); + const opMessagesInboxAddr = await opMessagesInbox.getAddress(); + await opMessagesInbox.waitForDeployment(); + console.log("Deployed OpMessagesInbox at:", opMessagesInboxAddr); + + // deploy HeaderStore + const HeadersStore = await hre.ethers.getContractFactory("HeadersStore"); + const headersStore = await HeadersStore.deploy(opMessagesInboxAddr); + const headersStoreAddr = await headersStore.getAddress(); + await headersStore.waitForDeployment(); + console.log("Deployed HeadersStore at:", headersStoreAddr); + + // deploy FactsRegistry + const FactsRegistry = await hre.ethers.getContractFactory("FactsRegistry"); + const factsRegistry = await FactsRegistry.deploy(headersStoreAddr); + const factsRegistryAddr = await factsRegistry.getAddress(); + await factsRegistry.waitForDeployment(); + console.log("Deployed FactsRegistry at:", factsRegistryAddr); + + // set OpMessagesInbox variables + await opMessagesInbox.setHeadersStore(headersStoreAddr); + await opMessagesInbox.setMessagesOriginChainId(CHAINID); + // setCrossDomainMsgSender will be called at step 3 + + // verify OpMessagesInbox + await hre.run("verify:verify", { + address: opMessagesInboxAddr, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddr, + constructorArguments: [opMessagesInboxAddr], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddr, + constructorArguments: [headersStoreAddr], + force: true, + }); + + console.log( + "===============================================================", + ); + console.log("HeadersStore:", headersStoreAddr); + console.log("FactsRegistry:", factsRegistryAddr); + console.log("OpMessagesInbox:", opMessagesInboxAddr); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Deploy_11155111_to_4801_part2.ts b/script/Deploy_11155111_to_4801_part2.ts new file mode 100644 index 0000000..e18b4af --- /dev/null +++ b/script/Deploy_11155111_to_4801_part2.ts @@ -0,0 +1,87 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const aggregatorsFactory = process.env.L1_SEPOLIA_AGGREGATORS_FACTORY || ""; +const l2Target = process.env.DEPLOYED_L2_INBOX || ""; +const crossDomainMsgSender = + process.env.WORLD_CHAIN_SEPOLIA_CROSS_DOMAIN_MESSENGER || ""; + +if (!aggregatorsFactory) { + throw new Error("L1_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} +if (!l2Target) { + throw new Error("DEPLOYED_L2_INBOX is not set in .env"); +} +if (!crossDomainMsgSender) { + throw new Error( + "WORLD_CHAIN_SEPOLIA_CROSS_DOMAIN_MESSENGER is not set in .env", + ); +} + +export async function main() { + // deploy NativeParentHashesFetcher + const NativeParentHashesFetcher = await hre.ethers.getContractFactory( + "NativeParentHashesFetcher", + ); + const nativeParentHashesFetcher = await NativeParentHashesFetcher.deploy(); + const nativeParentHashesFetcherAddress = + await nativeParentHashesFetcher.getAddress(); + await nativeParentHashesFetcher.waitForDeployment(); + console.log( + "Deployed NativeParentHashesFetcher at:", + nativeParentHashesFetcherAddress, + ); + + // deploy L1ToOptimismMessagesSender + const L1ToOptimismMessagesSender = await hre.ethers.getContractFactory( + "L1ToOptimismMessagesSender", + ); + const l1ToOptimismMessagesSender = await L1ToOptimismMessagesSender.deploy( + aggregatorsFactory, + nativeParentHashesFetcherAddress, + l2Target, + crossDomainMsgSender, + ); + const l1ToOptimismMessagesSenderAddress = + await l1ToOptimismMessagesSender.getAddress(); + await l1ToOptimismMessagesSender.waitForDeployment(); + console.log( + "Deployed L1ToOptimismMessagesSender at:", + l1ToOptimismMessagesSenderAddress, + ); + + // verify NativeParentHashesFetcher + await hre.run("verify:verify", { + address: nativeParentHashesFetcherAddress, + constructorArguments: [], + force: true, + }); + + // verify L1ToOptimismMessagesSender + await hre.run("verify:verify", { + address: l1ToOptimismMessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + nativeParentHashesFetcherAddress, + l2Target, + crossDomainMsgSender, + ], + force: true, + }); + + console.log( + "===============================================================", + ); + console.log("NativeParentHashesFetcher:", nativeParentHashesFetcherAddress); + console.log( + "L1ToOptimismMessagesSenderAddress:", + l1ToOptimismMessagesSenderAddress, + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Deploy_11155111_to_4801_part3.ts b/script/Deploy_11155111_to_4801_part3.ts new file mode 100644 index 0000000..8eb3843 --- /dev/null +++ b/script/Deploy_11155111_to_4801_part3.ts @@ -0,0 +1,39 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const PRIVATE_KEY = process.env.WORLD_CHAIN_PRIVATE_KEY || ""; +const opMessagesInboxAddress = process.env.DEPLOYED_L2_INBOX || ""; +const crossDomainMsgSenderAddress = process.env.DEPLOYED_L1_OUTBOX || ""; + +if (!PRIVATE_KEY) { + throw new Error("WORLD_CHAIN_PRIVATE_KEY is not set in .env"); +} +if (!opMessagesInboxAddress) { + throw new Error("DEPLOYED_L2_INBOX is not set in .env"); +} +if (!crossDomainMsgSenderAddress) { + throw new Error("DEPLOYED_L1_OUTBOX is not set in .env"); +} + +export async function main() { + // Call setCrossDomainMsgSender on OpMessagesInbox + const opMessagesInbox = await hre.ethers.getContractAt( + "OpMessagesInbox", + opMessagesInboxAddress, + ); + const tx = await opMessagesInbox.setCrossDomainMsgSender( + crossDomainMsgSenderAddress, + ); + await tx.wait(); + + console.log( + `crossDomainMsgSender of OpMessagesInbox(${opMessagesInboxAddress}) has been set to ${crossDomainMsgSenderAddress}`, + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); From 2b36fb7180df68ecbc4785828c327278d58e9423 Mon Sep 17 00:00:00 2001 From: Mikolaj Jakobiak Date: Thu, 5 Sep 2024 15:49:20 +0100 Subject: [PATCH 2/4] added verification script for 11155111->4801 and deployment script for 4801->4801 --- hardhat.config.ts | 10 ++ package.json | 5 +- script/Deploy_4801_to_4801.ts | 133 ++++++++++++++++++++++++ script/Verify_11155111_to_4801.sh | 28 +++++ script/Verify_11155111_to_4801_part1.ts | 46 ++++++++ script/Verify_11155111_to_4801_part2.ts | 55 ++++++++++ script/Verify_4801_to_4801.sh | 25 +++++ script/Verify_4801_to_4801.ts | 78 ++++++++++++++ 8 files changed, 379 insertions(+), 1 deletion(-) create mode 100644 script/Deploy_4801_to_4801.ts create mode 100644 script/Verify_11155111_to_4801.sh create mode 100644 script/Verify_11155111_to_4801_part1.ts create mode 100644 script/Verify_11155111_to_4801_part2.ts create mode 100644 script/Verify_4801_to_4801.sh create mode 100644 script/Verify_4801_to_4801.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index d8299a0..c6e689c 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -35,6 +35,7 @@ const config: HardhatUserConfig = { zkSyncSepolia: process.env.ZKSYNC_ETHERSCAN_API_KEY as string, optimismSepolia: process.env.OPTIMISM_ETHERSCAN_API_KEY as string, arbitrumSepolia: process.env.ARBITRUM_ETHERSCAN_API_KEY as string, + worldChainSepolia: process.env.WORLD_CHAIN_ETHERSCAN_API_KEY as string, }, customChains: [ { @@ -55,6 +56,15 @@ const config: HardhatUserConfig = { .ARBITRUM_SEPOLIA_ETHERSCAN_BROWSER_URL as string, }, }, + { + network: "worldChainSepolia", + chainId: parseInt(process.env.WORLD_CHAIN_SEPOLIA_CHAINID as string), + urls: { + apiURL: process.env.WORLD_CHAIN_SEPOLIA_ETHERSCAN_API_URL as string, + browserURL: process.env + .WORLD_CHAIN_SEPOLIA_ETHERSCAN_BROWSER_URL as string, + }, + }, ], }, defaultNetwork: "zkSyncSepolia", diff --git a/package.json b/package.json index ad42026..8428494 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,13 @@ "deploy:11155111_to_11155420": "bash script/Deploy_11155111_to_11155420.sh", "deploy:11155111_to_421614": "bash script/Deploy_11155111_to_421614.sh", "deploy:11155111_to_4801": "bash script/Deploy_11155111_to_4801.sh", + "deploy:4801_to_4801": "npx hardhat run script/Deploy_4801_to_4801.ts --network worldChainSepolia", "verify:11155111_to_300": "bash script/Verify_11155111_to_300.sh", "verify:11155111_to_11155111": "bash script/Verify_11155111_to_11155111.sh", "verify:11155111_to_11155420": "bash script/Verify_11155111_to_11155420.sh", - "verify:11155111_to_421614": "bash script/Verify_11155111_to_421614.sh" + "verify:11155111_to_421614": "bash script/Verify_11155111_to_421614.sh", + "verify:11155111_to_4801": "bash script/Verify_11155111_to_4801.sh", + "verify:4801_to_4801": "bash script/Verify_4801_to_4801.sh" }, "dependencies": { "@accumulators/hashers": "^4.2.3", diff --git a/script/Deploy_4801_to_4801.ts b/script/Deploy_4801_to_4801.ts new file mode 100644 index 0000000..0f8bf2e --- /dev/null +++ b/script/Deploy_4801_to_4801.ts @@ -0,0 +1,133 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const chainId = process.env.WORLD_CHAIN_SEPOLIA_CHAINID || ""; +const aggregatorsFactory = + process.env.WORLD_CHAIN_SEPOLIA_AGGREGATORS_FACTORY || ""; + +if (!chainId) { + throw new Error("WORLD_CHAIN_SEPOLIA_CHAINID is not set in .env"); +} +if (!aggregatorsFactory) { + throw new Error("WORLD_CHAIN_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} + +export async function main() { + // deploy SimpleMessagesInbox + const SimpleMessagesInbox = await hre.ethers.getContractFactory( + "SimpleMessagesInbox", + ); + const simpleMessagesInbox = await SimpleMessagesInbox.deploy(); + const simpleMessagesInboxAddress = await simpleMessagesInbox.getAddress(); + await simpleMessagesInbox.waitForDeployment(); + console.log("Deployed SimpleMessagesInbox at:", simpleMessagesInboxAddress); + + // deploy HeaderStore + const HeadersStore = await hre.ethers.getContractFactory("HeadersStore"); + const headersStore = await HeadersStore.deploy(simpleMessagesInboxAddress); + const headersStoreAddress = await headersStore.getAddress(); + await headersStore.waitForDeployment(); + console.log("Deployed HeadersStore at:", headersStoreAddress); + + // deploy FactsRegistry + const FactsRegistry = await hre.ethers.getContractFactory("FactsRegistry"); + const factsRegistry = await FactsRegistry.deploy(headersStoreAddress); + const factsRegistryAddress = await factsRegistry.getAddress(); + await factsRegistry.waitForDeployment(); + console.log("Deployed FactsRegistry at:", factsRegistryAddress); + + // set SimpleMessagesInbox variables + await simpleMessagesInbox.setHeadersStore(headersStoreAddress); + await simpleMessagesInbox.setMessagesOriginChainId(chainId); + // setCrossDomainMsgSender will be called at after L1ToL1MessagesSender deployment + + // deploy NativeParentHashesFetcher + const NativeParentHashesFetcher = await hre.ethers.getContractFactory( + "NativeParentHashesFetcher", + ); + const nativeParentHashesFetcher = await NativeParentHashesFetcher.deploy(); + const nativeParentHashesFetcherAddress = + await nativeParentHashesFetcher.getAddress(); + await nativeParentHashesFetcher.waitForDeployment(); + console.log( + "Deployed NativeParentHashesFetcher at:", + nativeParentHashesFetcherAddress, + ); + + // deploy L1ToL1MessagesSender + const L1ToL1MessagesSender = await hre.ethers.getContractFactory( + "L1ToL1MessagesSender", + ); + const l1ToL1MessagesSender = await L1ToL1MessagesSender.deploy( + aggregatorsFactory, + nativeParentHashesFetcherAddress, + simpleMessagesInboxAddress, + ); + const l1ToL1MessagesSenderAddress = await l1ToL1MessagesSender.getAddress(); + await l1ToL1MessagesSender.waitForDeployment(); + console.log("Deployed L1ToL1MessagesSender at:", l1ToL1MessagesSenderAddress); + + // set crossDomainMsgSender of SimpleMessagesInbox + const tx = await simpleMessagesInbox.setCrossDomainMsgSender( + l1ToL1MessagesSenderAddress, + ); + await tx.wait(); + console.log( + `crossDomainMsgSender of SimpleMessagesInbox(${simpleMessagesInboxAddress}) has been set to ${l1ToL1MessagesSenderAddress}`, + ); + + // verify SimpleMessagesInbox + await hre.run("verify:verify", { + address: simpleMessagesInboxAddress, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddress, + constructorArguments: [simpleMessagesInboxAddress], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddress, + constructorArguments: [headersStoreAddress], + force: true, + }); + + // verify NativeParentHashesFetcher + await hre.run("verify:verify", { + address: nativeParentHashesFetcherAddress, + constructorArguments: [], + force: true, + }); + + // verify L1ToL1MessagesSender + await hre.run("verify:verify", { + address: l1ToL1MessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + nativeParentHashesFetcherAddress, + simpleMessagesInboxAddress, + ], + force: true, + }); + + console.log( + "===============================================================", + ); + console.log("HeadersStore:", headersStoreAddress); + console.log("FactsRegistry:", factsRegistryAddress); + console.log("SimpleMessagesInbox:", simpleMessagesInboxAddress); + console.log("NativeParentHashesFetcher:", nativeParentHashesFetcherAddress); + console.log("L1ToL1MessagesSender:", l1ToL1MessagesSenderAddress); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Verify_11155111_to_4801.sh b/script/Verify_11155111_to_4801.sh new file mode 100644 index 0000000..cc05721 --- /dev/null +++ b/script/Verify_11155111_to_4801.sh @@ -0,0 +1,28 @@ +source .env + +echo -e "Please enter contract addresses for the following contracts:\n" + +echo -n "HeadersStore: " +read HEADERS_STORE + +echo -n "FactsRegistry: " +read FACTS_REGISTRY + +echo -n "OpMessagesInbox: " +read OP_MESSAGES_INBOX + +echo -n "NativeParentHashesFetcher: " +read NATIVE_PARENT_HASHES_FETCHER + +echo -n "L1ToOptimismMessagesSender: " +read L1_TO_OPTIMISM_MESSAGES_SENDER + +HEADERS_STORE=$HEADERS_STORE \ + FACTS_REGISTRY=$FACTS_REGISTRY \ + OP_MESSAGES_INBOX=$OP_MESSAGES_INBOX \ + npx hardhat run script/Verify_11155111_to_4801_part1.ts --network worldChainSepolia + +OP_MESSAGES_INBOX=$OP_MESSAGES_INBOX \ + NATIVE_PARENT_HASHES_FETCHER=$NATIVE_PARENT_HASHES_FETCHER \ + L1_TO_OPTIMISM_MESSAGES_SENDER=$L1_TO_OPTIMISM_MESSAGES_SENDER \ + npx hardhat run script/Verify_11155111_to_4801_part2.ts --network sepolia diff --git a/script/Verify_11155111_to_4801_part1.ts b/script/Verify_11155111_to_4801_part1.ts new file mode 100644 index 0000000..6f22456 --- /dev/null +++ b/script/Verify_11155111_to_4801_part1.ts @@ -0,0 +1,46 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const opMessagesInboxAddr = process.env.OP_MESSAGES_INBOX || ""; +const headersStoreAddr = process.env.HEADERS_STORE || ""; +const factsRegistryAddr = process.env.FACTS_REGISTRY || ""; + +if (!opMessagesInboxAddr) { + throw new Error("OP_MESSAGES_INBOX is not set"); +} +if (!headersStoreAddr) { + throw new Error("HEADERS_STORE is not set"); +} +if (!factsRegistryAddr) { + throw new Error("FACTS_REGISTRY is not set"); +} + +export async function main() { + // verify OpMessagesInbox + await hre.run("verify:verify", { + address: opMessagesInboxAddr, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddr, + constructorArguments: [opMessagesInboxAddr], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddr, + constructorArguments: [headersStoreAddr], + force: true, + }); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Verify_11155111_to_4801_part2.ts b/script/Verify_11155111_to_4801_part2.ts new file mode 100644 index 0000000..14995d2 --- /dev/null +++ b/script/Verify_11155111_to_4801_part2.ts @@ -0,0 +1,55 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const aggregatorsFactory = process.env.L1_SEPOLIA_AGGREGATORS_FACTORY || ""; +const l2Target = process.env.OP_MESSAGES_INBOX || ""; +const crossDomainMsgSender = + process.env.OPTIMISM_SEPOLIA_CROSS_DOMAIN_MESSENGER || ""; +const nativeParentHashesFetcherAddress = + process.env.NATIVE_PARENT_HASHES_FETCHER || ""; +const l1ToOptimismMessagesSenderAddress = + process.env.L1_TO_OPTIMISM_MESSAGES_SENDER || ""; + +if (!aggregatorsFactory) { + throw new Error("L1_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} +if (!crossDomainMsgSender) { + throw new Error("OPTIMISM_SEPOLIA_CROSS_DOMAIN_MESSENGER is not set in .env"); +} +if (!l2Target) { + throw new Error("OP_MESSAGES_INBOX is not set in .env"); +} +if (!nativeParentHashesFetcherAddress) { + throw new Error("NATIVE_PARENT_HASHES_FETCHER is not set"); +} +if (!l1ToOptimismMessagesSenderAddress) { + throw new Error("L1_TO_OPTIMISM_MESSAGES_SENDER is not set"); +} + +export async function main() { + // verify NativeParentHashesFetcher + await hre.run("verify:verify", { + address: nativeParentHashesFetcherAddress, + constructorArguments: [], + force: true, + }); + + // verify L1ToOptimismMessagesSender + await hre.run("verify:verify", { + address: l1ToOptimismMessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + nativeParentHashesFetcherAddress, + l2Target, + crossDomainMsgSender, + ], + force: true, + }); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Verify_4801_to_4801.sh b/script/Verify_4801_to_4801.sh new file mode 100644 index 0000000..4f08c23 --- /dev/null +++ b/script/Verify_4801_to_4801.sh @@ -0,0 +1,25 @@ +source .env + +echo -e "Please enter contract addresses for the following contracts:\n" + +echo -n "HeadersStore: " +read HEADERS_STORE + +echo -n "FactsRegistry: " +read FACTS_REGISTRY + +echo -n "SimpleMessagesInbox: " +read SIMPLE_MESSAGES_INBOX + +echo -n "NativeParentHashesFetcher: " +read NATIVE_PARENT_HASHES_FETCHER + +echo -n "L1ToL1MessagesSender: " +read L1_TO_L1_MESSAGES_SENDER + +HEADERS_STORE=$HEADERS_STORE \ + FACTS_REGISTRY=$FACTS_REGISTRY \ + SIMPLE_MESSAGES_INBOX=$SIMPLE_MESSAGES_INBOX \ + NATIVE_PARENT_HASHES_FETCHER=$NATIVE_PARENT_HASHES_FETCHER \ + L1_TO_L1_MESSAGES_SENDER=$L1_TO_L1_MESSAGES_SENDER \ + npx hardhat run script/Verify_4801_to_4801.ts --network worldChainSepolia diff --git a/script/Verify_4801_to_4801.ts b/script/Verify_4801_to_4801.ts new file mode 100644 index 0000000..0bec28d --- /dev/null +++ b/script/Verify_4801_to_4801.ts @@ -0,0 +1,78 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const aggregatorsFactory = + process.env.WORLD_CHAIN_SEPOLIA_AGGREGATORS_FACTORY || ""; +const simpleMessagesInboxAddress = process.env.SIMPLE_MESSAGES_INBOX || ""; +const headersStoreAddress = process.env.HEADERS_STORE || ""; +const factsRegistryAddress = process.env.FACTS_REGISTRY || ""; +const nativeParentHashesFetcherAddress = + process.env.NATIVE_PARENT_HASHES_FETCHER || ""; +const l1ToL1MessagesSenderAddress = process.env.L1_TO_L1_MESSAGES_SENDER || ""; + +if (!aggregatorsFactory) { + throw new Error("WORLD_CHAIN_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} +if (!simpleMessagesInboxAddress) { + throw new Error("SIMPLE_MESSAGES_INBOX is not set"); +} +if (!headersStoreAddress) { + throw new Error("HEADERS_STORE is not set"); +} +if (!factsRegistryAddress) { + throw new Error("FACTS_REGISTRY is not set"); +} +if (!nativeParentHashesFetcherAddress) { + throw new Error("NATIVE_PARENT_HASHES_FETCHER is not set"); +} +if (!l1ToL1MessagesSenderAddress) { + throw new Error("L1_TO_L1_MESSAGES_SENDER is not set"); +} + +export async function main() { + // verify SimpleMessagesInbox + await hre.run("verify:verify", { + address: simpleMessagesInboxAddress, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddress, + constructorArguments: [simpleMessagesInboxAddress], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddress, + constructorArguments: [headersStoreAddress], + force: true, + }); + + // verify NativeParentHashesFetcher + await hre.run("verify:verify", { + address: nativeParentHashesFetcherAddress, + constructorArguments: [], + force: true, + }); + + // verify L1ToL1MessagesSender + await hre.run("verify:verify", { + address: l1ToL1MessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + nativeParentHashesFetcherAddress, + simpleMessagesInboxAddress, + ], + force: true, + }); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); From 6c77a5d065bfaf7857c579e785afb9f571164d6e Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Thu, 12 Sep 2024 15:29:34 +0200 Subject: [PATCH 3/4] 4801 to 11155111 --- .env.example | 9 ++ package.json | 7 +- script/Deploy_4801_to_11155111.ts | 143 ++++++++++++++++++++++++++++++ script/Verify_4801_to_11155111.sh | 25 ++++++ script/Verify_4801_to_11155111.ts | 85 ++++++++++++++++++ 5 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 script/Deploy_4801_to_11155111.ts create mode 100644 script/Verify_4801_to_11155111.sh create mode 100644 script/Verify_4801_to_11155111.ts diff --git a/.env.example b/.env.example index 9d26125..0bd206b 100644 --- a/.env.example +++ b/.env.example @@ -48,6 +48,15 @@ ARBITRUM_SEPOLIA_ETHERSCAN_API_URL=https://api-sepolia.arbiscan.io/api ARBITRUM_SEPOLIA_ETHERSCAN_BROWSER_URL=https://sepolia.arbiscan.io/ ARBITRUM_SEPOLIA_INBOX=0xaAe29B0366299461418F5324a79Afc425BE5ae21 +# WORLD CHAIN + +WORLD_CHAIN_PRIVATE_KEY= + +# sepolia +WORLD_CHAIN_SEPOLIA_RPC= +WORLD_CHAIN_SEPOLIA_CHAINID=4801 +WORLD_CHAIN_SEPOLIA_L2_OUTPUT_ORACLE=0xc8886f8BAb6Eaeb215aDB5f1c686BF699248300e + # STARKNET STARKNET_SEPOLIA_CORE_ADDRESS=0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057 diff --git a/package.json b/package.json index 8428494..14fd2e1 100644 --- a/package.json +++ b/package.json @@ -6,18 +6,21 @@ "license": "GPL-3.0", "scripts": { "preinstall": "npx only-allow pnpm", + "compile": "npx hardhat compile", "deploy:11155111_to_300": "bash script/Deploy_11155111_to_300.sh", "deploy:11155111_to_11155111": "npx hardhat run script/Deploy_11155111_to_11155111.ts --network sepolia", "deploy:11155111_to_11155420": "bash script/Deploy_11155111_to_11155420.sh", "deploy:11155111_to_421614": "bash script/Deploy_11155111_to_421614.sh", "deploy:11155111_to_4801": "bash script/Deploy_11155111_to_4801.sh", "deploy:4801_to_4801": "npx hardhat run script/Deploy_4801_to_4801.ts --network worldChainSepolia", + "deploy:4801_to_11155111": "npx hardhat run script/Deploy_4801_to_11155111.ts --network sepolia", "verify:11155111_to_300": "bash script/Verify_11155111_to_300.sh", "verify:11155111_to_11155111": "bash script/Verify_11155111_to_11155111.sh", "verify:11155111_to_11155420": "bash script/Verify_11155111_to_11155420.sh", "verify:11155111_to_421614": "bash script/Verify_11155111_to_421614.sh", "verify:11155111_to_4801": "bash script/Verify_11155111_to_4801.sh", - "verify:4801_to_4801": "bash script/Verify_4801_to_4801.sh" + "verify:4801_to_4801": "bash script/Verify_4801_to_4801.sh", + "verify:4801_to_11155111": "bash script/Verify_4801_to_11155111.sh" }, "dependencies": { "@accumulators/hashers": "^4.2.3", @@ -45,4 +48,4 @@ "typescript": "^5.5.4", "zksync-ethers": "^6.11.2" } -} +} \ No newline at end of file diff --git a/script/Deploy_4801_to_11155111.ts b/script/Deploy_4801_to_11155111.ts new file mode 100644 index 0000000..040f894 --- /dev/null +++ b/script/Deploy_4801_to_11155111.ts @@ -0,0 +1,143 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const l2OutputOracle = process.env.WORLD_CHAIN_SEPOLIA_L2_OUTPUT_ORACLE || ""; +const messagesOriginChainId = process.env.L1_SEPOLIA_CHAINID || ""; +const fetchingChainId = process.env.WORLD_CHAIN_SEPOLIA_CHAINID || ""; +const aggregatorsFactory = process.env.L1_SEPOLIA_AGGREGATORS_FACTORY || ""; + +if (!l2OutputOracle) { + throw new Error("WORLD_CHAIN_SEPOLIA_L2_OUTPUT_ORACLE is not set in .env"); +} +if (!messagesOriginChainId) { + throw new Error("L1_SEPOLIA_CHAINID is not set in .env"); +} +if (!fetchingChainId) { + throw new Error("WORLD_CHAIN_SEPOLIA_CHAINID is not set in .env"); +} +if (!aggregatorsFactory) { + throw new Error("L1_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} + +export async function main() { + // deploy SimpleMessagesInbox + const SimpleMessagesInbox = await hre.ethers.getContractFactory( + "SimpleMessagesInbox", + ); + const simpleMessagesInbox = await SimpleMessagesInbox.deploy(); + const simpleMessagesInboxAddress = await simpleMessagesInbox.getAddress(); + await simpleMessagesInbox.waitForDeployment(); + console.log("Deployed SimpleMessagesInbox at:", simpleMessagesInboxAddress); + + // deploy HeaderStore + const HeadersStore = await hre.ethers.getContractFactory("HeadersStore"); + const headersStore = await HeadersStore.deploy(simpleMessagesInboxAddress); + const headersStoreAddress = await headersStore.getAddress(); + await headersStore.waitForDeployment(); + console.log("Deployed HeadersStore at:", headersStoreAddress); + + // deploy FactsRegistry + const FactsRegistry = await hre.ethers.getContractFactory("FactsRegistry"); + const factsRegistry = await FactsRegistry.deploy(headersStoreAddress); + const factsRegistryAddress = await factsRegistry.getAddress(); + await factsRegistry.waitForDeployment(); + console.log("Deployed FactsRegistry at:", factsRegistryAddress); + + // set SimpleMessagesInbox variables + await simpleMessagesInbox.setHeadersStore(headersStoreAddress); + await simpleMessagesInbox.setMessagesOriginChainId(messagesOriginChainId); + // setCrossDomainMsgSender will be called at after L1ToL1MessagesSender deployment + + // deploy OpStackParentHashesFetcher + const OpStackParentHashesFetcher = await hre.ethers.getContractFactory( + "OpStackParentHashesFetcher", + ); + const opStackParentHashesFetcher = await OpStackParentHashesFetcher.deploy( + l2OutputOracle, + fetchingChainId, + ); + const opStackParentHashesFetcherAddress = + await opStackParentHashesFetcher.getAddress(); + await opStackParentHashesFetcher.waitForDeployment(); + console.log( + "Deployed OpStackParentHashesFetcher at:", + opStackParentHashesFetcherAddress, + ); + + // deploy L1ToL1MessagesSender + const L1ToL1MessagesSender = await hre.ethers.getContractFactory( + "L1ToL1MessagesSender", + ); + const l1ToL1MessagesSender = await L1ToL1MessagesSender.deploy( + aggregatorsFactory, + opStackParentHashesFetcherAddress, + simpleMessagesInboxAddress, + ); + const l1ToL1MessagesSenderAddress = await l1ToL1MessagesSender.getAddress(); + await l1ToL1MessagesSender.waitForDeployment(); + console.log("Deployed L1ToL1MessagesSender at:", l1ToL1MessagesSenderAddress); + + // set crossDomainMsgSender of SimpleMessagesInbox + const tx = await simpleMessagesInbox.setCrossDomainMsgSender( + l1ToL1MessagesSenderAddress, + ); + await tx.wait(); + console.log( + `crossDomainMsgSender of SimpleMessagesInbox(${simpleMessagesInboxAddress}) has been set to ${l1ToL1MessagesSenderAddress}`, + ); + + // verify SimpleMessagesInbox + await hre.run("verify:verify", { + address: simpleMessagesInboxAddress, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddress, + constructorArguments: [simpleMessagesInboxAddress], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddress, + constructorArguments: [headersStoreAddress], + force: true, + }); + + // verify OpStackParentHashesFetcher + await hre.run("verify:verify", { + address: opStackParentHashesFetcherAddress, + constructorArguments: [l2OutputOracle, fetchingChainId], + force: true, + }); + + // verify L1ToL1MessagesSender + await hre.run("verify:verify", { + address: l1ToL1MessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + opStackParentHashesFetcherAddress, + simpleMessagesInboxAddress, + ], + force: true, + }); + + console.log( + "===============================================================", + ); + console.log("HeadersStore:", headersStoreAddress); + console.log("FactsRegistry:", factsRegistryAddress); + console.log("SimpleMessagesInbox:", simpleMessagesInboxAddress); + console.log("OpStackParentHashesFetcher:", opStackParentHashesFetcherAddress); + console.log("L1ToL1MessagesSender:", l1ToL1MessagesSenderAddress); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Verify_4801_to_11155111.sh b/script/Verify_4801_to_11155111.sh new file mode 100644 index 0000000..fb92b25 --- /dev/null +++ b/script/Verify_4801_to_11155111.sh @@ -0,0 +1,25 @@ +source .env + +echo -e "Please enter contract addresses for the following contracts:\n" + +echo -n "HeadersStore: " +read HEADERS_STORE + +echo -n "FactsRegistry: " +read FACTS_REGISTRY + +echo -n "SimpleMessagesInbox: " +read SIMPLE_MESSAGES_INBOX + +echo -n "OpStackParentHashesFetcher: " +read OP_STACK_PARENT_HASHES_FETCHER + +echo -n "L1ToL1MessagesSender: " +read L1_TO_L1_MESSAGES_SENDER + +HEADERS_STORE=$HEADERS_STORE \ + FACTS_REGISTRY=$FACTS_REGISTRY \ + SIMPLE_MESSAGES_INBOX=$SIMPLE_MESSAGES_INBOX \ + OP_STACK_PARENT_HASHES_FETCHER=$OP_STACK_PARENT_HASHES_FETCHER \ + L1_TO_L1_MESSAGES_SENDER=$L1_TO_L1_MESSAGES_SENDER \ + npx hardhat run script/Verify_4801_to_11155111.ts --network sepolia diff --git a/script/Verify_4801_to_11155111.ts b/script/Verify_4801_to_11155111.ts new file mode 100644 index 0000000..d4bf2da --- /dev/null +++ b/script/Verify_4801_to_11155111.ts @@ -0,0 +1,85 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const aggregatorsFactory = process.env.L1_SEPOLIA_AGGREGATORS_FACTORY || ""; +const simpleMessagesInboxAddress = process.env.SIMPLE_MESSAGES_INBOX || ""; +const headersStoreAddress = process.env.HEADERS_STORE || ""; +const factsRegistryAddress = process.env.FACTS_REGISTRY || ""; +const opStackParentHashesFetcherAddress = + process.env.OP_STACK_PARENT_HASHES_FETCHER || ""; +const l1ToL1MessagesSenderAddress = process.env.L1_TO_L1_MESSAGES_SENDER || ""; +const l2OutputOracle = process.env.WORLD_CHAIN_SEPOLIA_L2_OUTPUT_ORACLE || ""; +const fetchingChainId = process.env.WORLD_CHAIN_SEPOLIA_CHAINID || ""; + +if (!l2OutputOracle) { + throw new Error("WORLD_CHAIN_SEPOLIA_L2_OUTPUT_ORACLE is not set in .env"); +} +if (!fetchingChainId) { + throw new Error("WORLD_CHAIN_SEPOLIA_CHAINID is not set in .env"); +} +if (!aggregatorsFactory) { + throw new Error("L1_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} +if (!simpleMessagesInboxAddress) { + throw new Error("SIMPLE_MESSAGES_INBOX is not set"); +} +if (!headersStoreAddress) { + throw new Error("HEADERS_STORE is not set"); +} +if (!factsRegistryAddress) { + throw new Error("FACTS_REGISTRY is not set"); +} +if (!opStackParentHashesFetcherAddress) { + throw new Error("OP_STACK_PARENT_HASHES_FETCHER is not set"); +} +if (!l1ToL1MessagesSenderAddress) { + throw new Error("L1_TO_L1_MESSAGES_SENDER is not set"); +} + +export async function main() { + // verify SimpleMessagesInbox + await hre.run("verify:verify", { + address: simpleMessagesInboxAddress, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddress, + constructorArguments: [simpleMessagesInboxAddress], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddress, + constructorArguments: [headersStoreAddress], + force: true, + }); + + // verify OpStackParentHashesFetcher + await hre.run("verify:verify", { + address: opStackParentHashesFetcherAddress, + constructorArguments: [l2OutputOracle, fetchingChainId], + force: true, + }); + + // verify L1ToL1MessagesSender + await hre.run("verify:verify", { + address: l1ToL1MessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + opStackParentHashesFetcherAddress, + simpleMessagesInboxAddress, + ], + force: true, + }); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); From 44f0744d0d067f2f36306ae9bedbfe15f8210fa6 Mon Sep 17 00:00:00 2001 From: Mikolaj Jakobiak Date: Thu, 19 Sep 2024 16:14:56 +0100 Subject: [PATCH 4/4] base sepolia to world chain sepolia deploy --- hardhat.config.ts | 21 +++--- package.json | 3 +- script/Deploy_84532_to_4801.sh | 30 +++++++++ script/Deploy_84532_to_4801_part1.ts | 76 +++++++++++++++++++++ script/Deploy_84532_to_4801_part2.ts | 98 ++++++++++++++++++++++++++++ script/Deploy_84532_to_4801_part3.ts | 39 +++++++++++ 6 files changed, 256 insertions(+), 11 deletions(-) create mode 100644 script/Deploy_84532_to_4801.sh create mode 100644 script/Deploy_84532_to_4801_part1.ts create mode 100644 script/Deploy_84532_to_4801_part2.ts create mode 100644 script/Deploy_84532_to_4801_part3.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index c6e689c..445f998 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -35,7 +35,7 @@ const config: HardhatUserConfig = { zkSyncSepolia: process.env.ZKSYNC_ETHERSCAN_API_KEY as string, optimismSepolia: process.env.OPTIMISM_ETHERSCAN_API_KEY as string, arbitrumSepolia: process.env.ARBITRUM_ETHERSCAN_API_KEY as string, - worldChainSepolia: process.env.WORLD_CHAIN_ETHERSCAN_API_KEY as string, + // worldChainSepolia: process.env.WORLD_CHAIN_ETHERSCAN_API_KEY as string, }, customChains: [ { @@ -56,15 +56,16 @@ const config: HardhatUserConfig = { .ARBITRUM_SEPOLIA_ETHERSCAN_BROWSER_URL as string, }, }, - { - network: "worldChainSepolia", - chainId: parseInt(process.env.WORLD_CHAIN_SEPOLIA_CHAINID as string), - urls: { - apiURL: process.env.WORLD_CHAIN_SEPOLIA_ETHERSCAN_API_URL as string, - browserURL: process.env - .WORLD_CHAIN_SEPOLIA_ETHERSCAN_BROWSER_URL as string, - }, - }, + //? Verifying Probably does not work on World Chain yet + // { + // network: "worldChainSepolia", + // chainId: parseInt(process.env.WORLD_CHAIN_SEPOLIA_CHAINID as string), + // urls: { + // apiURL: process.env.WORLD_CHAIN_SEPOLIA_ETHERSCAN_API_URL as string, + // browserURL: process.env + // .WORLD_CHAIN_SEPOLIA_ETHERSCAN_BROWSER_URL as string, + // }, + // }, ], }, defaultNetwork: "zkSyncSepolia", diff --git a/package.json b/package.json index 14fd2e1..8a24fd0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "deploy:11155111_to_4801": "bash script/Deploy_11155111_to_4801.sh", "deploy:4801_to_4801": "npx hardhat run script/Deploy_4801_to_4801.ts --network worldChainSepolia", "deploy:4801_to_11155111": "npx hardhat run script/Deploy_4801_to_11155111.ts --network sepolia", + "deploy:84532_to_4801": "bash script/Deploy_84532_to_4801.sh", "verify:11155111_to_300": "bash script/Verify_11155111_to_300.sh", "verify:11155111_to_11155111": "bash script/Verify_11155111_to_11155111.sh", "verify:11155111_to_11155420": "bash script/Verify_11155111_to_11155420.sh", @@ -48,4 +49,4 @@ "typescript": "^5.5.4", "zksync-ethers": "^6.11.2" } -} \ No newline at end of file +} diff --git a/script/Deploy_84532_to_4801.sh b/script/Deploy_84532_to_4801.sh new file mode 100644 index 0000000..c8bfe92 --- /dev/null +++ b/script/Deploy_84532_to_4801.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +source .env +while IFS= read -r line; do + echo "$line" + + if [[ "$line" =~ ^Deployed\ OpMessagesInbox\ at:\ (0x[0-9A-Fa-f]+)$ ]]; then + DEPLOYED_L2_INBOX="${BASH_REMATCH[1]}" + fi +done < <(npx hardhat run script/Deploy_84532_to_4801_part1.ts --network worldChainSepolia) + +if [ -z "$DEPLOYED_L2_INBOX" ]; then + echo "Didn't find deployment address of OpMessagesInbox" + exit 1 +fi + +while IFS= read -r line; do + echo "$line" + + if [[ "$line" =~ ^Deployed\ L1ToOptimismMessagesSender\ at:\ (0x[0-9A-Fa-f]+)$ ]]; then + DEPLOYED_L1_OUTBOX="${BASH_REMATCH[1]}" + fi +done < <(DEPLOYED_L2_INBOX=$DEPLOYED_L2_INBOX npx hardhat run script/Deploy_84532_to_4801_part2.ts --network sepolia) + +if [ -z "$DEPLOYED_L1_OUTBOX" ]; then + echo "Didn't find deployment address of L1ToOptimismMessagesSender" + exit 1 +fi + +DEPLOYED_L2_INBOX=$DEPLOYED_L2_INBOX DEPLOYED_L1_OUTBOX=$DEPLOYED_L1_OUTBOX npx hardhat run script/Deploy_84532_to_4801_part3.ts --network worldChainSepolia \ No newline at end of file diff --git a/script/Deploy_84532_to_4801_part1.ts b/script/Deploy_84532_to_4801_part1.ts new file mode 100644 index 0000000..73c9420 --- /dev/null +++ b/script/Deploy_84532_to_4801_part1.ts @@ -0,0 +1,76 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const PRIVATE_KEY = process.env.WORLD_CHAIN_PRIVATE_KEY || ""; +const CHAINID = process.env.BASE_SEPOLIA_CHAINID || ""; + +if (!PRIVATE_KEY) { + throw new Error("WORLD_CHAIN_PRIVATE_KEY is not set in .env"); +} +if (!CHAINID) { + throw new Error("L1_SEPOLIA_CHAINID is not set in .env"); +} + +export async function main() { + // deploy OpMessagesInbox + const OpMessagesInbox = + await hre.ethers.getContractFactory("OpMessagesInbox"); + const opMessagesInbox = await OpMessagesInbox.deploy(); + const opMessagesInboxAddr = await opMessagesInbox.getAddress(); + await opMessagesInbox.waitForDeployment(); + console.log("Deployed OpMessagesInbox at:", opMessagesInboxAddr); + + // deploy HeaderStore + const HeadersStore = await hre.ethers.getContractFactory("HeadersStore"); + const headersStore = await HeadersStore.deploy(opMessagesInboxAddr); + const headersStoreAddr = await headersStore.getAddress(); + await headersStore.waitForDeployment(); + console.log("Deployed HeadersStore at:", headersStoreAddr); + + // deploy FactsRegistry + const FactsRegistry = await hre.ethers.getContractFactory("FactsRegistry"); + const factsRegistry = await FactsRegistry.deploy(headersStoreAddr); + const factsRegistryAddr = await factsRegistry.getAddress(); + await factsRegistry.waitForDeployment(); + console.log("Deployed FactsRegistry at:", factsRegistryAddr); + + // set OpMessagesInbox variables + await opMessagesInbox.setHeadersStore(headersStoreAddr); + await opMessagesInbox.setMessagesOriginChainId(CHAINID); + // setCrossDomainMsgSender will be called at step 3 + + // verify OpMessagesInbox + await hre.run("verify:verify", { + address: opMessagesInboxAddr, + constructorArguments: [], + force: true, + }); + + // verify HeadersStore + await hre.run("verify:verify", { + address: headersStoreAddr, + constructorArguments: [opMessagesInboxAddr], + force: true, + }); + + // verify FactsRegistry + await hre.run("verify:verify", { + address: factsRegistryAddr, + constructorArguments: [headersStoreAddr], + force: true, + }); + + console.log( + "===============================================================", + ); + console.log("HeadersStore:", headersStoreAddr); + console.log("FactsRegistry:", factsRegistryAddr); + console.log("OpMessagesInbox:", opMessagesInboxAddr); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Deploy_84532_to_4801_part2.ts b/script/Deploy_84532_to_4801_part2.ts new file mode 100644 index 0000000..9423725 --- /dev/null +++ b/script/Deploy_84532_to_4801_part2.ts @@ -0,0 +1,98 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const l2OutputOracle = process.env.BASE_SEPOLIA_L2_OUTPUT_ORACLE || ""; +const chainId = process.env.BASE_SEPOLIA_CHAINID || ""; +const aggregatorsFactory = process.env.BASE_SEPOLIA_AGGREGATORS_FACTORY || ""; +const l2Target = process.env.DEPLOYED_L2_INBOX || ""; +const crossDomainMsgSender = + process.env.WORLD_CHAIN_SEPOLIA_CROSS_DOMAIN_MESSENGER || ""; + +if (!l2OutputOracle) { + throw new Error("BASE_SEPOLIA_L2_OUTPUT_ORACLE is not set in .env"); +} +if (!chainId) { + throw new Error("BASE_SEPOLIA_CHAINID is not set in .env"); +} +if (!aggregatorsFactory) { + throw new Error("BASE_SEPOLIA_AGGREGATORS_FACTORY is not set in .env"); +} +if (!l2Target) { + throw new Error("DEPLOYED_L2_INBOX is not set in .env"); +} +if (!crossDomainMsgSender) { + throw new Error( + "WORLD_CHAIN_SEPOLIA_CROSS_DOMAIN_MESSENGER is not set in .env", + ); +} + +export async function main() { + // deploy OpStackParentHashesFetcher + const OpStackParentHashesFetcher = await hre.ethers.getContractFactory( + "OpStackParentHashesFetcher", + ); + const opStackParentHashesFetcher = await OpStackParentHashesFetcher.deploy( + l2OutputOracle, + chainId, + ); + const opStackParentHashesFetcherAddress = + await opStackParentHashesFetcher.getAddress(); + await opStackParentHashesFetcher.waitForDeployment(); + console.log( + "Deployed OpStackParentHashesFetcher at:", + opStackParentHashesFetcherAddress, + ); + + // deploy L1ToOptimismMessagesSender + const L1ToOptimismMessagesSender = await hre.ethers.getContractFactory( + "L1ToOptimismMessagesSender", + ); + const l1ToOptimismMessagesSender = await L1ToOptimismMessagesSender.deploy( + aggregatorsFactory, + opStackParentHashesFetcherAddress, + l2Target, + crossDomainMsgSender, + ); + const l1ToOptimismMessagesSenderAddress = + await l1ToOptimismMessagesSender.getAddress(); + await l1ToOptimismMessagesSender.waitForDeployment(); + console.log( + "Deployed L1ToOptimismMessagesSender at:", + l1ToOptimismMessagesSenderAddress, + ); + + // verify OpStackParentHashesFetcher + await hre.run("verify:verify", { + address: opStackParentHashesFetcherAddress, + constructorArguments: [l2OutputOracle, chainId], + force: true, + }); + + // verify L1ToOptimismMessagesSender + await hre.run("verify:verify", { + address: l1ToOptimismMessagesSenderAddress, + constructorArguments: [ + aggregatorsFactory, + opStackParentHashesFetcherAddress, + l2Target, + crossDomainMsgSender, + ], + force: true, + }); + + console.log( + "===============================================================", + ); + console.log("OpStackParentHashesFetcher:", opStackParentHashesFetcherAddress); + console.log( + "L1ToOptimismMessagesSenderAddress:", + l1ToOptimismMessagesSenderAddress, + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/script/Deploy_84532_to_4801_part3.ts b/script/Deploy_84532_to_4801_part3.ts new file mode 100644 index 0000000..8eb3843 --- /dev/null +++ b/script/Deploy_84532_to_4801_part3.ts @@ -0,0 +1,39 @@ +import dotenv from "dotenv"; +import hre from "hardhat"; + +dotenv.config(); + +const PRIVATE_KEY = process.env.WORLD_CHAIN_PRIVATE_KEY || ""; +const opMessagesInboxAddress = process.env.DEPLOYED_L2_INBOX || ""; +const crossDomainMsgSenderAddress = process.env.DEPLOYED_L1_OUTBOX || ""; + +if (!PRIVATE_KEY) { + throw new Error("WORLD_CHAIN_PRIVATE_KEY is not set in .env"); +} +if (!opMessagesInboxAddress) { + throw new Error("DEPLOYED_L2_INBOX is not set in .env"); +} +if (!crossDomainMsgSenderAddress) { + throw new Error("DEPLOYED_L1_OUTBOX is not set in .env"); +} + +export async function main() { + // Call setCrossDomainMsgSender on OpMessagesInbox + const opMessagesInbox = await hre.ethers.getContractAt( + "OpMessagesInbox", + opMessagesInboxAddress, + ); + const tx = await opMessagesInbox.setCrossDomainMsgSender( + crossDomainMsgSenderAddress, + ); + await tx.wait(); + + console.log( + `crossDomainMsgSender of OpMessagesInbox(${opMessagesInboxAddress}) has been set to ${crossDomainMsgSenderAddress}`, + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +});