Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Court configs: new oracle court, edited spanish non-technical court #1848

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 54 additions & 19 deletions contracts/config/courts.v2.devnet.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,82 @@
[
{
"name": "General Court",
"id": 1,
"parent": 0,
"hiddenVotes": true,
"minStake": "520000000000000000000",
"minStake": "1500000000000000000",
"alpha": "5000",
"feeForJuror": "15000000000000000000",
"feeForJuror": "100000000000",
"jurorsForCourtJump": "511",
"timesPerPeriod": [
280800,
583200,
583200,
388800
120,
240,
240,
600
]
},
{
"name": "Curation",
"id": 2,
"parent": 1,
"hiddenVotes": false,
"minStake": "520000000000000000000",
"minStake": "2000000000000000000",
"alpha": "3100",
"feeForJuror": "6900000000000000000",
"jurorsForCourtJump": "30",
"feeForJuror": "100000000000",
"jurorsForCourtJump": "31",
"timesPerPeriod": [
140400,
291600,
291600,
194400
120,
240,
240,
600
]
},
{
"name": "English Language",
"id": 3,
"parent": 1,
"hiddenVotes": false,
"minStake": "1200000000000000000000",
"minStake": "2000000000000000000",
"alpha": "5000",
"feeForJuror": "22000000000000000000",
"feeForJuror": "100000000000",
"jurorsForCourtJump": "63",
"timesPerPeriod": [
280800,
437400,
437400,
291600
120,
240,
240,
600
]
},
{
"name": "Corte de Disputas de Consumo y Vecindad",
"id": 4,
"parent": 1,
"hiddenVotes": false,
"minStake": "2000000000000000000",
"alpha": "5000",
"feeForJuror": "100000000000",
"jurorsForCourtJump": "63",
"timesPerPeriod": [
120,
240,
240,
600
]
},
{
"name": "Oracle Court",
"id": 5,
"parent": 1,
"hiddenVotes": false,
"minStake": "2000000000000000000",
"alpha": "5000",
"feeForJuror": "100000000000",
"jurorsForCourtJump": "31",
"timesPerPeriod": [
120,
240,
240,
600
]
}
]
18 changes: 17 additions & 1 deletion contracts/config/courts.v2.mainnet-neo.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
]
},
{
"name": "Blockchain No Técnica",
"name": "Corte de Disputas de Consumo y Vecindad",
"id": 29,
"parent": 23,
"hiddenVotes": false,
Expand All @@ -462,5 +462,21 @@
216000,
216000
]
},
{
"name": "Oracle Court",
"id": 30,
"parent": 1,
"hiddenVotes": false,
"minStake": "5000000000000000000000",
"feeForJuror": "6900000000000000",
"alpha": "5000",
"jurorsForCourtJump": "31",
"timesPerPeriod": [
280800,
583200,
583200,
388800
]
}
]
37 changes: 36 additions & 1 deletion contracts/config/courts.v2.testnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
{
"name": "General Court",
"id": 1,
"parent": 0,
"hiddenVotes": true,
Expand All @@ -15,13 +16,14 @@
]
},
{
"name": "Curation",
"id": 2,
"parent": 1,
"hiddenVotes": false,
"minStake": "200000000000000000000",
"alpha": "3100",
"feeForJuror": "10000000000000",
"jurorsForCourtJump": "30",
"jurorsForCourtJump": "31",
"timesPerPeriod": [
43200,
43200,
Expand All @@ -30,6 +32,7 @@
]
},
{
"name": "English Language",
"id": 3,
"parent": 1,
"hiddenVotes": false,
Expand All @@ -43,5 +46,37 @@
43200,
43200
]
},
{
"name": "Corte de Disputas de Consumo y Vecindad",
"id": 4,
"parent": 1,
"hiddenVotes": false,
"minStake": "200000000000000000000",
"alpha": "5000",
"feeForJuror": "10000000000000",
"jurorsForCourtJump": "63",
"timesPerPeriod": [
43200,
43200,
43200,
43200
]
},
{
"name": "Oracle Court",
"id": 5,
"parent": 1,
"hiddenVotes": false,
"minStake": "200000000000000000000",
"alpha": "5000",
"feeForJuror": "10000000000000",
"jurorsForCourtJump": "31",
"timesPerPeriod": [
43200,
43200,
43200,
43200
]
}
]
34 changes: 25 additions & 9 deletions contracts/config/policies.v2.devnet.json

