Skip to content

Commit

Permalink
Merge pull request #40 from helix-bridge/xiaoch05-deploy-arb2eth-lnbr…
Browse files Browse the repository at this point in the history
…idge

deploy mainnet(arbitrum->ethereum)
  • Loading branch information
xiaoch05 authored Oct 19, 2023
2 parents 78ef5e9 + 327206b commit 291f5c3
Show file tree
Hide file tree
Showing 17 changed files with 2,728 additions and 858 deletions.
24 changes: 24 additions & 0 deletions helix-contract/address/ln-product.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"messagers": {
"ethereum": {
"Eth2ArbSendService": "0x78a6831Da2293fbEFd0d8aFB4D1f7CBB751e0119"
},
"arbitrum": {
"Eth2ArbReceiveService": "0xc95D939Da72ECe8Bd794d42EaEd28974CDb0ADa2"
}
},
"ProxyAdmin": {
"common": "0x601dE3B81c7cE04BecE3b29e5cEe4F3251d250dB"
},
"LnOppositeBridgeLogic": {
"common": "0x90873fa1bbd028F22277567530A22E05f7721D37"
},
"LnOppositeBridgeProxy": {
"common": "0x48d769d5C7ff75703cDd1543A1a2ed9bC9044A23"
},
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3",
"ring": {
"arbitrum": "0x9e523234D36973f9e38642886197D023C88e307e",
"ethereum": "0x9469D013805bFfB7D3DEBe5E7839237e535ec483"
}
}
6 changes: 6 additions & 0 deletions helix-contract/contracts/ln/tool/ProxyAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
pragma solidity ^0.8.17;

import "@zeppelin-solidity/contracts/proxy/transparent/ProxyAdmin.sol";

contract HelixProxyAdmin is ProxyAdmin {
constructor(address initialOwner) {
_transferOwnership(initialOwner);
}
}
73 changes: 73 additions & 0 deletions helix-contract/deploy/deploy_bytescode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const ethUtil = require('ethereumjs-util');
const abi = require('ethereumjs-abi');
const secp256k1 = require('secp256k1');

var Create2 = require("./create2.js");
var ProxyDeployer = require("./proxy.js");

const privateKey = process.env.PRIKEY

function wallet(url) {
const provider = new ethers.providers.JsonRpcProvider(url);
const wallet = new ethers.Wallet(privateKey, provider);
return wallet;
}

async function getHelixProxyAdminBytecode(networkUrl, version) {
const w = wallet(networkUrl);
const salt = ethers.utils.hexZeroPad(ethers.utils.hexlify(ethers.utils.toUtf8Bytes(version)), 32);
const proxyAdminContract = await ethers.getContractFactory("HelixProxyAdmin", w);
const bytecode = Create2.getDeployedBytecode(proxyAdminContract, ["address"], [w.address]);
console.log(`get helix proxyAdmin bytecode, salt ${salt}, bytecode ${bytecode}`);
return;
}

async function getOppositeBridgeBytecode(networkUrl, version) {
const w = wallet(networkUrl);
const salt = ethers.utils.hexZeroPad(ethers.utils.hexlify(ethers.utils.toUtf8Bytes(version)), 32);
const oppositeBridgeContract = await ethers.getContractFactory("LnOppositeBridge", w);
const bytecode = Create2.getDeployedBytecode(oppositeBridgeContract, [], []);
console.log(`get helix opposite logic bridge bytecode, salt ${salt}, bytecode ${bytecode}`);
return;
}

async function getDefaultBridgeBytecode(networkUrl, version) {
const w = wallet(networkUrl);
const salt = ethers.utils.hexZeroPad(ethers.utils.hexlify(ethers.utils.toUtf8Bytes(version)), 32);
const defaultBridgeContract = await ethers.getContractFactory("LnDefaultBridge", w);
const bytecode = Create2.getDeployedBytecode(defaultBridgeContract, [], []);
console.log(`get helix default logic bridge bytecode, salt ${salt}, bytecode ${bytecode}`);
return;
}

async function getLnProxyBridgeBytecode(w, version, logicFactory, logicAddress, proxyAdminAddress, args) {
const salt = ethers.utils.hexZeroPad(ethers.utils.hexlify(ethers.utils.toUtf8Bytes(version)), 32);
const calldata = ProxyDeployer.getInitializerData(logicFactory.interface, args, "initialize");
const proxyContract = await ethers.getContractFactory("TransparentUpgradeableProxy", w);
const bytecode = Create2.getDeployedBytecode(proxyContract, ["address", "address", "bytes"], [logicAddress, proxyAdminAddress, calldata]);
console.log(`get helix proxy bridge bytecode, salt ${salt}, bytecode ${bytecode}`);
return;
}

async function getLnOppositeProxyBridgeBytecode(networkUrl, version, logicAddress, proxyAdminAddress) {
const w = wallet(networkUrl);
const oppositeFactory = await ethers.getContractFactory("LnOppositeBridge", w);
await getLnProxyBridgeBytecode(w, version, oppositeFactory, logicAddress, proxyAdminAddress, [w.address]);
return;
}

