From 18040143a39d4c3a5ce2a3d58bb5148f9aa74fcf Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Wed, 6 Nov 2024 18:01:15 +0000 Subject: [PATCH 1/2] chore: proposal for target dispenser L2 migration --- .../optimism/L1CrossDomainMessenger.json | 1 + abis/bridges/optimism/OptimismMessenger.json | 301 ++++++++++++++++++ .../proposal_11_migrate_l2_dispenser_mode.js | 93 ++++++ 3 files changed, 395 insertions(+) create mode 100644 abis/bridges/optimism/L1CrossDomainMessenger.json create mode 100644 abis/bridges/optimism/OptimismMessenger.json create mode 100644 scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js diff --git a/abis/bridges/optimism/L1CrossDomainMessenger.json b/abis/bridges/optimism/L1CrossDomainMessenger.json new file mode 100644 index 00000000..b8da6f20 --- /dev/null +++ b/abis/bridges/optimism/L1CrossDomainMessenger.json @@ -0,0 +1 @@ +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"}],"name":"FailedRelayedMessage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"}],"name":"RelayedMessage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"messageNonce","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"SentMessage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SentMessageExtension1","type":"event"},{"inputs":[],"name":"MESSAGE_VERSION","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_GAS_CALLDATA_OVERHEAD","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OTHER_MESSENGER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PORTAL","outputs":[{"internalType":"contract OptimismPortal","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RELAY_CALL_OVERHEAD","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RELAY_CONSTANT_OVERHEAD","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RELAY_GAS_CHECK_BUFFER","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RELAY_RESERVED_GAS","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"uint32","name":"_minGasLimit","type":"uint32"}],"name":"baseGas","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"failedMessages","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract OptimismPortal","name":"_portal","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"messageNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"portal","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_minGasLimit","type":"uint256"},{"internalType":"bytes","name":"_message","type":"bytes"}],"name":"relayMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"uint32","name":"_minGasLimit","type":"uint32"}],"name":"sendMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"successfulMessages","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"xDomainMessageSender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/abis/bridges/optimism/OptimismMessenger.json b/abis/bridges/optimism/OptimismMessenger.json new file mode 100644 index 00000000..39f99dc7 --- /dev/null +++ b/abis/bridges/optimism/OptimismMessenger.json @@ -0,0 +1,301 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "OptimismMessenger", + "sourceName": "contracts/bridges/OptimismMessenger.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_CDMContractProxyHome", + "type": "address" + }, + { + "internalType": "address", + "name": "_sourceGovernor", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "deliveryHash", + "type": "bytes32" + } + ], + "name": "AlreadyDelivered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "provided", + "type": "uint256" + } + ], + "name": "IncorrectDataLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "instance", + "type": "address" + } + ], + "name": "SelfCallOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "sourceGovernor", + "type": "address" + } + ], + "name": "SourceGovernorOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "sender", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "sourceGovernor", + "type": "bytes32" + } + ], + "name": "SourceGovernorOnly32", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "name": "TargetExecFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "targetRelayer", + "type": "address" + } + ], + "name": "TargetRelayerOnly", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "received", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "required", + "type": "uint256" + } + ], + "name": "WrongSourceChainId", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroValue", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "FundsReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sourceMessageSender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "MessageReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sourceGovernor", + "type": "address" + } + ], + "name": "SourceGovernorUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "CDMContractProxyHome", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_DATA_LENGTH", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newSourceGovernor", + "type": "address" + } + ], + "name": "changeSourceGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "processMessageFromSource", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "sourceGovernor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bytecode": "0x60a060405234801561001057600080fd5b50604051610b91380380610b9183398101604081905261002f916100ae565b6001600160a01b038216158061004c57506001600160a01b038116155b1561006a5760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03918216608052600080546001600160a01b031916919092161790556100e1565b80516001600160a01b03811681146100a957600080fd5b919050565b600080604083850312156100c157600080fd5b6100ca83610092565b91506100d860208401610092565b90509250929050565b608051610a816101106000396000818160b10152818161019a01528181610202015261027d0152610a816000f3fe60806040526004361061005e5760003560e01c8063e3b94a2311610043578063e3b94a2314610112578063f02fb7741461013f578063f8b4870f1461016257600080fd5b8063c84043301461009f578063d3042d2b146100fd57600080fd5b3661009a5760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100ab57600080fd5b506100d37f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61011061010b3660046107be565b610182565b005b34801561011e57600080fd5b506000546100d39073ffffffffffffffffffffffffffffffffffffffff1681565b34801561014b57600080fd5b50610154602481565b6040519081526020016100f4565b34801561016e57600080fd5b5061011061017d3660046108b2565b6103d0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610234576040517f2f3111fa00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b60008054604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff92831693927f00000000000000000000000000000000000000000000000000000000000000001691636e296e45916004808301926020929190829003018187875af11580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed91906108d6565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610374576040517f978c830c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528316602482015260440161022b565b61037d836104cb565b8173ffffffffffffffffffffffffffffffffffffffff167f3c64b439784b3c09eba93acf868463aed0e339a92920e1d8822118261dfc1a7d846040516103c39190610961565b60405180910390a2505050565b333014610411576040517f0dbc9bfc00000000000000000000000000000000000000000000000000000000815233600482015230602482015260440161022b565b73ffffffffffffffffffffffffffffffffffffffff811661045e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917fbbc9d5867fd60faf098cfaa8adb3402dd83501cc76385968ddbb6b2610800f8e91a250565b805160248110156105165781516040517f34c9027a00000000000000000000000000000000000000000000000000000000815261022b91602491600401918252602082015260400190565b60005b8181101561078a57828101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff8316610588576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff1611156105e6576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8316600482015247602482015260440161022b565b60008163ffffffff1667ffffffffffffffff8111156106075761060761078f565b6040519080825280601f01601f191660200182016040528015610631576020820181803683370190505b50905060005b8263ffffffff168110156106b457876106508288610974565b81518110610660576106606109b4565b602001015160f81c60f81b82828151811061067d5761067d6109b4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101610637565b506106c563ffffffff831686610974565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106fd91906109e3565b60006040518083038185875af1925050503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b5050905080610780578484836040517f6cfc79a500000000000000000000000000000000000000000000000000000000815260040161022b939291906109ff565b5050505050610519565b505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156107d057600080fd5b813567ffffffffffffffff808211156107e857600080fd5b818401915084601f8301126107fc57600080fd5b81358181111561080e5761080e61078f565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156108545761085461078f565b8160405282815287602084870101111561086d57600080fd5b826020860160208301376000928101602001929092525095945050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146108af57600080fd5b50565b6000602082840312156108c457600080fd5b81356108cf8161088d565b9392505050565b6000602082840312156108e857600080fd5b81516108cf8161088d565b60005b8381101561090e5781810151838201526020016108f6565b50506000910152565b6000815180845261092f8160208601602086016108f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006108cf6020830184610917565b808201808211156109ae577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082516109f58184602087016108f3565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610a426060830184610917565b9594505050505056fea2646970667358221220c8855bb8d138c809e71ccdac5baac500ad3deb2f38b2e82fe5572138dc23d8d064736f6c63430008170033", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c8063e3b94a2311610043578063e3b94a2314610112578063f02fb7741461013f578063f8b4870f1461016257600080fd5b8063c84043301461009f578063d3042d2b146100fd57600080fd5b3661009a5760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100ab57600080fd5b506100d37f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61011061010b3660046107be565b610182565b005b34801561011e57600080fd5b506000546100d39073ffffffffffffffffffffffffffffffffffffffff1681565b34801561014b57600080fd5b50610154602481565b6040519081526020016100f4565b34801561016e57600080fd5b5061011061017d3660046108b2565b6103d0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610234576040517f2f3111fa00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b60008054604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff92831693927f00000000000000000000000000000000000000000000000000000000000000001691636e296e45916004808301926020929190829003018187875af11580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed91906108d6565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610374576040517f978c830c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528316602482015260440161022b565b61037d836104cb565b8173ffffffffffffffffffffffffffffffffffffffff167f3c64b439784b3c09eba93acf868463aed0e339a92920e1d8822118261dfc1a7d846040516103c39190610961565b60405180910390a2505050565b333014610411576040517f0dbc9bfc00000000000000000000000000000000000000000000000000000000815233600482015230602482015260440161022b565b73ffffffffffffffffffffffffffffffffffffffff811661045e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917fbbc9d5867fd60faf098cfaa8adb3402dd83501cc76385968ddbb6b2610800f8e91a250565b805160248110156105165781516040517f34c9027a00000000000000000000000000000000000000000000000000000000815261022b91602491600401918252602082015260400190565b60005b8181101561078a57828101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff8316610588576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff1611156105e6576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8316600482015247602482015260440161022b565b60008163ffffffff1667ffffffffffffffff8111156106075761060761078f565b6040519080825280601f01601f191660200182016040528015610631576020820181803683370190505b50905060005b8263ffffffff168110156106b457876106508288610974565b81518110610660576106606109b4565b602001015160f81c60f81b82828151811061067d5761067d6109b4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101610637565b506106c563ffffffff831686610974565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106fd91906109e3565b60006040518083038185875af1925050503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b5050905080610780578484836040517f6cfc79a500000000000000000000000000000000000000000000000000000000815260040161022b939291906109ff565b5050505050610519565b505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156107d057600080fd5b813567ffffffffffffffff808211156107e857600080fd5b818401915084601f8301126107fc57600080fd5b81358181111561080e5761080e61078f565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156108545761085461078f565b8160405282815287602084870101111561086d57600080fd5b826020860160208301376000928101602001929092525095945050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146108af57600080fd5b50565b6000602082840312156108c457600080fd5b81356108cf8161088d565b9392505050565b6000602082840312156108e857600080fd5b81516108cf8161088d565b60005b8381101561090e5781810151838201526020016108f6565b50506000910152565b6000815180845261092f8160208601602086016108f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006108cf6020830184610917565b808201808211156109ae577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082516109f58184602087016108f3565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610a426060830184610917565b9594505050505056fea2646970667358221220c8855bb8d138c809e71ccdac5baac500ad3deb2f38b2e82fe5572138dc23d8d064736f6c63430008170033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js b/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js new file mode 100644 index 00000000..5eac881b --- /dev/null +++ b/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js @@ -0,0 +1,93 @@ +/*global process*/ + +const { ethers } = require("hardhat"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const provider = await ethers.providers.getDefaultProvider("mainnet"); + + const optimisticURL = "https://optimism.drpc.org"; + const optimisticProvider = new ethers.providers.JsonRpcProvider(optimisticURL); + + // Get EOAs + const account = ethers.utils.HDNode.fromMnemonic(process.env.TESTNET_MNEMONIC).derivePath("m/44'/60'/0'/0/0"); + const EOAmainnet = new ethers.Wallet(account, provider); + const EOAoptimistic = new ethers.Wallet(account, optimisticProvider); + + // CDMProxy address on mainnet + const CDMProxyAddress = parsedData.modeL1CrossDomainMessengerProxyAddress; + const CDMProxyJSON = "abis/bridges/optimism/L1CrossDomainMessenger.json"; + let contractFromJSON = fs.readFileSync(CDMProxyJSON, "utf8"); + const CDMProxyABI = JSON.parse(contractFromJSON); + const CDMProxy = new ethers.Contract(CDMProxyAddress, CDMProxyABI, provider); + + // OptimismMessenger address on Mode + const optimismMessengerAddress = "0x9338b5153AE39BB89f50468E608eD9d764B755fD"; + const optimismMessengerJSON = "abis/bridges/optimism/OptimismMessenger.json"; + contractFromJSON = fs.readFileSync(optimismMessengerJSON, "utf8"); + let parsedFile = JSON.parse(contractFromJSON); + const optimismMessengerABI = parsedFile["abi"]; + const optimismMessenger = new ethers.Contract(optimismMessengerAddress, optimismMessengerABI, optimisticProvider); + + // Get all the necessary contract addresses + const oldTargetDispenserL2Address = "0x47135D1Cf850d7Df7f7f563F300cc7022F7978a4"; + const targetDispenserL2Address = parsedData.modeTargetDispenserL2Address; + + // Get TargetDispenserL2 contracts + const oldTargetDispenserL2 = (await ethers.getContractAt("OptimismTargetDispenserL2", oldTargetDispenserL2Address)); + const targetDispenserL2 = (await ethers.getContractAt("OptimismTargetDispenserL2", targetDispenserL2Address)).connect(EOAoptimistic); + + // Bridge mediator to migrate TargetDispenserL2 funds and execute the undelivered data + const value = 0; + let target = oldTargetDispenserL2Address; + let rawPayload = oldTargetDispenserL2.interface.encodeFunctionData("migrate", [targetDispenserL2Address]); + // Pack the second part of data + let payload = ethers.utils.arrayify(rawPayload); + let data = ethers.utils.solidityPack( + ["address", "uint96", "uint32", "bytes"], + [target, value, payload.length, payload] + ); + + target = targetDispenserL2Address; + // Original un-delivered data: + // 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0e16c2d52963fd5d073b1f3907986b0a183c6e39399e5d8ef866c954b73886d7200000000000000000000000000000000000000000000000000000000000000010000000000000000000000005fc25f50e96857373c64dc0edb1abcbed4587e910000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000056a07b266954609c24 + // https://dashboard.tenderly.co/tx/mainnet/0xc947f7c5bc0c683ddb274030aa6e4d1305b0fc14bd17935598dc5b8a79922a5c/logs + const dataToProcess = ethers.utils.defaultAbiCoder.encode(["address[]", "uint256[]", "bytes32"], + [["0x5fc25f50e96857373c64dc0edb1abcbed4587e91"], ["1597983869041054358564"], "0xe16c2d52963fd5d073b1f3907986b0a183c6e39399e5d8ef866c954b73886d72"]); + rawPayload = targetDispenserL2.interface.encodeFunctionData("processDataMaintenance", [dataToProcess]); + payload = ethers.utils.arrayify(rawPayload); + data += ethers.utils.solidityPack( + ["address", "uint96", "uint32", "bytes"], + [target, value, payload.length, payload] + ).slice(2); + + // Proposal preparation + console.log("Proposal 11. Migrate funds from oldTargetDispenserL2Address to targetDispenserL2Address and re-deliver funds"); + // Build the bridge payload + const messengerPayload = await optimismMessenger.interface.encodeFunctionData("processMessageFromSource", [data]); + const minGasLimit = "2000000"; + // Build the final payload for the Timelock + const timelockPayload = await CDMProxy.interface.encodeFunctionData("sendMessage", [optimismMessengerAddress, + messengerPayload, minGasLimit]); + + const targets = [CDMProxyAddress]; + const values = [0]; + const callDatas = [timelockPayload]; + const description = "Migrate funds from oldTargetDispenserL2Address to targetDispenserL2Address and re-deliver funds"; + + // Proposal details + console.log("targets:", targets); + console.log("values:", values); + console.log("call datas:", callDatas); + console.log("description:", description); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); From 4de0bea2725a2be01136feee432658155840cf7b Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Tue, 19 Nov 2024 12:34:20 +0000 Subject: [PATCH 2/2] chore: proposal adjustment and addresses for Mode --- docs/configuration.json | 4 ++-- hardhat.config.js | 2 +- .../deployment/staking/mode/globals_mode_mainnet.json | 2 +- .../proposals/proposal_11_migrate_l2_dispenser_mode.js | 10 +++++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/configuration.json b/docs/configuration.json index 20545c4b..b40cc09c 100644 --- a/docs/configuration.json +++ b/docs/configuration.json @@ -76,7 +76,7 @@ { "name": "OptimismDepositProcessorL1", "artifact": "abis/0.8.28/OptimismDepositProcessorL1.json", - "address": "0x792CDB3c195E688F6dCEB0B7631510D03144087F" + "address": "0x1bCAE95aF8ce25b44Af3F8aA781a4E743eB4522f" } ] }, @@ -153,7 +153,7 @@ { "name": "OptimismTargetDispenserL2", "artifact": "abis/0.8.28/OptimismTargetDispenserL2.json", - "address": "0x47135D1Cf850d7Df7f7f563F300cc7022F7978a4" + "address": "0xc40C79C275F3fA1F3f4c723755C81ED2D53A8D81" } ] } diff --git a/hardhat.config.js b/hardhat.config.js index edc6eca9..10d05a06 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -62,7 +62,7 @@ module.exports = { chainId: 42161, }, optimistic: { - url: "https://optimism.llamarpc.com", + url: "https://optimism.drpc.org", accounts: accounts, chainId: 10, }, diff --git a/scripts/deployment/staking/mode/globals_mode_mainnet.json b/scripts/deployment/staking/mode/globals_mode_mainnet.json index 16f17bf1..955c380d 100644 --- a/scripts/deployment/staking/mode/globals_mode_mainnet.json +++ b/scripts/deployment/staking/mode/globals_mode_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"mode","networkURL":"https://mainnet.mode.network","gasPriceInGwei":"1","olasAddress":"0xcfD1D50ce23C46D3Cf6407487B2F8934e96DC8f9","serviceStakingFactoryAddress":"0x75D529FAe220bC8db714F0202193726b46881B76","bridgeMediatorAddress":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","modeL2CrossDomainMessengerAddress":"0x4200000000000000000000000000000000000007","l1ChainId":"1","modeDepositProcessorL1Address":"0x1bcae95af8ce25b44af3f8aa781a4e743eb4522f","modeTargetDispenserL2Address":"0xc40C79C275F3fA1F3f4c723755C81ED2D53A8D81"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"mode","networkURL":"https://mainnet.mode.network","gasPriceInGwei":"1","olasAddress":"0xcfD1D50ce23C46D3Cf6407487B2F8934e96DC8f9","serviceStakingFactoryAddress":"0x75D529FAe220bC8db714F0202193726b46881B76","bridgeMediatorAddress":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","modeL2CrossDomainMessengerAddress":"0x4200000000000000000000000000000000000007","l1ChainId":"1","modeDepositProcessorL1Address":"0x1bCAE95aF8ce25b44Af3F8aA781a4E743eB4522f","modeTargetDispenserL2Address":"0xc40C79C275F3fA1F3f4c723755C81ED2D53A8D81"} \ No newline at end of file diff --git a/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js b/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js index 5eac881b..01519972 100644 --- a/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js +++ b/scripts/proposals/proposal_11_migrate_l2_dispenser_mode.js @@ -43,7 +43,7 @@ async function main() { // Bridge mediator to migrate TargetDispenserL2 funds and execute the undelivered data const value = 0; let target = oldTargetDispenserL2Address; - let rawPayload = oldTargetDispenserL2.interface.encodeFunctionData("migrate", [targetDispenserL2Address]); + let rawPayload = oldTargetDispenserL2.interface.encodeFunctionData("pause", []); // Pack the second part of data let payload = ethers.utils.arrayify(rawPayload); let data = ethers.utils.solidityPack( @@ -51,6 +51,14 @@ async function main() { [target, value, payload.length, payload] ); + rawPayload = oldTargetDispenserL2.interface.encodeFunctionData("migrate", [targetDispenserL2Address]); + // Pack the second part of data + payload = ethers.utils.arrayify(rawPayload); + data += ethers.utils.solidityPack( + ["address", "uint96", "uint32", "bytes"], + [target, value, payload.length, payload] + ).slice(2); + target = targetDispenserL2Address; // Original un-delivered data: // 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0e16c2d52963fd5d073b1f3907986b0a183c6e39399e5d8ef866c954b73886d7200000000000000000000000000000000000000000000000000000000000000010000000000000000000000005fc25f50e96857373c64dc0edb1abcbed4587e910000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000056a07b266954609c24