Large diffs are not rendered by default.

192 changes: 100 additions & 92 deletions contracts/config/policies.v2.mainnet-neo.json

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions contracts/config/policies.v2.testnet.json

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions contracts/config/policies.v2/Curation-Court-Policy.json

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/config/policies.v2/General-Court-Policy.json

This file was deleted.

7 changes: 7 additions & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
"docgen": "hardhat docgen",
"docserve": "scripts/docPreprocess.sh && forge doc --serve",
"docbuild": "scripts/docPreprocess.sh && forge doc --build --out dist && scripts/docPostprocess.sh",
"populate:courts:devnet": "hardhat populate:courts --from v2_devnet --network arbitrumSepoliaDevnet",
"populate:courts:testnet": "hardhat populate:courts --from v2_testnet --network arbitrumSepolia",
"populate:courts:mainnetNeo": "hardhat populate:courts --core-type neo --from v2_mainnet_neo --network arbitrum",
"populate:policiesUris": "scripts/setPoliciesURIs.sh config/policies.v2.{devnet,testnet,mainnet-neo}.json",
"populate:policies:devnet": "hardhat populate:policy-registry --from v2_devnet --network arbitrumSepoliaDevnet",
"populate:policies:testnet": "hardhat populate:policy-registry --from v2_testnet --network arbitrumSepolia",
"populate:policies:mainnetNeo": "hardhat populate:policy-registry --core-type neo --from v2_mainnet_neo --network arbitrum",
"release:patch": "scripts/publish.sh patch",
"release:minor": "scripts/publish.sh minor",
"release:major": "scripts/publish.sh major",
Expand Down
17 changes: 13 additions & 4 deletions contracts/scripts/populateCourts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ task("populate:courts", "Populates the courts and their parameters")
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo (default: auto depending on the network)",
undefined
)
.addOptionalParam("start", "The starting index for the courts to populate (default: 0)", 0, types.int)
.addOptionalParam(
"maxNumberOfCourts",
"The maximum number of courts to populate (default: all)",
Expand All @@ -61,6 +62,7 @@ task("populate:courts", "Populates the courts and their parameters")
"The type of core to use between base, neo, university (default: base)",
Cores.BASE.toString()
)
.addFlag("reverse", "Iterates the courts in reverse order, useful to increase minStake in the child courts first")
.addFlag("forceV1ParametersToDev", "Use development values for the v1 courts parameters")
.setAction(async (taskArgs, hre) => {
const { getNamedAccounts, getChainId, ethers, network } = hre;
Expand Down Expand Up @@ -133,7 +135,7 @@ task("populate:courts", "Populates the courts and their parameters")
break;
}
case Sources.V2_DEVNET: {
courtsV2 = courtsV2ArbitrumDevnet.map(parametersProductionToDev);
courtsV2 = courtsV2ArbitrumDevnet;
break;
}
case Sources.V2_TESTNET: {
Expand All @@ -148,9 +150,16 @@ task("populate:courts", "Populates the courts and their parameters")
throw new Error("Unknown source");
}

const maxNumberOfCourts = taskArgs.maxNumberOfCourts; // set to undefined for all the courts
console.log("Keeping only the first %d courts", maxNumberOfCourts ?? courtsV2.length);
courtsV2 = courtsV2.slice(0, maxNumberOfCourts);
// 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
const start = taskArgs.start;
const end = taskArgs.maxNumberOfCourts ? start + taskArgs.maxNumberOfCourts : courtsV2.length;
console.log(`Keeping only the first ${end - start} courts, starting from ${start}`);
courtsV2 = courtsV2.slice(start, end);

if (taskArgs.reverse) {
console.log("Reversing the order of courts");
courtsV2.reverse();
}

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

Expand Down
9 changes: 6 additions & 3 deletions contracts/scripts/populatePolicyRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ task("populate:policy-registry", "Populates the policy registry for each court")
"The source of the policies between v1_mainnet, v1_gnosis, v2_devnet, v2_testnet, v2_mainnet_neo (default: auto depending on the network)",
undefined
)
.addOptionalParam("start", "The starting index for the courts to populate (default: 0)", 0, types.int)
.addOptionalParam(
"maxNumberOfCourts",
"The maximum number of courts to populate (default: all)",
Expand Down Expand Up @@ -94,9 +95,11 @@ task("populate:policy-registry", "Populates the policy registry for each court")
return;
}

