From b616524545db2768fb9a3772ffd05c6e0a7f2d8b Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 11:35:04 +0100 Subject: [PATCH 1/9] chore: adding scripts to update owners on L2 --- .../arbitrum/deploy_21_change_owner.js | 48 +++++++++++++++++++ .../arbitrum/globals_arbitrum_one.json | 2 +- .../staking/base/deploy_71_change_owner.js | 48 +++++++++++++++++++ .../staking/base/globals_base_mainnet.json | 2 +- .../staking/celo/deploy_051_change_owner.js | 48 +++++++++++++++++++ .../staking/celo/globals_celo_mainnet.json | 2 +- .../staking/gnosis/deploy_031_change_owner.js | 48 +++++++++++++++++++ .../gnosis/globals_gnosis_mainnet.json | 2 +- .../optimistic/deploy_41_change_owner.js | 48 +++++++++++++++++++ .../globals_optimistic_mainnet.json | 2 +- .../staking/polygon/deploy_61_change_owner.js | 48 +++++++++++++++++++ .../polygon/globals_polygon_mainnet.json | 2 +- 12 files changed, 294 insertions(+), 6 deletions(-) create mode 100644 scripts/deployment/staking/arbitrum/deploy_21_change_owner.js create mode 100644 scripts/deployment/staking/base/deploy_71_change_owner.js create mode 100644 scripts/deployment/staking/celo/deploy_051_change_owner.js create mode 100644 scripts/deployment/staking/gnosis/deploy_031_change_owner.js create mode 100644 scripts/deployment/staking/optimistic/deploy_41_change_owner.js create mode 100644 scripts/deployment/staking/polygon/deploy_61_change_owner.js diff --git a/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js b/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js new file mode 100644 index 00000000..6d3fc97d --- /dev/null +++ b/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js @@ -0,0 +1,48 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const arbitrumTargetDispenserL2Address = parsedData.arbitrumTargetDispenserL2Address; + const bridgeMediatorAddress = parsedData.bridgeMediatorAddress; + + let networkURL = parsedData.networkURL; + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("21. EOA to change owner in ArbitrumTargetDispenserL2"); + const ArbitrumTargetDispenserL2 = await ethers.getContractAt("ArbitrumTargetDispenserL2", arbitrumTargetDispenserL2Address); + console.log("You are signing the following transaction: ArbitrumTargetDispenserL2.connect(EOA).changeOwner()"); + const result = await arbitrumTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); + + // Transaction details + console.log("Contract deployment: ArbitrumTargetDispenserL2"); + console.log("Contract address:", arbitrumTargetDispenserL2.address); + console.log("Transaction:", result.hash); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/staking/arbitrum/globals_arbitrum_one.json b/scripts/deployment/staking/arbitrum/globals_arbitrum_one.json index 6943f3d5..cc50b481 100644 --- a/scripts/deployment/staking/arbitrum/globals_arbitrum_one.json +++ b/scripts/deployment/staking/arbitrum/globals_arbitrum_one.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"arbitrumOne","networkURL":"https://arb1.arbitrum.io/rpc","gasPriceInGwei":"5","olasAddress":"0x064F8B858C2A603e1b106a2039f5446D32dc81c1","serviceStakingFactoryAddress":"0xEB5638eefE289691EcE01943f768EDBF96258a80","timelockAddress":"","arbitrumArbSysAddress":"0x0000000000000000000000000000000000000064","l1ChainId":"1","arbitrumDepositProcessorL1Address":"0x5e13E07006D68B097DCb5979ef5545C4f9156162","arbitrumTargetDispenserL2Address":"0x10c5525F77F13b28f42c5626240c001c2D57CAd4"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"arbitrumOne","networkURL":"https://arb1.arbitrum.io/rpc","gasPriceInGwei":"5","olasAddress":"0x064F8B858C2A603e1b106a2039f5446D32dc81c1","serviceStakingFactoryAddress":"0xEB5638eefE289691EcE01943f768EDBF96258a80","bridgeMediatorAddress":"0x4d30F68F5AA342d296d4deE4bB1Cacca912dA70F","arbitrumArbSysAddress":"0x0000000000000000000000000000000000000064","l1ChainId":"1","arbitrumDepositProcessorL1Address":"0x5e13E07006D68B097DCb5979ef5545C4f9156162","arbitrumTargetDispenserL2Address":"0x10c5525F77F13b28f42c5626240c001c2D57CAd4"} \ No newline at end of file diff --git a/scripts/deployment/staking/base/deploy_71_change_owner.js b/scripts/deployment/staking/base/deploy_71_change_owner.js new file mode 100644 index 00000000..676943b2 --- /dev/null +++ b/scripts/deployment/staking/base/deploy_71_change_owner.js @@ -0,0 +1,48 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const baseTargetDispenserL2Address = parsedData.baseTargetDispenserL2Address; + const bridgeMediatorAddress = parsedData.bridgeMediatorAddress; + + let networkURL = parsedData.networkURL; + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("71. EOA to change owner in OptimismTargetDispenserL2 (Base)"); + const OptimismTargetDispenserL2 = await ethers.getContractAt("OptimismTargetDispenserL2", baseTargetDispenserL2Address); + console.log("You are signing the following transaction: OptimismTargetDispenserL2.connect(EOA).changeOwner()"); + const result = await baseTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); + + // Transaction details + console.log("Contract deployment: OptimismTargetDispenserL2"); + console.log("Contract address:", baseTargetDispenserL2.address); + console.log("Transaction:", result.hash); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/staking/base/globals_base_mainnet.json b/scripts/deployment/staking/base/globals_base_mainnet.json index a6640187..0feae934 100644 --- a/scripts/deployment/staking/base/globals_base_mainnet.json +++ b/scripts/deployment/staking/base/globals_base_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"base","networkURL":"https://mainnet.base.org","gasPriceInGwei":"2","olasAddress":"0x54330d28ca3357F294334BDC454a032e7f353416","serviceStakingFactoryAddress":"0x1cEe30D08943EB58EFF84DD1AB44a6ee6FEff63a","timelockAddress":"","baseL2CrossDomainMessengerAddress":"0x4200000000000000000000000000000000000007","l1ChainId":"1","baseDepositProcessorL1Address":"0x42BA1BbD797E4C90F386F03a544F3b62C1f917d0","baseTargetDispenserL2Address":"0xcDdD9D9ABaB36fFa882530D69c73FeE5D4001C2d"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"base","networkURL":"https://mainnet.base.org","gasPriceInGwei":"2","olasAddress":"0x54330d28ca3357F294334BDC454a032e7f353416","serviceStakingFactoryAddress":"0x1cEe30D08943EB58EFF84DD1AB44a6ee6FEff63a","bridgeMediatorAddress":"0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA","baseL2CrossDomainMessengerAddress":"0x4200000000000000000000000000000000000007","l1ChainId":"1","baseDepositProcessorL1Address":"0x42BA1BbD797E4C90F386F03a544F3b62C1f917d0","baseTargetDispenserL2Address":"0xcDdD9D9ABaB36fFa882530D69c73FeE5D4001C2d"} \ No newline at end of file diff --git a/scripts/deployment/staking/celo/deploy_051_change_owner.js b/scripts/deployment/staking/celo/deploy_051_change_owner.js new file mode 100644 index 00000000..86a6dd91 --- /dev/null +++ b/scripts/deployment/staking/celo/deploy_051_change_owner.js @@ -0,0 +1,48 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const celoTargetDispenserL2Address = parsedData.celoTargetDispenserL2Address; + const bridgeMediatorAddress = parsedData.bridgeMediatorAddress; + + let networkURL = parsedData.networkURL; + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("51. EOA to change owner in WormholeTargetDispenserL2 (Celo)"); + const WormholeTargetDispenserL2 = await ethers.getContractAt("WormholeTargetDispenserL2", celoTargetDispenserL2Address); + console.log("You are signing the following transaction: WormholeTargetDispenserL2.connect(EOA).changeOwner()"); + const result = await celoTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); + + // Transaction details + console.log("Contract deployment: WormholeTargetDispenserL2"); + console.log("Contract address:", celoTargetDispenserL2.address); + console.log("Transaction:", result.hash); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/staking/celo/globals_celo_mainnet.json b/scripts/deployment/staking/celo/globals_celo_mainnet.json index ec8058c7..69e8f1aa 100644 --- a/scripts/deployment/staking/celo/globals_celo_mainnet.json +++ b/scripts/deployment/staking/celo/globals_celo_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"celo","networkURL":"https://forno.celo.org","gasPriceInGwei":"2","olasAddress":"0xaCFfAe8e57Ec6E394Eb1b41939A8CF7892DbDc51","serviceStakingFactoryAddress":"0x1c2cD884127b080F940b7546c1e9aaf525b1FA55","timelockAddress":"","wormholeL2CoreAddress":"0xa321448d90d4e5b0A732867c18eA198e75CAC48E","wormholeL2TokenRelayerAddress":"0x796Dff6D74F3E27060B71255Fe517BFb23C93eed","wormholeL2MessageRelayer":"0x27428DD2d3DD32A4D7f7C497eAaa23130d894911","wormholel1ChainId":"2","celoDepositProcessorL1Address":"0x223902b6C583f18E8dc84AF4E6a8fa523d088B78","celoTargetDispenserL2Address":"0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"celo","networkURL":"https://forno.celo.org","gasPriceInGwei":"2","olasAddress":"0xaCFfAe8e57Ec6E394Eb1b41939A8CF7892DbDc51","serviceStakingFactoryAddress":"0x1c2cD884127b080F940b7546c1e9aaf525b1FA55","bridgeMediatorAddress":"0x397125902ED2cA2d42104F621f448A2cE1bC8Fb7","wormholeL2CoreAddress":"0xa321448d90d4e5b0A732867c18eA198e75CAC48E","wormholeL2TokenRelayerAddress":"0x796Dff6D74F3E27060B71255Fe517BFb23C93eed","wormholeL2MessageRelayer":"0x27428DD2d3DD32A4D7f7C497eAaa23130d894911","wormholel1ChainId":"2","celoDepositProcessorL1Address":"0x223902b6C583f18E8dc84AF4E6a8fa523d088B78","celoTargetDispenserL2Address":"0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7"} \ No newline at end of file diff --git a/scripts/deployment/staking/gnosis/deploy_031_change_owner.js b/scripts/deployment/staking/gnosis/deploy_031_change_owner.js new file mode 100644 index 00000000..bfa68ce4 --- /dev/null +++ b/scripts/deployment/staking/gnosis/deploy_031_change_owner.js @@ -0,0 +1,48 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const gnosisTargetDispenserL2Address = parsedData.gnosisTargetDispenserL2Address; + const bridgeMediatorAddress = parsedData.bridgeMediatorAddress; + + let networkURL = parsedData.networkURL; + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("31. EOA to change owner in GnosisTargetDispenserL2"); + const GnosisTargetDispenserL2 = await ethers.getContractAt("GnosisTargetDispenserL2", gnosisTargetDispenserL2Address); + console.log("You are signing the following transaction: GnosisTargetDispenserL2.connect(EOA).changeOwner()"); + const result = await gnosisTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); + + // Transaction details + console.log("Contract deployment: GnosisTargetDispenserL2"); + console.log("Contract address:", gnosisTargetDispenserL2.address); + console.log("Transaction:", result.hash); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json b/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json index 37a56e96..d02dee98 100644 --- a/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json +++ b/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL":"https://rpc.gnosischain.com","gasPriceInGwei":"5","olasAddress":"0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f","serviceStakingFactoryAddress":"0xb0228CA253A88Bc8eb4ca70BCAC8f87b381f4700","timelockAddress":"","gnosisAMBHomeAddress":"0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59","l1ChainId":"1","gnosisDepositProcessorL1Address":"0xEEf2c02cFC445bFFf1c891D486424Ef3aBc66AB0","gnosisTargetDispenserL2Address":"0x67722c823010CEb4BED5325fE109196C0f67D053"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL":"https://rpc.gnosischain.com","gasPriceInGwei":"5","olasAddress":"0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f","serviceStakingFactoryAddress":"0xb0228CA253A88Bc8eb4ca70BCAC8f87b381f4700","bridgeMediatorAddress": "0x15bd56669F57192a97dF41A2aa8f4403e9491776","gnosisAMBHomeAddress":"0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59","l1ChainId":"1","gnosisDepositProcessorL1Address":"0xEEf2c02cFC445bFFf1c891D486424Ef3aBc66AB0","gnosisTargetDispenserL2Address":"0x67722c823010CEb4BED5325fE109196C0f67D053"} \ No newline at end of file diff --git a/scripts/deployment/staking/optimistic/deploy_41_change_owner.js b/scripts/deployment/staking/optimistic/deploy_41_change_owner.js new file mode 100644 index 00000000..51f4989d --- /dev/null +++ b/scripts/deployment/staking/optimistic/deploy_41_change_owner.js @@ -0,0 +1,48 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const optimismTargetDispenserL2Address = parsedData.optimismTargetDispenserL2Address; + const bridgeMediatorAddress = parsedData.bridgeMediatorAddress; + + let networkURL = parsedData.networkURL; + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("41. EOA to change owner in OptimismTargetDispenserL2"); + const OptimismTargetDispenserL2 = await ethers.getContractAt("OptimismTargetDispenserL2", optimismTargetDispenserL2Address); + console.log("You are signing the following transaction: OptimismTargetDispenserL2.connect(EOA).changeOwner()"); + const result = await optimismTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); + + // Transaction details + console.log("Contract deployment: OptimismTargetDispenserL2"); + console.log("Contract address:", optimismTargetDispenserL2.address); + console.log("Transaction:", result.hash); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/staking/optimistic/globals_optimistic_mainnet.json b/scripts/deployment/staking/optimistic/globals_optimistic_mainnet.json index 84be078f..d8a04c79 100644 --- a/scripts/deployment/staking/optimistic/globals_optimistic_mainnet.json +++ b/scripts/deployment/staking/optimistic/globals_optimistic_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"optimistic","networkURL":"https://optimism.drpc.org","gasPriceInGwei":"2","olasAddress":"0xFC2E6e6BCbd49ccf3A5f029c79984372DcBFE527","serviceStakingFactoryAddress":"0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8","timelockAddress":"","optimisticL2CrossDomainMessengerAddress":"0x4200000000000000000000000000000000000007","l1ChainId":"1","optimismDepositProcessorL1Address":"0xAB787ceebe8F2b8dca44e3bB744D6e63003ee978","optimismTargetDispenserL2Address":"0x04b0007b2aFb398015B76e5f22993a1fddF83644"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"optimistic","networkURL":"https://optimism.drpc.org","gasPriceInGwei":"2","olasAddress":"0xFC2E6e6BCbd49ccf3A5f029c79984372DcBFE527","serviceStakingFactoryAddress":"0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8","bridgeMediatorAddress":"0x87c511c8aE3fAF0063b3F3CF9C6ab96c4AA5C60c","optimisticL2CrossDomainMessengerAddress":"0x4200000000000000000000000000000000000007","l1ChainId":"1","optimismDepositProcessorL1Address":"0xAB787ceebe8F2b8dca44e3bB744D6e63003ee978","optimismTargetDispenserL2Address":"0x04b0007b2aFb398015B76e5f22993a1fddF83644"} \ No newline at end of file diff --git a/scripts/deployment/staking/polygon/deploy_61_change_owner.js b/scripts/deployment/staking/polygon/deploy_61_change_owner.js new file mode 100644 index 00000000..ef8713d1 --- /dev/null +++ b/scripts/deployment/staking/polygon/deploy_61_change_owner.js @@ -0,0 +1,48 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const polygonTargetDispenserL2Address = parsedData.polygonTargetDispenserL2Address; + const bridgeMediatorAddress = parsedData.bridgeMediatorAddress; + + let networkURL = parsedData.networkURL; + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("61. EOA to change owner in PolygonTargetDispenserL2"); + const PolygonTargetDispenserL2 = await ethers.getContractAt("PolygonTargetDispenserL2", polygonTargetDispenserL2Address); + console.log("You are signing the following transaction: PolygonTargetDispenserL2.connect(EOA).changeOwner()"); + const result = await polygonTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); + + // Transaction details + console.log("Contract deployment: PolygonTargetDispenserL2"); + console.log("Contract address:", polygonTargetDispenserL2.address); + console.log("Transaction:", result.hash); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/staking/polygon/globals_polygon_mainnet.json b/scripts/deployment/staking/polygon/globals_polygon_mainnet.json index 9ba8200c..41760b04 100644 --- a/scripts/deployment/staking/polygon/globals_polygon_mainnet.json +++ b/scripts/deployment/staking/polygon/globals_polygon_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"polygon","networkURL":"https://polygon-mainnet.g.alchemy.com/v2/","gasPriceInGwei":"5","olasAddress":"0xFEF5d947472e72Efbb2E388c730B7428406F2F95","serviceStakingFactoryAddress":"0x46C0D07F55d4F9B5Eed2Fc9680B5953e5fd7b461","timelockAddress":"","polygonFXChildAddress":"0x8397259c983751DAf40400790063935a11afa28a","l1ChainId":"1","polygonDepositProcessorL1Address":"0x4Ce43b82EF1298E1466D3b3Cee67BA6680bF82FB","polygonTargetDispenserL2Address":"0xf76953444C35F1FcE2F6CA1b167173357d3F5C17"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"polygon","networkURL":"https://polygon-mainnet.g.alchemy.com/v2/","gasPriceInGwei":"5","olasAddress":"0xFEF5d947472e72Efbb2E388c730B7428406F2F95","serviceStakingFactoryAddress":"0x46C0D07F55d4F9B5Eed2Fc9680B5953e5fd7b461","bridgeMediatorAddress":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","polygonFXChildAddress":"0x8397259c983751DAf40400790063935a11afa28a","l1ChainId":"1","polygonDepositProcessorL1Address":"0x4Ce43b82EF1298E1466D3b3Cee67BA6680bF82FB","polygonTargetDispenserL2Address":"0xf76953444C35F1FcE2F6CA1b167173357d3F5C17"} \ No newline at end of file From 05c1937fbd2a0f42d39cbb060e42cc2d6c66bbaf Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 11:37:15 +0100 Subject: [PATCH 2/9] chore: gitleaksignore --- .gitleaksignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitleaksignore b/.gitleaksignore index 3156ba94..0d3b257c 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -184,3 +184,5 @@ e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/globals_mainnet.json e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/staking/globals_mainnet.json:generic-api-key:2 e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/staking/globals_sepolia.json:generic-api-key:2 +3068b0eefad400612f18c193fa62e11974c0fbd5:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:1 +3068b0eefad400612f18c193fa62e11974c0fbd5:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 From de29c4ce8cd4d9471781ec03e561a724acf1ddcd Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 11:39:19 +0100 Subject: [PATCH 3/9] chore: gitleaksignore --- .gitleaksignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitleaksignore b/.gitleaksignore index 0d3b257c..b09343db 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -186,3 +186,5 @@ e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/staking/globals_main e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/staking/globals_sepolia.json:generic-api-key:2 3068b0eefad400612f18c193fa62e11974c0fbd5:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:1 3068b0eefad400612f18c193fa62e11974c0fbd5:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 +b616524545db2768fb9a3772ffd05c6e0a7f2d8b:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:1 +b616524545db2768fb9a3772ffd05c6e0a7f2d8b:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 From 2ac921bf568ab8e38956335f5de82a7e1a7b8b1e Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 11:41:03 +0100 Subject: [PATCH 4/9] chore: linter --- scripts/deployment/staking/arbitrum/deploy_21_change_owner.js | 2 +- scripts/deployment/staking/base/deploy_71_change_owner.js | 2 +- scripts/deployment/staking/celo/deploy_051_change_owner.js | 2 +- scripts/deployment/staking/gnosis/deploy_031_change_owner.js | 2 +- scripts/deployment/staking/optimistic/deploy_41_change_owner.js | 2 +- scripts/deployment/staking/polygon/deploy_61_change_owner.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js b/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js index 6d3fc97d..f05cdf37 100644 --- a/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js +++ b/scripts/deployment/staking/arbitrum/deploy_21_change_owner.js @@ -30,7 +30,7 @@ async function main() { // Transaction signing and execution console.log("21. EOA to change owner in ArbitrumTargetDispenserL2"); - const ArbitrumTargetDispenserL2 = await ethers.getContractAt("ArbitrumTargetDispenserL2", arbitrumTargetDispenserL2Address); + const arbitrumTargetDispenserL2 = await ethers.getContractAt("ArbitrumTargetDispenserL2", arbitrumTargetDispenserL2Address); console.log("You are signing the following transaction: ArbitrumTargetDispenserL2.connect(EOA).changeOwner()"); const result = await arbitrumTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); diff --git a/scripts/deployment/staking/base/deploy_71_change_owner.js b/scripts/deployment/staking/base/deploy_71_change_owner.js index 676943b2..d959f2e7 100644 --- a/scripts/deployment/staking/base/deploy_71_change_owner.js +++ b/scripts/deployment/staking/base/deploy_71_change_owner.js @@ -30,7 +30,7 @@ async function main() { // Transaction signing and execution console.log("71. EOA to change owner in OptimismTargetDispenserL2 (Base)"); - const OptimismTargetDispenserL2 = await ethers.getContractAt("OptimismTargetDispenserL2", baseTargetDispenserL2Address); + const baseTargetDispenserL2 = await ethers.getContractAt("OptimismTargetDispenserL2", baseTargetDispenserL2Address); console.log("You are signing the following transaction: OptimismTargetDispenserL2.connect(EOA).changeOwner()"); const result = await baseTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); diff --git a/scripts/deployment/staking/celo/deploy_051_change_owner.js b/scripts/deployment/staking/celo/deploy_051_change_owner.js index 86a6dd91..6ca830ec 100644 --- a/scripts/deployment/staking/celo/deploy_051_change_owner.js +++ b/scripts/deployment/staking/celo/deploy_051_change_owner.js @@ -30,7 +30,7 @@ async function main() { // Transaction signing and execution console.log("51. EOA to change owner in WormholeTargetDispenserL2 (Celo)"); - const WormholeTargetDispenserL2 = await ethers.getContractAt("WormholeTargetDispenserL2", celoTargetDispenserL2Address); + const celoTargetDispenserL2 = await ethers.getContractAt("WormholeTargetDispenserL2", celoTargetDispenserL2Address); console.log("You are signing the following transaction: WormholeTargetDispenserL2.connect(EOA).changeOwner()"); const result = await celoTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); diff --git a/scripts/deployment/staking/gnosis/deploy_031_change_owner.js b/scripts/deployment/staking/gnosis/deploy_031_change_owner.js index bfa68ce4..5170247f 100644 --- a/scripts/deployment/staking/gnosis/deploy_031_change_owner.js +++ b/scripts/deployment/staking/gnosis/deploy_031_change_owner.js @@ -30,7 +30,7 @@ async function main() { // Transaction signing and execution console.log("31. EOA to change owner in GnosisTargetDispenserL2"); - const GnosisTargetDispenserL2 = await ethers.getContractAt("GnosisTargetDispenserL2", gnosisTargetDispenserL2Address); + const gnosisTargetDispenserL2 = await ethers.getContractAt("GnosisTargetDispenserL2", gnosisTargetDispenserL2Address); console.log("You are signing the following transaction: GnosisTargetDispenserL2.connect(EOA).changeOwner()"); const result = await gnosisTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); diff --git a/scripts/deployment/staking/optimistic/deploy_41_change_owner.js b/scripts/deployment/staking/optimistic/deploy_41_change_owner.js index 51f4989d..5213fc69 100644 --- a/scripts/deployment/staking/optimistic/deploy_41_change_owner.js +++ b/scripts/deployment/staking/optimistic/deploy_41_change_owner.js @@ -30,7 +30,7 @@ async function main() { // Transaction signing and execution console.log("41. EOA to change owner in OptimismTargetDispenserL2"); - const OptimismTargetDispenserL2 = await ethers.getContractAt("OptimismTargetDispenserL2", optimismTargetDispenserL2Address); + const optimismTargetDispenserL2 = await ethers.getContractAt("OptimismTargetDispenserL2", optimismTargetDispenserL2Address); console.log("You are signing the following transaction: OptimismTargetDispenserL2.connect(EOA).changeOwner()"); const result = await optimismTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); diff --git a/scripts/deployment/staking/polygon/deploy_61_change_owner.js b/scripts/deployment/staking/polygon/deploy_61_change_owner.js index ef8713d1..7a15c82b 100644 --- a/scripts/deployment/staking/polygon/deploy_61_change_owner.js +++ b/scripts/deployment/staking/polygon/deploy_61_change_owner.js @@ -30,7 +30,7 @@ async function main() { // Transaction signing and execution console.log("61. EOA to change owner in PolygonTargetDispenserL2"); - const PolygonTargetDispenserL2 = await ethers.getContractAt("PolygonTargetDispenserL2", polygonTargetDispenserL2Address); + const polygonTargetDispenserL2 = await ethers.getContractAt("PolygonTargetDispenserL2", polygonTargetDispenserL2Address); console.log("You are signing the following transaction: PolygonTargetDispenserL2.connect(EOA).changeOwner()"); const result = await polygonTargetDispenserL2.connect(EOA).changeOwner(bridgeMediatorAddress); From be06facb7a03b35ba4290e7c49fa96656b249345 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 12:30:29 +0100 Subject: [PATCH 5/9] chore: adding contract addresses into configuration files --- docs/configuration.json | 182 +++++++++++++++++++++++++++++++++------- 1 file changed, 154 insertions(+), 28 deletions(-) diff --git a/docs/configuration.json b/docs/configuration.json index e01ac5b3..6be16f37 100644 --- a/docs/configuration.json +++ b/docs/configuration.json @@ -37,47 +37,173 @@ "name": "Depository", "artifact": "abis/0.8.20/Depository.json", "address": "0xfF8697d8d2998d6AA2e09B405795C6F4BEeB0C81" - } - ] - }, - { - "name": "goerli", - "chainId": "5", - "contracts": [ + }, { - "name": "DonatorBlacklist", - "artifact": "abis/0.8.18/DonatorBlacklist.json", - "address": "0x1E11f1224e32Fe0f65FF7D13aD4b053B83bD09FA" + "name": "ArbitrumDepositProcessorL1", + "artifact": "abis/0.8.25/ArbitrumDepositProcessorL1.json", + "address": "0x5e13E07006D68B097DCb5979ef5545C4f9156162" }, { - "name": "Tokenomics", - "artifact": "abis/0.8.20/Tokenomics.json", - "address": "0x93Cd3f6DcE64d67f4420939865A00aC89776D4b5" + "name": "OptimismDepositProcessorL1", + "artifact": "abis/0.8.25/OptimismDepositProcessorL1.json", + "address": "0x42BA1BbD797E4C90F386F03a544F3b62C1f917d0" }, { - "name": "TokenomicsProxy", - "artifact": "abis/0.8.18/TokenomicsProxy.json", - "address": "0x10100e74b7F706222F8A7C0be9FC7Ae1717Ad8B2" + "name": "WormholeDepositProcessorL1", + "artifact": "abis/0.8.25/WormholeDepositProcessorL1.json", + "address": "0x223902b6C583f18E8dc84AF4E6a8fa523d088B78" }, { - "name": "Treasury", - "artifact": "abis/0.8.18/Treasury.json", - "address": "0x7bedCA17D29e53C8062d10902a6219F8d1E3B9B5" + "name": "EthereumDepositProcessor", + "artifact": "abis/0.8.25/EthereumDepositProcessor.json", + "address": "0x15CD7fAeE048c7673aB818C9e582630F1a924593" }, { - "name": "GenericBondCalculator", - "artifact": "abis/0.8.18/GenericBondCalculator.json", - "address": "0x77290FF625fc576f465D0256F6a12Ce4480a5b8a" + "name": "GnosisDepositProcessorL1", + "artifact": "abis/0.8.25/GnosisDepositProcessorL1.json", + "address": "0xEEf2c02cFC445bFFf1c891D486424Ef3aBc66AB0" }, { - "name": "Dispenser", - "artifact": "abis/0.8.18/Dispenser.json", - "address": "0xeDd71796B90eaCc56B074C39BAC90ED2Ca6D93Ee" + "name": "OptimismDepositProcessorL1", + "artifact": "abis/0.8.25/OptimismDepositProcessorL1.json", + "address": "0xAB787ceebe8F2b8dca44e3bB744D6e63003ee978" }, { - "name": "Depository", - "artifact": "abis/0.8.20/Depository.json", - "address": "0x5FDc466f4A7547c876eF40CD30fFA2A89F1EcDE7" + "name": "PolygonDepositProcessorL1", + "artifact": "abis/0.8.25/PolygonDepositProcessorL1.json", + "address": "0x4Ce43b82EF1298E1466D3b3Cee67BA6680bF82FB" + } + ] + }, + { + "name": "arbitrumOne", + "chainId": "42161", + "contracts": [ + { + "name": "ArbitrumTargetDispenserL2", + "artifact": "abis/0.8.25/ArbitrumTargetDispenserL2.json", + "address": "0x10c5525F77F13b28f42c5626240c001c2D57CAd4" + } + ] + }, + { + "name": "arbitrumSepolia", + "chainId": "421614", + "contracts": [ + { + "name": "ArbitrumTargetDispenserL2", + "artifact": "abis/0.8.25/ArbitrumTargetDispenserL2.json", + "address": "" + } + ] + }, + { + "name": "base", + "chainId": "8453", + "contracts": [ + { + "name": "OptimismTargetDispenserL2", + "artifact": "abis/0.8.25/OptimismTargetDispenserL2.json", + "address": "0xcDdD9D9ABaB36fFa882530D69c73FeE5D4001C2d" + } + ] + }, + { + "name": "baseSepolia", + "chainId": "84532", + "contracts": [ + { + "name": "OptimismTargetDispenserL2", + "artifact": "abis/0.8.25/OptimismTargetDispenserL2.json", + "address": "" + } + ] + }, + { + "name": "celo", + "chainId": "42220", + "contracts": [ + { + "name": "WormholeTargetDispenserL2", + "artifact": "abis/0.8.25/WormholeTargetDispenserL2.json", + "address": "0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7" + } + ] + }, + { + "name": "celoAlfajores", + "chainId": "44787", + "contracts": [ + { + "name": "WormholeTargetDispenserL2", + "artifact": "abis/0.8.25/WormholeTargetDispenserL2.json", + "address": "" + } + ] + }, + { + "name": "gnosis", + "chainId": "100", + "contracts": [ + { + "name": "GnosisTargetDispenserL2", + "artifact": "abis/0.8.25/GnosisTargetDispenserL2.json", + "address": "0x67722c823010CEb4BED5325fE109196C0f67D053" + } + ] + }, + { + "name": "chiado", + "chainId": "10200", + "contracts": [ + { + "name": "GnosisTargetDispenserL2", + "artifact": "abis/0.8.25/GnosisTargetDispenserL2.json", + "address": "" + } + ] + }, + { + "name": "optimistic", + "chainId": "10", + "contracts": [ + { + "name": "OptimismTargetDispenserL2", + "artifact": "abis/0.8.25/OptimismTargetDispenserL2.json", + "address": "0x04b0007b2aFb398015B76e5f22993a1fddF83644" + } + ] + }, + { + "name": "optimisticSepolia", + "chainId": "11155420", + "contracts": [ + { + "name": "OptimismTargetDispenserL2", + "artifact": "abis/0.8.25/OptimismTargetDispenserL2.json", + "address": "" + } + ] + }, + { + "name": "polygon", + "chainId": "137", + "contracts": [ + { + "name": "PolygonTargetDispenserL2", + "artifact": "abis/0.8.25/PolygonTargetDispenserL2.json", + "address": "0xf76953444C35F1FcE2F6CA1b167173357d3F5C17" + } + ] + }, + { + "name": "polygonAmoy", + "chainId": "80002", + "contracts": [ + { + "name": "PolygonTargetDispenserL2", + "artifact": "abis/0.8.25/PolygonTargetDispenserL2.json", + "address": "" } ] } From b74f36b5fd47b5b0f52414aa8f46438aaafd24b6 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 12:47:53 +0100 Subject: [PATCH 6/9] chore: updating static audit --- docs/configuration.json | 4 +- scripts/audit_chains/audit_contracts_setup.js | 78 +++++++------------ 2 files changed, 32 insertions(+), 50 deletions(-) diff --git a/docs/configuration.json b/docs/configuration.json index 6be16f37..eca1c39c 100644 --- a/docs/configuration.json +++ b/docs/configuration.json @@ -30,8 +30,8 @@ }, { "name": "Dispenser", - "artifact": "abis/0.8.18/Dispenser.json", - "address": "0xeED0000fE94d7cfeF4Dc0CA86a223f0F603A61B8" + "artifact": "abis/0.8.25/Dispenser.json", + "address": "0x5650300fCBab43A0D7D02F8Cb5d0f039402593f0" }, { "name": "Depository", diff --git a/scripts/audit_chains/audit_contracts_setup.js b/scripts/audit_chains/audit_contracts_setup.js index 4fd2dc98..62428523 100644 --- a/scripts/audit_chains/audit_contracts_setup.js +++ b/scripts/audit_chains/audit_contracts_setup.js @@ -249,8 +249,8 @@ async function checkDepository(chainId, provider, globalsInstance, configContrac async function main() { // Check for the API keys - if (!process.env.ALCHEMY_API_KEY_MAINNET || !process.env.ALCHEMY_API_KEY_GOERLI || - !process.env.ALCHEMY_API_KEY_MATIC || !process.env.ALCHEMY_API_KEY_MUMBAI) { + if (!process.env.ALCHEMY_API_KEY_MAINNET || !process.env.ALCHEMY_API_KEY_SEPOLIA || + !process.env.ALCHEMY_API_KEY_MATIC || !process.env.ALCHEMY_API_KEY_AMOY) { console.log("Check API keys!"); return; } @@ -260,49 +260,33 @@ async function main() { const dataFromJSON = fs.readFileSync(configFile, "utf8"); const configs = JSON.parse(dataFromJSON); - const numChains = configs.length; // ################################# VERIFY CONTRACTS WITH REPO ################################# - // For now gnosis chains are not supported - const networks = { - "mainnet": "etherscan", - "goerli": "goerli.etherscan", - }; - console.log("\nVerifying deployed contracts vs the repo... If no error is output, then the contracts are correct."); - // Traverse all chains - for (let i = 0; i < numChains; i++) { - // Skip gnosis chains - if (!networks[configs[i]["name"]]) { + // Currently the verification is fo mainnet only + const network = "etherscan"; + const contracts = configs[0]["contracts"]; + + // Verify contracts + for (let i = 0; i < contracts.length; i++) { + console.log("Checking " + contracts[i]["name"]); + const execSync = require("child_process").execSync; + try { + execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[i]["name"] + " " + contracts[i]["address"]); + } catch (error) { continue; } - - console.log("\n\nNetwork:", configs[i]["name"]); - const network = networks[configs[i]["name"]]; - const contracts = configs[i]["contracts"]; - - // Verify contracts - for (let j = 0; j < contracts.length; j++) { - console.log("Checking " + contracts[j]["name"]); - const execSync = require("child_process").execSync; - try { - execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[j]["name"] + " " + contracts[j]["address"]); - } catch (error) { - continue; - } - } } + return; // ################################# /VERIFY CONTRACTS WITH REPO ################################# // ################################# VERIFY CONTRACTS SETUP ################################# const globalNames = { - "mainnet": "scripts/deployment/globals_mainnet.json", - "goerli": "scripts/deployment/globals_goerli.json", + "mainnet": "scripts/deployment/globals_mainnet.json" }; const providerLinks = { - "mainnet": "https://eth-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY_MAINNET, - "goerli": "https://eth-goerli.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY_GOERLI, + "mainnet": "https://eth-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY_MAINNET }; // Get all the globals processed @@ -318,29 +302,27 @@ async function main() { console.log("\nVerifying deployed contracts setup... If no error is output, then the contracts are correct."); // L1 contracts - for (let i = 0; i < 2; i++) { - console.log("\n######## Verifying setup on CHAIN ID", configs[i]["chainId"]); + console.log("\n######## Verifying setup on CHAIN ID", configs[i]["chainId"]); - const initLog = "ChainId: " + configs[i]["chainId"] + ", network: " + configs[i]["name"]; + const initLog = "ChainId: " + configs[i]["chainId"] + ", network: " + configs[i]["name"]; - let log = initLog + ", contract: " + "DonatorBlacklist"; - await checkDonatorBlacklist(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "DonatorBlacklist", log); + let log = initLog + ", contract: " + "DonatorBlacklist"; + await checkDonatorBlacklist(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "DonatorBlacklist", log); - log = initLog + ", contract: " + "TokenomicsProxy"; - await checkTokenomicsProxy(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "TokenomicsProxy", log); + log = initLog + ", contract: " + "TokenomicsProxy"; + await checkTokenomicsProxy(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "TokenomicsProxy", log); - log = initLog + ", contract: " + "Treasury"; - await checkTreasury(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Treasury", log); + log = initLog + ", contract: " + "Treasury"; + await checkTreasury(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Treasury", log); - log = initLog + ", contract: " + "GenericBondCalculator"; - await checkGenericBondCalculator(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "GenericBondCalculator", log); + log = initLog + ", contract: " + "GenericBondCalculator"; + await checkGenericBondCalculator(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "GenericBondCalculator", log); - log = initLog + ", contract: " + "Dispenser"; - await checkDispenser(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Dispenser", log); + log = initLog + ", contract: " + "Dispenser"; + await checkDispenser(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Dispenser", log); - log = initLog + ", contract: " + "Depository"; - await checkDepository(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Depository", log); - } + log = initLog + ", contract: " + "Depository"; + await checkDepository(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Depository", log); // ################################# /VERIFY CONTRACTS SETUP ################################# } From 5e43d545806f8e2d6e8ffd8190d7d704bf663d5f Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 19:16:21 +0100 Subject: [PATCH 7/9] chore: static audit --- scripts/audit_chains/audit_contracts_setup.js | 522 ++++++++++++++++-- .../staking/celo/globals_celo_mainnet.json | 2 +- 2 files changed, 487 insertions(+), 37 deletions(-) diff --git a/scripts/audit_chains/audit_contracts_setup.js b/scripts/audit_chains/audit_contracts_setup.js index 62428523..f56f9e51 100644 --- a/scripts/audit_chains/audit_contracts_setup.js +++ b/scripts/audit_chains/audit_contracts_setup.js @@ -3,6 +3,7 @@ const { ethers } = require("ethers"); const { expect } = require("chai"); const fs = require("fs"); +const AddressZero = ethers.constants.AddressZero; // Custom expect that is wrapped into try / catch block function customExpect(arg1, arg2, log) { @@ -58,10 +59,18 @@ async function checkBytecode(provider, configContracts, contractName, log) { } // Find the contract name from the configuration data -async function findContractInstance(provider, configContracts, contractName) { +// idx is to choose the contract, if there are more than one +async function findContractInstance(provider, configContracts, contractName, idx = 0) { + let numFound = 0; // Get the contract number from the set of configuration contracts for (let i = 0; i < configContracts.length; i++) { if (configContracts[i]["name"] === contractName) { + // Keep searching if needed idx is not found + if (numFound != idx) { + numFound++; + continue; + } + // Get the contract instance let contractFromJSON = fs.readFileSync(configContracts[i]["artifact"], "utf8"); @@ -127,7 +136,7 @@ async function checkTokenomicsProxy(chainId, provider, globalsInstance, configCo const implementationHash = await tokenomics.PROXY_TOKENOMICS(); const implementation = await provider.getStorageAt(tokenomics.address, implementationHash); // Need to extract address size of bytes from the storage return value - customExpect("0x" + implementation.slice(-40), globalsInstance["tokenomicsTwoAddress"].toLowerCase(), + customExpect("0x" + implementation.slice(-40), globalsInstance["tokenomicsThreeAddress"].toLowerCase(), log + ", function: PROXY_TOKENOMICS()"); } @@ -166,7 +175,7 @@ async function checkTreasury(chainId, provider, globalsInstance, configContracts // Check paused const paused = await treasury.paused(); - customExpect(paused, false, log + ", function: paused()"); + customExpect(paused, 1, log + ", function: paused()"); } // Check Generic Bond Calculator: chain Id, provider, parsed globals, configuration contracts, contract name @@ -247,6 +256,372 @@ async function checkDepository(chainId, provider, globalsInstance, configContrac customExpect(minVesting, 3600 * 24, log + ", function: VERSION()"); } +// Check DepositProcessorL1: contract, globalsInstance +async function checkDepositProcessorL1(depositProcessorL1, globalsInstance, log) { + log += ", address: " + depositProcessorL1.address; + // Check contract owner + const owner = await depositProcessorL1.owner(); + customExpect(owner, AddressZero, log + ", function: owner()"); + + // Check L1 OLAS token + const olas = await depositProcessorL1.olas(); + customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()"); + + // Check L1 dispenser + const dispenser = await depositProcessorL1.l1Dispenser(); + customExpect(dispenser, globalsInstance["dispenserAddress"], log + ", function: dispenser ()"); +} + +// Check ArbitrumDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkArbitrumDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const arbitrumDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + arbitrumDepositProcessorL1.address; + await checkDepositProcessorL1(arbitrumDepositProcessorL1, globalsInstance, log); + + // Check L1 token relayer + const l1TokenRelayer = await arbitrumDepositProcessorL1.l1TokenRelayer(); + customExpect(l1TokenRelayer, globalsInstance["arbitrumL1ERC20GatewayRouterAddress"], log + ", function: l1TokenRelayer()"); + + // Check L1 message relayer + const l1MessageRelayer = await arbitrumDepositProcessorL1.l1MessageRelayer(); + customExpect(l1MessageRelayer, globalsInstance["arbitrumInboxAddress"], log + ", function: l1MessageRelayer()"); + + // Check L2 target chain Id + const l2TargetChainId = await arbitrumDepositProcessorL1.l2TargetChainId(); + customExpect(l2TargetChainId.toString(), globalsInstance["arbitrumL2TargetChainId"], log + ", function: l2TargetChainId()"); + + // Check L1 ERC20Gateway + const l1ERC20Gateway = await arbitrumDepositProcessorL1.l1ERC20Gateway(); + customExpect(l1ERC20Gateway, globalsInstance["arbitrumL1ERC20GatewayAddress"], log + ", function: l1ERC20Gateway()"); + + // Check L1 outbox + const outbox = await arbitrumDepositProcessorL1.outbox(); + customExpect(outbox, globalsInstance["arbitrumOutboxAddress"], log + ", function: outbox()"); + + // Check L1 bridge + const bridge = await arbitrumDepositProcessorL1.bridge(); + customExpect(bridge, globalsInstance["arbitrumBridgeAddress"], log + ", function: bridge()"); +} + +// Check checkEthereumDepositProcessor: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkEthereumDepositProcessor(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const ethereumDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + ethereumDepositProcessorL1.address; + // Check OLAS token + const olas = await ethereumDepositProcessorL1.olas(); + customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()"); + + // Check dispenser + const dispenser = await ethereumDepositProcessorL1.dispenser(); + customExpect(dispenser, globalsInstance["dispenserAddress"], log + ", function: dispenser()"); + + // Check L1 staking factory + const stakingFactory = await ethereumDepositProcessorL1.stakingFactory(); + customExpect(stakingFactory, globalsInstance["serviceStakingFactoryAddress"], log + ", function: stakingFactory()"); + + // Check L1 timelock + const timelock = await ethereumDepositProcessorL1.timelock(); + customExpect(timelock, globalsInstance["timelockAddress"], log + ", function: timelock()"); +} + +// Check GnosisDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkGnosisDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const gnosisDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + gnosisDepositProcessorL1.address; + await checkDepositProcessorL1(gnosisDepositProcessorL1, globalsInstance, log); + + // Check L1 token relayer + const l1TokenRelayer = await gnosisDepositProcessorL1.l1TokenRelayer(); + customExpect(l1TokenRelayer, globalsInstance["gnosisOmniBridgeAddress"], log + ", function: l1TokenRelayer()"); + + // Check L1 message relayer + const l1MessageRelayer = await gnosisDepositProcessorL1.l1MessageRelayer(); + customExpect(l1MessageRelayer, globalsInstance["gnosisAMBForeignAddress"], log + ", function: l1MessageRelayer()"); + + // Check L2 target chain Id + const l2TargetChainId = await gnosisDepositProcessorL1.l2TargetChainId(); + customExpect(l2TargetChainId.toString(), globalsInstance["gnosisL2TargetChainId"], log + ", function: l2TargetChainId()"); +} + +// Check OptimismDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkOptimismDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const optimismDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName, 1); + + log += ", address: " + optimismDepositProcessorL1.address; + await checkDepositProcessorL1(optimismDepositProcessorL1, globalsInstance, log); + + // Check L1 token relayer + const l1TokenRelayer = await optimismDepositProcessorL1.l1TokenRelayer(); + customExpect(l1TokenRelayer, globalsInstance["optimisticL1StandardBridgeProxyAddress"], log + ", function: l1TokenRelayer()"); + + // Check L1 message relayer + const l1MessageRelayer = await optimismDepositProcessorL1.l1MessageRelayer(); + customExpect(l1MessageRelayer, globalsInstance["optimisticL1CrossDomainMessengerProxyAddress"], log + ", function: l1MessageRelayer()"); + + // Check L2 target chain Id + const l2TargetChainId = await optimismDepositProcessorL1.l2TargetChainId(); + customExpect(l2TargetChainId.toString(), globalsInstance["optimisticL2TargetChainId"], log + ", function: l2TargetChainId()"); + + // Check L2 OLAS address + const olasL2 = await optimismDepositProcessorL1.olasL2(); + customExpect(olasL2, globalsInstance["optimisticOLASAddress"], log + ", function: olasL2()"); +} + +// Check BaseDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkBaseDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const baseDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + baseDepositProcessorL1.address; + await checkDepositProcessorL1(baseDepositProcessorL1, globalsInstance, log); + + // Check L1 token relayer + const l1TokenRelayer = await baseDepositProcessorL1.l1TokenRelayer(); + customExpect(l1TokenRelayer, globalsInstance["baseL1StandardBridgeProxyAddress"], log + ", function: l1TokenRelayer()"); + + // Check L1 message relayer + const l1MessageRelayer = await baseDepositProcessorL1.l1MessageRelayer(); + customExpect(l1MessageRelayer, globalsInstance["baseL1CrossDomainMessengerProxyAddress"], log + ", function: l1MessageRelayer()"); + + // Check L2 target chain Id + const l2TargetChainId = await baseDepositProcessorL1.l2TargetChainId(); + customExpect(l2TargetChainId.toString(), globalsInstance["baseL2TargetChainId"], log + ", function: l2TargetChainId()"); + + // Check L2 OLAS address + const olasL2 = await baseDepositProcessorL1.olasL2(); + customExpect(olasL2, globalsInstance["baseOLASAddress"], log + ", function: olasL2()"); +} + +// Check PolygonDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkPolygonDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const polygonDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + polygonDepositProcessorL1.address; + await checkDepositProcessorL1(polygonDepositProcessorL1, globalsInstance, log); + + // Check L1 token relayer + const l1TokenRelayer = await polygonDepositProcessorL1.l1TokenRelayer(); + customExpect(l1TokenRelayer, globalsInstance["polygonRootChainManagerProxyAddress"], log + ", function: l1TokenRelayer()"); + + // Check L1 message relayer + const l1MessageRelayer = await polygonDepositProcessorL1.l1MessageRelayer(); + customExpect(l1MessageRelayer, globalsInstance["polygonFXRootAddress"], log + ", function: l1MessageRelayer()"); + + // Check L2 target chain Id + const l2TargetChainId = await polygonDepositProcessorL1.l2TargetChainId(); + customExpect(l2TargetChainId.toString(), globalsInstance["polygonL2TargetChainId"], log + ", function: l2TargetChainId()"); + + // Check L1 checkpoint manager + const checkpointManager = await polygonDepositProcessorL1.checkpointManager(); + customExpect(checkpointManager, globalsInstance["polygonCheckpointManagerAddress"], log + ", function: checkpointManager()"); + + // Check L1 predicate + const predicate = await polygonDepositProcessorL1.predicate(); + customExpect(predicate, globalsInstance["polygonERC20PredicateAddress"], log + ", function: predicate()"); +} + +// Check CeloDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkCeloDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const celoDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + celoDepositProcessorL1.address; + await checkDepositProcessorL1(celoDepositProcessorL1, globalsInstance, log); + + // Check L1 token relayer + const l1TokenRelayer = await celoDepositProcessorL1.l1TokenRelayer(); + customExpect(l1TokenRelayer, globalsInstance["wormholeL1TokenRelayerAddress"], log + ", function: l1TokenRelayer()"); + + // Check L1 message relayer + const l1MessageRelayer = await celoDepositProcessorL1.l1MessageRelayer(); + customExpect(l1MessageRelayer, globalsInstance["wormholeL1MessageRelayerAddress"], log + ", function: l1MessageRelayer()"); + + // Check L2 target chain Id + const l2TargetChainId = await celoDepositProcessorL1.l2TargetChainId(); + customExpect(l2TargetChainId.toString(), globalsInstance["celoL2TargetChainId"], log + ", function: l2TargetChainId()"); + + // Check L1 wormhole core + const wormhole = await celoDepositProcessorL1.wormhole(); + customExpect(wormhole, globalsInstance["wormholeL1CoreAddress"], log + ", function: wormhole()"); + + // Check L2 wormhole chain Id format + const wormholeTargetChainId = await celoDepositProcessorL1.wormholeTargetChainId(); + customExpect(wormholeTargetChainId.toString(), globalsInstance["celoWormholeL2TargetChainId"], log + ", function: wormholeTargetChainId()"); +} + +// Check TargetDispenserL2: contract, globalsInstance +async function checkTargetDispenserL2(targetDispenserL2, globalsInstance, log) { + log += ", address: " + targetDispenserL2.address; + // Check contract owner + const owner = await targetDispenserL2.owner(); + customExpect(owner, globalsInstance["bridgeMediatorAddress"], log + ", function: owner()"); + + // Check L2 OLAS token + const olas = await targetDispenserL2.olas(); + customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()"); + + // Check L2 staking factory + const stakingFactory = await targetDispenserL2.stakingFactory(); + customExpect(stakingFactory, globalsInstance["serviceStakingFactoryAddress"], log + ", function: stakingFactory()"); + + // Check L1 source chain Id + const l1SourceChainId = await targetDispenserL2.l1SourceChainId(); + customExpect(l1SourceChainId.toString(), globalsInstance["l1ChainId"], log + ", function: l1SourceChainId()"); +} + +// Check PolygonTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkPolygonTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const polygonTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + polygonTargetDispenserL2.address; + await checkTargetDispenserL2(polygonTargetDispenserL2, globalsInstance, log); + + // Check L2 message relayer + const l2MessageRelayer = await polygonTargetDispenserL2.l2MessageRelayer(); + customExpect(l2MessageRelayer, globalsInstance["polygonFXChildAddress"], log + ", function: l2MessageRelayer()"); + + // Check L1 deposit processor + const l1DepositProcessor = await polygonTargetDispenserL2.l1DepositProcessor(); + customExpect(l1DepositProcessor, globalsInstance["polygonDepositProcessorL1Address"], log + ", function: l1DepositProcessor()"); +} + +// Check GnosisTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkGnosisTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const gnosisTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + gnosisTargetDispenserL2.address; + await checkTargetDispenserL2(gnosisTargetDispenserL2, globalsInstance, log); + + // Check L2 message relayer + const l2MessageRelayer = await gnosisTargetDispenserL2.l2MessageRelayer(); + customExpect(l2MessageRelayer, globalsInstance["gnosisAMBHomeAddress"], log + ", function: l2MessageRelayer()"); + + // Check L1 deposit processor + const l1DepositProcessor = await gnosisTargetDispenserL2.l1DepositProcessor(); + customExpect(l1DepositProcessor, globalsInstance["gnosisDepositProcessorL1Address"], log + ", function: l1DepositProcessor()"); +} + +// Check ArbitrumTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkArbitrumTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const arbitrumTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + arbitrumTargetDispenserL2.address; + await checkTargetDispenserL2(arbitrumTargetDispenserL2, globalsInstance, log); + + // Check L2 message relayer + const l2MessageRelayer = await arbitrumTargetDispenserL2.l2MessageRelayer(); + customExpect(l2MessageRelayer, globalsInstance["arbitrumArbSysAddress"], log + ", function: l2MessageRelayer()"); + + // Check L1 deposit processor + const l1DepositProcessor = await arbitrumTargetDispenserL2.l1DepositProcessor(); + customExpect(l1DepositProcessor, globalsInstance["arbitrumDepositProcessorL1Address"], log + ", function: l1DepositProcessor()"); +} + +// Check OptimismTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkOptimismTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const optimismTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + optimismTargetDispenserL2.address; + await checkTargetDispenserL2(optimismTargetDispenserL2, globalsInstance, log); + + // Check L2 message relayer + const l2MessageRelayer = await optimismTargetDispenserL2.l2MessageRelayer(); + customExpect(l2MessageRelayer, globalsInstance["optimisticL2CrossDomainMessengerAddress"], log + ", function: l2MessageRelayer()"); + + // Check L1 deposit processor + const l1DepositProcessor = await optimismTargetDispenserL2.l1DepositProcessor(); + customExpect(l1DepositProcessor, globalsInstance["optimismDepositProcessorL1Address"], log + ", function: l1DepositProcessor()"); +} + +// Check BaseTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkBaseTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const baseTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + baseTargetDispenserL2.address; + await checkTargetDispenserL2(baseTargetDispenserL2, globalsInstance, log); + + // Check L2 message relayer + const l2MessageRelayer = await baseTargetDispenserL2.l2MessageRelayer(); + customExpect(l2MessageRelayer, globalsInstance["baseL2CrossDomainMessengerAddress"], log + ", function: l2MessageRelayer()"); + + // Check L1 deposit processor + const l1DepositProcessor = await baseTargetDispenserL2.l1DepositProcessor(); + customExpect(l1DepositProcessor, globalsInstance["baseDepositProcessorL1Address"], log + ", function: l1DepositProcessor()"); +} + +// Check CeloTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name +async function checkCeloTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) { + // Check the bytecode + await checkBytecode(provider, configContracts, contractName, log); + + // Get the contract instance + const celoTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName); + + log += ", address: " + celoTargetDispenserL2.address; + await checkTargetDispenserL2(celoTargetDispenserL2, globalsInstance, log); + + // Check L2 message relayer + const l2MessageRelayer = await celoTargetDispenserL2.l2MessageRelayer(); + customExpect(l2MessageRelayer, globalsInstance["wormholeL2MessageRelayer"], log + ", function: l2MessageRelayer()"); + + // Check L1 deposit processor + const l1DepositProcessor = await celoTargetDispenserL2.l1DepositProcessor(); + customExpect(l1DepositProcessor, globalsInstance["celoDepositProcessorL1Address"], log + ", function: l1DepositProcessor()"); + + // Check L2 wormhole core + const wormhole = await celoTargetDispenserL2.wormhole(); + customExpect(wormhole, globalsInstance["wormholeL2CoreAddress"], log + ", function: wormhole()"); +} + async function main() { // Check for the API keys if (!process.env.ALCHEMY_API_KEY_MAINNET || !process.env.ALCHEMY_API_KEY_SEPOLIA || @@ -261,68 +636,143 @@ async function main() { const configs = JSON.parse(dataFromJSON); // ################################# VERIFY CONTRACTS WITH REPO ################################# - console.log("\nVerifying deployed contracts vs the repo... If no error is output, then the contracts are correct."); - - // Currently the verification is fo mainnet only - const network = "etherscan"; - const contracts = configs[0]["contracts"]; - - // Verify contracts - for (let i = 0; i < contracts.length; i++) { - console.log("Checking " + contracts[i]["name"]); - const execSync = require("child_process").execSync; - try { - execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[i]["name"] + " " + contracts[i]["address"]); - } catch (error) { - continue; - } - } - return; +// console.log("\nVerifying deployed contracts vs the repo... If no error is output, then the contracts are correct."); +// +// // Currently the verification is fo mainnet only +// const network = "etherscan"; +// const contracts = configs[0]["contracts"]; +// +// // Verify contracts +// for (let i = 0; i < contracts.length; i++) { +// console.log("Checking " + contracts[i]["name"]); +// const execSync = require("child_process").execSync; +// try { +// execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[i]["name"] + " " + contracts[i]["address"]); +// } catch (error) { +// continue; +// } +// } // ################################# /VERIFY CONTRACTS WITH REPO ################################# // ################################# VERIFY CONTRACTS SETUP ################################# const globalNames = { - "mainnet": "scripts/deployment/globals_mainnet.json" + "mainnet": "scripts/deployment/globals_mainnet.json", + "polygon": "scripts/deployment/staking/polygon/globals_polygon_mainnet.json", + "gnosis": "scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json", + "arbitrumOne": "scripts/deployment/staking/arbitrum/globals_arbitrum_one.json", + "optimistic": "scripts/deployment/staking/optimistic/globals_optimistic_mainnet.json", + "base": "scripts/deployment/staking/base/globals_base_mainnet.json", + "celo": "scripts/deployment/staking/celo/globals_celo_mainnet.json" }; + const globals = new Array(); + for (let k in globalNames) { + const dataJSON = fs.readFileSync(globalNames[k], "utf8"); + globals.push(JSON.parse(dataJSON)); + } + // Special case for staking (also on L1) + const dataJSON = fs.readFileSync("scripts/deployment/staking/globals_mainnet.json", "utf8"); + const globalsStaking = JSON.parse(dataJSON); + + const providerLinks = { - "mainnet": "https://eth-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY_MAINNET + "mainnet": "https://eth-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY_MAINNET, + "polygon": "https://polygon-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY_MATIC, + "gnosis": "https://rpc.gnosischain.com", + "arbitrumOne": "https://arb1.arbitrum.io/rpc", + "optimistic": "https://optimism.drpc.org", + "base": "https://mainnet.base.org", + "celo": "https://forno.celo.org" }; - // Get all the globals processed - const globals = new Array(); const providers = new Array(); - for (let i = 0; i < numChains; i++) { - const dataJSON = fs.readFileSync(globalNames[configs[i]["name"]], "utf8"); - globals.push(JSON.parse(dataJSON)); - const provider = new ethers.providers.JsonRpcProvider(providerLinks[configs[i]["name"]]); + for (let k in providerLinks) { + const provider = new ethers.providers.JsonRpcProvider(providerLinks[k]); providers.push(provider); } console.log("\nVerifying deployed contracts setup... If no error is output, then the contracts are correct."); // L1 contracts - console.log("\n######## Verifying setup on CHAIN ID", configs[i]["chainId"]); + console.log("\n######## Verifying setup on CHAIN ID", configs[0]["chainId"]); - const initLog = "ChainId: " + configs[i]["chainId"] + ", network: " + configs[i]["name"]; + let initLog = "ChainId: " + configs[0]["chainId"] + ", network: " + configs[0]["name"]; let log = initLog + ", contract: " + "DonatorBlacklist"; - await checkDonatorBlacklist(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "DonatorBlacklist", log); + await checkDonatorBlacklist(configs[0]["chainId"], providers[0], globals[0], configs[0]["contracts"], "DonatorBlacklist", log); log = initLog + ", contract: " + "TokenomicsProxy"; - await checkTokenomicsProxy(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "TokenomicsProxy", log); + await checkTokenomicsProxy(configs[0]["chainId"], providers[0], globals[0], configs[0]["contracts"], "TokenomicsProxy", log); log = initLog + ", contract: " + "Treasury"; - await checkTreasury(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Treasury", log); + await checkTreasury(configs[0]["chainId"], providers[0], globals[0], configs[0]["contracts"], "Treasury", log); log = initLog + ", contract: " + "GenericBondCalculator"; - await checkGenericBondCalculator(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "GenericBondCalculator", log); + await checkGenericBondCalculator(configs[0]["chainId"], providers[0], globals[0], configs[0]["contracts"], "GenericBondCalculator", log); log = initLog + ", contract: " + "Dispenser"; - await checkDispenser(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Dispenser", log); + await checkDispenser(configs[0]["chainId"], providers[0], globals[0], configs[0]["contracts"], "Dispenser", log); log = initLog + ", contract: " + "Depository"; - await checkDepository(configs[i]["chainId"], providers[i], globals[i], configs[i]["contracts"], "Depository", log); + await checkDepository(configs[0]["chainId"], providers[0], globals[0], configs[0]["contracts"], "Depository", log); + + log = initLog + ", contract: " + "ArbitrumDepositProcessorL1"; + await checkArbitrumDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "ArbitrumDepositProcessorL1", log); + + log = initLog + ", contract: " + "EthereumDepositProcessor"; + await checkEthereumDepositProcessor(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "EthereumDepositProcessor", log); + + log = initLog + ", contract: " + "GnosisDepositProcessorL1"; + await checkGnosisDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "GnosisDepositProcessorL1", log); + + log = initLog + ", contract: " + "OptimismDepositProcessorL1"; + await checkOptimismDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "OptimismDepositProcessorL1", log); + + log = initLog + ", contract: " + "BaseDepositProcessorL1"; + await checkBaseDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "OptimismDepositProcessorL1", log); + + log = initLog + ", contract: " + "PolygonDepositProcessorL1"; + await checkPolygonDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "PolygonDepositProcessorL1", log); + + log = initLog + ", contract: " + "CeloDepositProcessorL1"; + await checkCeloDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "WormholeDepositProcessorL1", log); + + // L2 contracts + // Polygon + console.log("\n######## Verifying setup on CHAIN ID", configs[11]["chainId"]); + initLog = "ChainId: " + configs[11]["chainId"] + ", network: " + configs[11]["name"]; + log = initLog + ", contract: " + "PolygonTargetDispenserL2"; + await checkPolygonTargetDispenserL2(configs[11]["chainId"], providers[1], globals[1], configs[11]["contracts"], "PolygonTargetDispenserL2", log); + + // Gnosis + console.log("\n######## Verifying setup on CHAIN ID", configs[7]["chainId"]); + initLog = "ChainId: " + configs[7]["chainId"] + ", network: " + configs[7]["name"]; + log = initLog + ", contract: " + "GnosisTargetDispenserL2"; + await checkGnosisTargetDispenserL2(configs[7]["chainId"], providers[2], globals[2], configs[7]["contracts"], "GnosisTargetDispenserL2", log); + + // Arbitrum + console.log("\n######## Verifying setup on CHAIN ID", configs[1]["chainId"]); + initLog = "ChainId: " + configs[1]["chainId"] + ", network: " + configs[1]["name"]; + log = initLog + ", contract: " + "ArbitrumTargetDispenserL2"; + await checkArbitrumTargetDispenserL2(configs[1]["chainId"], providers[3], globals[3], configs[1]["contracts"], "ArbitrumTargetDispenserL2", log); + + // Optimism + console.log("\n######## Verifying setup on CHAIN ID", configs[9]["chainId"]); + initLog = "ChainId: " + configs[9]["chainId"] + ", network: " + configs[9]["name"]; + log = initLog + ", contract: " + "OptimismTargetDispenserL2"; + await checkOptimismTargetDispenserL2(configs[9]["chainId"], providers[4], globals[4], configs[9]["contracts"], "OptimismTargetDispenserL2", log); + + // Base + console.log("\n######## Verifying setup on CHAIN ID", configs[3]["chainId"]); + initLog = "ChainId: " + configs[3]["chainId"] + ", network: " + configs[3]["name"]; + log = initLog + ", contract: " + "BaseTargetDispenserL2"; + await checkBaseTargetDispenserL2(configs[3]["chainId"], providers[5], globals[5], configs[3]["contracts"], "OptimismTargetDispenserL2", log); + + // Celo + console.log("\n######## Verifying setup on CHAIN ID", configs[5]["chainId"]); + initLog = "ChainId: " + configs[5]["chainId"] + ", network: " + configs[5]["name"]; + log = initLog + ", contract: " + "CeloTargetDispenserL2"; + await checkCeloTargetDispenserL2(configs[5]["chainId"], providers[6], globals[6], configs[5]["contracts"], "WormholeTargetDispenserL2", log); // ################################# /VERIFY CONTRACTS SETUP ################################# } diff --git a/scripts/deployment/staking/celo/globals_celo_mainnet.json b/scripts/deployment/staking/celo/globals_celo_mainnet.json index 69e8f1aa..a6d7d552 100644 --- a/scripts/deployment/staking/celo/globals_celo_mainnet.json +++ b/scripts/deployment/staking/celo/globals_celo_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"celo","networkURL":"https://forno.celo.org","gasPriceInGwei":"2","olasAddress":"0xaCFfAe8e57Ec6E394Eb1b41939A8CF7892DbDc51","serviceStakingFactoryAddress":"0x1c2cD884127b080F940b7546c1e9aaf525b1FA55","bridgeMediatorAddress":"0x397125902ED2cA2d42104F621f448A2cE1bC8Fb7","wormholeL2CoreAddress":"0xa321448d90d4e5b0A732867c18eA198e75CAC48E","wormholeL2TokenRelayerAddress":"0x796Dff6D74F3E27060B71255Fe517BFb23C93eed","wormholeL2MessageRelayer":"0x27428DD2d3DD32A4D7f7C497eAaa23130d894911","wormholel1ChainId":"2","celoDepositProcessorL1Address":"0x223902b6C583f18E8dc84AF4E6a8fa523d088B78","celoTargetDispenserL2Address":"0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"celo","networkURL":"https://forno.celo.org","gasPriceInGwei":"2","olasAddress":"0xaCFfAe8e57Ec6E394Eb1b41939A8CF7892DbDc51","serviceStakingFactoryAddress":"0x1c2cD884127b080F940b7546c1e9aaf525b1FA55","bridgeMediatorAddress":"0x397125902ED2cA2d42104F621f448A2cE1bC8Fb7","wormholeL2CoreAddress":"0xa321448d90d4e5b0A732867c18eA198e75CAC48E","wormholeL2TokenRelayerAddress":"0x796Dff6D74F3E27060B71255Fe517BFb23C93eed","wormholeL2MessageRelayer":"0x27428DD2d3DD32A4D7f7C497eAaa23130d894911","l1ChainId":"2","celoDepositProcessorL1Address":"0x223902b6C583f18E8dc84AF4E6a8fa523d088B78","celoTargetDispenserL2Address":"0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7"} \ No newline at end of file From b946818c103ddc6dbc07956cc7e2a4695573e7b7 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 19:26:16 +0100 Subject: [PATCH 8/9] chore: gitleaksignore --- .gitleaksignore | 2 ++ scripts/audit_chains/audit_contracts_setup.js | 32 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.gitleaksignore b/.gitleaksignore index b09343db..d8e0189d 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -188,3 +188,5 @@ e9945cd0dd6c8c0dc0fefda76d7f60e7ef56511b:scripts/deployment/staking/globals_sepo 3068b0eefad400612f18c193fa62e11974c0fbd5:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 b616524545db2768fb9a3772ffd05c6e0a7f2d8b:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:1 b616524545db2768fb9a3772ffd05c6e0a7f2d8b:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 +5e43d545806f8e2d6e8ffd8190d7d704bf663d5f:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:1 +5e43d545806f8e2d6e8ffd8190d7d704bf663d5f:scripts/deployment/staking/celo/globals_celo_mainnet.json:generic-api-key:2 diff --git a/scripts/audit_chains/audit_contracts_setup.js b/scripts/audit_chains/audit_contracts_setup.js index f56f9e51..112a4667 100644 --- a/scripts/audit_chains/audit_contracts_setup.js +++ b/scripts/audit_chains/audit_contracts_setup.js @@ -636,22 +636,22 @@ async function main() { const configs = JSON.parse(dataFromJSON); // ################################# VERIFY CONTRACTS WITH REPO ################################# -// console.log("\nVerifying deployed contracts vs the repo... If no error is output, then the contracts are correct."); -// -// // Currently the verification is fo mainnet only -// const network = "etherscan"; -// const contracts = configs[0]["contracts"]; -// -// // Verify contracts -// for (let i = 0; i < contracts.length; i++) { -// console.log("Checking " + contracts[i]["name"]); -// const execSync = require("child_process").execSync; -// try { -// execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[i]["name"] + " " + contracts[i]["address"]); -// } catch (error) { -// continue; -// } -// } + console.log("\nVerifying deployed contracts vs the repo... If no error is output, then the contracts are correct."); + + // Currently the verification is fo mainnet only + const network = "etherscan"; + const contracts = configs[0]["contracts"]; + + // Verify contracts + for (let i = 0; i < contracts.length; i++) { + console.log("Checking " + contracts[i]["name"]); + const execSync = require("child_process").execSync; + try { + execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[i]["name"] + " " + contracts[i]["address"]); + } catch (error) { + continue; + } + } // ################################# /VERIFY CONTRACTS WITH REPO ################################# // ################################# VERIFY CONTRACTS SETUP ################################# From 72084706adf0adab312ac082af3363cee3e39e0f Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 22 Jul 2024 20:03:15 +0100 Subject: [PATCH 9/9] chore: space --- scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json b/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json index d02dee98..8697e959 100644 --- a/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json +++ b/scripts/deployment/staking/gnosis/globals_gnosis_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL":"https://rpc.gnosischain.com","gasPriceInGwei":"5","olasAddress":"0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f","serviceStakingFactoryAddress":"0xb0228CA253A88Bc8eb4ca70BCAC8f87b381f4700","bridgeMediatorAddress": "0x15bd56669F57192a97dF41A2aa8f4403e9491776","gnosisAMBHomeAddress":"0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59","l1ChainId":"1","gnosisDepositProcessorL1Address":"0xEEf2c02cFC445bFFf1c891D486424Ef3aBc66AB0","gnosisTargetDispenserL2Address":"0x67722c823010CEb4BED5325fE109196C0f67D053"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL":"https://rpc.gnosischain.com","gasPriceInGwei":"5","olasAddress":"0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f","serviceStakingFactoryAddress":"0xb0228CA253A88Bc8eb4ca70BCAC8f87b381f4700","bridgeMediatorAddress":"0x15bd56669F57192a97dF41A2aa8f4403e9491776","gnosisAMBHomeAddress":"0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59","l1ChainId":"1","gnosisDepositProcessorL1Address":"0xEEf2c02cFC445bFFf1c891D486424Ef3aBc66AB0","gnosisTargetDispenserL2Address":"0x67722c823010CEb4BED5325fE109196C0f67D053"} \ No newline at end of file