Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Nov 14, 2023
2 parents 3051fb8 + ad95dbc commit 0af6beb
Show file tree
Hide file tree
Showing 13 changed files with 534 additions and 14 deletions.
18 changes: 13 additions & 5 deletions helix-contract/address/ln-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"axelarMessager": "0x037c7b64c80251Cf5C64Ed8f731c799Dc1856701",
"debugMessager": "0x2e8D237226041FAFe3F66b6cfc54b064923D454E"
},
"sepolia": {
"Eth2ScrollSendService": "0x89AF830781A2C1d3580Db930bea11094F55AfEae"
},
"arbitrum-goerli": {
"Eth2ArbReceiveService": "0x102F8D7Cfe692AA79c17E3958aB00D060Df0B88f",
"layerzeroMessager": "0x953bE65E685099277F1f09Ebe10746810dC0593D",
Expand All @@ -27,11 +30,11 @@
"axelarMessager": "0xbb593913a4f3E4eE77861f743c697A4cb95837eF",
"debugMessager": "0x84f7a56483C100ECb12CbB4A31b7873dAE0d8E9B"
},
"crab": {
"darwiniaMsglineMessager": "0xe6C6B5Ff91720ECda6B27bce2fBa490a25B2a015"
"base-goerli": {
"layerzeroMessager": "0x463D1730a8527CA58d48EF70C7460B9920346567"
},
"arbitrum-sepolia": {
"darwiniaMsglineMessager": "0x0c2D2918136E8341d630E12Cb8e9C60b453658B0"
"darwiniaMsglineMessager": "0xCddD3e43dA1e9485d4FcD3782DFba04aADCfC9B2"
}
},
"ProxyAdmin": {
Expand All @@ -54,7 +57,10 @@
"mantle-goerli": "0xDb06D904AC5Bdff3b8E6Ac96AFedd3381d94CFDD",
"arbitrum-goerli": "0x543bf1AC41485dc78039b9351563E4Dd13A288cb",
"linea-goerli": "0x8f3663930211f3DE17619FEB2eeB44c9c3F44a06",
"zksync-goerli": "0xb5372ed3bb2CbA63e7908066ac10ee94d30eA839"
"zksync-goerli": "0xb5372ed3bb2CbA63e7908066ac10ee94d30eA839",
"base-goerli": "0x876A4f6eCF13EEb101F9E75FCeF58f19Ff383eEB",
"sepolia": "0x876A4f6eCF13EEb101F9E75FCeF58f19Ff383eEB",
"scroll-sepolia": "0x9C80EdD342b5D179c3a87946fC1F0963BfcaAa09"
},
"usdc": {
"goerli": "0xe9784E0d9A939dbe966b021DE3cd877284DB1B99",
Expand All @@ -63,7 +69,9 @@
"linea-goerli": "0xeC89AF5FF618bbF667755BE9d63C69F21F1c00C8",
"zksync-goerli": "0xAe60e005C560E869a2bad271e38e3C9D78381aFF",
"crab": "0x4bA86B5D0F8D2DCB3FC23757cAA6EA71157F74E9",
"arbitrum-sepolia": "0x8A87497488073307E1a17e8A12475a94Afcb413f"
"arbitrum-sepolia": "0x8A87497488073307E1a17e8A12475a94Afcb413f",
"sepolia": "0x0ac58Df0cc3542beC4cDa71B16D06C3cCc39f405",
"scroll-sepolia": "0x8A87497488073307E1a17e8A12475a94Afcb413f"
},
"keyTool": {
"goerli": "0xCD45731FFF1b250e9433A1F1F5A609F3A19557A5"
Expand Down
37 changes: 32 additions & 5 deletions helix-contract/address/ln-product.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
"Eth2ArbSendService": "0x78a6831Da2293fbEFd0d8aFB4D1f7CBB751e0119"
},
"arbitrum": {
"Eth2ArbReceiveService": "0xc95D939Da72ECe8Bd794d42EaEd28974CDb0ADa2"
"Eth2ArbReceiveService": "0xc95D939Da72ECe8Bd794d42EaEd28974CDb0ADa2",
"LayerZeroMessager": "0x509354A4ebf98aCC7a65d2264694A65a2938cac9"
},
"polygon": {
"LayerZeroMessager": "0x463D1730a8527CA58d48EF70C7460B9920346567"
},
"zkSync": {
"LayerZeroMessager": "0x96892F3EaD26515592Da38432cFABad991BBd69d"
},
"mantle": {
"LayerZeroMessager": "0x61B6B8c7C00aA7F060a2BEDeE6b11927CC9c3eF1"
},
"scroll": {
"LayerZeroMessager": "0x463d1730a8527ca58d48ef70c7460b9920346567"
}
},
"ProxyAdmin": {
"common": "0x601dE3B81c7cE04BecE3b29e5cEe4F3251d250dB"
"common": "0x601dE3B81c7cE04BecE3b29e5cEe4F3251d250dB",
"zkSync": "0xA0d8a3C04580a8503ed3Ff30deBb22B83EE615F4"
},
"LnOppositeBridgeLogic": {
"common": "0x90873fa1bbd028F22277567530A22E05f7721D37"
Expand All @@ -17,14 +31,27 @@
"common": "0x48d769d5C7ff75703cDd1543A1a2ed9bC9044A23"
},
"LnDefaultBridgeLogic": {
"common": "0x8af688056c6614acb5A78c62e1f9f49022C0452f"
"common": "0x8af688056c6614acb5A78c62e1f9f49022C0452f",
"zkSync": "0xefD0DE72e407A55E9b624A91E6d5D6A0CE8490D1"
},
"LnDefaultBridgeProxy": {
"common": "0x94C614DAeFDbf151E1BB53d6A201ae5fF56A9337"
"common": "0x94C614DAeFDbf151E1BB53d6A201ae5fF56A9337",
"zkSync": "0x767Bc046c989f5e63683fB530f939DD34b91ceAC"
},
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3",
"ring": {
"arbitrum": "0x9e523234D36973f9e38642886197D023C88e307e",
"ethereum": "0x9469D013805bFfB7D3DEBe5E7839237e535ec483"
"ethereum": "0x9469D013805bFfB7D3DEBe5E7839237e535ec483",
"polygon": "0x9C1C23E60B72Bc88a043bf64aFdb16A02540Ae8f"
},
"usdt": {
"arbitrum": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
"mantle": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
"zkSync": "0x493257fD37EDB34451f62EDf8D2a0C418852bA4C",
"scroll": "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df"
},
"usdc": {
"arbitrum": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"mantle": "0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9"
}
}
44 changes: 44 additions & 0 deletions helix-contract/contracts/ln/messager/Eth2ScrollReceiveService.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "./interface/IScrollMessenger.sol";
import "../base/LnAccessController.sol";
import "../interface/ILowLevelMessager.sol";

