From 96e73cfcdc1fe3a701a45fada82cce6388861458 Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Tue, 23 Jan 2024 10:51:30 +0000 Subject: [PATCH] Set addresses consistently using rawTx --- .../bridge/001_deploy_bridge.ts | 35 +++++++++++++------ .../001_deploy_cross_chain_messenger.ts | 17 ++++++--- .../001_deploy_cross_chain_messenger.ts | 17 ++++++--- 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/contracts/deployment_scripts/bridge/001_deploy_bridge.ts b/contracts/deployment_scripts/bridge/001_deploy_bridge.ts index 03b66c9dc4..8ef944bd48 100644 --- a/contracts/deployment_scripts/bridge/001_deploy_bridge.ts +++ b/contracts/deployment_scripts/bridge/001_deploy_bridge.ts @@ -38,12 +38,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // get management contract and write the L1 bridge address to it const mgmtContract = (await hre.ethers.getContractFactory('ManagementContract')).attach(mgmtContractAddress) - const recordL1AddressTx = await mgmtContract.SetImportantContractAddress("L1Bridge", layer1BridgeDeployment.address); - const receipt = await recordL1AddressTx.wait(); - if (receipt.status !== 1) { - console.log("Failed to set L1BridgeAddress in management contract"); + const recordL1AddressTx = await mgmtContract.populateTransaction.SetImportantContractAddress("L1Bridge", layer1BridgeDeployment.address); + + const receipt = await hre.companionNetworks.layer1.deployments.rawTx({ + from: accountsL1.deployer, + to: mgmtContractAddress, + data: recordL1AddressTx.data, + log: true, + waitConfirmations: 1, + }); + if (receipt.events?.length === 0) { + console.log(`Failed to set L1BridgeAddress=${layer1BridgeDeployment.address} on management contract.`); + } else { + console.log(`L1BridgeAddress=${layer1BridgeDeployment.address}`); } - console.log(`L1BridgeAddress=${layer1BridgeDeployment.address}`) // We get the Cross chain messenger deployment on the layer 2 network. const messengerL2 = await deployments.get("CrossChainMessenger"); @@ -69,12 +77,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }, "setRemoteBridge", layer2BridgeDeployment.address); - const recordL2AddressTx = await mgmtContract.SetImportantContractAddress("L2Bridge", layer2BridgeDeployment.address); - const receipt2 = await recordL2AddressTx.wait(); - if (receipt2.status !== 1) { - console.log("Failed to set L2BridgeAddress in management contract"); + const recordL2AddressTx = await mgmtContract.populateTransaction.SetImportantContractAddress("L2Bridge", layer2BridgeDeployment.address); + const receipt2 = await hre.companionNetworks.layer1.deployments.rawTx({ + from: accountsL1.deployer, + to: mgmtContractAddress, + data: recordL2AddressTx.data, + log: true, + waitConfirmations: 1, + }); + if (receipt2.events?.length === 0) { + console.log(`Failed to set L2BridgeAddress=${layer2BridgeDeployment.address} on management contract.`); + } else { + console.log(`L2BridgeAddress=${layer2BridgeDeployment.address}`); } - console.log(`L2BridgeAddress=${layer2BridgeDeployment.address}`) console.log(` Bridge deployed with from L1 address=${accountsL1.deployer} L2 Address=${accountsL2.deployer}`); }; diff --git a/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts b/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts index bbe54b4b37..eb67bfee9a 100644 --- a/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts +++ b/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts @@ -36,12 +36,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // get management contract and write the cross chain messenger address to it const mgmtContract = (await hre.ethers.getContractFactory('ManagementContract')).attach(mgmtContractAddress) - const tx = await mgmtContract.SetImportantContractAddress("L1CrossChainMessenger", crossChainDeployment.address); - const receipt = await tx.wait(); - if (receipt.status !== 1) { - console.log("Failed to set L1CrossChainMessenger in management contract"); + const tx = await mgmtContract.populateTransaction.SetImportantContractAddress("L1CrossChainMessenger", crossChainDeployment.address); + const receipt = await hre.companionNetworks.layer1.deployments.rawTx({ + from: deployer, + to: mgmtContractAddress, + data: tx.data, + log: true, + waitConfirmations: 1, + }); + if (receipt.events?.length === 0) { + console.log(`Failed to set L1CrossChainMessenger=${crossChainDeployment.address} on management contract.`); + } else { + console.log(`L1CrossChainMessenger=${crossChainDeployment.address}`); } - console.log(`L1CrossChainMessenger=${crossChainDeployment.address}`); }; export default func; diff --git a/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts b/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts index bf46fa65aa..f1456ceedc 100644 --- a/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts +++ b/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts @@ -40,12 +40,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); // get L1 management contract and write the cross chain messenger address to it const mgmtContract = (await hre.ethers.getContractFactory('ManagementContract')).attach(mgmtContractAddress); - const tx = await mgmtContract.SetImportantContractAddress("L2CrossChainMessenger", crossChainDeployment.address); - const receipt = await tx.wait(); - if (receipt.status !== 1) { - console.log("Failed to set L2CrossChainMessenger in management contract"); + const tx = await mgmtContract.populateTransaction.SetImportantContractAddress("L2CrossChainMessenger", crossChainDeployment.address); + const receipt = await companionNetworks.layer1.deployments.rawTx({ + from: deployer, + to: mgmtContractAddress, + data: tx.data, + log: true, + waitConfirmations: 1, + }); + if (receipt.events?.length === 0) { + console.log(`Failed to set L2CrossChainMessenger=${crossChainDeployment.address} on management contract.`); + } else { + console.log(`L2CrossChainMessenger=${crossChainDeployment.address}`); } - console.log(`L2CrossChainMessenger=${crossChainDeployment.address}`); }; export default func;