diff --git a/script/input/5/integration.json b/script/input/5/integration.json new file mode 100644 index 0000000..f0591a3 --- /dev/null +++ b/script/input/5/integration.json @@ -0,0 +1,23 @@ +{ + "domains": { + "root": { + "rpc": "ETH_RPC_URL", + "chainlog": "0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F" + }, + "optimism": { + "rpc": "OPT_RPC_URL", + "l1Messenger": "0x5086d1eEF304eb5284A0f6720f79403b4e9bE294", + "l2Messenger": "0x4200000000000000000000000000000000000007" + }, + "arbitrum": { + "rpc": "ARB_RPC_URL", + "inbox": "0x6BEbC4925716945D46F0Ec336D5C2564F419682C", + "arbSys": "0x0000000000000000000000000000000000000064" + }, + "zkSync": { + "rpc": "ZKSYNC_RPC_URL", + "zkSyncMailbox": "0xcB3D5008e03Bf569dcdf17259Fa30726ED646931", + "l1MessengerContract": "0x0000000000000000000000000000000000008008" + } + } +} diff --git a/src/domains/ZKSyncDomain.sol b/src/domains/ZKSyncDomain.sol new file mode 100644 index 0000000..e9c08a1 --- /dev/null +++ b/src/domains/ZKSyncDomain.sol @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +// Copyright (C) 2022 Dai Foundation +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +pragma solidity >=0.8.0; + +import "forge-std/Vm.sol"; + +import { Domain, BridgedDomain } from "./BridgedDomain.sol"; + +contract ZKSyncDomain is BridgedDomain { + + address public immutable zkSyncMailbox; + address public immutable l1MessengerContract; + + bytes32 constant SENT_MESSAGE_TOPIC = keccak256("SentMessage(address,address,bytes,uint256,uint256)"); + + constructor(string memory _config, string memory _name, Domain _hostDomain) Domain(_config, _name) BridgedDomain(_hostDomain) { + zkSyncMailbox = MessengerLike(readConfigAddress("zkSyncMailbox")); + l1MessengerContract = MessengerLike(readConfigAddress("l1MessengerContract")); + vm.recordLogs(); + } + + function relayFromHost(bool switchToGuest) external override { + selectFork(); + address malias; + unchecked { + malias = address(uint160(address(l1Messenger)) + OFFSET); + } + + // Read all L1 -> L2 messages and relay them this fork + Vm.Log[] memory logs = vm.getRecordedLogs(); + for (uint256 i = 0; i < logs.length; i++) { + Vm.Log memory log = logs[i]; + if (log.topics[0] == SENT_MESSAGE_TOPIC) { + // TODO + } + } + + if (!switchToGuest) { + hostDomain.selectFork(); + } + } + + function relayToHost(bool switchToHost) external override { + hostDomain.selectFork(); + + // Read all L2 -> L1 messages and relay them under host fork + Vm.Log[] memory logs = vm.getRecordedLogs(); + for (uint256 i = 0; i < logs.length; i++) { + Vm.Log memory log = logs[i]; + if (log.topics[0] == SENT_MESSAGE_TOPIC) { + // TODO + } + } + + if (!switchToHost) { + selectFork(); + } + } + +}