|
| 1 | +# @kleros/kleros-v2-contracts |
| 2 | + |
| 3 | +Smart contracts for Kleros v2 |
| 4 | + |
| 5 | +## Deployments |
| 6 | + |
| 7 | +Refresh the list of deployed contracts by running `./scripts/generateDeploymentsMarkdown.sh` or `./scripts/populateReadme.sh`. |
| 8 | + |
| 9 | +$deployments |
| 10 | + |
| 11 | +## Getting Started |
| 12 | + |
| 13 | +### Install the Dependencies |
| 14 | + |
| 15 | +```bash |
| 16 | +yarn install |
| 17 | +``` |
| 18 | + |
| 19 | +### Run Tests |
| 20 | + |
| 21 | +```bash |
| 22 | +yarn test |
| 23 | +``` |
| 24 | + |
| 25 | +### Compile the Contracts |
| 26 | + |
| 27 | +```bash |
| 28 | +yarn build |
| 29 | +``` |
| 30 | + |
| 31 | +### Run Linter on Files |
| 32 | + |
| 33 | +```bash |
| 34 | +yarn lint |
| 35 | +``` |
| 36 | + |
| 37 | +### Fix Linter Issues on Files |
| 38 | + |
| 39 | +```bash |
| 40 | +yarn fix |
| 41 | +``` |
| 42 | + |
| 43 | +### Deploy Instructions |
| 44 | + |
| 45 | +**NOTICE:** the commands below work only if you are inside the `contracts/` directory. |
| 46 | + |
| 47 | +#### 0. Set the Environment Variables |
| 48 | + |
| 49 | +Copy `.env.example` file as `.env` and edit it accordingly. |
| 50 | + |
| 51 | +```bash |
| 52 | +cp .env.example .env |
| 53 | +``` |
| 54 | + |
| 55 | +The following env vars are required: |
| 56 | + |
| 57 | +- `PRIVATE_KEY`: the private key of the deployer account used for the testnets. |
| 58 | +- `MAINNET_PRIVATE_KEY`: the private key of the deployer account used for Mainnet. |
| 59 | +- `INFURA_API_KEY`: the API key for infura. |
| 60 | + |
| 61 | +The ones below are optional: |
| 62 | + |
| 63 | +- `ETHERSCAN_API_KEY`: to verify the source of the newly deployed contracts on **Etherscan**. |
| 64 | +- `ARBISCAN_API_KEY`: to verify the source of the newly deployed contracts on **Arbitrum**. |
| 65 | +- `GNOSISSCAN_API_KEY`: to verify the source of the newly deployed contracts on **Gnosis chain**. |
| 66 | + |
| 67 | +#### 1. Update the Constructor Parameters (optional) |
| 68 | + |
| 69 | +If some of the constructor parameters (such as the Meta Evidence) needs to change, you need to update the files in the `deploy/` directory. |
| 70 | + |
| 71 | +#### 2. Deploy to a Local Network |
| 72 | + |
| 73 | +The complete deployment is multi-chain, so a deployment to the local network can only simulate either the Home chain or the Foreign chain. |
| 74 | + |
| 75 | +**Shell 1: the node** |
| 76 | + |
| 77 | +```bash |
| 78 | +yarn hardhat node --tags nothing |
| 79 | +``` |
| 80 | + |
| 81 | +**Shell 2: the deploy script** |
| 82 | + |
| 83 | +```bash |
| 84 | +yarn deploy --network localhost --tags <Arbitration|VeaMock|ForeignGatewayOnEthereum|HomeGateway> |
| 85 | +``` |
| 86 | + |
| 87 | +#### 3. Deploy to Public Testnets |
| 88 | + |
| 89 | +```bash |
| 90 | +# ArbitrumSepolia to Chiado |
| 91 | +yarn deploy --network arbitrumSepolia --tags Arbitration |
| 92 | +yarn deploy --network arbitrumSepolia --tags HomeArbitrable |
| 93 | +yarn deploy --network chiado --tags ForeignGatewayOnGnosis |
| 94 | +yarn deploy --network chiado --tags KlerosLiquidOnGnosis |
| 95 | +yarn deploy --network chiado --tags ForeignArbitrable |
| 96 | +yarn deploy --network arbitrumSepolia --tags HomeGatewayToGnosis |
| 97 | + |
| 98 | +# Sepolia |
| 99 | +yarn deploy --network sepolia --tags ForeignGatewayOnEthereum |
| 100 | +yarn deploy --network sepolia --tags ForeignArbitrable |
| 101 | +yarn deploy --network arbitrumSepolia --tags HomeGatewayToEthereum |
| 102 | +``` |
| 103 | + |
| 104 | +The deployed addresses should be displayed to the screen after the deployment is complete. If you missed them, you can always go to the `deployments/<network>` directory and look for the respective file. |
| 105 | + |
| 106 | +#### 4. Deploy a Devnet on Public Testnets |
| 107 | + |
| 108 | +Same steps as above but append `Devnet` to the `--network` parameter. |
| 109 | + |
| 110 | +#### Running Test Fixtures |
| 111 | + |
| 112 | +**Shell 1: the node** |
| 113 | + |
| 114 | +```bash |
| 115 | +yarn hardhat node --tags Arbitration,VeaMock |
| 116 | +``` |
| 117 | + |
| 118 | +**Shell 2: the test scripts** |
| 119 | + |
| 120 | +```bash |
| 121 | +yarn test --network localhost |
| 122 | +``` |
| 123 | + |
| 124 | +#### 4. Verify the Source Code |
| 125 | + |
| 126 | +This must be done for each network separately. |
| 127 | + |
| 128 | +```bash |
| 129 | +# explorer |
| 130 | +yarn etherscan-verify --network <arbitrumSepolia|arbitrum|chiado|gnosischain|sepolia|mainnet> |
| 131 | +yarn etherscan-verify-proxies |
| 132 | + |
| 133 | +# sourcify |
| 134 | +yarn sourcify --network <arbitrumSepolia|arbitrum|chiado|gnosischain|sepolia|mainnet> |
| 135 | + |
| 136 | +``` |
| 137 | + |
| 138 | +## Ad-hoc procedures |
| 139 | + |
| 140 | +### Populating the policy registry and courts |
| 141 | + |
| 142 | +The policy registry and courts configuration can be found in `config/policies.*.json` and `config/courts.*.json`. |
| 143 | + |
| 144 | +#### 1/ Export the registry data from V1 |
| 145 | + |
| 146 | +```bash |
| 147 | +for network in mainnet gnosischain |
| 148 | +do |
| 149 | + yarn hardhat run scripts/getPoliciesV1.ts --network $network | tee config/policies.v1.$network.json |
| 150 | + yarn hardhat run scripts/getCourtsV1.ts --network $network | tee config/courts.v1.$network.json |
| 151 | +done |
| 152 | +``` |
| 153 | + |
| 154 | +#### 2/ Import the data to V2 - Local Network |
| 155 | + |
| 156 | +Shell 1: |
| 157 | + |
| 158 | +```bash |
| 159 | +yarn hardhat node --tags Arbitration |
| 160 | +``` |
| 161 | + |
| 162 | +Shell 2: |
| 163 | + |
| 164 | +```bash |
| 165 | +yarn hardhat run scripts/populateCourts.ts --network localhost |
| 166 | +yarn hardhat run scripts/populatePolicyRegistry.ts --network localhost |
| 167 | +``` |
| 168 | + |
| 169 | +#### 3/ Import the data to V2 - Public Testnet |
| 170 | + |
| 171 | +```bash |
| 172 | +yarn hardhat run scripts/populateCourts.ts --network arbitrumSepolia |
| 173 | +yarn hardhat run scripts/populatePolicyRegistry.ts --network arbitrumSepolia |
| 174 | +``` |
| 175 | + |
| 176 | +### Generate deployment artifacts for existing contracts |
| 177 | + |
| 178 | +#### Usage |
| 179 | + |
| 180 | +```bash |
| 181 | +scripts/generateDeploymentArtifact.sh <network> <address> |
| 182 | +``` |
| 183 | + |
| 184 | +#### Example: WETH on Gnosis chain |
| 185 | + |
| 186 | +```bash |
| 187 | +scripts/generateDeploymentArtifact.sh gnosischain 0xf8d1677c8a0c961938bf2f9adc3f3cfda759a9d9 > deployments/gnosischain/WETH.json |
| 188 | +``` |
| 189 | + |
| 190 | +### Push the contracts to a Tenderly project |
| 191 | + |
| 192 | +Ensure that your `$TENDERLY_PROJECT` and `$TENDERLY_USERNAME` is set correctly in `.env`. |
| 193 | + |
| 194 | +```bash |
| 195 | +yarn tenderly-verify --network sepolia |
| 196 | +yarn tenderly-verify --network arbitrumSepolia |
| 197 | +``` |
0 commit comments