-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from gluwa/fork-off-testnet
merge testnet into main
- Loading branch information
Showing
292 changed files
with
61,922 additions
and
17,937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dryRunSpec.json filter=lfs diff=lfs merge=lfs -text | ||
dryRunSpecRaw.json filter=lfs diff=lfs merge=lfs -text | ||
mainnetSpecRaw.json filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Default owners for everything in the repository | ||
|
||
* @gluwa/blockchain-engineering | ||
* @gluwa/creditcoin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOYiBGthrSNqUJdN9h9PHzXQL8cP8gj5pP9LZDx7BVgt/Knm9NwAe9hD/7fs9zmyECmZ5ubHDqG0x7Hb7DAjl+oPkCOxqRj5Npfvl1VRwwgXl3ymfI3JJpF7Cna4n0XdylBsTiwOL1/zoVXEJgTYEDEsP4gv65i8M/uWlsrfFwHLDEr3EQKnA0H4Ekz1CU2n9MFprX1hzA5IItozQUsYxKTPr1mxNTi1AFMhDEztMelvPO1OuC8MBZURR9S/+SlZ8ydCUcwl0gdCcgpUfouiuN9Yr9UbiV/yrAxEY3oKX8OegFmWEioUIZoFSiXl3sNP39ntOR4i+GV54g4omN6JbN3ios9LXBPMuvCy1NgFYPmDmmSEuo7n2IsP3pcXjZXpl4Ymwvn4RJviOZq8vghF5p0YMtCis1LxHL90epibxGoV6nc5isrOzqfgNUA9IS1zx7ZMoaF1PT8QcT8NzgNocrrhH4xGeTLD7WOOxykVASBnIXea8p7dl29/G0ThmS7Bc= [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Example: Compile and benchmark the bridge pallet. | ||
# ./scripts/bench.sh -p bridge -cb | ||
|
||
PALLET=bridge | ||
COMMAND=build | ||
BENCH=1 | ||
BUILD=1 | ||
REPEAT=30 | ||
STEPS=50 | ||
|
||
while getopts "fcbp:r:s:" opt;do | ||
case $opt in | ||
(f) COMMAND=check BUILD=0;; | ||
(c) BUILD=0;; | ||
(p) PALLET=$OPTARG;; | ||
(b) BENCH=0;; | ||
(r) REPEAT=$OPTARG;; | ||
(s) STEPS=$OPTARG;; | ||
(*) | ||
echo "ERROR: Invalid flag detected" | ||
exit 3 | ||
esac | ||
done | ||
|
||
|
||
OUTPUT="./pallets/${PALLET//_/-}/src/weights.rs" | ||
mkdir -p "pallets/$PALLET/src" | ||
|
||
if [[ $BUILD -eq 0 ]] | ||
then | ||
cargo $COMMAND --release --features runtime-benchmarks || exit 1; | ||
fi | ||
|
||
if [[ $BENCH -eq 0 ]] | ||
then | ||
./target/release/creditcoin3-node benchmark pallet --chain dev --steps="$STEPS" --repeat="$REPEAT" --pallet "pallet_$PALLET" --extrinsic='*' --wasm-execution=compiled --heap-pages=10000 --output "$OUTPUT" | ||
sed -i "s/pallet_$PALLET/crate/" "$OUTPUT" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Directory containing JSON files | ||
chainspecs_dir="chainspecs" | ||
|
||
# Check if chainspecs directory exists | ||
if [ ! -d "$chainspecs_dir" ]; then | ||
echo "Error: Directory $chainspecs_dir does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Flag to track if bootNodes are found | ||
bootnodes_found=0 | ||
|
||
# Iterate over JSON files in the directory | ||
for file in "$chainspecs_dir"/*.json; do | ||
echo "Checking $file" | ||
# Read the JSON file | ||
json=$(cat "$file") | ||
|
||
# Check if the bootNodes field is empty | ||
if [[ $(echo "$json" | jq -r '.bootNodes | length') -ne 0 ]]; then | ||
echo "BootNodes field is not empty." | ||
bootnodes_found=1 | ||
fi | ||
done | ||
|
||
# Exit with error if bootNodes are found | ||
if [ $bootnodes_found -eq 1 ]; then | ||
echo "Error: BootNodes found in at least one chainspec file." | ||
exit 1 | ||
else | ||
echo "No BootNodes found in any chainspec file." | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script: | ||
# - Checks for changes in transaction version in runtime/src/version.rs | ||
# - Downloads latest release binary from gluwa/creditcoin (RELEASE_BIN) | ||
# - Compiles and build a binary from the current branch (HEAD_BIN) | ||
# - Runs the two nodes | ||
|
||
set -ex | ||
|
||
HEAD_BIN=./target/release/creditcoin3-node | ||
HEAD_WS=ws://localhost:9944 | ||
RELEASE_WS=ws://localhost:9955 | ||
|
||
runtimes=( | ||
"creditcoin3-runtime" | ||
) | ||
|
||
# First we fetch the latest released binary | ||
latest_release_tag() { | ||
# WARNING: $GITHUB_TOKEN must be defined in the calling environment because this is a private repository | ||
curl --silent --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$1/releases/latest" | jq -r '.tag_name' | ||
} | ||
|
||
latest_release_url() { | ||
# WARNING: $GITHUB_TOKEN must be defined in the calling environment because this is a private repository | ||
curl --silent --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$1/releases/latest" | jq -r '.url' | ||
} | ||
|
||
latest_tag=$(latest_release_tag 'gluwa/creditcoin3') | ||
latest_url=$(latest_release_url 'gluwa/creditcoin3') | ||
RELEASE_BIN="./creditcoin3-node" | ||
echo "[+] Fetching binary for Creditcoin version $latest_tag" | ||
# WARNING: $GITHUB_TOKEN must be defined in the calling environment because this is a private repository | ||
asset_url=$(curl --silent --header "Authorization: Bearer $GITHUB_TOKEN" \ | ||
"${latest_url}" | jq -r ".assets[] | select(.name==\"creditcoin-${latest_tag}-x86_64-unknown-linux-gnu.zip\") | .url" | ||
) | ||
curl --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/octet-stream" -L \ | ||
"${asset_url}" --output creditcoin.zip | ||
unzip creditcoin.zip | ||
chmod +x "$RELEASE_BIN" | ||
git fetch --depth="${GIT_DEPTH:-100}" origin 'refs/tags/*:refs/tags/*' | ||
|
||
|
||
for RUNTIME in "${runtimes[@]}"; do | ||
echo "[+] Checking runtime: ${RUNTIME}" | ||
|
||
release_transaction_version=$(git show "tags/$latest_tag:runtime/src/version.rs" | grep 'transaction_version') | ||
|
||
current_transaction_version=$( | ||
grep 'transaction_version' "./runtime/src/version.rs" | ||
) | ||
|
||
echo "[+] Release: ${release_transaction_version}" | ||
echo "[+] Ours: ${current_transaction_version}" | ||
|
||
|
||
# Start running the nodes in the background | ||
$HEAD_BIN --chain=local --tmp >head-node.log 2>&1 & | ||
$RELEASE_BIN --chain=local --rpc-port 9955 --tmp --port 30555 >release-node.log 2>&1 & | ||
jobs | ||
|
||
#Wait for HEAD BINARY | ||
./.github/wait-for-creditcoin.sh 'http://127.0.0.1:9944' | ||
#Wait for RELEASE BINARY | ||
./.github/wait-for-creditcoin.sh 'http://127.0.0.1:9955' | ||
|
||
changed_extrinsics=$( | ||
polkadot-js-metadata-cmp "$RELEASE_WS" "$HEAD_WS" \ | ||
| sed 's/^ \+//g' | grep -e 'idx: [0-9]\+ -> [0-9]\+' || true | ||
) | ||
|
||
# compare to mainnet and testnet explicitly b/c latest release could be any of them | ||
# for now this comparison is only used to provide more info in CI | ||
# polkadot-js-metadata-cmp wss://rpc.cc3-mainnet.creditcoin.network/ws "$HEAD_WS" > metadata-cmp-with-mainnet.txt | ||
# polkadot-js-metadata-cmp wss://rpc.cc3-testnet.creditcoin.network/ws "$HEAD_WS" > metadata-cmp-with-testnet.txt | ||
|
||
if [ -n "$changed_extrinsics" ]; then | ||
echo "[!] Extrinsics indexing/ordering has changed in the ${RUNTIME} runtime! If this change is intentional, please bump transaction_version in lib.rs. Changed extrinsics:" | ||
echo "$changed_extrinsics" | ||
|
||
if [ "$release_transaction_version" == "$current_transaction_version" ]; then | ||
exit 1 | ||
else | ||
echo "[+] Transaction version for ${RUNTIME} has been bumped since last release. Exiting." | ||
fi | ||
fi | ||
|
||
echo "[+] No change in extrinsics ordering for the ${RUNTIME} runtime" | ||
jobs -p | xargs kill -9 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
set -xeuo pipefail | ||
|
||
# Colorful output. | ||
function greenprint { | ||
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" | ||
} | ||
|
||
check_block_time() { | ||
# WARNING: exits on error | ||
from=$1 | ||
to=$2 | ||
|
||
if git --no-pager diff "${from}...${to}" | grep 'MILLISECS_PER_BLOCK'; then | ||
greenprint "FAIL: MILLISECS_PER_BLOCK has been modified! This will brick the blockchain!" | ||
exit 1 | ||
else | ||
greenprint "PASS: MILLISECS_PER_BLOCK has not been modified!" | ||
fi | ||
} | ||
|
||
check_blocks_for_faster_epoch() { | ||
# WARNING: exits on error | ||
from=$1 | ||
to=$2 | ||
|
||
if git --no-pager diff "${from}...${to}" | grep 'BLOCKS_FOR_FASTER_EPOCH'; then | ||
greenprint "FAIL: BLOCKS_FOR_FASTER_EPOCH has been modified! This will brick Devnet!" | ||
exit 1 | ||
else | ||
greenprint "PASS: BLOCKS_FOR_FASTER_EPOCH has not been modified!" | ||
fi | ||
} | ||
|
||
check_epoch_duration() { | ||
# WARNING: exits on error | ||
from=$1 | ||
to=$2 | ||
|
||
if git --no-pager diff "${from}...${to}" | grep 'EPOCH_DURATION'; then | ||
greenprint "FAIL: EPOCH_DURATION has been modified! This will brick the blockchain!" | ||
exit 1 | ||
else | ||
greenprint "PASS: EPOCH_DURATION has not been modified!" | ||
fi | ||
} | ||
|
||
check_slot_duration() { | ||
# WARNING: exits on error | ||
from=$1 | ||
to=$2 | ||
|
||
if git --no-pager diff "${from}...${to}" | grep 'SLOT_DURATION'; then | ||
greenprint "FAIL: SLOT_DURATION has been modified! This will brick the blockchain!" | ||
exit 1 | ||
else | ||
greenprint "PASS: SLOT_DURATION has not been modified!" | ||
fi | ||
} | ||
|
||
|
||
#### main part | ||
|
||
FROM=$(git rev-parse "${1:-origin/dev}") | ||
TO=$(git rev-parse "${2:-HEAD}") | ||
|
||
greenprint "DEBUG: Inspecting range $FROM..$TO" | ||
|
||
if [ -z "$FROM" ]; then | ||
echo "ERROR: FROM is empty. Exiting..." | ||
exit 2 | ||
fi | ||
|
||
if [ -z "$TO" ]; then | ||
echo "ERROR: TO is empty. Exiting..." | ||
exit 2 | ||
fi | ||
|
||
if git --no-pager diff --name-only "${FROM}"..."${TO}" | grep -e '^runtime'; then | ||
greenprint "INFO: runtime/ has been modified. Checking for changes in EPOCH_DURATION!" | ||
check_block_time "${FROM}" "${TO}" | ||
check_blocks_for_faster_epoch "${FROM}" "${TO}" | ||
check_epoch_duration "${FROM}" "${TO}" | ||
check_slot_duration "${FROM}" "${TO}" | ||
else | ||
greenprint "INFO: runtime/ has NOT been modified. Will NOT check for changes in EPOCH_DURATION!" | ||
fi |
40 changes: 40 additions & 0 deletions
40
.github/check-for-missing-Cargo-toml-in-Dependabot-config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Check if there are Cargo.toml files which have not been specified in | ||
# Dependabot's configuration! | ||
# | ||
# WARNING: needs to be executed from the project root directory | ||
|
||
DEPENDABOT_YAML=".github/dependabot.yml" | ||
|
||
CARGO_FILES_IN_DEPENDABOT_YAML=$(grep package-ecosystem -A1 "$DEPENDABOT_YAML" | grep -A1 cargo | grep directory | cut -f2 -d'"' | sort | while IFS= read -r DIR; do echo ".$DIR/Cargo.toml" | tr -s "//"; done) | ||
echo "INFO: Cargo.toml files found in $DEPENDABOT_YAML" | ||
echo "$CARGO_FILES_IN_DEPENDABOT_YAML" | ||
echo "----- END -----" | ||
echo | ||
echo | ||
CARGO_FILES_IN_SOURCE_CODE=$(find ./ -name Cargo.toml | sort) | ||
echo "INFO: Cargo.toml files found in source code" | ||
echo "$CARGO_FILES_IN_SOURCE_CODE" | ||
echo "----- END -----" | ||
echo | ||
echo | ||
MISSING_FILES=0 | ||
for FILE in $CARGO_FILES_IN_SOURCE_CODE; do | ||
if [[ $CARGO_FILES_IN_DEPENDABOT_YAML = *$FILE* ]]; then | ||
echo "PASS: $FILE is accounted for in $DEPENDABOT_YAML" | ||
else | ||
echo "FAIL: $FILE is NOT accounted for in $DEPENDABOT_YAML" | ||
MISSING_FILES=$((MISSING_FILES + 1)) | ||
fi | ||
done | ||
if [ "$MISSING_FILES" -gt 0 ]; then | ||
echo "FAIL: There are Cargo.toml files MISSING in $DEPENDABOT_YAML" | ||
else | ||
echo "PASS: All Cargo.toml files are specified in $DEPENDABOT_YAML" | ||
fi | ||
exit $MISSING_FILES |
40 changes: 40 additions & 0 deletions
40
.github/check-for-missing-package-json-in-Dependabot-config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Check if there are package.json files which have not been specified in | ||
# Dependabot's configuration! | ||
# | ||
# WARNING: needs to be executed from the project root directory | ||
|
||
DEPENDABOT_YAML=".github/dependabot.yml" | ||
|
||
PACKAGE_JSON_FILES_IN_DEPENDABOT_YAML=$(grep package-ecosystem -A1 "$DEPENDABOT_YAML" | grep -A1 npm | grep directory | cut -f2 -d'"' | sort | while IFS= read -r DIR; do echo ".$DIR/package.json" | tr -s "//"; done) | ||
echo "INFO: package.json files found in $DEPENDABOT_YAML" | ||
echo "$PACKAGE_JSON_FILES_IN_DEPENDABOT_YAML" | ||
echo "----- END -----" | ||
echo | ||
echo | ||
PACKAGE_JSON_FILES_IN_SOURCE_CODE=$(find ./ -name package.json | grep -v node_modules | sort) | ||
echo "INFO: package.json files found in source code" | ||
echo "$PACKAGE_JSON_FILES_IN_SOURCE_CODE" | ||
echo "----- END -----" | ||
echo | ||
echo | ||
MISSING_FILES=0 | ||
for FILE in $PACKAGE_JSON_FILES_IN_SOURCE_CODE; do | ||
if [[ $PACKAGE_JSON_FILES_IN_DEPENDABOT_YAML = *$FILE* ]]; then | ||
echo "PASS: $FILE is accounted for in $DEPENDABOT_YAML" | ||
else | ||
echo "FAIL: $FILE is NOT accounted for in $DEPENDABOT_YAML" | ||
MISSING_FILES=$((MISSING_FILES + 1)) | ||
fi | ||
done | ||
if [ "$MISSING_FILES" -gt 0 ]; then | ||
echo "FAIL: There are package.json files MISSING in $DEPENDABOT_YAML" | ||
else | ||
echo "PASS: All package.json files are specified in $DEPENDABOT_YAML" | ||
fi | ||
exit $MISSING_FILES |
Oops, something went wrong.