Skip to content

feat(deploy): deployed PR #49 #48 and ArbitrableExample #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
### Rinkeby

- [PNK](https://rinkeby.etherscan.io/token/0x14aba1fa8a31a8649e8098ad067b739cc5708f30)
- [FastBridgeReceiver](https://rinkeby.etherscan.io/address/0x300CbF0829762FeDc90287D08aeDf261EE6ED8eB)
- [ForeignGateway](https://rinkeby.etherscan.io/address/0x8F1a2B8F9b04320375856580Fc6B1669Cb12a9EE)
- [ArbitrableExample](https://rinkeby.etherscan.io/address/0xf2a59723c5d625D646668E0B615B5764c3F81540)
- [FastBridgeReceiver](https://rinkeby.etherscan.io/address/0xD78DCddE2C5a2Bd4BB246Bc7dB6994b95f7c442C)
- [ForeignGateway](https://rinkeby.etherscan.io/address/0xf02733d9e5CbfE67B54F165b0277E1995106D526)

### Arbitrum Rinkeby

- [PNK](https://testnet.arbiscan.io/token/0x364530164a2338cdba211f72c1438eb811b5c639)
- [ConstantNG](https://testnet.arbiscan.io/address/0x4401A368dea8D5761AEEFfd3c4a674086dea0666)
- [DisputeKitClassic](https://testnet.arbiscan.io/address/0xD78DCddE2C5a2Bd4BB246Bc7dB6994b95f7c442C)
- [FastBridgeSender](https://testnet.arbiscan.io/address/0x34E520dc1d2Db660113b64724e14CEdCD01Ee879)
- [HomeGateway](https://testnet.arbiscan.io/address/0x4d18b9792e0D8F5aF696E71dBEDff8fcBEed6e8C)
- [KlerosCore](https://testnet.arbiscan.io/address/0x5A407DcbD0F83ECbc1894C4B4f8Fc5b699D4822F)
- [SafeBridgeArbitrum](https://testnet.arbiscan.io/address/0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD)
- [DisputeKitClassic](https://testnet.arbiscan.io/address/0xed12799915180a257985631fbD2ead261eD838cf)
- [FastBridgeSender](https://testnet.arbiscan.io/address/0x0b9e03455Fed83f209Fa7ce596c93ba6aBAd1f46)
- [HomeGateway](https://testnet.arbiscan.io/address/0x2Aa1f82d363f79c1E7a4CcF955Fb7E4306b9B260)
- [KlerosCore](https://testnet.arbiscan.io/address/0xd08452AEE7ab5bE3BF6733BA0d3F0CFdaf060Aa2)
- [SafeBridgeArbitrum](https://testnet.arbiscan.io/address/0x1406bC99873d16Cde3491F809f1Af9442cb5A338)
- [SortitionSumTreeFactory](https://testnet.arbiscan.io/address/0xf02733d9e5CbfE67B54F165b0277E1995106D526)

## Contributing
Expand Down
46 changes: 32 additions & 14 deletions contracts/deploy/01-foreign-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { DeployFunction } from "hardhat-deploy/types";

import getContractAddress from "../deploy-helpers/getContractAddress";

const FOREIGN_CHAIN_IDS = [1, 4, 31337]; // Mainnet, Rinkeby, Hardhat
enum ForeignChains {
ETHEREUM_MAINNET = 1,
ETHEREUM_RINKEBY = 4,
HARDHAT = 31337,
}
const paramsByChainId = {
1: {
claimDeposit: parseEther("0.1"),
Expand All @@ -17,6 +21,11 @@ const paramsByChainId = {
challengeDuration: 3600, // 1 hour
homeChainId: 421611,
},
31337: {
claimDeposit: parseEther("0.1"),
challengeDuration: 3600, // 1 hour
homeChainId: 421611,
},
};

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
Expand All @@ -25,26 +34,24 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
const { providers } = ethers;
const { hexZeroPad } = hre.ethers.utils;

const { deployer } = await getNamedAccounts();
const chainId = await getChainId();
// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
const chainId = Number(await getChainId());
console.log("deploying to chainId %s with deployer %s", chainId, deployer);

const homeNetworks = {
1: config.networks.arbitrum,
4: config.networks.arbitrumRinkeby,
31337: config.networks.localhost,
};
const { url } = homeNetworks[chainId];
const homeChainProvider = new providers.JsonRpcProvider(url);
const homeChainProvider = new providers.JsonRpcProvider(homeNetworks[chainId].url);
const nonce = await homeChainProvider.getTransactionCount(deployer);

const { claimDeposit, challengeDuration, homeChainId } = paramsByChainId[chainId];
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);

// home Gateway deploy tx will the third tx after this on it's network,
// so we add two to the current nonce.
// HomeGateway deploy tx will the third tx after this on it's network, so we add two to the current nonce.
const homeGatewayAddress = getContractAddress(deployer, nonce + 2);

const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);
console.log(nonce + 2);
console.log(homeGatewayAddress);
console.log("calculated future HomeGateway address for nonce %d: %s", nonce + 2, homeGatewayAddress);

const fastBridgeReceiver = await deploy("FastBridgeReceiver", {
from: deployer,
Expand All @@ -57,9 +64,20 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
args: [deployer, fastBridgeReceiver.address, ["1000", "10000"], homeGatewayAddress, homeChainIdAsBytes32],
log: true,
});

const metaEvidenceUri =
"https://github.com/raw/kleros/kleros-v2/master/contracts/deployments/rinkeby/MetaEvidence_ArbitrableExample.json";
const arbitrable = await deploy("ArbitrableExample", {
from: deployer,
args: [foreignGateway.address, metaEvidenceUri],
log: true,
});
};

deployForeignGateway.tags = ["ForeignChain"];
deployForeignGateway.skip = async ({ getChainId }) => !FOREIGN_CHAIN_IDS.includes(Number(await getChainId()));
deployForeignGateway.tags = ["ForeignChain", "ForeignGateway"];
deployForeignGateway.skip = async ({ getChainId }) => {
const chainId = Number(await getChainId());
return !ForeignChains[chainId];
};

export default deployForeignGateway;
6 changes: 3 additions & 3 deletions contracts/deploy/02-home-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const safeBridge = await deploy("SafeBridgeArbitrum", {
from: deployer,
log: true,
});
}); // nonce

const fastBridgeReceiver = await hre.companionNetworks.foreign.deployments.get("FastBridgeReceiver");
const fastBridgeSender = await deploy("FastBridgeSender", {
from: deployer,
args: [safeBridge.address, fastBridgeReceiver.address],
log: true,
});
}); // nonce+1

const klerosCore = await deployments.get("KlerosCore");
const foreignGateway = await hre.companionNetworks.foreign.deployments.get("ForeignGateway");
Expand All @@ -30,7 +30,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
from: deployer,
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
log: true,
});
}); // nonce+2

await execute("FastBridgeSender", { from: deployer, log: true }, "setFastSender", homeGateway.address);
};
Expand Down
156 changes: 106 additions & 50 deletions contracts/deployments/arbitrumRinkeby/DisputeKitClassic.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions contracts/deployments/arbitrumRinkeby/FastBridgeSender.json

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions contracts/deployments/arbitrumRinkeby/HomeGateway.json

Large diffs are not rendered by default.

196 changes: 112 additions & 84 deletions contracts/deployments/arbitrumRinkeby/KlerosCore.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions contracts/deployments/arbitrumRinkeby/SafeBridgeArbitrum.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD",
"address": "0x1406bC99873d16Cde3491F809f1Af9442cb5A338",
"abi": [
{
"anonymous": false,
Expand Down Expand Up @@ -39,25 +39,25 @@
"type": "function"
}
],
"transactionHash": "0x29b0ca8c481531a2209f2f268db8195d6d2398f9dc93c09401bd65482ba71bc3",
"transactionHash": "0xa7899bcb74e96e88994d8a9cccf51136680b236c2cfdab4ea2e7f3db5c4d797b",
"receipt": {
"to": null,
"from": "0xF50E77f2A2B6138D16c6c7511562E5C33c4B15A3",
"contractAddress": "0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD",
"contractAddress": "0x1406bC99873d16Cde3491F809f1Af9442cb5A338",
"transactionIndex": 0,
"gasUsed": "1574087",
"gasUsed": "1575466",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x191b5cf71955a086a177cc63ee65b9def4d729d65b90f1b7d2e3b7c152a46c74",
"transactionHash": "0x29b0ca8c481531a2209f2f268db8195d6d2398f9dc93c09401bd65482ba71bc3",
"blockHash": "0x1129d518a7b3498206754578e5c8882dd2266ece37a097986b2b3a0429ae58b6",
"transactionHash": "0xa7899bcb74e96e88994d8a9cccf51136680b236c2cfdab4ea2e7f3db5c4d797b",
"logs": [],
"blockNumber": 9361449,
"cumulativeGasUsed": "10087",
"blockNumber": 9610366,
"cumulativeGasUsed": "10086",
"status": 1,
"byzantium": true
},
"args": [],
"numDeployments": 1,
"solcInputHash": "9627b78546d73cee66a2022d221ca6c9",
"solcInputHash": "0a1ec2a631b00a23a4a92b2eaceb36a5",
"metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"withdrawalId\",\"type\":\"uint256\"}],\"name\":\"L2ToL1TxCreated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"sendSafe\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"sendSafe(address,bytes)\":{\"params\":{\"_calldata\":\"The L2 encoded message data.\",\"_receiver\":\"The L1 contract address who will receive the calldata\"},\"returns\":{\"_0\":\"Unique id to track the message request/transaction.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"sendSafe(address,bytes)\":{\"notice\":\"Sends an arbitrary message from one domain to another.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/bridge/SafeBridgeArbitrum.sol\":\"SafeBridgeArbitrum\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"src/bridge/SafeBridgeArbitrum.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n/**\\n * @authors: [@shalzz]\\n * @reviewers: []\\n * @auditors: []\\n * @bounties: []\\n * @deployments: []\\n */\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./interfaces/arbitrum/IArbSys.sol\\\";\\nimport \\\"./interfaces/arbitrum/AddressAliasHelper.sol\\\";\\n\\nimport \\\"./interfaces/ISafeBridge.sol\\\";\\n\\ncontract SafeBridgeArbitrum is ISafeBridge {\\n IArbSys constant arbsys = IArbSys(address(100));\\n\\n event L2ToL1TxCreated(uint256 indexed withdrawalId);\\n\\n function sendSafe(address _receiver, bytes memory _calldata) external payable override returns (uint256) {\\n uint256 withdrawalId = arbsys.sendTxToL1(_receiver, _calldata);\\n\\n emit L2ToL1TxCreated(withdrawalId);\\n return withdrawalId;\\n }\\n}\\n\",\"keccak256\":\"0x0079614dca40603a39d3f61fa9e31f0dbe267897b926774953c889a8c599e3fa\",\"license\":\"MIT\"},\"src/bridge/interfaces/ISafeBridge.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface ISafeBridge {\\n /**\\n * Sends an arbitrary message from one domain to another.\\n *\\n * @param _receiver The L1 contract address who will receive the calldata\\n * @param _calldata The L2 encoded message data.\\n * @return Unique id to track the message request/transaction.\\n */\\n function sendSafe(address _receiver, bytes memory _calldata) external payable returns (uint256);\\n}\\n\",\"keccak256\":\"0x2e7ab23dc7721f51f3d115ea3a06c590869e8671ed824987756ab4bb224845d1\",\"license\":\"MIT\"},\"src/bridge/interfaces/arbitrum/AddressAliasHelper.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\n\\n/*\\n * Copyright 2019-2021, Offchain Labs, Inc.\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n */\\n\\npragma solidity >=0.7.0;\\n\\nlibrary AddressAliasHelper {\\n uint160 constant offset = uint160(0x1111000000000000000000000000000000001111);\\n\\n /// @notice Utility function that converts the address in the L1 that submitted a tx to\\n /// the inbox to the msg.sender viewed in the L2\\n /// @param l1Address the address in the L1 that triggered the tx to L2\\n /// @return l2Address L2 address as viewed in msg.sender\\n function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {\\n l2Address = address(uint160(l1Address) + offset);\\n }\\n\\n /// @notice Utility function that converts the msg.sender viewed in the L2 to the\\n /// address in the L1 that submitted a tx to the inbox\\n /// @param l2Address L2 address as viewed in msg.sender\\n /// @return l1Address the address in the L1 that triggered the tx to L2\\n function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {\\n l1Address = address(uint160(l2Address) - offset);\\n }\\n}\\n\",\"keccak256\":\"0xdd595bb9f30932cb16758f5f561b80a8fcfbf239e68319615c39441b2781a9cd\",\"license\":\"Apache-2.0\"},\"src/bridge/interfaces/arbitrum/IArbSys.sol\":{\"content\":\"pragma solidity >=0.7.0;\\n\\n/**\\n * @title Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064. Exposes a variety of system-level functionality.\\n */\\ninterface IArbSys {\\n /**\\n * @notice Get internal version number identifying an ArbOS build\\n * @return version number as int\\n */\\n function arbOSVersion() external pure returns (uint256);\\n\\n /**\\n * @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)\\n * @return block number as int\\n */\\n function arbBlockNumber() external view returns (uint256);\\n\\n /**\\n * @notice Send given amount of Eth to dest from sender.\\n * This is a convenience function, which is equivalent to calling sendTxToL1 with empty calldataForL1.\\n * @param destination recipient address on L1\\n * @return unique identifier for this L2-to-L1 transaction.\\n */\\n function withdrawEth(address destination) external payable returns (uint256);\\n\\n /**\\n * @notice Send a transaction to L1\\n * @param destination recipient address on L1\\n * @param calldataForL1 (optional) calldata for L1 contract call\\n * @return a unique identifier for this L2-to-L1 transaction.\\n */\\n function sendTxToL1(address destination, bytes calldata calldataForL1) external payable returns (uint256);\\n\\n /**\\n * @notice get the number of transactions issued by the given external account or the account sequence number of the given contract\\n * @param account target account\\n * @return the number of transactions issued by the given external account or the account sequence number of the given contract\\n */\\n function getTransactionCount(address account) external view returns (uint256);\\n\\n /**\\n * @notice get the value of target L2 storage slot\\n * This function is only callable from address 0 to prevent contracts from being able to call it\\n * @param account target account\\n * @param index target index of storage slot\\n * @return stotage value for the given account at the given index\\n */\\n function getStorageAt(address account, uint256 index) external view returns (uint256);\\n\\n /**\\n * @notice check if current call is coming from l1\\n * @return true if the caller of this was called directly from L1\\n */\\n function isTopLevelCall() external view returns (bool);\\n\\n event EthWithdrawal(address indexed destAddr, uint256 amount);\\n\\n event L2ToL1Transaction(\\n address caller,\\n address indexed destination,\\n uint256 indexed uniqueId,\\n uint256 indexed batchNumber,\\n uint256 indexInBatch,\\n uint256 arbBlockNum,\\n uint256 ethBlockNum,\\n uint256 timestamp,\\n uint256 callvalue,\\n bytes data\\n );\\n}\\n\",\"keccak256\":\"0xb4607d26251273b1f9307a845295fcb982d729eb5b40efeadefb21795fad9370\"}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b50610285806100206000396000f3fe60806040526004361061001e5760003560e01c8063be44ae1c14610023575b600080fd5b610036610031366004610101565b610048565b60405190815260200160405180910390f35b6040516349460b4d60e11b8152600090819060649063928c169a9061007390879087906004016101d1565b6020604051808303816000875af1158015610092573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b69190610236565b60405190915081907facd96f3817031b95eab52de9132d4a9dd13dac3d9dfcfe950ca9283c89b851a590600090a29392505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561011457600080fd5b82356001600160a01b038116811461012b57600080fd5b9150602083013567ffffffffffffffff8082111561014857600080fd5b818501915085601f83011261015c57600080fd5b81358181111561016e5761016e6100eb565b604051601f8201601f19908116603f01168101908382118183101715610196576101966100eb565b816040528281528860208487010111156101af57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60018060a01b038316815260006020604081840152835180604085015260005b8181101561020d578581018301518582016060015282016101f1565b8181111561021f576000606083870101525b50601f01601f191692909201606001949350505050565b60006020828403121561024857600080fd5b505191905056fea2646970667358221220691aeb3681b0b3a9b12bd40f31d52435b0fb90aeb41a724c79e99fdcc31d653c64736f6c634300080a0033",
"deployedBytecode": "0x60806040526004361061001e5760003560e01c8063be44ae1c14610023575b600080fd5b610036610031366004610101565b610048565b60405190815260200160405180910390f35b6040516349460b4d60e11b8152600090819060649063928c169a9061007390879087906004016101d1565b6020604051808303816000875af1158015610092573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b69190610236565b60405190915081907facd96f3817031b95eab52de9132d4a9dd13dac3d9dfcfe950ca9283c89b851a590600090a29392505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561011457600080fd5b82356001600160a01b038116811461012b57600080fd5b9150602083013567ffffffffffffffff8082111561014857600080fd5b818501915085601f83011261015c57600080fd5b81358181111561016e5761016e6100eb565b604051601f8201601f19908116603f01168101908382118183101715610196576101966100eb565b816040528281528860208487010111156101af57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60018060a01b038316815260006020604081840152835180604085015260005b8181101561020d578581018301518582016060015282016101f1565b8181111561021f576000606083870101525b50601f01601f191692909201606001949350505050565b60006020828403121561024857600080fd5b505191905056fea2646970667358221220691aeb3681b0b3a9b12bd40f31d52435b0fb90aeb41a724c79e99fdcc31d653c64736f6c634300080a0033",
Expand Down
Loading