Skip to content

Commit e1a8571

Browse files
authored
Merge pull request #1848 from kleros/feat/court-configs
Court configs: new oracle court, edited spanish non-technical court
2 parents 4ed43ef + 5af7b1b commit e1a8571

15 files changed

+387
-162
lines changed
+54-19
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,82 @@
11
[
22
{
3+
"name": "General Court",
34
"id": 1,
45
"parent": 0,
56
"hiddenVotes": true,
6-
"minStake": "520000000000000000000",
7+
"minStake": "1500000000000000000",
78
"alpha": "5000",
8-
"feeForJuror": "15000000000000000000",
9+
"feeForJuror": "100000000000",
910
"jurorsForCourtJump": "511",
1011
"timesPerPeriod": [
11-
280800,
12-
583200,
13-
583200,
14-
388800
12+
120,
13+
240,
14+
240,
15+
600
1516
]
1617
},
1718
{
19+
"name": "Curation",
1820
"id": 2,
1921
"parent": 1,
2022
"hiddenVotes": false,
21-
"minStake": "520000000000000000000",
23+
"minStake": "2000000000000000000",
2224
"alpha": "3100",
23-
"feeForJuror": "6900000000000000000",
24-
"jurorsForCourtJump": "30",
25+
"feeForJuror": "100000000000",
26+
"jurorsForCourtJump": "31",
2527
"timesPerPeriod": [
26-
140400,
27-
291600,
28-
291600,
29-
194400
28+
120,
29+
240,
30+
240,
31+
600
3032
]
3133
},
3234
{
35+
"name": "English Language",
3336
"id": 3,
3437
"parent": 1,
3538
"hiddenVotes": false,
36-
"minStake": "1200000000000000000000",
39+
"minStake": "2000000000000000000",
3740
"alpha": "5000",
38-
"feeForJuror": "22000000000000000000",
41+
"feeForJuror": "100000000000",
3942
"jurorsForCourtJump": "63",
4043
"timesPerPeriod": [
41-
280800,
42-
437400,
43-
437400,
44-
291600
44+
120,
45+
240,
46+
240,
47+
600
48+
]
49+
},
50+
{
51+
"name": "Corte de Disputas de Consumo y Vecindad",
52+
"id": 4,
53+
"parent": 1,
54+
"hiddenVotes": false,
55+
"minStake": "2000000000000000000",
56+
"alpha": "5000",
57+
"feeForJuror": "100000000000",
58+
"jurorsForCourtJump": "63",
59+
"timesPerPeriod": [
60+
120,
61+
240,
62+
240,
63+
600
64+
]
65+
},
66+
{
67+
"name": "Oracle Court",
68+
"id": 5,
69+
"parent": 1,
70+
"hiddenVotes": false,
71+
"minStake": "2000000000000000000",
72+
"alpha": "5000",
73+
"feeForJuror": "100000000000",
74+
"jurorsForCourtJump": "31",
75+
"timesPerPeriod": [
76+
120,
77+
240,
78+
240,
79+
600
4580
]
4681
}
4782
]

contracts/config/courts.v2.mainnet-neo.json

+17-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
]
449449
},
450450
{
451-
"name": "Blockchain No Técnica",
451+
"name": "Corte de Disputas de Consumo y Vecindad",
452452
"id": 29,
453453
"parent": 23,
454454
"hiddenVotes": false,
@@ -462,5 +462,21 @@
462462
216000,
463463
216000
464464
]
465+
},
466+
{
467+
"name": "Oracle Court",
468+
"id": 30,
469+
"parent": 1,
470+
"hiddenVotes": false,
471+
"minStake": "5000000000000000000000",
472+
"feeForJuror": "6900000000000000",
473+
"alpha": "5000",
474+
"jurorsForCourtJump": "31",
475+
"timesPerPeriod": [
476+
280800,
477+
583200,
478+
583200,
479+
388800
480+
]
465481
}
466482
]

contracts/config/courts.v2.testnet.json

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
{
3+
"name": "General Court",
34
"id": 1,
45
"parent": 0,
56
"hiddenVotes": true,
@@ -15,13 +16,14 @@
1516
]
1617
},
1718
{
19+
"name": "Curation",
1820
"id": 2,
1921
"parent": 1,
2022
"hiddenVotes": false,
2123
"minStake": "200000000000000000000",
2224
"alpha": "3100",
2325
"feeForJuror": "10000000000000",
24-
"jurorsForCourtJump": "30",
26+
"jurorsForCourtJump": "31",
2527
"timesPerPeriod": [
2628
43200,
2729
43200,
@@ -30,6 +32,7 @@
3032
]
3133
},
3234
{
35+
"name": "English Language",
3336
"id": 3,
3437
"parent": 1,
3538
"hiddenVotes": false,
@@ -43,5 +46,37 @@
4346
43200,
4447
43200
4548
]
49+
},
50+
{
51+
"name": "Corte de Disputas de Consumo y Vecindad",
52+
"id": 4,
53+
"parent": 1,
54+
"hiddenVotes": false,
55+
"minStake": "200000000000000000000",
56+
"alpha": "5000",
57+
"feeForJuror": "10000000000000",
58+
"jurorsForCourtJump": "63",
59+
"timesPerPeriod": [
60+
43200,
61+
43200,
62+
43200,
63+
43200
64+
]
65+
},
66+
{
67+
"name": "Oracle Court",
68+
"id": 5,
69+
"parent": 1,
70+
"hiddenVotes": false,
71+
"minStake": "200000000000000000000",
72+
"alpha": "5000",
73+
"feeForJuror": "10000000000000",
74+
"jurorsForCourtJump": "31",
75+
"timesPerPeriod": [
76+
43200,
77+
43200,
78+
43200,
79+
43200
80+
]
4681
}
4782
]