// from ethereum to arbitrum messager
contract Eth2ScrollReceiveService is ILowLevelMessageReceiver, LnAccessController {
uint256 immutable public REMOTE_CHAINID;
address immutable public scrollMessager;
address public remoteMessager;

mapping(address=>address) public appPairs;

modifier onlyRemoteBridge() {
require(msg.sender == scrollMessager, "invalid caller");
require(remoteMessager == IScrollMessenger(scrollMessager).xDomainMessageSender(), "invalid remote caller");
_;
}

constructor(address _dao, address _scrollMessager, uint256 _remoteChainId) {
_initialize(_dao);
REMOTE_CHAINID = _remoteChainId;
scrollMessager = _scrollMessager;
}

function setRemoteMessager(address _remoteMessager) onlyDao external {
remoteMessager = _remoteMessager;
}

function registerRemoteSender(uint256 _remoteChainId, address _remoteBridge) onlyWhiteListCaller external {
require(_remoteChainId == REMOTE_CHAINID, "invalid remote chainId");
appPairs[msg.sender] = _remoteBridge;
}

function recvMessage(address _remoteApp, address _localApp, bytes memory _message) onlyRemoteBridge external {
address remoteAppAddress = appPairs[_localApp];
require(remoteAppAddress == _remoteApp, "invalid remote app");
(bool result,) = _localApp.call(_message);
require(result == true, "local call failed");
}
}

62 changes: 62 additions & 0 deletions helix-contract/contracts/ln/messager/Eth2ScrollSendService.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "./interface/IScrollMessenger.sol";
import "../base/LnAccessController.sol";
import "../interface/ILowLevelMessager.sol";

