Skip to content

Commit 8e6da44

Browse files
committed
feat(deploy): deployed PR #49 #48 and ArbitrableExample
1 parent 9f60e5c commit 8e6da44

14 files changed

+809
-285
lines changed

contracts/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
99
### Rinkeby
1010

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

1516
### Arbitrum Rinkeby
1617

1718
- [PNK](https://testnet.arbiscan.io/token/0x364530164a2338cdba211f72c1438eb811b5c639)
1819
- [ConstantNG](https://testnet.arbiscan.io/address/0x4401A368dea8D5761AEEFfd3c4a674086dea0666)
19-
- [DisputeKitClassic](https://testnet.arbiscan.io/address/0xD78DCddE2C5a2Bd4BB246Bc7dB6994b95f7c442C)
20-
- [FastBridgeSender](https://testnet.arbiscan.io/address/0x34E520dc1d2Db660113b64724e14CEdCD01Ee879)
21-
- [HomeGateway](https://testnet.arbiscan.io/address/0x4d18b9792e0D8F5aF696E71dBEDff8fcBEed6e8C)
22-
- [KlerosCore](https://testnet.arbiscan.io/address/0x5A407DcbD0F83ECbc1894C4B4f8Fc5b699D4822F)
23-
- [SafeBridgeArbitrum](https://testnet.arbiscan.io/address/0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD)
20+
- [DisputeKitClassic](https://testnet.arbiscan.io/address/0xed12799915180a257985631fbD2ead261eD838cf)
21+
- [FastBridgeSender](https://testnet.arbiscan.io/address/0x0b9e03455Fed83f209Fa7ce596c93ba6aBAd1f46)
22+
- [HomeGateway](https://testnet.arbiscan.io/address/0x2Aa1f82d363f79c1E7a4CcF955Fb7E4306b9B260)
23+
- [KlerosCore](https://testnet.arbiscan.io/address/0xd08452AEE7ab5bE3BF6733BA0d3F0CFdaf060Aa2)
24+
- [SafeBridgeArbitrum](https://testnet.arbiscan.io/address/0x1406bC99873d16Cde3491F809f1Af9442cb5A338)
2425
- [SortitionSumTreeFactory](https://testnet.arbiscan.io/address/0xf02733d9e5CbfE67B54F165b0277E1995106D526)
2526

2627
## Contributing

contracts/deploy/01-foreign-chain.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { DeployFunction } from "hardhat-deploy/types";
55

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

8-
const FOREIGN_CHAIN_IDS = [1, 4, 31337]; // Mainnet, Rinkeby, Hardhat
8+
enum ForeignChains {
9+
ETHEREUM_MAINNET = 1,
10+
ETHEREUM_RINKEBY = 4,
11+
HARDHAT = 31337,
12+
}
913
const paramsByChainId = {
1014
1: {
1115
claimDeposit: parseEther("0.1"),
@@ -17,6 +21,11 @@ const paramsByChainId = {
1721
challengeDuration: 3600, // 1 hour
1822
homeChainId: 421611,
1923
},
24+
31337: {
25+
claimDeposit: parseEther("0.1"),
26+
challengeDuration: 3600, // 1 hour
27+
homeChainId: 421611,
28+
},
2029
};
2130

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

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

3142
const homeNetworks = {
3243
1: config.networks.arbitrum,
3344
4: config.networks.arbitrumRinkeby,
45+
31337: config.networks.localhost,
3446
};
35-
const { url } = homeNetworks[chainId];
36-
const homeChainProvider = new providers.JsonRpcProvider(url);
47+
const homeChainProvider = new providers.JsonRpcProvider(homeNetworks[chainId].url);
3748
const nonce = await homeChainProvider.getTransactionCount(deployer);
38-
3949
const { claimDeposit, challengeDuration, homeChainId } = paramsByChainId[chainId];
50+
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);
4051

41-
// home Gateway deploy tx will the third tx after this on it's network,
42-
// so we add two to the current nonce.
52+
// HomeGateway deploy tx will the third tx after this on it's network, so we add two to the current nonce.
4353
const homeGatewayAddress = getContractAddress(deployer, nonce + 2);
44-
45-
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);
46-
console.log(nonce + 2);
47-
console.log(homeGatewayAddress);
54+
console.log("calculated future HomeGateway address for nonce %d: %s", nonce + 2, homeGatewayAddress);
4855

4956
const fastBridgeReceiver = await deploy("FastBridgeReceiver", {
5057
from: deployer,
@@ -57,9 +64,20 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
5764
args: [deployer, fastBridgeReceiver.address, ["1000", "10000"], homeGatewayAddress, homeChainIdAsBytes32],
5865
log: true,
5966
});
67+
68+
const metaEvidenceUri =
69+
"https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/rinkeby/MetaEvidence_ArbitrableExample.json";
70+
const arbitrable = await deploy("ArbitrableExample", {
71+
from: deployer,
72+
args: [foreignGateway.address, metaEvidenceUri],
73+
log: true,
74+
});
6075
};
6176

62-
deployForeignGateway.tags = ["ForeignChain"];
63-
deployForeignGateway.skip = async ({ getChainId }) => !FOREIGN_CHAIN_IDS.includes(Number(await getChainId()));
77+
deployForeignGateway.tags = ["ForeignChain", "ForeignGateway"];
78+
deployForeignGateway.skip = async ({ getChainId }) => {
79+
const chainId = Number(await getChainId());
80+
return !ForeignChains[chainId];
81+
};
6482

6583
export default deployForeignGateway;

contracts/deploy/02-home-chain.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
1414
const safeBridge = await deploy("SafeBridgeArbitrum", {
1515
from: deployer,
1616
log: true,
17-
});
17+
}); // nonce
1818

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

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

3535
await execute("FastBridgeSender", { from: deployer, log: true }, "setFastSender", homeGateway.address);
3636
};

contracts/deployments/arbitrumRinkeby/DisputeKitClassic.json

Lines changed: 106 additions & 50 deletions
Large diffs are not rendered by default.

contracts/deployments/arbitrumRinkeby/FastBridgeSender.json

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

contracts/deployments/arbitrumRinkeby/HomeGateway.json

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

contracts/deployments/arbitrumRinkeby/KlerosCore.json

Lines changed: 112 additions & 84 deletions
Large diffs are not rendered by default.

contracts/deployments/arbitrumRinkeby/SafeBridgeArbitrum.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"address": "0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD",
2+
"address": "0x1406bC99873d16Cde3491F809f1Af9442cb5A338",
33
"abi": [
44
{
55
"anonymous": false,
@@ -39,25 +39,25 @@
3939
"type": "function"
4040
}
4141
],
42-
"transactionHash": "0x29b0ca8c481531a2209f2f268db8195d6d2398f9dc93c09401bd65482ba71bc3",
42+
"transactionHash": "0xa7899bcb74e96e88994d8a9cccf51136680b236c2cfdab4ea2e7f3db5c4d797b",
4343
"receipt": {
4444
"to": null,
4545
"from": "0xF50E77f2A2B6138D16c6c7511562E5C33c4B15A3",
46-
"contractAddress": "0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD",
46+
"contractAddress": "0x1406bC99873d16Cde3491F809f1Af9442cb5A338",
4747
"transactionIndex": 0,
48-
"gasUsed": "1574087",
48+
"gasUsed": "1575466",
4949
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
50-
"blockHash": "0x191b5cf71955a086a177cc63ee65b9def4d729d65b90f1b7d2e3b7c152a46c74",
51-
"transactionHash": "0x29b0ca8c481531a2209f2f268db8195d6d2398f9dc93c09401bd65482ba71bc3",
50+
"blockHash": "0x1129d518a7b3498206754578e5c8882dd2266ece37a097986b2b3a0429ae58b6",
51+
"transactionHash": "0xa7899bcb74e96e88994d8a9cccf51136680b236c2cfdab4ea2e7f3db5c4d797b",
5252
"logs": [],
53-
"blockNumber": 9361449,
54-
"cumulativeGasUsed": "10087",
53+
"blockNumber": 9610366,
54+
"cumulativeGasUsed": "10086",
5555
"status": 1,
5656
"byzantium": true
5757
},
5858
"args": [],
5959
"numDeployments": 1,
60-
"solcInputHash": "9627b78546d73cee66a2022d221ca6c9",
60+
"solcInputHash": "0a1ec2a631b00a23a4a92b2eaceb36a5",
6161
"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}",
6262
"bytecode": "0x608060405234801561001057600080fd5b50610285806100206000396000f3fe60806040526004361061001e5760003560e01c8063be44ae1c14610023575b600080fd5b610036610031366004610101565b610048565b60405190815260200160405180910390f35b6040516349460b4d60e11b8152600090819060649063928c169a9061007390879087906004016101d1565b6020604051808303816000875af1158015610092573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b69190610236565b60405190915081907facd96f3817031b95eab52de9132d4a9dd13dac3d9dfcfe950ca9283c89b851a590600090a29392505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561011457600080fd5b82356001600160a01b038116811461012b57600080fd5b9150602083013567ffffffffffffffff8082111561014857600080fd5b818501915085601f83011261015c57600080fd5b81358181111561016e5761016e6100eb565b604051601f8201601f19908116603f01168101908382118183101715610196576101966100eb565b816040528281528860208487010111156101af57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60018060a01b038316815260006020604081840152835180604085015260005b8181101561020d578581018301518582016060015282016101f1565b8181111561021f576000606083870101525b50601f01601f191692909201606001949350505050565b60006020828403121561024857600080fd5b505191905056fea2646970667358221220691aeb3681b0b3a9b12bd40f31d52435b0fb90aeb41a724c79e99fdcc31d653c64736f6c634300080a0033",
6363
"deployedBytecode": "0x60806040526004361061001e5760003560e01c8063be44ae1c14610023575b600080fd5b610036610031366004610101565b610048565b60405190815260200160405180910390f35b6040516349460b4d60e11b8152600090819060649063928c169a9061007390879087906004016101d1565b6020604051808303816000875af1158015610092573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b69190610236565b60405190915081907facd96f3817031b95eab52de9132d4a9dd13dac3d9dfcfe950ca9283c89b851a590600090a29392505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561011457600080fd5b82356001600160a01b038116811461012b57600080fd5b9150602083013567ffffffffffffffff8082111561014857600080fd5b818501915085601f83011261015c57600080fd5b81358181111561016e5761016e6100eb565b604051601f8201601f19908116603f01168101908382118183101715610196576101966100eb565b816040528281528860208487010111156101af57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60018060a01b038316815260006020604081840152835180604085015260005b8181101561020d578581018301518582016060015282016101f1565b8181111561021f576000606083870101525b50601f01601f191692909201606001949350505050565b60006020828403121561024857600080fd5b505191905056fea2646970667358221220691aeb3681b0b3a9b12bd40f31d52435b0fb90aeb41a724c79e99fdcc31d653c64736f6c634300080a0033",

0 commit comments

Comments
 (0)