// 2. deploy mapping token factory
async function main() {
//await getHelixProxyAdminBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0');
//await getOppositeBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0');
//await getDefaultBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0');
await getLnOppositeProxyBridgeBytecode('https://rpc.ankr.com/eth_goerli', 'v1.0.0', '0x90873fa1bbd028F22277567530A22E05f7721D37', '0x601dE3B81c7cE04BecE3b29e5cEe4F3251d250dB');
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

26 changes: 0 additions & 26 deletions helix-contract/deploy/deploy_ln_configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,6 @@ const zkSyncGoerliNetwork = {
eth: "0x0000000000000000000000000000000000000000",
}

const messagers = {
goerli: {
Eth2ArbSendService: "0xa4eE139bE76d277D997aCf9D58053D8DaF7E050a",
Eth2LineaSendService: "0x9878e74634544d92a043f1826a94465035FA51f4",
layerzeroMessager: "0xca4490875739BEb1c4ec9ee5d6814774114e1973",
axelarMessager: "0x037c7b64c80251Cf5C64Ed8f731c799Dc1856701"
},
arbitrumGoerli: {
Eth2ArbReceiveService: "0x102F8D7Cfe692AA79c17E3958aB00D060Df0B88f",
layerzeroMessager: "0x953bE65E685099277F1f09Ebe10746810dC0593D",
axelarMessager: "0xBc30913CC01A2eC70483681841bbb43D2f77caEd"
},
lineaGoerli: {
Eth2LineaReceiveService: "0x8200b3130416F633A696FB9bb0e689a356625075",
layerzeroMessager: "0xfB09042050868594a54a59EdEAEa96e2765dAd0B",
axelarMessager: "0x14DB1d462ED061b037C7920857Fc66522ed5bf85"
},
mantleGoerli: {
layerzeroMessager: "0xBE4a32f37d11e8227444837DFb3c634d189ccEDc",
axelarMessager: "0xbb593913a4f3E4eE77861f743c697A4cb95837eF"
},
zkSyncGoerli: {
layerzeroMessager: "0x7e303b0A3F08F9fa5F5629Abb998B8Deba89049B"
}
};

function wait(ms) {
return new Promise(resolve => setTimeout(() => resolve(), ms));
};
Expand Down
12 changes: 7 additions & 5 deletions helix-contract/deploy/deploy_ln_create2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ function wallet(url) {
}

async function deployCreate2Deployer(networkUrl, version) {
const w = wallet(networkUrl);
const salt = ethers.utils.hexZeroPad(ethers.utils.hexlify(ethers.utils.toUtf8Bytes(version)), 32);
const create2Contract = await ethers.getContractFactory("Create2Deployer", wallet);
const create2Contract = await ethers.getContractFactory("Create2Deployer", w);
const bytecode = Create2.getDeployedBytecode(create2Contract, [], []);
const w = wallet(networkUrl);
const unsignedTransaction = {
from: w.address,
to: "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
data: `${salt}${bytecode.slice(2)}`
data: `${salt}${bytecode.slice(2)}`,
gasPrice: 100000000,
};
const tx = await w.sendTransaction(unsignedTransaction);
console.log(`deploy create2 tx: ${tx.hash}, salt: ${salt}`);
Expand All @@ -31,8 +32,9 @@ async function deployCreate2Deployer(networkUrl, version) {
async function main() {
//await deployCreate2Deployer('https://rpc.ankr.com/eth_goerli', 'v1.0.0');
//await deployCreate2Deployer('https://goerli-rollup.arbitrum.io/rpc', 'v1.0.0');
await deployCreate2Deployer('https://rpc.testnet.mantle.xyz', 'v1.0.0');
await deployCreate2Deployer('https://rpc.goerli.linea.build', 'v1.0.0');
//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');
}

main()
Expand Down
2 changes: 2 additions & 0 deletions helix-contract/deploy/flatten-ln.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
path=flatten/lnv2
mkdir -p $path
yarn flat contracts/ln/tool/ProxyAdmin.sol --output $path/ProxyAdmin.sol
yarn flat contracts/ln/tool/TransparentUpgradeableProxy.sol --output $path/TransparentUpgradeableProxy.sol
yarn flat contracts/ln/LnDefaultBridge.sol --output $path/LnDefaultBridge.sol
yarn flat contracts/ln/LnOppositeBridge.sol --output $path/LnOppositeBridge.sol
yarn flat contracts/ln/messager/Eth2LineaSendService.sol --output $path/Eth2LineaSendService.sol
Expand Down
28 changes: 14 additions & 14 deletions helix-contract/flatten/lnv2/Eth2ArbReceiveService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@
* '----------------' '----------------' '----------------' '----------------' '----------------' '
*
*
* 10/17/2023
* 10/18/2023
**/

pragma solidity ^0.8.17;

// File contracts/ln/interface/ILowLevelMessager.sol
// License-Identifier: MIT

interface ILowLevelMessageSender {
function registerRemoteReceiver(uint256 remoteChainId, address remoteBridge) external;
function sendMessage(uint256 remoteChainId, bytes memory message, bytes memory params) external payable;
}

interface ILowLevelMessageReceiver {
function registerRemoteSender(uint256 remoteChainId, address remoteBridge) external;
function recvMessage(address remoteSender, address localReceiver, bytes memory payload) external;
}

// File contracts/ln/base/LnAccessController.sol
// License-Identifier: MIT

Expand Down Expand Up @@ -64,19 +77,6 @@ contract LnAccessController {
}
}

// File contracts/ln/interface/ILowLevelMessager.sol
// License-Identifier: MIT

interface ILowLevelMessageSender {
function registerRemoteReceiver(uint256 remoteChainId, address remoteBridge) external;
function sendMessage(uint256 remoteChainId, bytes memory message, bytes memory params) external payable;
}

interface ILowLevelMessageReceiver {
function registerRemoteSender(uint256 remoteChainId, address remoteBridge) external;
function recvMessage(address remoteSender, address localReceiver, bytes memory payload) external;
}

// File @arbitrum/nitro-contracts/src/libraries/AddressAliasHelper.sol@v1.0.1
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
Expand Down
28 changes: 14 additions & 14 deletions helix-contract/flatten/lnv2/Eth2ArbSendService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@
* '----------------' '----------------' '----------------' '----------------' '----------------' '
*
*
* 10/17/2023
* 10/18/2023
**/

pragma solidity ^0.8.17;

// File contracts/ln/interface/ILowLevelMessager.sol
// License-Identifier: MIT

interface ILowLevelMessageSender {
function registerRemoteReceiver(uint256 remoteChainId, address remoteBridge) external;
function sendMessage(uint256 remoteChainId, bytes memory message, bytes memory params) external payable;
}

interface ILowLevelMessageReceiver {
function registerRemoteSender(uint256 remoteChainId, address remoteBridge) external;
function recvMessage(address remoteSender, address localReceiver, bytes memory payload) external;
}

// File contracts/ln/base/LnAccessController.sol
// License-Identifier: MIT

Expand Down Expand Up @@ -64,19 +77,6 @@ contract LnAccessController {
}
}

// File contracts/ln/interface/ILowLevelMessager.sol
// License-Identifier: MIT

interface ILowLevelMessageSender {
function registerRemoteReceiver(uint256 remoteChainId, address remoteBridge) external;
function sendMessage(uint256 remoteChainId, bytes memory message, bytes memory params) external payable;
}

interface ILowLevelMessageReceiver {
function registerRemoteSender(uint256 remoteChainId, address remoteBridge) external;
function recvMessage(address remoteSender, address localReceiver, bytes memory payload) external;
}

// File @arbitrum/nitro-contracts/src/bridge/IOwnable.sol@v1.0.1
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
Expand Down
28 changes: 14 additions & 14 deletions helix-contract/flatten/lnv2/Eth2LineaReceiveService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@
* '----------------' '----------------' '----------------' '----------------' '----------------' '
*
*
* 10/17/2023
* 10/18/2023
**/

pragma solidity ^0.8.17;

// File contracts/ln/interface/ILowLevelMessager.sol
// License-Identifier: MIT

interface ILowLevelMessageSender {
function registerRemoteReceiver(uint256 remoteChainId, address remoteBridge) external;
function sendMessage(uint256 remoteChainId, bytes memory message, bytes memory params) external payable;
}

interface ILowLevelMessageReceiver {
function registerRemoteSender(uint256 remoteChainId, address remoteBridge) external;
function recvMessage(address remoteSender, address localReceiver, bytes memory payload) external;
}

// File contracts/ln/base/LnAccessController.sol
// License-Identifier: MIT

Expand Down Expand Up @@ -72,19 +85,6 @@ interface ILineaMessageService {
function sender() external view returns (address);
}

// File contracts/ln/interface/ILowLevelMessager.sol
// License-Identifier: MIT

interface ILowLevelMessageSender {
function registerRemoteReceiver(uint256 remoteChainId, address remoteBridge) external;
function sendMessage(uint256 remoteChainId, bytes memory message, bytes memory params) external payable;
}

interface ILowLevelMessageReceiver {
function registerRemoteSender(uint256 remoteChainId, address remoteBridge) external;
function recvMessage(address remoteSender, address localReceiver, bytes memory payload) external;
}

// File contracts/ln/messager/Eth2LineaReceiveService.sol
// License-Identifier: MIT

Expand Down
2 changes: 1 addition & 1 deletion helix-contract/flatten/lnv2/Eth2LineaSendService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* '----------------' '----------------' '----------------' '----------------' '----------------' '
*
*
* 10/17/2023
* 10/18/2023
**/

pragma solidity ^0.8.17;
Expand Down
2 changes: 1 addition & 1 deletion helix-contract/flatten/lnv2/LayerZeroMessager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* '----------------' '----------------' '----------------' '----------------' '----------------' '
*
*
* 10/17/2023
* 10/18/2023
**/

pragma solidity ^0.8.17;
Expand Down
Loading

0 comments on commit 291f5c3

Please sign in to comment.