Skip to content

Commit

Permalink
Merge pull request #44 from helix-bridge/xiaoch05-lnbridge-v3
Browse files Browse the repository at this point in the history
lnbridge v3
  • Loading branch information
xiaoch05 authored Jan 30, 2024
2 parents 3fc4241 + 3e76bd5 commit f893088
Show file tree
Hide file tree
Showing 43 changed files with 4,577 additions and 1,121 deletions.
103 changes: 53 additions & 50 deletions helix-contract/address/ln-dev.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,76 @@
{
"messagers": {
"zksync-goerli": {
"layerzeroMessager": "0x7e303b0A3F08F9fa5F5629Abb998B8Deba89049B"
},
"goerli": {
"Eth2ArbSendService": "0xa4eE139bE76d277D997aCf9D58053D8DaF7E050a",
"Eth2LineaSendService": "0x9878e74634544d92a043f1826a94465035FA51f4",
"layerzeroMessager": "0xca4490875739BEb1c4ec9ee5d6814774114e1973",
"axelarMessager": "0x037c7b64c80251Cf5C64Ed8f731c799Dc1856701",
"debugMessager": "0x2e8D237226041FAFe3F66b6cfc54b064923D454E"
},
"chains": {
"sepolia": {
"Eth2ScrollSendService": "0x89AF830781A2C1d3580Db930bea11094F55AfEae"
},
"arbitrum-goerli": {
"Eth2ArbReceiveService": "0x102F8D7Cfe692AA79c17E3958aB00D060Df0B88f",
"layerzeroMessager": "0x953bE65E685099277F1f09Ebe10746810dC0593D",
"axelarMessager": "0xBc30913CC01A2eC70483681841bbb43D2f77caEd",
"debugMessager": "0x7f431D5ba484Eb96811C469BE3DcbB23c67ae4a8"
"name": "sepolia",
"url": "https://rpc2.sepolia.org",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 11155111,
"lzChainId": 10161,
"lzEndpoint": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1",
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3"
},
"linea-goerli": {
"Eth2LineaReceiveService": "0x8200b3130416F633A696FB9bb0e689a356625075",
"layerzeroMessager": "0xfB09042050868594a54a59EdEAEa96e2765dAd0B",
"axelarMessager": "0x14DB1d462ED061b037C7920857Fc66522ed5bf85",
"debugMessager": "0x25Ce9C92526D002a11aBA105563a713357429A99"
},
"mantle-goerli": {
"layerzeroMessager": "0xBE4a32f37d11e8227444837DFb3c634d189ccEDc",
"axelarMessager": "0xbb593913a4f3E4eE77861f743c697A4cb95837eF",
"debugMessager": "0x84f7a56483C100ECb12CbB4A31b7873dAE0d8E9B"
"arbitrum-sepolia": {
"name": "arbitrum-sepolia",
"url": "https://sepolia-rollup.arbitrum.io/rpc",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 421614,
"lzChainId": 10231,
"lzEndpoint": "0x6098e96a28E02f27B1e6BD381f870F1C8Bd169d3",
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3"
},
"base-goerli": {
"layerzeroMessager": "0x463D1730a8527CA58d48EF70C7460B9920346567"
"zksync": {
"name": "zksync",
"url": "https://sepolia.era.zksync.dev",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 300
}
},
"messagers": {
"sepolia": {
"chainId": 11155111,
"Eth2ScrollSendService": "0x89AF830781A2C1d3580Db930bea11094F55AfEae",
"layerzeroMessager": "0x33C9916a43507aa0a89a3e889522f840aa1245fE"
},
"arbitrum-sepolia": {
"darwiniaMsglineMessager": "0xCddD3e43dA1e9485d4FcD3782DFba04aADCfC9B2"
"chainId": "421614",
"darwiniaMsglineMessager": "0xCddD3e43dA1e9485d4FcD3782DFba04aADCfC9B2",
"layerzeroMessager": "0x87A649246974732f7AbBe01F2DD81E3D829EF0B7"
},
"zksync": {
"layerzeroMessager": "0xf29244511DA9242D8A452f7EB1264B52A19f5058"
}
},
"ProxyAdmin": {
"zkSync": "0xd7b3aC0c9E99e9B2EF1C9D2a5ff397867c8c8A3E",
"zksync": "0x57E8fcaAfDE61b179BAe86cDAbfaca99E2A16484",
"others": "0xE3979fFa68BBa1F53c6F502c8F5788B370d28730"
},
"LnDefaultBridgeLogic": {
"zkSync": "0x6213E3bc566f7d7A73Fd7565c97ac5Ffb8624674",
"others": "0x310bbebF08cbCC1DB41299E602Ef0319b9D1d979"
"zksync": "0xa1C2a266Ba82ce80243B975090016EE68C6d125B",
"others": "0x7CE46A6Bd9FB685b4fd6AE18888D71A9D4750e6E"
},
"LnDefaultBridgeProxy": {
"zkSync": "0xe8d55759c32fb608fD092aB2C0ef8A1F52B254d4",
"others": "0x7e101911E5FB461d78FBde3992f76F3Bf8BbA829"
"zksync": "0xBe23e871318E49C747CB909AC65aCCFAEAac3a37",
"others": "0x8429D7Dfd91D6F970ba89fFC005e67D15f1E4739"
},
"LnOppositeBridgeLogic": "0x08F2a6B3F8f67E6604aBb731FC318cf1f3EAaF53",
"LnOppositeBridgeProxy": "0xbA96d83E2A04c4E50F2D6D7eCA03D70bA2426e5f",
"LnV3BridgeLogic": {
"zksync": "0x67C3C81113Afb9A73d7ce5868046D97D0e44db59",
"others": "0xdf383487CB33a3C78a884494e2456910d79d361c"
},
"LnV3BridgeProxy": {
"zksync": "0xDc55fF59F82AA50D8A4A61dB8CcaDffD26Fb7dD2",
"others": "0x38627Cb033De66a1E07e73f5D0a7a7adFB6741fa"
},
"LnOppositeBridgeLogic": "0x3CFe649a4d5530AA2c716F0ca279b937687684f9",
"LnOppositeBridgeProxy": "0x4C538EfA6e3f9Dfb939AA4F0B224577DA665923a",
"deployer": "0xbe6b2860d3c17a719be0A4911EA0EE689e8357f3",
"usdt": {
"goerli": "0xa39cffE89567eBfb5c306a07dfb6e5B3ba41F358",
"mantle-goerli": "0xDb06D904AC5Bdff3b8E6Ac96AFedd3381d94CFDD",
"arbitrum-goerli": "0x543bf1AC41485dc78039b9351563E4Dd13A288cb",
"linea-goerli": "0x8f3663930211f3DE17619FEB2eeB44c9c3F44a06",
"zksync-goerli": "0xb5372ed3bb2CbA63e7908066ac10ee94d30eA839",
"base-goerli": "0x876A4f6eCF13EEb101F9E75FCeF58f19Ff383eEB",
"zksync": "0x3350f1ef046e21E052dCbA60Fc575919CCaFEdeb",
"sepolia": "0x876A4f6eCF13EEb101F9E75FCeF58f19Ff383eEB",
"scroll-sepolia": "0x9C80EdD342b5D179c3a87946fC1F0963BfcaAa09"
"scroll-sepolia": "0x9C80EdD342b5D179c3a87946fC1F0963BfcaAa09",
"arbitrum-sepolia": "0x3b8Bb7348D4F581e67E2498574F73e4B9Fc51855"
},
"usdc": {
"goerli": "0xe9784E0d9A939dbe966b021DE3cd877284DB1B99",
"mantle-goerli": "0xD610DE267f7590D5bCCE89489ECd2C1A4AfdF76B",
"arbitrum-goerli": "0xBAD026e314a77e727dF643B02f63adA573a3757c",
"linea-goerli": "0xeC89AF5FF618bbF667755BE9d63C69F21F1c00C8",
"zksync-goerli": "0xAe60e005C560E869a2bad271e38e3C9D78381aFF",
"zksync": "0x253adBFE99Fcd096B9b5502753F96CF78D42eaD0",
"crab": "0x4bA86B5D0F8D2DCB3FC23757cAA6EA71157F74E9",
"arbitrum-sepolia": "0x8A87497488073307E1a17e8A12475a94Afcb413f",
"sepolia": "0x0ac58Df0cc3542beC4cDa71B16D06C3cCc39f405",
Expand Down
35 changes: 35 additions & 0 deletions helix-contract/address/ln-product.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
{
"chains": {
"arbitrum": {
"name": "arbitrum",
"url": "https://arb1.arbitrum.io/rpc",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 42161,
"lzChainId": 110,
"lzEndpoint": "0x3c2269811836af69497E5F486A85D7316753cf62",
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3"
},
"polygon-pos": {
"name": "polygon-pos",
"url": "https://polygon-rpc.com",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 137,
"lzChainId": 109,
"lzEndpoint": "0x3c2269811836af69497E5F486A85D7316753cf62",
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3"
},
"bsc": {
"name": "bsc",
"url": "https://bsc-dataseed1.defibit.io",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 56,
"lzChainId": 102,
"lzEndpoint": "0x3c2269811836af69497E5F486A85D7316753cf62",
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3"
}
},
"messagers": {
"ethereum": {
"Eth2ArbSendService": "0x78a6831Da2293fbEFd0d8aFB4D1f7CBB751e0119"
Expand Down Expand Up @@ -64,6 +93,12 @@
"common": "0x94C614DAeFDbf151E1BB53d6A201ae5fF56A9337",
"zkSync": "0x767Bc046c989f5e63683fB530f939DD34b91ceAC"
},
"LnV3BridgeLogic": {
"common": "0xdf383487CB33a3C78a884494e2456910d79d361c"
},
"LnV3BridgeProxy": {
"common": "0xbA5D580B18b6436411562981e02c8A9aA1776D10"
},
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3",
"ring": {
"arbitrum": "0x9e523234D36973f9e38642886197D023C88e307e",
Expand Down
46 changes: 46 additions & 0 deletions helix-contract/contracts/ln/HelixLnBridgeV3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@zeppelin-solidity/contracts/proxy/utils/Initializable.sol";
import "./base/LnBridgeSourceV3.sol";
import "./base/LnBridgeTargetV3.sol";
import "../interfaces/IMessager.sol";

contract HelixLnBridgeV3 is Initializable, LnBridgeSourceV3, LnBridgeTargetV3 {
struct MessagerService {
address sendService;
address receiveService;
}

// remoteChainId => messager
mapping(uint256=>MessagerService) public messagers;

receive() external payable {}

function initialize(address dao) public initializer {
_initialize(dao);
}

// the remote endpoint is unique, if we want multi-path to remote endpoint, then the messager should support multi-path
function setSendService(uint256 _remoteChainId, address _remoteBridge, address _service) external onlyDao {
messagers[_remoteChainId].sendService = _service;
ILowLevelMessageSender(_service).registerRemoteReceiver(_remoteChainId, _remoteBridge);
}

function setReceiveService(uint256 _remoteChainId, address _remoteBridge, address _service) external onlyDao {
messagers[_remoteChainId].receiveService = _service;
ILowLevelMessageReceiver(_service).registerRemoteSender(_remoteChainId, _remoteBridge);
}

function _sendMessageToSource(uint256 _remoteChainId, bytes memory _payload, uint256 feePrepaid, bytes memory _extParams) whenNotPaused internal override {
address sendService = messagers[_remoteChainId].sendService;
require(sendService != address(0), "invalid messager");
ILowLevelMessageSender(sendService).sendMessage{value: feePrepaid}(_remoteChainId, _payload, _extParams);
}

function _verifyRemote(uint256 _remoteChainId) whenNotPaused internal view override {
address receiveService = messagers[_remoteChainId].receiveService;
require(receiveService == msg.sender, "invalid messager");
}
}

10 changes: 9 additions & 1 deletion helix-contract/contracts/ln/base/LnAccessController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pragma solidity ^0.8.17;
contract LnAccessController {
address public dao;
address public operator;
address public pendingDao;

mapping(address=>bool) public callerWhiteList;

Expand Down Expand Up @@ -39,7 +40,14 @@ contract LnAccessController {
}

function transferOwnership(address _dao) onlyDao external {
dao = _dao;
pendingDao = _dao;
}

function acceptOwnership() external {
address newDao = msg.sender;
require(pendingDao == newDao, "!pendingDao");
delete pendingDao;
dao = newDao;
}
}

2 changes: 1 addition & 1 deletion helix-contract/contracts/ln/base/LnBridgeHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "@zeppelin-solidity/contracts/token/ERC20/IERC20.sol";
library LnBridgeHelper {
// the time(seconds) for liquidity provider to delivery message
// if timeout, slasher can work.
uint256 constant public SLASH_EXPIRE_TIME = 30 * 60;
uint256 constant public SLASH_EXPIRE_TIME = 60 * 60;
bytes32 constant public INIT_SLASH_TRANSFER_ID = bytes32(uint256(1));
// liquidity fee base rate
// liquidityFee = liquidityFeeRate / LIQUIDITY_FEE_RATE_BASE * sendAmount
Expand Down
Loading

0 comments on commit f893088

Please sign in to comment.