Skip to content

Commit 1a1c6fe

Browse files
committed
feat(deploy): referencing the PNK token for each chain
Updated the docs
1 parent 4b57748 commit 1a1c6fe

File tree

11 files changed

+220
-131
lines changed

11 files changed

+220
-131
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"mochaExplorer.files": "contracts/test/**/*.{j,t}s",
44
"cSpell.words": [
55
"arbitrum",
6+
"IERC",
67
"kleros"
78
]
89
}

contracts/README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
1616
- [ConstantNG](https://testnet.arbiscan.io/address/0x4401A368dea8D5761AEEFfd3c4a674086dea0666)
1717
- [DisputeKitClassic](https://testnet.arbiscan.io/address/0xD78DCddE2C5a2Bd4BB246Bc7dB6994b95f7c442C)
1818
- [FastBridgeSender](https://testnet.arbiscan.io/address/0x34E520dc1d2Db660113b64724e14CEdCD01Ee879)
19-
- [HomeGateway](https://testnet.arbiscan.io/address/0x40a78989317B953e427B3BD87C59eA003fcC2296)
20-
- [KlerosCore](https://testnet.arbiscan.io/address/0xf2a59723c5d625D646668E0B615B5764c3F81540)
19+
- [HomeGateway](https://testnet.arbiscan.io/address/0x4d18b9792e0D8F5aF696E71dBEDff8fcBEed6e8C)
20+
- [KlerosCore](https://testnet.arbiscan.io/address/0x5A407DcbD0F83ECbc1894C4B4f8Fc5b699D4822F)
2121
- [SafeBridgeArbitrum](https://testnet.arbiscan.io/address/0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD)
2222
- [SortitionSumTreeFactory](https://testnet.arbiscan.io/address/0xf02733d9e5CbfE67B54F165b0277E1995106D526)
2323

@@ -80,11 +80,34 @@ The ones below are optional:
8080

8181
If some of the constructor parameters (such as the Meta Evidence) needs to change, you need to update the files in the `deploy/` directory.
8282

83+
#### 2. Deploy to a Local Network
84+
85+
The complete deployment is multi-chain, so a deployment to the local network can only simulate either the Home chain or the Foreign chain.
86+
Currently the scripts support only deploying the HomeChain contracts to the local network.
87+
88+
**Shell 1: the node**
89+
90+
```bash
91+
yarn hardhat node --tags nothing
92+
```
93+
94+
**Shell 2: the deploy script**
95+
96+
```bash
97+
yarn hardhat deploy --network localhost --tags HomeChain
98+
```
99+
83100
#### 2. Deploy to Public Testnets
84101

85102
```bash
86-
yarn deploy:staging # to deploy to L1/L2 testnet
87-
# yarn deploy:production # to deploy to L1/L2 mainnet
103+
# To deploy on L2 only
104+
yarn hardhat deploy --network arbitrumRinkeby --tags HomeChain
105+
106+
# To deploy on L1 only
107+
yarn hardhat deploy --network rinkeby --tags ForeignChain
108+
109+
# To deploy both L1 and L2
110+
yarn deploy:staging
88111
```
89112

90113
The deployed addresses should be output to the screen after the deployment is complete.

contracts/deploy/00-home-chain-arbitration.ts

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33

4-
const HOME_CHAIN_IDS = [42161, 421611, 31337]; // ArbOne, ArbRinkeby, Hardhat
4+
enum HomeChains {
5+
ARBITRUM_ONE = 42161,
6+
ARBITRUM_RINKEBY = 421611,
7+
HARDHAT = 31337,
8+
}
9+
10+
const pnkByChain = new Map<HomeChains, string>([
11+
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
12+
[HomeChains.ARBITRUM_RINKEBY, "0x364530164a2338cdba211f72c1438eb811b5c639"],
13+
]);
514

615
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7-
const { deployments, getNamedAccounts } = hre;
16+
const { deployments, getNamedAccounts, getChainId } = hre;
817
const { deploy, execute } = deployments;
918
const { AddressZero } = hre.ethers.constants;
1019

1120
// fallback to hardhat node signers on local network
1221
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
13-
console.log("deployer: %s", deployer);
22+
const chainId = Number(await getChainId());
23+
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
1424

1525
const rng = await deploy("ConstantNG", {
1626
from: deployer,
@@ -29,21 +39,39 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2939
log: true,
3040
});
3141

32-
// TODO: deploy a PNK token if there isn't one already
42+
if (chainId === HomeChains.HARDHAT) {
43+
pnkByChain.set(
44+
HomeChains.HARDHAT,
45+
(
46+
await deploy("PNK", {
47+
from: deployer,
48+
log: true,
49+
})
50+
).address
51+
);
52+
}
53+
const pnk = pnkByChain.get(Number(await getChainId())) ?? AddressZero;
3354

3455
const klerosCore = await deploy("KlerosCore", {
3556
from: deployer,
3657
libraries: {
3758
SortitionSumTreeFactory: sortitionSumTreeLibrary.address,
3859
},
39-
args: [deployer, AddressZero, AddressZero, disputeKit.address, false, 200, 10000, 100, 3, [0, 0, 0, 0], 3],
60+
args: [deployer, pnk, AddressZero, disputeKit.address, false, 200, 10000, 100, 3, [0, 0, 0, 0], 3],
4061
log: true,
4162
});
4263

43-
await execute("DisputeKitClassic", { from: deployer, log: true }, "changeCore", klerosCore.address);
64+
// execute DisputeKitClassic.changeCore() only if necessary
65+
const currentCore = await hre.ethers.getContractAt("DisputeKitClassic", disputeKit.address).then((dk) => dk.core());
66+
if (currentCore !== klerosCore.address) {
67+
await execute("DisputeKitClassic", { from: deployer, log: true }, "changeCore", klerosCore.address);
68+
}
4469
};
4570

4671
deployArbitration.tags = ["HomeChain", "Arbitration"];
47-
deployArbitration.skip = async ({ getChainId }) => !HOME_CHAIN_IDS.includes(Number(await getChainId()));
72+
deployArbitration.skip = async ({ getChainId }) => {
73+
const chainId = Number(await getChainId());
74+
return !HomeChains[chainId];
75+
};
4876

4977
export default deployArbitration;

contracts/deploy/01-foreign-chain.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const paramsByChainId = {
2222
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2323
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
2424
const { deploy } = deployments;
25-
const { providers, constants } = ethers;
25+
const { providers } = ethers;
2626
const { hexZeroPad } = hre.ethers.utils;
2727

2828
const { deployer } = await getNamedAccounts();

contracts/deployments/arbitrumRinkeby/HomeGateway.json

+34-34
Large diffs are not rendered by default.

contracts/deployments/arbitrumRinkeby/KlerosCore.json

+83-83
Large diffs are not rendered by default.

contracts/hardhat.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "hardhat-deploy";
99
import "hardhat-deploy-ethers";
1010
import "hardhat-watcher";
1111
import "hardhat-docgen";
12+
import "hardhat-contract-sizer";
1213

1314
dotenv.config();
1415

contracts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"ethers": "^5.5.1",
3838
"follow-redirects": "^1.14.7",
3939
"hardhat": "^2.6.8",
40+
"hardhat-contract-sizer": "^2.4.0",
4041
"hardhat-deploy": "^0.10.5",
4142
"hardhat-deploy-ethers": "^0.3.0-beta.11",
4243
"hardhat-docgen": "^1.2.1",

contracts/src/arbitration/PNK.sol

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8;
4+
5+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6+
7+
contract PNK is ERC20 {
8+
constructor() ERC20("Pinakion", "PNK") {}
9+
}

contracts/test/arbitration/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function deployContracts(deployer) {
4141

4242
const disputeKitFactory = await ethers.getContractFactory("DisputeKitClassic", deployer);
4343
const disputeKit = await disputeKitFactory.deploy(
44-
deployer.address,
44+
deployer.address,
4545
ethers.constants.AddressZero, // KlerosCore is set later once it is deployed
4646
rng.address
4747
);
@@ -57,7 +57,7 @@ async function deployContracts(deployer) {
5757
},
5858
});
5959
const core = await klerosCoreFactory.deploy(
60-
deployer.address,
60+
deployer.address,
6161
ethers.constants.AddressZero, // should be an ERC20
6262
ethers.constants.AddressZero, // should be a Juror Prosecution module
6363
disputeKit.address,

yarn.lock

+26
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ __metadata:
10281028
ethers: ^5.5.1
10291029
follow-redirects: ^1.14.7
10301030
hardhat: ^2.6.8
1031+
hardhat-contract-sizer: ^2.4.0
10311032
hardhat-deploy: ^0.10.5
10321033
hardhat-deploy-ethers: ^0.3.0-beta.11
10331034
hardhat-docgen: ^1.2.1
@@ -4233,6 +4234,19 @@ __metadata:
42334234
languageName: node
42344235
linkType: hard
42354236

4237+
"cli-table3@npm:^0.6.0":
4238+
version: 0.6.1
4239+
resolution: "cli-table3@npm:0.6.1"
4240+
dependencies:
4241+
colors: 1.4.0
4242+
string-width: ^4.2.0
4243+
dependenciesMeta:
4244+
colors:
4245+
optional: true
4246+
checksum: 956e175f8eb019c26465b9f1e51121c08d8978e2aab04be7f8520ea8a4e67906fcbd8516dfb77e386ae3730ef0281aa21a65613dffbfa3d62969263252bd25a9
4247+
languageName: node
4248+
linkType: hard
4249+
42364250
"cli-truncate@npm:2.1.0, cli-truncate@npm:^2.1.0":
42374251
version: 2.1.0
42384252
resolution: "cli-truncate@npm:2.1.0"
@@ -8023,6 +8037,18 @@ __metadata:
80238037
languageName: node
80248038
linkType: hard
80258039

8040+
"hardhat-contract-sizer@npm:^2.4.0":
8041+
version: 2.4.0
8042+
resolution: "hardhat-contract-sizer@npm:2.4.0"
8043+
dependencies:
8044+
chalk: ^4.0.0
8045+
cli-table3: ^0.6.0
8046+
peerDependencies:
8047+
hardhat: ^2.0.0
8048+
checksum: 813111c3ae27264a1e50feecd0c2670421e9c77eb08ac474ab9b88b1c5cc7578cf3a7f0778f583d684e127084de9ca81be9412eeb02c593aa8acc7e6a42bde89
8049+
languageName: node
8050+
linkType: hard
8051+
80268052
"hardhat-deploy-ethers@npm:^0.3.0-beta.11":
80278053
version: 0.3.0-beta.13
80288054
resolution: "hardhat-deploy-ethers@npm:0.3.0-beta.13"

0 commit comments

Comments
 (0)