contract Eth2ScrollSendService is ILowLevelMessageSender, LnAccessController {
uint256 immutable public REMOTE_CHAINID;
IScrollMessenger immutable public scrollMessager;
address public remoteMessager;
mapping(address=>address) public appPairs;

constructor(address _dao, address _scrollMessager, uint256 _remoteChainId) {
_initialize(_dao);
scrollMessager = IScrollMessenger(_scrollMessager);
REMOTE_CHAINID = _remoteChainId;
}

function setRemoteMessager(address _remoteMessager) onlyDao external {
remoteMessager = _remoteMessager;
}

function registerRemoteReceiver(uint256 _remoteChainId, address _remoteBridge) onlyWhiteListCaller external {
require(_remoteChainId == REMOTE_CHAINID, "invalid remote chainId");
appPairs[msg.sender] = _remoteBridge;
}

function sendMessage(uint256 _remoteChainId, bytes memory _message, bytes memory _params) onlyWhiteListCaller external payable {
require(_remoteChainId == REMOTE_CHAINID, "invalid remote chainId");
address remoteAppAddress = appPairs[msg.sender];
require(remoteAppAddress != address(0), "app not registered");

(uint256 l2GasLimit, address refunder) = abi.decode(_params, (uint256, address));

bytes memory remoteReceiveCall = abi.encodeWithSelector(
ILowLevelMessageReceiver.recvMessage.selector,
msg.sender,
remoteAppAddress,
_message
);
scrollMessager.sendMessage{value: msg.value}(
remoteMessager,
0,
remoteReceiveCall,
l2GasLimit,
refunder
);
}

function fee(uint256 _l2GasLimit) external view returns(uint256) {
address messageQueue = scrollMessager.messageQueue();
return IL1MessageQueue(messageQueue).estimateCrossDomainMessageFee(_l2GasLimit);
}

function encodeParams(
uint256 _l2GasLimit,
address _refunder
) external pure returns(bytes memory) {
return abi.encode(_l2GasLimit, _refunder);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IScrollMessenger {
function sendMessage(address target, uint256 value, bytes calldata message, uint256 gasLimit, address refundAddress) external payable;
function messageQueue() external view returns (address);
function xDomainMessageSender() external view returns (address);
}

interface IL1MessageQueue {
function estimateCrossDomainMessageFee(uint256 gasLimit) external view returns(uint256);
}
1 change: 1 addition & 0 deletions helix-contract/deploy/deploy_ln_create2.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async function main() {
//await deployCreate2Deployer('https://rpc.testnet.mantle.xyz', 'v1.0.0');
//await deployCreate2Deployer('https://rpc.goerli.linea.build', 'v1.0.0');
//await deployCreate2Deployer('https://arb1.arbitrum.io/rpc', 'v1.0.0');
await deployCreate2Deployer('https://rpc.mantle.xyz', 'v1.0.0');
}

main()
Expand Down
13 changes: 11 additions & 2 deletions helix-contract/deploy/deploy_ln_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ const arbitrumSepolia = {
deployer: "0xbe6b2860d3c17a719be0A4911EA0EE689e8357f3",
};

const sepoliaNetwork = {
url: "https://rpc-sepolia.rockx.com",
deployer: "0xbe6b2860d3c17a719be0A4911EA0EE689e8357f3",
}

const scrollSepoliaNetwork = {
url: "https://sepolia-rpc.scroll.io/",
deployer: "0xbe6b2860d3c17a719be0A4911EA0EE689e8357f3",
}

function wallet(url) {
const provider = new ethers.providers.JsonRpcProvider(url);
const wallet = new ethers.Wallet(privateKey, provider);
Expand All @@ -60,8 +70,7 @@ async function deployLnOppositeBridge(wallet, deployerAddress, salt) {

// 2. deploy mapping token factory
async function main() {
//const networks = [goerliNetwork, mantleNetwork, arbitrumNetwork, lineaNetwork];
const networks = [arbitrumSepolia];
const networks = [goerliNetwork, mantleNetwork, arbitrumNetwork, lineaNetwork, sepoliaNetwork, scrollSepoliaNetwork];
for (const network of networks) {
const w = wallet(network.url);
const logicAddress = await deployLnDefaultBridge(w, network.deployer, "ln-default-logic-v1.0.0");
Expand Down
26 changes: 26 additions & 0 deletions helix-contract/deploy/deploy_ln_messager.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ const arbitrumSepoliaNetwork = {



const scrollNetwork = {
url: "https://sepolia-rpc.scroll.io/",
dao: "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
chainId: 534351,
scrollMessager: "0xBa50f5340FB9F3Bd074bD638c9BE13eCB36E603d",
}

const sepoliaNetwork = {
url: "https://rpc2.sepolia.org",
dao: "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
chainId: 11155111,
scrollMessager: "0x50c7d3e7f7c656493D1D76aaa1a836CedfCBB16A",
}

function wait(ms) {
return new Promise(resolve => setTimeout(() => resolve(), ms));
};
Expand Down Expand Up @@ -109,7 +123,10 @@ async function main() {
const zkSyncWallet = wallet(zkSyncNetwork.url);
const crabWallet = wallet(crabNetwork.url);
const arbSepoliaWallet = wallet(arbitrumSepoliaNetwork.url);
const scrollWallet = wallet(scrollNetwork.url);
const sepoliaWallet = wallet(sepoliaNetwork.url);

/*
// deploy arb<>eth
console.log("deploy arb <> eth messager");
const Eth2ArbReceiveService = await deployContract(arbWallet, "Eth2ArbReceiveService", arbitrumNetwork.dao, goerliNetwork.chainId);
Expand Down Expand Up @@ -180,13 +197,22 @@ async function main() {
await axArbitrum.setRemoteMessager(mantleNetwork.chainId, mantleNetwork.axName, axMantle.address);
await axLinea.setRemoteMessager(mantleNetwork.chainId, mantleNetwork.axName, axMantle.address);
await axMantle.setRemoteMessager(lineaNetwork.chainId, lineaNetwork.axName, axLinea.address);
*/

// deploy crab<>arbitrum sepolia
const msglineCrab = await deployContract(crabWallet, "DarwiniaMsglineMessager", crabNetwork.dao, arbitrumSepoliaNetwork.msglineAddress);
const msglineArbSepolia = await deployContract(arbSepoliaWallet, "DarwiniaMsglineMessager", arbitrumSepoliaNetwork.dao, crabNetwork.msglineAddress);
await msglineCrab.setRemoteMessager(arbitrumSepoliaNetwork.chainId, arbitrumSepoliaNetwork.msglineChainId, msglineArbSepolia.address);
await msglineArbSepolia.setRemoteMessager(crabNetwork.chainId, crabNetwork.msglineChainId, msglineCrab.address);

// deploy scroll
console.log("deploy scroll <> eth messager");
const Eth2ScrollReceiveService = await deployContract(scrollWallet, "Eth2ScrollReceiveService", scrollNetwork.dao, scrollNetwork.scrollMessager, sepoliaNetwork.chainId);
const Eth2ScrollSendService = await deployContract(sepoliaWallet, "Eth2ScrollSendService", sepoliaNetwork.dao, sepoliaNetwork.scrollMessager, scrollNetwork.chainId);
await wait(10000);
await Eth2ScrollReceiveService.setRemoteMessager(Eth2ScrollSendService.address);
await Eth2ScrollSendService.setRemoteMessager(Eth2ScrollReceiveService.address);
await wait(10000);
/*
// deploy debug messager
await deployContract(goerliWallet, "DebugMessager");
Expand Down
13 changes: 12 additions & 1 deletion helix-contract/deploy/deploy_ln_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ const crabNetwork = {
const arbitrumSepoliaNetwork = {
name: "arbitrum-sepolia",
url: "https://sepolia-rollup.arbitrum.io/rpc",
}

const sepoliaNetwork = {
name: "sepolia",
url: "https://rpc-sepolia.rockx.com",
dao: "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
};

const scrollSepoliaNetwork = {
name: "scroll-sepolia",
url: "https://sepolia-rpc.scroll.io/",
dao: "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
};

Expand Down Expand Up @@ -84,7 +95,7 @@ async function deploy() {
fs.readFileSync(pathConfig, "utf8")
);

const chains = [goerliNetwork, lineaGoerliNetwork, arbitrumGoerliNetwork, mantleGoerliNetwork, crabNetwork, arbitrumSepoliaNetwork];
const chains = [goerliNetwork, lineaGoerliNetwork, arbitrumGoerliNetwork, mantleGoerliNetwork, sepoliaNetwork, scrollSepoliaNetwork];
for (const chain of chains) {
const w = wallet(chain.url);
const proxyAdmin = configure.ProxyAdmin.others;
Expand Down
Loading

0 comments on commit 0af6beb

Please sign in to comment.