const maxNumberOfCourts = taskArgs.maxNumberOfCourts; // set to undefined for all the courts
console.log("Keeping only the first %d courts", maxNumberOfCourts ?? policiesV2.length);
policiesV2 = policiesV2.slice(0, maxNumberOfCourts);
// 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
const start = taskArgs.start;
const end = taskArgs.maxNumberOfCourts ? start + taskArgs.maxNumberOfCourts : policiesV2.length;
console.log(`Keeping only the first ${end - start} courts, starting from ${start}`);
policiesV2 = policiesV2.slice(start, end);

const policyRegistryDeployment = await deployments.get("PolicyRegistry");
const policyRegistry = (await ethers.getContractAt(
Expand Down
70 changes: 70 additions & 0 deletions contracts/scripts/setPoliciesURIs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

# Check if at least one input file is provided
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <input_policies_file1> [input_policies_file2 ...]"
exit 1
fi

# Process each input file
for INPUT_FILE in "$@"; do
# Validate file extension
if [[ ! "$INPUT_FILE" =~ \.json$ ]]; then
echo "Error: Input file $INPUT_FILE must have a .json extension"
continue
fi

echo "Processing $INPUT_FILE..."

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
INPUT_FILE_WITHOUT_EXTENSION="${INPUT_FILE%.json}"
POLICIES_DIR="$SCRIPT_DIR/../$INPUT_FILE_WITHOUT_EXTENSION"
HASHES_FILE=$(mktemp)

echo "Creating $POLICIES_DIR directory..."
mkdir -p $POLICIES_DIR

# Step 1: Create individual policy files and collect their hashes
echo "Creating individual policy files..."
echo "{" > "$HASHES_FILE"
first=true

jq -c '.[]' "$INPUT_FILE" | while read -r policy; do
name=$(echo "$policy" | jq -r '.name' | tr ' ' '-')
court=$(echo "$policy" | jq -r '.court')
policy_filepath="$POLICIES_DIR/${name}-Policy.json"

# Remove the uri field if it exists and save to a temporary file
echo "$policy" | jq 'del(.uri)' > "$policy_filepath"

# Get IPFS hash
ipfs_hash=$(ipfs add -Q "$policy_filepath")
if [ -n "$ipfs_hash" ]; then
echo "Preparing $name Court ($court): ${name}-Policy.json"
# Add comma for all but the first entry
if [ "$first" = true ]; then
first=false
else
echo "," >> "$HASHES_FILE"
fi
# Store the hash with court as key
echo "\"$court\": \"$ipfs_hash\"" >> "$HASHES_FILE"
else
echo "Failed to get IPFS hash for ${name}-Policy.json"
rm "$HASHES_FILE"
continue 2
fi
done

echo "}" >> "$HASHES_FILE"

# Step 2: Update the input file with URIs
echo "Updating URIs in $INPUT_FILE..."
jq --slurpfile hashes "$HASHES_FILE" '
map(. + {uri: ("/ipfs/" + ($hashes[0][.court | tostring]))})
' "$INPUT_FILE" > "${INPUT_FILE}.tmp" && mv "${INPUT_FILE}.tmp" "$INPUT_FILE"

rm "$HASHES_FILE"
echo "Done! URIs updated in $INPUT_FILE"
echo "----------------------------------------"
done
Loading
Loading