contracts/config/policies.v2.devnet.json

+25-9
Large diffs are not rendered by default.

contracts/config/policies.v2.mainnet-neo.json

+100-92
Large diffs are not rendered by default.

contracts/config/policies.v2.testnet.json

+25-9
Large diffs are not rendered by default.

contracts/config/policies.v2/Curation-Court-Policy.json

-6
This file was deleted.

contracts/config/policies.v2/English-Language-Court-Policy.json

-6
This file was deleted.

contracts/config/policies.v2/General-Court-Policy.json

-5
This file was deleted.

contracts/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
"docgen": "hardhat docgen",
5353
"docserve": "scripts/docPreprocess.sh && forge doc --serve",
5454
"docbuild": "scripts/docPreprocess.sh && forge doc --build --out dist && scripts/docPostprocess.sh",
55+
"populate:courts:devnet": "hardhat populate:courts --from v2_devnet --network arbitrumSepoliaDevnet",
56+
"populate:courts:testnet": "hardhat populate:courts --from v2_testnet --network arbitrumSepolia",
57+
"populate:courts:mainnetNeo": "hardhat populate:courts --core-type neo --from v2_mainnet_neo --network arbitrum",
58+
"populate:policiesUris": "scripts/setPoliciesURIs.sh config/policies.v2.{devnet,testnet,mainnet-neo}.json",
59+
"populate:policies:devnet": "hardhat populate:policy-registry --from v2_devnet --network arbitrumSepoliaDevnet",
60+
"populate:policies:testnet": "hardhat populate:policy-registry --from v2_testnet --network arbitrumSepolia",
61+
"populate:policies:mainnetNeo": "hardhat populate:policy-registry --core-type neo --from v2_mainnet_neo --network arbitrum",
5562
"release:patch": "scripts/publish.sh patch",
5663
"release:minor": "scripts/publish.sh minor",
5764
"release:major": "scripts/publish.sh major",

contracts/scripts/populateCourts.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ task("populate:courts", "Populates the courts and their parameters")
5050
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo (default: auto depending on the network)",
5151
undefined
5252
)
53+
.addOptionalParam("start", "The starting index for the courts to populate (default: 0)", 0, types.int)
5354
.addOptionalParam(
5455
"maxNumberOfCourts",
5556
"The maximum number of courts to populate (default: all)",
@@ -61,6 +62,7 @@ task("populate:courts", "Populates the courts and their parameters")
6162
"The type of core to use between base, neo, university (default: base)",
6263
Cores.BASE.toString()
6364
)
65+
.addFlag("reverse", "Iterates the courts in reverse order, useful to increase minStake in the child courts first")
6466
.addFlag("forceV1ParametersToDev", "Use development values for the v1 courts parameters")
6567
.setAction(async (taskArgs, hre) => {
6668
const { getNamedAccounts, getChainId, ethers, network } = hre;
@@ -133,7 +135,7 @@ task("populate:courts", "Populates the courts and their parameters")
133135
break;
134136
}
135137
case Sources.V2_DEVNET: {
136-
courtsV2 = courtsV2ArbitrumDevnet.map(parametersProductionToDev);
138+
courtsV2 = courtsV2ArbitrumDevnet;
137139
break;
138140
}
139141
case Sources.V2_TESTNET: {
@@ -148,9 +150,16 @@ task("populate:courts", "Populates the courts and their parameters")
148150
throw new Error("Unknown source");
149151
}
150152

151-
const maxNumberOfCourts = taskArgs.maxNumberOfCourts; // set to undefined for all the courts
152-
console.log("Keeping only the first %d courts", maxNumberOfCourts ?? courtsV2.length);
153-
courtsV2 = courtsV2.slice(0, maxNumberOfCourts);
153+
// Warning: the indices are NOT the court IDs, e.g. the forking court is not present in the config so the indices are shifted by 1
154+
const start = taskArgs.start;
155+
const end = taskArgs.maxNumberOfCourts ? start + taskArgs.maxNumberOfCourts : courtsV2.length;
156+
console.log(`Keeping only the first ${end - start} courts, starting from ${start}`);
157+
courtsV2 = courtsV2.slice(start, end);
158+
159+
if (taskArgs.reverse) {
160+
console.log("Reversing the order of courts");
161+
courtsV2.reverse();
162+
}
154163

155164
console.log("courtsV2 = %O", courtsV2);
156165

contracts/scripts/populatePolicyRegistry.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ task("populate:policy-registry", "Populates the policy registry for each court")
2727
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo (default: auto depending on the network)",
2828
undefined
2929
)
30+
.addOptionalParam("start", "The starting index for the courts to populate (default: 0)", 0, types.int)
3031
.addOptionalParam(
3132
"maxNumberOfCourts",
3233
"The maximum number of courts to populate (default: all)",
@@ -94,9 +95,11 @@ task("populate:policy-registry", "Populates the policy registry for each court")
9495
return;
9596
}
9697

