Skip to content

Commit 408d8ae

Browse files
authored
Merge branch 'dev' into add-loading-error-states-stats
2 parents 552dfeb + 5e987c4 commit 408d8ae

31 files changed

+2666
-454
lines changed

.github/workflows/contracts-testing.yml

Lines changed: 121 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,129 @@ on:
1515
pull_request:
1616
branches:
1717
- "*"
18-
19-
permissions: # added using https://github.com/step-security/secure-workflows
18+
19+
permissions: # added using https://github.com/step-security/secure-workflows
2020
contents: read
2121

2222
jobs:
23-
contracts-testing:
23+
# *********************************************************************************** #
24+
# ******************************* Hardhat Tests ************************************* #
25+
# *********************************************************************************** #
26+
hardhat-tests:
2427
runs-on: ubuntu-latest
2528
steps:
26-
- name: Harden Runner
27-
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
28-
with:
29-
disable-sudo: false
30-
egress-policy: block
31-
allowed-endpoints: >
32-
binaries.soliditylang.org:443
33-
classic.yarnpkg.com:443
34-
github.com:443
35-
nightly.yarnpkg.com:443
36-
nodejs.org:443
37-
objects.githubusercontent.com:443
38-
registry.yarnpkg.com:443
39-
registry.npmjs.org:443
40-
54.185.253.63:443
41-
42-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43-
with:
44-
submodules: recursive
45-
46-
- name: Set up corepack (for yarn)
47-
run: |
48-
corepack enable
49-
corepack prepare [email protected] --activate
50-
yarn set version 4.9.2
51-
52-
- name: Setup Node.js environment
53-
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
54-
with:
55-
node-version: 20.x
56-
cache: yarn
57-
58-
- name: Cache node modules
59-
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
60-
env:
61-
cache-name: cache-node-modules
62-
with:
63-
path: |
64-
~/.npm
65-
**/node_modules
66-
key: ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
67-
restore-keys: |
68-
${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
69-
70-
- name: Install contracts dependencies
71-
run: yarn workspace @kleros/kleros-v2-contracts install
72-
73-
- name: Install Foundry
74-
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c # v1.3.1
75-
76-
- name: Install lcov
77-
run: sudo apt-get install -y lcov
78-
79-
- name: Run Hardhat and Foundry tests with coverage
80-
run: yarn coverage
81-
working-directory: contracts
82-
83-
- name: Upload a build artifact
84-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
85-
with:
86-
name: code-coverage-report
87-
path: contracts/coverage
29+
- name: Harden Runner
30+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
31+
with:
32+
disable-sudo: false
33+
egress-policy: block
34+
allowed-endpoints: >
35+
binaries.soliditylang.org:443
36+
classic.yarnpkg.com:443
37+
github.com:443
38+
nightly.yarnpkg.com:443
39+
nodejs.org:443
40+
objects.githubusercontent.com:443
41+
registry.yarnpkg.com:443
42+
registry.npmjs.org:443
43+
54.185.253.63:443
44+
45+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46+
with:
47+
submodules: recursive
48+
49+
- name: Set up corepack (for yarn)
50+
run: |
51+
corepack enable
52+
corepack prepare [email protected] --activate
53+
yarn set version 4.9.2
54+
55+
- name: Setup Node.js environment
56+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
57+
with:
58+
node-version: 20.x
59+
cache: yarn
60+
61+
- name: Cache node modules
62+
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
63+
env:
64+
cache-name: cache-node-modules
65+
with:
66+
path: |
67+
~/.npm
68+
**/node_modules
69+
key: ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
70+
restore-keys: |
71+
${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
72+
73+
- name: Install contracts dependencies
74+
run: yarn workspace @kleros/kleros-v2-contracts install
75+
76+
- name: Run Hardhat tests
77+
run: yarn test
78+
working-directory: contracts
79+
80+
# *********************************************************************************** #
81+
# ******************************* Foundry Tests ************************************* #
82+
# *********************************************************************************** #
83+
# COMPILATION FAILS 🤬
84+
# foundry-tests:
85+
# runs-on: ubuntu-latest
86+
# steps:
87+
# - name: Harden Runner
88+
# uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
89+
# with:
90+
# disable-sudo: false
91+
# egress-policy: block
92+
# allowed-endpoints: >
93+
# binaries.soliditylang.org:443
94+
# classic.yarnpkg.com:443
95+
# github.com:443
96+
# nightly.yarnpkg.com:443
97+
# nodejs.org:443
98+
# objects.githubusercontent.com:443
99+
# registry.yarnpkg.com:443
100+
# registry.npmjs.org:443
101+
# 54.185.253.63:443
102+
103+
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
104+
# with:
105+
# submodules: recursive
106+
107+
# - name: Set up corepack (for yarn)
108+
# run: |
109+
# corepack enable
110+
# corepack prepare [email protected] --activate
111+
# yarn set version 4.9.2
112+
113+
# - name: Setup Node.js environment
114+
# uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
115+
# with:
116+
# node-version: 20.x
117+
# cache: yarn
118+
119+
# - name: Cache node modules
120+
# uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
121+
# env:
122+
# cache-name: cache-node-modules
123+
# with:
124+
# path: |
125+
# ~/.npm
126+
# **/node_modules
127+
# key: ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
128+
# restore-keys: |
129+
# ${{ runner.os }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
130+
131+
# # - name: Install contracts dependencies
132+
# # run: yarn workspace @kleros/kleros-v2-contracts install
133+
134+
# - name: Install Foundry
135+
# uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
136+
137+
# - name: Run Foundry tests
138+
# run: forge test --config-path ./foundry.toml
139+
# working-directory: contracts
140+
141+
# - name: Run snapshot
142+
# run: NO_COLOR=1 forge snapshot >> $GITHUB_STEP_SUMMARY
143+
# working-directory: contracts

contracts/CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,33 @@ The format is based on [Common Changelog](https://common-changelog.org/).
1313
- **Breaking:** Rename the interface from `RNG` to `IRNG` ([#2054](https://github.com/kleros/kleros-v2/issues/2054))
1414
- **Breaking:** Remove the `_block` parameter from `IRNG.requestRandomness()` and `IRNG.receiveRandomness()`, not needed for the primary VRF-based RNG ([#2054](https://github.com/kleros/kleros-v2/issues/2054))
1515
- **Breaking:** Rename `governor` to `owner` in order to comply with the lightweight ownership standard [ERC-5313](https://eipsinsight.com/ercs/erc-5313) ([#2112](https://github.com/kleros/kleros-v2/issues/2112))
16+
- **Breaking:** Apply the penalties to the stakes in the Sortition Tree ([#2107](https://github.com/kleros/kleros-v2/issues/2107))
17+
- **Breaking:** Make `SortitionModule.getJurorBalance().stakedInCourt` include the penalties ([#2107](https://github.com/kleros/kleros-v2/issues/2107))
18+
- Make `IDisputeKit.draw()` and `ISortitionModule.draw()` return the court ID from which the juror was drawn ([#2107](https://github.com/kleros/kleros-v2/issues/2107))
19+
- Rename `SortitionModule.setJurorInactive()` to `SortitionModule.forcedUnstakeAllCourts()` ([#2107](https://github.com/kleros/kleros-v2/issues/2107))
1620
- Make the primary VRF-based RNG fall back to `BlockhashRNG` if the VRF request is not fulfilled within a timeout ([#2054](https://github.com/kleros/kleros-v2/issues/2054))
1721
- Authenticate the calls to the RNGs to prevent 3rd parties from depleting the Chainlink VRF subscription funds ([#2054](https://github.com/kleros/kleros-v2/issues/2054))
1822
- Use `block.timestamp` rather than `block.number` for `BlockhashRNG` for better reliability on Arbitrum as block production is sporadic depending on network conditions. ([#2054](https://github.com/kleros/kleros-v2/issues/2054))
23+
- Replace the `bytes32 _key` parameter in `SortitionTrees.createTree()` and `SortitionTrees.draw()` by `uint96 courtID` ([#2113](https://github.com/kleros/kleros-v2/issues/2113))
24+
- Extract the sortition sum trees logic into a library `SortitionTrees` ([#2113](https://github.com/kleros/kleros-v2/issues/2113))
25+
- Make `IDisputeKit.getDegreeOfCoherenceReward()` multi-dimensional so different calculations may be applied to PNK rewards, fee rewards and PNK penalties (future-proofing) ([#2090](https://github.com/kleros/kleros-v2/issues/2090))
26+
- Consolidate the constant `ALPHA_DIVISOR` with `ONE_BASIS_POINTS` ([#2090](https://github.com/kleros/kleros-v2/issues/2090))
1927
- Set the Hardhat Solidity version to v0.8.30 and enable the IR pipeline ([#2069](https://github.com/kleros/kleros-v2/issues/2069))
2028
- Set the Foundry Solidity version to v0.8.30 and enable the IR pipeline ([#2073](https://github.com/kleros/kleros-v2/issues/2073))
2129
- Widen the allowed solc version to any v0.8.x for the interfaces only ([#2083](https://github.com/kleros/kleros-v2/issues/2083))
22-
- Make `IDisputeKit.getDegreeOfCoherenceReward()` multi-dimensional so different calculations may be applied to PNK rewards, fee rewards and PNK penalties (future-proofing) ([#2090](https://github.com/kleros/kleros-v2/issues/2090))
23-
- Consolidate the constant `ALPHA_DIVISOR` with `ONE_BASIS_POINTS` ([#2090](https://github.com/kleros/kleros-v2/issues/2090))
2430
- Bump `hardhat` to v2.26.2 ([#2069](https://github.com/kleros/kleros-v2/issues/2069))
2531
- Bump `@kleros/vea-contracts` to v0.7.0 ([#2073](https://github.com/kleros/kleros-v2/issues/2073))
2632

2733
### Added
2834

35+
- **Breaking:** Add a new field `drawnJurorFromCourtIDs` to the `Round` struct in `KlerosCoreBase` and `KlerosCoreUniversity` ([#2107](https://github.com/kleros/kleros-v2/issues/2107))
36+
- **Breaking:** Add a new state variable `jumpDisputeKitID` to the `DisputeKitClassicBase` contract ([#2114](https://github.com/kleros/kleros-v2/issues/2114))
37+
- **Breaking:** Add a parameter `_recoveryCommit` to the event `DisputeKitShutter.CommitCastShutter` ([#2100](https://github.com/kleros/kleros-v2/issues/2100))
38+
- **Breaking:** Add a storage variable `recoveryCommitments` to `DisputeKitShutter` ([#2100](https://github.com/kleros/kleros-v2/issues/2100))
39+
- Allow the Shutter commitment to be recovered by the juror using only the salt and the choice, without having to provide the justification ([#2100](https://github.com/kleros/kleros-v2/issues/2100))
2940
- Allow the dispute kits to force an early court jump and to override the number of votes after an appeal (future-proofing) ([#2110](https://github.com/kleros/kleros-v2/issues/2110))
41+
- Allow the dispute kits to specify which new dispute kit to use when a court jump occurs ([#2114](https://github.com/kleros/kleros-v2/issues/2114))
42+
- Allow stake changes to by-pass delayed stakes when initiated by the SortitionModule by setting the `_noDelay` parameter to `true` in `SortitionModule.validateStake()` ([#2107](https://github.com/kleros/kleros-v2/issues/2107))
3043

3144
### Fixed
3245

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2828

2929
await deployUpgradable(deployments, "EvidenceModule", { from: deployer, args: [deployer], log: true });
3030

31+
const classicDisputeKitID = 1; // Classic DK
3132
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
3233
from: deployer,
3334
contract: "DisputeKitClassic",
34-
args: [deployer, ZeroAddress, weth.target],
35+
args: [deployer, ZeroAddress, weth.target, classicDisputeKitID],
3536
log: true,
3637
});
3738

@@ -124,24 +125,27 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
124125
// Extra dispute kits
125126
const disputeKitShutter = await deployUpgradable(deployments, "DisputeKitShutter", {
126127
from: deployer,
127-
args: [deployer, core.target, weth.target],
128+
args: [deployer, core.target, weth.target, classicDisputeKitID],
128129
log: true,
129130
});
130131
await core.addNewDisputeKit(disputeKitShutter.address);
132+
const disputeKitShutterID = (await core.getDisputeKitsLength()) - 1n;
131133

132134
const disputeKitGated = await deployUpgradable(deployments, "DisputeKitGated", {
133135
from: deployer,
134-
args: [deployer, core.target, weth.target],
136+
args: [deployer, core.target, weth.target, classicDisputeKitID],
135137
log: true,
136138
});
137139
await core.addNewDisputeKit(disputeKitGated.address);
140+
const disputeKitGatedID = (await core.getDisputeKitsLength()) - 1n;
138141

139142
const disputeKitGatedShutter = await deployUpgradable(deployments, "DisputeKitGatedShutter", {
140143
from: deployer,
141-
args: [deployer, core.target, weth.target],
144+
args: [deployer, core.target, weth.target, disputeKitShutterID], // Does not jump to DKClassic
142145
log: true,
143146
});
144147
await core.addNewDisputeKit(disputeKitGatedShutter.address);
148+
const disputeKitGatedShutterID = (await core.getDisputeKitsLength()) - 1n;
145149

146150
// Snapshot proxy
147151
await deploy("KlerosCoreSnapshotProxy", {

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3434
log: true,
3535
});
3636

37+
const classicDisputeKitID = 1; // Classic DK
3738
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
3839
from: deployer,
39-
args: [deployer, ZeroAddress, weth.target],
40+
args: [deployer, ZeroAddress, weth.target, classicDisputeKitID],
4041
log: true,
4142
});
4243

@@ -105,27 +106,30 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
105106
// Extra dispute kits
106107
const disputeKitShutter = await deployUpgradable(deployments, "DisputeKitShutter", {
107108
from: deployer,
108-
args: [deployer, core.target, weth.target],
109+
args: [deployer, core.target, weth.target, classicDisputeKitID],
109110
log: true,
110111
});
111112
await core.addNewDisputeKit(disputeKitShutter.address);
112-
await core.enableDisputeKits(Courts.GENERAL, [2], true); // enable disputeKitShutter on the General Court
113+
const disputeKitShutterID = (await core.getDisputeKitsLength()) - 1n;
114+
await core.enableDisputeKits(Courts.GENERAL, [disputeKitShutterID], true); // enable disputeKitShutter on the General Court
113115

114116
const disputeKitGated = await deployUpgradable(deployments, "DisputeKitGated", {
115117
from: deployer,
116-
args: [deployer, core.target, weth.target],
118+
args: [deployer, core.target, weth.target, classicDisputeKitID],
117119
log: true,
118120
});
119121
await core.addNewDisputeKit(disputeKitGated.address);
120-
await core.enableDisputeKits(Courts.GENERAL, [3], true); // enable disputeKitGated on the General Court
122+
const disputeKitGatedID = (await core.getDisputeKitsLength()) - 1n;
123+
await core.enableDisputeKits(Courts.GENERAL, [disputeKitGatedID], true); // enable disputeKitGated on the General Court
121124

122125
const disputeKitGatedShutter = await deployUpgradable(deployments, "DisputeKitGatedShutter", {
123126
from: deployer,
124-
args: [deployer, core.target, weth.target],
127+
args: [deployer, core.target, weth.target, disputeKitShutterID], // Does not jump to DKClassic
125128
log: true,
126129
});
127130
await core.addNewDisputeKit(disputeKitGatedShutter.address);
128-
await core.enableDisputeKits(Courts.GENERAL, [4], true); // enable disputeKitGatedShutter on the General Court
131+
const disputeKitGatedShutterID = (await core.getDisputeKitsLength()) - 1n;
132+
await core.enableDisputeKits(Courts.GENERAL, [disputeKitGatedShutterID], true); // enable disputeKitGatedShutter on the General Court
129133

130134
// Snapshot proxy
131135
await deploy("KlerosCoreSnapshotProxy", {

contracts/foundry.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11

22
[profile.default]
33
solc = "0.8.30"
4+
evm_version = "cancun"
45
via_ir = true
56
optimizer = true
6-
optimizer_runs = 500
7-
optimizer_details = { yulDetails = { stackAllocation = true } }
8-
additional_compiler_profiles = [
9-
{ name = "tests", via_ir = false }
10-
]
11-
compilation_restrictions = [
12-
{ paths = "test/foundry/KlerosCore.t.sol", via_ir = false },
13-
]
7+
optimizer_runs = 10000
8+
149
src = 'src'
1510
out = 'out'
1611
libs = ['../node_modules', 'lib']

contracts/hardhat.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const config: HardhatUserConfig = {
2828
{
2929
version: "0.8.30",
3030
settings: {
31+
evmVersion: "cancun",
3132
viaIR: process.env.VIA_IR !== "false", // Defaults to true
3233
optimizer: {
3334
enabled: true,

0 commit comments

Comments
 (0)