97-
const maxNumberOfCourts = taskArgs.maxNumberOfCourts; // set to undefined for all the courts
98-
console.log("Keeping only the first %d courts", maxNumberOfCourts ?? policiesV2.length);
99-
policiesV2 = policiesV2.slice(0, maxNumberOfCourts);
98+
// Warning: the indices are NOT the court IDs, e.g. the forking court is not present in the config so the indices are shifted by 1
99+
const start = taskArgs.start;
100+
const end = taskArgs.maxNumberOfCourts ? start + taskArgs.maxNumberOfCourts : policiesV2.length;
101+
console.log(`Keeping only the first ${end - start} courts, starting from ${start}`);
102+
policiesV2 = policiesV2.slice(start, end);
100103

101104
const policyRegistryDeployment = await deployments.get("PolicyRegistry");
102105
const policyRegistry = (await ethers.getContractAt(

contracts/scripts/setPoliciesURIs.sh

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
# Check if at least one input file is provided
4+
if [ "$#" -lt 1 ]; then
5+
echo "Usage: $0 <input_policies_file1> [input_policies_file2 ...]"
6+
exit 1
7+
fi
8+
9+
# Process each input file
10+
for INPUT_FILE in "$@"; do
11+
# Validate file extension
12+
if [[ ! "$INPUT_FILE" =~ \.json$ ]]; then
13+
echo "Error: Input file $INPUT_FILE must have a .json extension"
14+
continue
15+
fi
16+
17+
echo "Processing $INPUT_FILE..."
18+
19+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
20+
INPUT_FILE_WITHOUT_EXTENSION="${INPUT_FILE%.json}"
21+
POLICIES_DIR="$SCRIPT_DIR/../$INPUT_FILE_WITHOUT_EXTENSION"
22+
HASHES_FILE=$(mktemp)
23+
24+
echo "Creating $POLICIES_DIR directory..."
25+
mkdir -p $POLICIES_DIR
26+
27+
# Step 1: Create individual policy files and collect their hashes
28+
echo "Creating individual policy files..."
29+
echo "{" > "$HASHES_FILE"
30+
first=true
31+
32+
jq -c '.[]' "$INPUT_FILE" | while read -r policy; do
33+
name=$(echo "$policy" | jq -r '.name' | tr ' ' '-')
34+
court=$(echo "$policy" | jq -r '.court')
35+
policy_filepath="$POLICIES_DIR/${name}-Policy.json"
36+
37+
# Remove the uri field if it exists and save to a temporary file
38+
echo "$policy" | jq 'del(.uri)' > "$policy_filepath"
39+
40+
# Get IPFS hash
41+
ipfs_hash=$(ipfs add -Q "$policy_filepath")
42+
if [ -n "$ipfs_hash" ]; then
43+
echo "Preparing $name Court ($court): ${name}-Policy.json"
44+
# Add comma for all but the first entry
45+
if [ "$first" = true ]; then
46+
first=false
47+
else
48+
echo "," >> "$HASHES_FILE"
49+
fi
50+
# Store the hash with court as key
51+
echo "\"$court\": \"$ipfs_hash\"" >> "$HASHES_FILE"
52+
else
53+
echo "Failed to get IPFS hash for ${name}-Policy.json"
54+
rm "$HASHES_FILE"
55+
continue 2
56+
fi
57+
done
58+
59+
echo "}" >> "$HASHES_FILE"
60+
61+
# Step 2: Update the input file with URIs
62+
echo "Updating URIs in $INPUT_FILE..."
63+
jq --slurpfile hashes "$HASHES_FILE" '
64+
map(. + {uri: ("/ipfs/" + ($hashes[0][.court | tostring]))})
65+
' "$INPUT_FILE" > "${INPUT_FILE}.tmp" && mv "${INPUT_FILE}.tmp" "$INPUT_FILE"
66+
67+
rm "$HASHES_FILE"
68+
echo "Done! URIs updated in $INPUT_FILE"
69+
echo "----------------------------------------"
70+
done

0 commit comments

Comments
 (0)