Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • nodes/rust/duniter-v2s
  • llaq/lc-core-substrate
  • pini-gh/duniter-v2s
  • vincentux/duniter-v2s
  • mildred/duniter-v2s
  • d0p1/duniter-v2s
  • bgallois/duniter-v2s
  • Nicolas80/duniter-v2s
8 results
Select Git revision
Show changes
Commits on Source (243)
Showing
with 11335 additions and 5703 deletions
[alias]
cucumber = "test -p duniter-end2end-tests --test cucumber_tests --"
sanity-gdev = "test -p duniter-live-tests --test sanity_gdev -- --nocapture"
tu = "test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests"
tb = "test --features runtime-benchmarks -p"
rbp = "run --release --features runtime-benchmarks -- benchmark pallet --chain=dev --steps=50 --repeat=20 --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=. --pallet"
xtask = "run --package xtask --"
[alias]
sanity-gdev = "test -Zgit=shallow-deps -p duniter-live-tests --test sanity_gdev -- --nocapture"
tu = "test -Zgit=shallow-deps --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests --features constant-fees" # Unit tests with constant-fees
tf = "test -Zgit=shallow-deps --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests test_fee" # Custom fee model tests
# `te` and `cucumber` are synonyms
te = "test -p duniter-end2end-tests --test cucumber_tests --features constant-fees --"
cucumber-build = "build -Zgit=shallow-deps --features constant-fees"
cucumber = "test -Zgit=shallow-deps -p duniter-end2end-tests --test cucumber_tests --"
ta = "test -Zgit=shallow-deps --workspace --exclude duniter-live-tests --features constant-fees"
tb = "test -Zgit=shallow-deps --features runtime-benchmarks -p"
rbp = "run -Zgit=shallow-deps --release --features runtime-benchmarks -- benchmark pallet --chain=dev --steps=50 --repeat=20 --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=. --pallet"
xtask = "run -Zgit=shallow-deps --package xtask --"
cucumber-node = "run -Zgit=shallow-deps -- --chain=gdev_dev --execution=Native --sealing=manual --force-authoring --rpc-cors=all --tmp --rpc-port 9944 --alice --features constant-fees"
...@@ -6,3 +6,4 @@ docker/Dockerfile ...@@ -6,3 +6,4 @@ docker/Dockerfile
docker-compose.yml docker-compose.yml
arm-build/ arm-build/
**/target/ **/target/
build/
# Runner tags:
# - podman: use 'podman' to build multiplatform images
stages: stages:
- schedule - schedule
- labels - labels
- quality - quality
- build - build
- tests - tests
- release
- deploy - deploy
- deploy_readme - deploy_readme
...@@ -19,6 +23,12 @@ workflow: ...@@ -19,6 +23,12 @@ workflow:
- Cargo.toml - Cargo.toml
- Cargo.lock - Cargo.lock
.is_network_branch: &is_network_branch
if: $CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_BRANCH =~ /^(network\/).+/
.is_runtime_branch: &is_runtime_branch
if: $CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_BRANCH =~ /^(runtime\/).+/
sanity_tests: sanity_tests:
extends: .env extends: .env
rules: rules:
...@@ -37,10 +47,19 @@ check_labels: ...@@ -37,10 +47,19 @@ check_labels:
script: script:
- ./scripts/check_labels.sh $CI_MERGE_REQUEST_LABELS $CI_MERGE_REQUEST_MILESTONE - ./scripts/check_labels.sh $CI_MERGE_REQUEST_LABELS $CI_MERGE_REQUEST_MILESTONE
check_metadata:
extends: .env
stage: tests
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- when: never
script:
- ./scripts/check_metadata.sh
.env: .env:
image: paritytech/ci-linux:production image: paritytech/ci-linux:production
tags: tags:
- dind - kepler
fmt_and_clippy: fmt_and_clippy:
extends: .env extends: .env
...@@ -49,245 +68,474 @@ fmt_and_clippy: ...@@ -49,245 +68,474 @@ fmt_and_clippy:
when: manual when: manual
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "master"'
when: never when: never
- <<: *is_network_branch
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: always
- when: manual - when: manual
stage: quality stage: quality
script: script:
- cargo fmt -- --version - cargo fmt -- --version
- cargo fmt -- --check - cargo fmt -- --check
- cargo clippy -- -V - cargo clippy -- -V
- cargo clippy --all --tests -- -D warnings - cargo clippy -Zgit=shallow-deps --features runtime-benchmarks --all --tests -- -D warnings
build_debug: run_benchmarks:
extends: .env extends: .env
stage: tests
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/
when: manual
- <<: *is_network_branch
when: never
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "master"' - if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
changes: - when: manual
- Cargo.lock
- when: never
stage: build
script: script:
- cargo clean -p duniter - cargo build -Zgit=shallow-deps --release --features runtime-benchmarks
- cargo build --locked - target/release/duniter benchmark storage --chain=dev --mul=2 --state-version=1 --weight-path=./runtime/gdev/src/weights/
- mkdir build - target/release/duniter benchmark overhead --chain=dev --wasm-execution=compiled --warmup=1 --repeat=100 --weight-path=./runtime/gdev/src/weights/
- mv target/debug/duniter build/duniter - target/release/duniter benchmark pallet --chain=dev --steps=5 --repeat=2 --pallet="*" --extrinsic="*" --wasm-execution=compiled --output=./runtime/gdev/src/weights/
artifacts: - cargo build -Zgit=shallow-deps --release --features runtime-benchmarks # Check if autogenerated weights work
paths:
- build/
expire_in: 3 day
cache:
- key:
files:
- Cargo.lock
paths:
- target/debug
policy: push
build_debug_with_cache: gtest_build:
stage: build
extends: .env extends: .env
rules: rules:
- changes: - <<: *is_network_branch
- Cargo.lock
when: never when: never
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/
when: manual
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "master"' - if: $CI_COMMIT_BRANCH =~ /^(release\/runtime-)[0-9].*/
- when: never when: never
stage: build - if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
- when: manual
variables:
DEBIAN_FRONTEND: noninteractive
script: script:
- cargo clean -p duniter - cargo build -Zgit=shallow-deps --no-default-features --features gtest
- cargo build --locked
- mkdir build
- mv target/debug/duniter build/duniter
artifacts:
paths:
- build/
expire_in: 3 day
cache:
- key:
files:
- Cargo.lock
paths:
- target/debug
policy: pull
build_release: build_deb:
stage: deploy
extends: .env extends: .env
rules: rules:
- if: "$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v*/" - if: $CI_COMMIT_REF_NAME =~ /^wip*$/
- when: never when: manual
stage: build - if: $CI_COMMIT_TAG
when: never
- <<: *is_network_branch
needs: ["build_raw_specs"]
when: always
- if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
- when: manual
variables:
DEBIAN_FRONTEND: noninteractive
script: script:
- cargo build --locked --release - cargo install cargo-deb
- mkdir build - cargo build -Zgit=shallow-deps --release
- mv target/release/duniter build/duniter - cargo deb --no-build -p duniter
artifacts: artifacts:
paths: paths:
- build/ - target/debian/duniter*.deb
expire_in: 3 day
build_release_manual: build_rpm:
stage: deploy
extends: .env extends: .env
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/
when: manual
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- <<: *is_network_branch
needs: ["build_raw_specs"]
when: always
- if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
- when: manual - when: manual
stage: build
allow_failure: true
script: script:
- cargo build --locked --release - cargo install cargo-generate-rpm
- mkdir build - cargo build -Zgit=shallow-deps --release
- mv target/release/duniter build/duniter - cargo generate-rpm -p node
artifacts: artifacts:
paths: paths:
- build/ - target/generate-rpm/duniter*.rpm
expire_in: 3 day
tests_debug: tests:
stage: tests
extends: .env extends: .env
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/ - if: $CI_COMMIT_REF_NAME =~ /^wip*$/
when: manual when: manual
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- <<: *is_network_branch
when: never
- if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"' - if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"'
- when: manual - when: manual
stage: tests
variables: variables:
DUNITER_BINARY_PATH: "../build/duniter" DEBIAN_FRONTEND: noninteractive
DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT: "20" script:
- export RUST_MIN_STACK=16777216 # 16MB stack size otherwise CI fail during LLVM's Thin LTO (Link Time Optimization) phase
- cargo tu
- cargo tf
- cargo cucumber-build
- cargo cucumber
.network_branch_vars: &define_network_branch_vars
- export NETWORK=$(echo $CI_COMMIT_BRANCH | sed -e "s/network\///g")
- echo "NETWORK = $NETWORK"
- export RUNTIME=$(echo $NETWORK | grep -Po "gdev|gtest|g1")
- echo "RUNTIME = $RUNTIME"
# srtool specific
- export RUNTIME_DIR=runtime/$RUNTIME
- echo "RUNTIME_DIR = $RUNTIME_DIR"
# srtool specific
- export PACKAGE=$RUNTIME-runtime
- echo "PACKAGE = $PACKAGE"
# GitLab milestone : used for both GitLab and Docker releases. Milestone must match source code's runtime version to fetch the git changes for release notes.
- export CLIENT_VERSION=$(cat node/Cargo.toml | grep version | sed "s/version = \"//g" | sed "s/\"//")
- echo $CLIENT_VERSION
- export RUNTIME_VERSION=$(cat runtime/$RUNTIME/src/lib.rs | grep "spec_version:" | sed "s/ *spec_version. //g" | sed "s/,//g")
- echo $RUNTIME_VERSION
- export CLIENT_MILESTONE="client-$CLIENT_VERSION"
- echo $CLIENT_MILESTONE
- export NETWORK_RELEASE="$NETWORK"
- echo $NETWORK_RELEASE
- export DOCKER_TAG="$RUNTIME_VERSION-$CLIENT_VERSION"
# Tags for Docker images
- export IMAGE_NAME="duniter/duniter-v2s-$NETWORK"
- echo $IMAGE_NAME
- export MANIFEST=localhost/manifest-$IMAGE_NAME:$DOCKER_TAG
- echo $MANIFEST
# Files to be pushed in a release
- export RELEASE_FILE_G1_DATA=release/genesis.json
- echo $RELEASE_FILE_G1_DATA
- export RELEASE_FILE_SPEC_CONFIG=release/${RUNTIME}.yaml
- echo $RELEASE_FILE_SPEC_CONFIG
- export RELEASE_FILE_SPEC=release/${RUNTIME}.json
- echo $RELEASE_FILE_SPEC
- export RELEASE_FILE_WASM=release/${RUNTIME}_runtime.compact.compressed.wasm
- echo $RELEASE_FILE_WASM
- export RELEASE_FILE_RAW_SPEC=release/${RUNTIME}-raw.json
- echo $RELEASE_FILE_RAW_SPEC
- export RELEASE_FILE_CLIENT_SPEC=release/gdev_client-specs.yaml
- echo $RELEASE_FILE_CLIENT_SPEC
- export CLIENT_RELEASE_NAME=$RUNTIME-$RUNTIME_VERSION-$CLIENT_VERSION
- echo $CLIENT_RELEASE_NAME
.release_runtime_vars: &define_release_runtime_vars
- echo "RUNTIME = $RUNTIME"
- export RUNTIME_VERSION=$(cat runtime/$RUNTIME/src/lib.rs | grep "spec_version:" | sed "s/ *spec_version. //g" | sed "s/,//g")
- echo $RUNTIME_VERSION
- export RUNTIME_MILESTONE="runtime-$RUNTIME_VERSION"
- echo $RUNTIME_MILESTONE
- export SRTOOL_OUTPUT=$CI_PROJECT_DIR/release/srtool_output_$RUNTIME.json
- echo "SRTOOL_OUTPUT = $SRTOOL_OUTPUT"
- export RELEASE_FILE_WASM=release/${RUNTIME}_runtime.compact.compressed.wasm
- echo $RELEASE_FILE_WASM
# srtool specific
- export RUNTIME_DIR=runtime/$RUNTIME
- echo "RUNTIME_DIR = $RUNTIME_DIR"
# srtool specific
- export PACKAGE=$RUNTIME-runtime
- echo "PACKAGE = $PACKAGE"
trigger_runtime_release:
stage: build
rules:
- <<: *is_runtime_branch
when: manual
variables:
RUNTIME: gdev
script:
- *define_release_runtime_vars
- echo "Vérification de l'absence de la release $RUNTIME_MILESTONE"
- echo "Contrôle de l'URL https://git.duniter.org/api/v4/projects/$CI_PROJECT_ID/releases/$RUNTIME_MILESTONE"
- curl -s https://git.duniter.org/api/v4/projects/$CI_PROJECT_ID/releases/$RUNTIME_MILESTONE --fail 1>/dev/null && (echo "Release déjà présente" && exit 1) || echo "Release absente"
trigger_network_release:
stage: build
rules:
- <<: *is_network_branch
when: manual
script:
- *define_network_branch_vars
- echo "Vérification de l'absence de la release $NETWORK"
- echo "Contrôle de l'URL https://git.duniter.org/api/v4/projects/$CI_PROJECT_ID/releases/$NETWORK"
- curl -s https://git.duniter.org/api/v4/projects/$CI_PROJECT_ID/releases/$NETWORK --fail 1>/dev/null && (echo "Release déjà présente" && exit 1) || echo "Release absente"
trigger_client_release:
stage: build
rules:
- <<: *is_network_branch
when: manual
script: script:
- cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests - *define_network_branch_vars
- cargo cucumber -i account_creation* - echo "Vérification de la présence de la release $NETWORK"
- cargo cucumber -i certification* - echo "Contrôle de l'URL https://git.duniter.org/api/v4/projects/$CI_PROJECT_ID/releases/$NETWORK"
- cargo cucumber -i identity_creation* - curl -s https://git.duniter.org/api/v4/projects/$CI_PROJECT_ID/releases/$NETWORK --fail 1>/dev/null && echo "Release présente" || (echo "Release absente" && exit 1)
- cargo cucumber -i monetary_mass*
- cargo cucumber -i oneshot_account* docker_deploy:
- cargo cucumber -i transfer_all* stage: release
needs: ["build_raw_specs"]
rules:
- <<: *is_network_branch
- when: never
before_script:
- sh -c "[ -n '$DUNITERTEAM_PASSWD' ] || ( echo No access to environment variable 'DUNITERTEAM_PASSWD'; exit 1 )"
- podman login -u "duniterteam" -p "$DUNITERTEAM_PASSWD" docker.io
script:
- *define_network_branch_vars
- podman manifest rm "$MANIFEST" 2>/dev/null || true
- podman build --layers --platform linux/amd64,linux/arm64 --manifest "$MANIFEST" -f docker/Dockerfile --build-arg chain=$RUNTIME .
- podman manifest push --all "$MANIFEST" "docker://docker.io/$IMAGE_NAME:$DOCKER_TAG"
- podman manifest push --all "$MANIFEST" "docker://docker.io/$IMAGE_NAME:latest"
after_script: after_script:
- cd target/debug/deps/ - *define_network_branch_vars
- rm cucumber_tests-*.d - echo $MANIFEST
- mv cucumber_tests* ../../../build/duniter-cucumber - podman manifest rm "$MANIFEST"
tags:
- podman
############## SRTOOL ##############
# The Network Runtime is only built when creating a network release (i.e.: genesis)
build_network_runtime:
stage: build
needs: ["trigger_network_release"]
rules:
- <<: *is_network_branch
image: paritytech/srtool:1.77.0-0.15.0
variables:
SRTOOL_OUTPUT: $CI_PROJECT_DIR/release/network_srtool_output.json
script:
- *define_network_branch_vars
- echo "SRTOOL_OUTPUT = $SRTOOL_OUTPUT"
- mkdir -p $CI_PROJECT_DIR/release
# Copy sources to the expected directory of srtool
- cp -R * /build/
# Build the runtime
- /srtool/build --app --json -cM | tee -a $SRTOOL_OUTPUT
- mv /build/runtime/$RUNTIME/target/srtool/release/wbuild/$RUNTIME-runtime/${RUNTIME}_runtime.compact.compressed.wasm $CI_PROJECT_DIR/release/
artifacts: artifacts:
expire_in: never
name: "runtime"
paths: paths:
- build/ - $CI_PROJECT_DIR/release
expire_in: 3 day tags:
- kepler
tests_release: build_gdev_runtime:
extends: .env stage: build
needs: ["trigger_runtime_release"]
rules: rules:
- if: "$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v*/" - <<: *is_runtime_branch
- when: never image: paritytech/srtool:1.77.0-0.15.0
stage: tests
variables: variables:
DUNITER_BINARY_PATH: "../build/duniter" RUNTIME: gdev
DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT: "20"
script: script:
- cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests - *define_release_runtime_vars
- cargo cucumber -i account_creation* - mkdir -p $CI_PROJECT_DIR/release
- cargo cucumber -i certification* # Copy sources to the expected directory of srtool
- cargo cucumber -i identity_creation* - cp -R * /build/
- cargo cucumber -i monetary_mass* # Build the runtime
- cargo cucumber -i oneshot_account* - /srtool/build --app --json -cM | tee -a $SRTOOL_OUTPUT
- cargo cucumber -i transfer_all* - mv /build/runtime/$RUNTIME/target/srtool/release/wbuild/$RUNTIME-runtime/${RUNTIME}_runtime.compact.compressed.wasm $CI_PROJECT_DIR/release/
after_script:
- cd target/debug/deps/
- rm cucumber_tests-*.d
- mv cucumber_tests* ../../../build/duniter-cucumber
artifacts: artifacts:
expire_in: never
name: "runtime"
paths: paths:
- build/ - $CI_PROJECT_DIR/release
expire_in: 3 day
dependencies:
- build_release
.docker-build-app-image:
stage: deploy
image: docker:18.06
tags: tags:
- docker - kepler
services:
- docker:dind ############## SPECS ##############
before_script:
- docker info build_g1-migrator:
script: stage: build
- docker pull $CI_REGISTRY_IMAGE:$IMAGE_TAG || true
- docker build --cache-from $CI_REGISTRY_IMAGE:$IMAGE_TAG --pull -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" -f $DOCKERFILE_PATH .
- docker login -u "duniterteam" -p "$DUNITERTEAM_PASSWD"
- docker tag "$CI_REGISTRY_IMAGE:$IMAGE_TAG" "duniter/duniter-v2s:$IMAGE_TAG"
- docker push "duniter/duniter-v2s:$IMAGE_TAG"
deploy_docker_test_image:
extends: .docker-build-app-image
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^wip*$/ - <<: *is_network_branch
when: manual trigger:
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "master"' project: tools/py-g1-migrator
when: never
- when: manual
allow_failure: true
variables:
DOCKERFILE_PATH: "docker/Dockerfile"
IMAGE_TAG: "test-image-$CI_COMMIT_SHORT_SHA"
deploy_docker_debug_sha: g1_data:
extends: .docker-build-app-image stage: build
needs: ["trigger_network_release", "build_g1-migrator"]
rules: rules:
- if: $CI_COMMIT_TAG - <<: *is_network_branch
when: never # following image already has g1-migrator and dependency embedded
- if: $CI_COMMIT_BRANCH == "master" image: registry.duniter.org/tools/py-g1-migrator:latest
variables: variables:
DOCKERFILE_PATH: "docker/Dockerfile" LEVELDB_PATH: /dump/duniter_default/data/leveldb
IMAGE_TAG: "debug-sha-$CI_COMMIT_SHORT_SHA" script:
after_script: - *define_network_branch_vars
- docker login -u "duniterteam" -p "$DUNITERTEAM_PASSWD" # Duniter 1.8.7 dump
- docker tag "duniter/duniter-v2s:$IMAGE_TAG" "duniter/duniter-v2s:debug-latest" - mkdir /dump
- docker push "duniter/duniter-v2s:debug-latest" - cd /dump
# Export file constructed using Duniter 1.8.7:
# - bin/duniter sync g1.cgeek.fr --store-txs --nointeractive --mdb 1.8.7
# - mkdir -p /tmp/backup-g1-duniter-1.8.7
# - cp -R $HOME/.config/duniter/1.8.7/data /tmp/backup-g1-duniter-1.8.7
# - tar -cvzf /tmp/backup-g1-duniter-1.8.7.tgz /tmp/backup-g1-duniter-1.8.7
# Then the file is uploaded to dl.cgeek.fr manually
- curl https://dl.cgeek.fr/public/backup-g1-duniter-1.8.7.tgz -o g1-dump.tgz
- tar xvzf g1-dump.tgz
- rm g1-dump.tgz
- mv tmp/backup-g1-duniter-1.8.7 duniter_default
# py-g1-migrator conversion
- cd /py-g1-migrator
# Export genesis file
- ./main.py # ./output/genesis.json
# Expore history files for squid
- ./squid-block.py # ./output/block_hist.json
- ./squid-cert.py # ./output/cert_hist.json
- ./squid-tx.py # ./output/tx_hist.json
# Make the exported file available for next jobs
- mkdir -p $CI_PROJECT_DIR/release/
- cp output/genesis.json $CI_PROJECT_DIR/$RELEASE_FILE_G1_DATA
- cp output/block_hist.json $CI_PROJECT_DIR/release/
- cp output/cert_hist.json $CI_PROJECT_DIR/release/
- cp output/tx_hist.json $CI_PROJECT_DIR/release/
artifacts:
expire_in: never
paths:
- $CI_PROJECT_DIR/release/
tags:
- kepler
deploy_docker_release_sha: build_specs:
extends: .docker-build-app-image stage: build
needs: ["build_network_runtime", "g1_data"]
rules: rules:
- if: $CI_COMMIT_TAG - <<: *is_network_branch
when: never extends: .env
- when: manual
allow_failure: true
variables: variables:
DOCKERFILE_PATH: "docker/Dockerfile" DEBIAN_FRONTEND: noninteractive
IMAGE_TAG: "sha-$CI_COMMIT_SHORT_SHA" script:
dependencies: - *define_network_branch_vars
- build_release_manual - export FEATURES="--features $RUNTIME --no-default-features"
- echo "FEATURES = $FEATURES"
- export WASM_FILE="$CI_PROJECT_DIR/$RELEASE_FILE_WASM"
- echo "WASM_FILE = $WASM_FILE"
- export DUNITER_GENESIS_DATA=$CI_PROJECT_DIR/$RELEASE_FILE_G1_DATA
- echo "DUNITER_GENESIS_DATA = $DUNITER_GENESIS_DATA"
- apt-get update
- apt-get install -y clang cmake protobuf-compiler
# Build the spec file (including the G1 data), e.g.: "release/gdev.json"
- cargo run -Zgit=shallow-deps ${FEATURES} -- build-spec --chain=${RUNTIME}_live > $RELEASE_FILE_SPEC
# Save spec configuration file for release
- cp resources/${RUNTIME}.yaml $RELEASE_FILE_SPEC_CONFIG
artifacts:
expire_in: never
name: "runtime"
paths:
- $CI_PROJECT_DIR/release
tags:
- kepler
deploy_docker_release_tag: build_raw_specs:
extends: .docker-build-app-image stage: build
needs: ["trigger_client_release"]
rules: rules:
- if: "$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v*/" - <<: *is_network_branch
- when: never image: rust:1-bullseye
variables: script:
DOCKERFILE_PATH: "docker/Dockerfile" - *define_network_branch_vars
IMAGE_TAG: "$CI_COMMIT_TAG" - export FEATURES="--features $RUNTIME --no-default-features"
after_script: - echo "FEATURES = $FEATURES"
- docker login -u "duniterteam" -p "$DUNITERTEAM_PASSWD" - apt-get update
- docker tag "duniter/duniter-v2s:$IMAGE_TAG" "duniter/duniter-v2s:latest" - apt-get install -y clang cmake protobuf-compiler jq
- docker push "duniter/duniter-v2s:latest" # Print chainspec to file
dependencies: - cargo xtask print-spec $NETWORK_RELEASE > ${RUNTIME}-printed.json
- build_release # Merge client specs into chainspec file (to update bootnodes for example)
# 1. Download yq to create a json client spec file
readme_docker_release_tag: - wget https://github.com/mikefarah/yq/releases/download/v4.44.6/yq_linux_arm64 -O yq
stage: deploy_readme - chmod +x ./yq
# 2. YML -> JSON for the client specs
- cat node/specs/${RUNTIME}_client-specs.yaml | ./yq --output-format json > node/specs/${RUNTIME}_client-specs.json
# 3. Merge the client spec file into chainspec file and create the final spec file (e.g. gdev.json)
- jq -s '.[0] * .[1]' node/specs/${RUNTIME}_client-specs.json ${RUNTIME}-printed.json > ${RUNTIME}.json
# Produce raw spec file
- mkdir -p $CI_PROJECT_DIR/release
- cargo run -Zgit=shallow-deps ${FEATURES} -- build-spec --chain=${RUNTIME}.json --disable-default-bootnode --raw > $RELEASE_FILE_RAW_SPEC
artifacts:
expire_in: never
name: "runtime"
paths:
- $CI_PROJECT_DIR/release
tags:
- kepler
############## RELEASE ##############
create_network_release:
stage: release
needs: ["build_specs"]
rules: rules:
- if: "$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v*/" - <<: *is_network_branch
- when: never image: rust:1-bullseye
image:
name: chko/docker-pushrm
entrypoint: ["/bin/sh", "-c", "/docker-pushrm"]
variables: variables:
DOCKER_USER: "duniterteam" # Used by `release-network` command
DOCKER_PASS: "$DUNITERTEAM_PASSWD" SRTOOL_OUTPUT: $CI_PROJECT_DIR/release/network_srtool_output.json
PUSHRM_SHORT: "Duniter v2 based on Substrate framework" script:
PUSHRM_TARGET: "docker.io/duniter/duniter-v2s" - *define_network_branch_vars
PUSHRM_DEBUG: 1 # Release creation
PUSHRM_FILE: "$CI_PROJECT_DIR/docker/README.md" - cargo xtask release-network $NETWORK_RELEASE $CI_COMMIT_BRANCH
script: "/bin/true" # g1-data (initial data)
- cargo xtask create-asset-link $NETWORK_RELEASE g1-data.json https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_G1_DATA
# gdev.yaml (spec configuration)
- cargo xtask create-asset-link $NETWORK_RELEASE ${RUNTIME}.yaml https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_SPEC_CONFIG
# initial runtime
- cargo xtask create-asset-link $NETWORK_RELEASE ${RUNTIME}_runtime.compact.compressed.wasm https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_WASM
# the result: gdev.json (genesis)
- cargo xtask create-asset-link $NETWORK_RELEASE ${RUNTIME}.json https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_SPEC
artifacts:
expire_in: never
paths:
- $CI_PROJECT_DIR/release/
tags:
- kepler
create_client_release:
stage: release
needs: ["build_raw_specs"]
rules:
- <<: *is_network_branch
image: rust:1-bullseye
script:
- *define_network_branch_vars
# Create the GitLab release page + tag and associate the milestone
- cargo xtask release-client $CLIENT_RELEASE_NAME $CI_COMMIT_BRANCH $CLIENT_MILESTONE
# Add the client assets
- cargo xtask create-asset-link $CLIENT_RELEASE_NAME ${RUNTIME}_client-specs.yaml https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_CLIENT_SPEC
- cargo xtask create-asset-link $CLIENT_RELEASE_NAME ${RUNTIME}-raw.json https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_RAW_SPEC
artifacts:
expire_in: never
paths:
- $CI_PROJECT_DIR/release/
tags:
- kepler
create_runtime_release:
stage: release
needs: ["build_gdev_runtime"]
rules:
- <<: *is_runtime_branch
image: rust:1-bullseye
variables:
RUNTIME: gdev
script:
- *define_release_runtime_vars
# Create the GitLab release page + tag and associate the milestone.
# Note: the release name = the release tag = runtime milesone ($RUNTIME_MILESTONE)
- cargo xtask release-runtime $RUNTIME_MILESTONE $RUNTIME $CI_COMMIT_BRANCH $RUNTIME_MILESTONE
- cargo xtask create-asset-link $RUNTIME_MILESTONE ${RUNTIME}_runtime.compact.compressed.wasm https://nodes.pages.duniter.org/-/rust/duniter-v2s/-/jobs/$CI_JOB_ID/artifacts/$RELEASE_FILE_WASM
# In the future: also build gtest and g1 runtimes and atach them
artifacts:
expire_in: never
paths:
- $CI_PROJECT_DIR/release/
tags:
- kepler
...@@ -29,7 +29,7 @@ USER duniter ...@@ -29,7 +29,7 @@ USER duniter
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/duniter --version RUN /usr/local/bin/duniter --version
EXPOSE 30333 9933 9944 EXPOSE 30333 9944
VOLUME ["/duniter"] VOLUME ["/duniter"]
ENTRYPOINT ["/usr/local/bin/duniter"] ENTRYPOINT ["/usr/local/bin/duniter"]
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
100 100
], ],
"[json]": { "[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "vscode.json-language-features"
}, },
"[yaml]": { "[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
...@@ -14,5 +14,6 @@ ...@@ -14,5 +14,6 @@
"port_p2p": 19931, "port_p2p": 19931,
"port_rpc": 19932, "port_rpc": 19932,
"port_ws": 19933 "port_ws": 19933
} },
"rust-analyzer.showUnlinkedFileNotification": false
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ Before contributing, please make sure that your development environment is prope ...@@ -4,7 +4,7 @@ Before contributing, please make sure that your development environment is prope
[Setting up your development environment] [Setting up your development environment]
Sign-ups on our gitlab are disabled. If you would like to contribute, please ask for its creation on [the technical forum]. Sign-ups on our gitlab are disabled. If you would like to contribute, please ask for an account on [the technical forum].
When contributing to this repository, please first discuss the change you wish to make via issue or When contributing to this repository, please first discuss the change you wish to make via issue or
via [the technical forum] before making a change. via [the technical forum] before making a change.
...@@ -13,13 +13,15 @@ Please note we have a specific workflow, please follow it in all your interactio ...@@ -13,13 +13,15 @@ Please note we have a specific workflow, please follow it in all your interactio
## Developer documentation ## Developer documentation
Please read [Developer documentation] before contribute. Please read [Developer documentation] before contributing.
## Workflow ## Workflow
- If there is an unassigned issue about the thing you want to contribute to, assign the issue to yourself.
- Create a branch based on `master` and prefixed with your nickname. Give your branch a short name indicating the subject. - Create a branch based on `master` and prefixed with your nickname. Give your branch a short name indicating the subject.
- Create an MR from your branch to `master`. - Create an MR from your branch to `master`. Prefix the title with `Draft: ` until it's ready to be merged.
- Never contribute to a branch of another contributor! If the contributor makes a `git rebase` your commit will be lost! - If the MR is related to an issue, mention the issue in the description using the `#42` syntax.
- Never push to a branch of another contributor! If the contributor makes a `git rebase` your commit will be lost!
- Before you push your commit: - Before you push your commit:
- Apply formatters (rustfmt and prettier) and linter (clippy) - Apply formatters (rustfmt and prettier) and linter (clippy)
- Document your code - Document your code
...@@ -30,14 +32,15 @@ Please read [Developer documentation] before contribute. ...@@ -30,14 +32,15 @@ Please read [Developer documentation] before contribute.
1. Ensure you rebased your branch on the latest `master` commit to avoid any merge conflicts. 1. Ensure you rebased your branch on the latest `master` commit to avoid any merge conflicts.
1. Ensure that you respect the [commit naming conventions]. 1. Ensure that you respect the [commit naming conventions].
1. Ensure that all automated tests pass with the `cargo test` command. 1. Ensure that all automated tests pass with the `cargo test` command.
1. Ensure that the code is well formated `cargo fmt` and comply with the good practices `cargo clippy`. If you have been working on tests, check everything with `cargo clippy --all --tests`. 1. Ensure that the code is well formatted `cargo fmt` and complies with the good practices `cargo clippy`. If you have been working on tests, check everything with `cargo clippy --all --tests`.
1. Update the documentation with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. 1. Update the documentation with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
1. Push your branch on the gitlab and create a merge request. Briefly explain the purpose of your contribution in the description of the merge request. 1. Push your branch on the gitlab and create a merge request. Briefly explain the purpose of your contribution in the description of the merge request.
1. Tag a Duniter reviewer so they will review your contribution. If you still have no news after several weeks, tag another reviewer or/and talk about your contribution on [the technical forum]. 1. Mark the MR as ready (or remove the `Draft: ` prefix) only when you think it can be reviewed or merged.
1. Assign a Duniter reviewer so they will review your contribution. If you still have no news after several weeks, ask explicitly for a review, or tag another reviewer or/and talk about your contribution on [the technical forum].
## List of Duniter's reviewers ## List of Duniter's reviewers
- @librelois - @HugoTrentesaux
- @tuxmain - @tuxmain
[commit naming conventions]: ./docs/dev/git-conventions.md#naming-commits [commit naming conventions]: ./docs/dev/git-conventions.md#naming-commits
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
[package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>']
build = 'node/build.rs'
description = 'Crypto-currency software (based on Substrate framework) to operate Ğ1 libre currency'
edition = "2021"
homepage = 'https://duniter.org'
license = 'AGPL-3.0'
name = 'duniter'
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s'
version = '0.3.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[[bin]]
bench = false
name = 'duniter'
path = "node/src/main.rs"
[features]
default = ["gdev"]
g1 = ["g1-runtime"]
gdev = ["gdev-runtime"]
gtest = ["gtest-runtime"]
runtime-benchmarks = [
#'g1-runtime',
#'g1-runtime/runtime-benchmarks',
'gdev-runtime',
'gdev-runtime/runtime-benchmarks',
#'gtest-runtime',
#'gtest-runtime/runtime-benchmarks',
'sc-client-db/runtime-benchmarks',
]
try-runtime = [
#"g1-runtime/try-runtime",
"gdev-runtime/try-runtime",
#"gtest-runtime/try-runtime",
"try-runtime-cli"
]
[build-dependencies]
clap = { version = "4.0" }
#clap_complete = { version = "4.0" }
substrate-build-script-utils = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32' }
[dev-dependencies]
rusty-hook = "^0.11.2"
# Dependencies for specific targets
[target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies]
sc-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false, features = ["wasmtime"] }
sc-service = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false, features = ["wasmtime"] }
sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", features = ["memory-tracker"] }
[dependencies]
# local dependencies
common-runtime = { path = 'runtime/common' }
g1-runtime = { path = 'runtime/g1', optional = true }
gdev-runtime = { path = 'runtime/gdev', optional = true }
gtest-runtime = { path = 'runtime/gtest', optional = true }
pallet-certification = { path = 'pallets/certification' }
pallet-oneshot-account = { path = 'pallets/oneshot-account' }
sp-membership = { path = 'primitives/membership' }
# crates.io dependencies
async-io = "1.3"
clap = { version = "4.0", features = ["derive"] }
clap_complete = { version = "4" }
futures = { version = "0.3.1", features = ["compat"] }
hex = "0.4.3"
jsonrpsee = { version = "0.15.1", features = ["server"] }
lazy_static = "1.4.0"
log = "0.4"
maplit = '1.0.2'
memmap2 = "0.5.0"
serde = "1.0"
serde_json = "1.0.64"
tracing-core = "0.1.28"
# substrate dependencies
frame-benchmarking = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
frame-benchmarking-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
frame-system = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false }
pallet-grandpa = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
pallet-transaction-payment = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false }
pallet-transaction-payment-rpc = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-basic-authorship = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-chain-spec = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false }
sc-client-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-consensus = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
babe = { package = "sc-consensus-babe", git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
manual-seal = { package = "sc-consensus-manual-seal", git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-client-db = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false }
sc-consensus-uncles = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-executor = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-finality-grandpa = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-keystore = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-network = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-rpc-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-service = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false }
sc-telemetry = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-transaction-pool = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sc-transaction-pool-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-authority-discovery = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-block-builder = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-blockchain = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-consensus = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-consensus-babe = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-core = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-finality-grandpa = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-inherents = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-io = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-offchain = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-keyring = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-keystore = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-runtime = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-session = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-storage = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-timestamp = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-transaction-pool = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
substrate-frame-rpc-system = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32" }
try-runtime-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", optional = true }
[workspace] [workspace]
resolver = "2" resolver = "2"
members = [ members = [
'client/distance',
'distance-oracle',
'end2end-tests', 'end2end-tests',
'live-tests', 'live-tests',
'node',
'pallets/authority-members',
'pallets/certification', 'pallets/certification',
'pallets/distance',
'pallets/duniter-test-parameters', 'pallets/duniter-test-parameters',
'pallets/duniter-test-parameters/macro', 'pallets/duniter-test-parameters/macro',
'pallets/duniter-wot', 'pallets/duniter-wot',
'pallets/identity', 'pallets/identity',
'pallets/membership', 'pallets/membership',
'pallets/oneshot-account', 'pallets/oneshot-account',
'pallets/authority-members', 'pallets/quota',
'pallets/smith-members',
'pallets/universal-dividend', 'pallets/universal-dividend',
'pallets/upgrade-origin', 'pallets/upgrade-origin',
'primitives/distance',
'primitives/membership', 'primitives/membership',
'resources/weight_analyzer',
'runtime/common', 'runtime/common',
'runtime/gdev', 'runtime/gdev',
'xtask', 'xtask',
] ]
[workspace.package]
authors = [
'librelois <c@elo.tf>',
'tuxmain <tuxmain@zettascript.org>',
'c-geek <https://forum.duniter.org/u/cgeek>',
'HugoTrentesaux <https://trentesaux.fr>',
'bgallois <benjamin@gallois.cc>',
'Duniter Developers <https://duniter.org>',
'Axiom-Team Developers <https://axiom-team.fr>',
]
description = 'Crypto-currency software (based on Substrate framework) to operate Ğ1 libre currency'
edition = '2021'
homepage = 'https://duniter.org'
license = 'AGPL-3.0'
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s'
version = '1.0.0'
[workspace.dependencies]
# crates.io dependencies
anyhow = { version = "1.0.81", default-features = false }
base64 = { version = "0.22.1", default-features = false }
countmap = { version = "0.2.0", default-features = false }
ctrlc = { version = "3.4.4", default-features = false }
cucumber = { version = "0.20.2", default-features = false }
env_logger = { version = "0.11.3", default-features = false }
notify = { version = "6.1.1", default-features = false }
portpicker = { version = "0.1.1", default-features = false }
notify-debouncer-mini = { version = "0.4.1", default-features = false }
async-io = { version = "2.3.1", default-features = false }
async-trait = { version = "0.1.78", default-features = false }
thiserror = { version = "1.0.58", default-features = false }
frame-metadata = { version = "16.0.0", default-features = false }
graphql_client = { version = "0.13.0" }
bs58 = { version = "0.5.1", default-features = false }
placeholder = { version = "1.1.4", default-features = false }
clap = { version = "4.5.3" }
clap_complete = { version = "4.5.1" }
reqwest = { version = "0.12.0", default-features = false, features = [
"rustls-tls",
] }
glob = { version = "0.3.1", default-features = false }
convert_case = { version = "0.6.0", default-features = false }
subweight-core = { version = "3.3.1", default-features = false }
version_check = { version = "0.9.4", default-features = false }
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false }
enum-as-inner = { version = "=0.5.1", default-features = false } #https://github.com/bluejekyll/trust-dns/issues/1946
futures = { version = "0.3.30", default-features = false }
tera = { version = "1", default-features = false }
hex = { version = "0.4.3", default-features = false }
jsonrpsee = { version = "0.24.3", default-features = false } # Version should exactly match polkadot one
lazy_static = { version = "1.4.0", default-features = false }
log = { version = "0.4.21", default-features = false }
maplit = { version = '1.0.2', default-features = false }
proc-macro2 = { version = '1.0.79', default-features = false }
quote = { version = '1.0.35', default-features = false }
syn = { version = '2.0.53', default-features = false }
memmap2 = { version = "0.9.4", default-features = false }
num-format = { version = "0.4.4", default-features = false }
smallvec = { version = "1.13.2", default-features = false }
hex-literal = { version = '0.4.1', default-features = false }
scale-info = { version = "2.11.0", default-features = false }
scale-value = { version = "0.14.1", default-features = false }
serde = { version = "1.0.197", default-features = false }
serde_derive = { version = "1.0.197", default-features = false }
serde_yaml = { version = "0.9.33", default-features = false }
serde_json = { version = "1.0.114", default-features = false }
fnv = { version = "1.0.7", default-features = false }
tokio = { version = "1.36.0", default-features = false }
time = { version = "0.3.34", default-features = false }
time-macros = { version = "0.2.17", default-features = false }
num-traits = { version = "0.2.18", default-features = false }
rayon = { version = "1.9.0", default-features = false }
simple_logger = { version = "4.3.3", default-features = false }
bincode = { version = "1.3.3", default-features = false }
dubp-wot = { version = "0.11.1", default-features = false }
flate2 = { version = "1.0.28", default-features = false }
array-bytes = { version = "6.2.2", default-features = false }
parking_lot = { version = "0.12.1" }
# Subxt
subxt = { git = 'https://github.com/paritytech/subxt', tags = '0.41.0', default-features = false }
# local dependencies
weight-analyzer = { path = "resources/weight_analyzer", default-features = false }
common-runtime = { path = 'runtime/common', default-features = false }
dc-distance = { path = 'client/distance', default-features = false }
distance-oracle = { path = 'distance-oracle', default-features = false }
g1-runtime = { path = 'runtime/g1', default-features = false }
gdev-runtime = { path = 'runtime/gdev', default-features = false }
gtest-runtime = { path = 'runtime/gtest', default-features = false }
pallet-authority-members = { path = 'pallets/authority-members', default-features = false }
pallet-certification = { path = 'pallets/certification', default-features = false }
pallet-distance = { path = "pallets/distance", default-features = false }
pallet-duniter-account = { path = 'pallets/duniter-account', default-features = false }
pallet-duniter-test-parameters = { path = 'pallets/duniter-test-parameters', default-features = false }
pallet-duniter-test-parameters-macro = { path = 'pallets/duniter-test-parameters/macro', default-features = false }
duniter-primitives = { path = 'primitives/duniter', default-features = false }
pallet-duniter-wot = { path = 'pallets/duniter-wot', default-features = false }
pallet-identity = { path = 'pallets/identity', default-features = false }
pallet-membership = { path = 'pallets/membership', default-features = false }
pallet-offences = { path = 'pallets/offences', default-features = false }
pallet-oneshot-account = { path = 'pallets/oneshot-account', default-features = false }
pallet-provide-randomness = { path = 'pallets/provide-randomness', default-features = false }
pallet-quota = { path = 'pallets/quota', default-features = false }
pallet-session-benchmarking = { path = 'pallets/session-benchmarking', default-features = false }
pallet-smith-members = { path = 'pallets/smith-members', default-features = false }
pallet-universal-dividend = { path = 'pallets/universal-dividend', default-features = false }
pallet-upgrade-origin = { path = 'pallets/upgrade-origin', default-features = false }
sp-distance = { path = 'primitives/distance', default-features = false }
sp-membership = { path = 'primitives/membership', default-features = false }
# substrate dependencies
pallet-transaction-payment-rpc = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-benchmarking = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-metadata-hash-extension = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-executive = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-support = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-system = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-system-benchmarking = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-try-runtime = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-atomic-swap = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-authority-discovery = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-authorship = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-babe = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-balances = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-collective = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-grandpa = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-im-online = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-multisig = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-preimage = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-proxy = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-scheduler = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-session = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-sudo = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-timestamp = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-transaction-payment = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-treasury = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
pallet-utility = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-api = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-arithmetic = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-block-builder = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-client-db = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-client-api = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-consensus-grandpa = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-rpc = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-consensus-grandpa-rpc = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-consensus-babe = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-consensus-babe-rpc = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-blockchain = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-offchain = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-consensus-babe = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-consensus-grandpa = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-core = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-inherents = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-offchain = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-runtime = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-session = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-staking = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-weights = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-transaction-pool = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-version = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-cli = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-service = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-trie = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-authority-discovery = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-genesis-builder = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-keyring = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-consensus = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-core-hashing = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-keystore = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-rpc-api = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
substrate-wasm-builder = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-io = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
substrate-build-script-utils = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0' }
node-primitives = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
frame-benchmarking-cli = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-chain-spec = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-consensus = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-consensus-manual-seal = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-executor = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-telemetry = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-transaction-pool = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-basic-authorship = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-network = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-network-sync = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-network-test = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-utils = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-keystore = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-storage = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-timestamp = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-transaction-storage-proof = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sc-transaction-pool-api = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
sp-state-machine = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
substrate-frame-rpc-system = { git = 'https://github.com/duniter/duniter-polkadot-sdk', branch = 'duniter-substrate-v1.18.0', default-features = false }
# The list of dependencies below (which can be both direct and indirect dependencies) are crates # The list of dependencies below (which can be both direct and indirect dependencies) are crates
# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of # that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of
# their debug info might be missing) or to require to be frequently recompiled. We compile these # their debug info might be missing) or to require to be frequently recompiled. We compile these
...@@ -163,7 +240,6 @@ members = [ ...@@ -163,7 +240,6 @@ members = [
# This list is ordered alphabetically. # This list is ordered alphabetically.
[profile.dev.package] [profile.dev.package]
blake2 = { opt-level = 3 } blake2 = { opt-level = 3 }
blake2-rfc = { opt-level = 3 }
blake2b_simd = { opt-level = 3 } blake2b_simd = { opt-level = 3 }
chacha20poly1305 = { opt-level = 3 } chacha20poly1305 = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 } cranelift-codegen = { opt-level = 3 }
...@@ -171,9 +247,6 @@ cranelift-wasm = { opt-level = 3 } ...@@ -171,9 +247,6 @@ cranelift-wasm = { opt-level = 3 }
crc32fast = { opt-level = 3 } crc32fast = { opt-level = 3 }
crossbeam-deque = { opt-level = 3 } crossbeam-deque = { opt-level = 3 }
crypto-mac = { opt-level = 3 } crypto-mac = { opt-level = 3 }
curve25519-dalek = { opt-level = 3 }
ed25519-dalek = { opt-level = 3 }
flate2 = { opt-level = 3 }
futures-channel = { opt-level = 3 } futures-channel = { opt-level = 3 }
hashbrown = { opt-level = 3 } hashbrown = { opt-level = 3 }
hash-db = { opt-level = 3 } hash-db = { opt-level = 3 }
...@@ -199,84 +272,12 @@ smallvec = { opt-level = 3 } ...@@ -199,84 +272,12 @@ smallvec = { opt-level = 3 }
snow = { opt-level = 3 } snow = { opt-level = 3 }
twox-hash = { opt-level = 3 } twox-hash = { opt-level = 3 }
uint = { opt-level = 3 } uint = { opt-level = 3 }
wasmi = { opt-level = 3 }
x25519-dalek = { opt-level = 3 } x25519-dalek = { opt-level = 3 }
yamux = { opt-level = 3 } yamux = { opt-level = 3 }
zeroize = { opt-level = 3 } zeroize = { opt-level = 3 }
[profile.release] [profile.release]
# Link Time Optimization
lto = "thin"
# Substrate runtime requires unwinding. # Substrate runtime requires unwinding.
panic = "unwind" panic = "unwind"
[patch.crates-io]
#[patch."https://github.com/duniter/substrate"]
#fork-tree = { path = "../substrate/utils/fork-tree" }
#frame-support = { path = "../substrate/frame/support" }
#frame-support-procedural = { path = "../substrate/frame/support/procedural" }
#frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" }
#frame-system = { path = "../substrate/frame/system" }
#frame-benchmarking = { path = "../substrate/frame/benchmarking" }
#frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" }
#sc-basic-authorship = { path = "../substrate/client/basic-authorship" }
#sc-block-builder = { path = "../substrate/client/block-builder" }
#sc-chain-spec = { path = "../substrate/client/chain-spec" }
#sc-cli = { path = "../substrate/client/cli" }
#sc-client-api = { path = "../substrate/client/api" }
#sc-client-db = { path = "../substrate/client/db" }
#sc-consensus = { path = "../substrate/client/consensus/common" }
#sc-consensus-aura = { path = "../substrate/client/consensus/aura" }
#sc-consensus-babe = { path = "../substrate/client/consensus/babe" }
#sc-consensus-manual-seal = { path = "../substrate/client/consensus/manual-seal" }
#sc-consensus-slots = { path = "../substrate/client/consensus/slots" }
#sc-consensus-uncles = { path = "../substrate/client/consensus/uncles" }
#sc-executor = { path = "../substrate/client/executor" }
#sc-executor-common = { path = "../substrate/client/executor/common" }
#sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" }
#sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" }
#sc-finality-grandpa = { path = "../substrate/client/finality-grandpa" }
#sc-keystore = { path = "../substrate/client/keystore" }
#sc-network = { path = "../substrate/client/network" }
#sc-rpc-api = { path = "../substrate/client/rpc-api" }
#sc-service = { path = "../substrate/client/service" }
#sc-telemetry = { path = "../substrate/client/telemetry" }
#sc-transaction-pool = { path = "../substrate/client/transaction-pool" }
#sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" }
#sp-api = { path = "../substrate/primitives/api" }
#sp-application-crypto = { path = "../substrate/primitives/application-crypto" }
#sp-arithmetic = { path = "../substrate/primitives/arithmetic" }
#sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" }
#sp-authorship = { path = "../substrate/primitives/authorship" }
#sp-block-builder = { path = "../substrate/primitives/block-builder" }
#sp-blockchain = { path = "../substrate/primitives/blockchain" }
#sp-consensus = { path = "../substrate/primitives/consensus/common" }
#sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" }
#sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" }
#sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" }
#sp-core = { path = "../substrate/primitives/core" }
#sp-core-hashing = { path = "../substrate/primitives/core/hashing" }
#sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" }
#sp-debug-derive = { path = "../substrate/primitives/debug-derive" }
#sp-externalities = { path = "../substrate/primitives/externalities" }
#sp-finality-grandpa = { path = "../substrate/primitives/finality-grandpa" }
#sp-inherents = { path = "../substrate/primitives/inherents" }
#sp-io = { path = "../substrate/primitives/io" }
#sp-keyring = { path = "../substrate/primitives/keyring" }
#sp-keystore = { path = "../substrate/primitives/keystore" }
#sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" }
#sp-offchain = { path = "../substrate/primitives/offchain" }
#sp-panic-handler = { path = "../substrate/primitives/panic-handler" }
#sp-rpc = { path = "../substrate/primitives/rpc" }
#sp-runtime = { path = "../substrate/primitives/runtime" }
#sp-session = { path = "../substrate/primitives/session" }
#sp-staking = { path = "../substrate/primitives/staking" }
#sp-state-machine = { path = "../substrate/primitives/state-machine" }
#sp-std = { path = "../substrate/primitives/std" }
#sp-storage = { path = "../substrate/primitives/storage" }
#sp-timestamp = { path = "../substrate/primitives/timestamp" }
#sp-tracing = { path = "../substrate/primitives/tracing" }
#sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" }
#sp-trie = { path = "../substrate/primitives/trie" }
#sp-version = { path = "../substrate/primitives/version" }
#sp-weights = { path = "../substrate/primitives/weights" }
#substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" }
...@@ -10,32 +10,46 @@ ...@@ -10,32 +10,46 @@
<img alt="logov2" src="https://duniter.fr/img/duniterv2.svg" width="128" height="128"/> <img alt="logov2" src="https://duniter.fr/img/duniterv2.svg" width="128" height="128"/>
</div> </div>
## Documentation TOC ## Documentation
- [README](./README.md) Multiple documentation sources are available depending on the level of detail you need.
- Full technical Rust doc (auto-generated with `cargo xtask gen-doc`) : https://doc-duniter-org.ipns.pagu.re/duniter/
- User and client developer doc (official website) : https://duniter.org/wiki/duniter-v2/
- Internal documentation (within git repository), see table of contents below : [./doc](./doc)
### Internal documentation TOC
- [README](./README.md) (this file)
- [Use](#use) - [Use](#use)
- [Test](#test)
- [Contribute](#contribute) - [Contribute](#contribute)
- [Structure](#project-structure) - [License](#license)
- [docs](./docs/) - [docs](./docs/) internal documentation
- [api](./docs/api/) - [api](./docs/api/) API
- [manual](./docs/api/manual.md) - [manual](./docs/api/manual.md) manage account and identities
- [runtime-calls](./docs/api/runtime-calls.md) the calls you can submit through the RPC API - [runtime-calls](./docs/api/runtime-calls.md) the calls you can submit through the RPC API
- [dev](./docs/dev/) - [runtime-errors](./docs/api/runtime-errors.md) the errors you can get submitting a call
- [runtime-events](./docs/api/runtime-events.md) the events you can get submitting a call
- [dev](./docs/dev/) developer documentation
- [beginner-walkthrough](./docs/dev/beginner-walkthrough.md) - [beginner-walkthrough](./docs/dev/beginner-walkthrough.md)
- [git-conventions](./docs/dev/git-conventions.md) - [git-conventions](./docs/dev/git-conventions.md)
- [pallet_conventions](./docs/dev/pallet_conventions.md)
- [launch-a-live-network](./docs/dev/launch-a-live-network.md) - [launch-a-live-network](./docs/dev/launch-a-live-network.md)
- [setup](./docs/dev/setup.md) - [setup](./docs/dev/setup.md)
- [compilation features](./docs/dev/compilation.md)
- [verify-runtime-code](./docs/dev/verify-runtime-code.md) - [verify-runtime-code](./docs/dev/verify-runtime-code.md)
- [weights-benchmarking](./docs/dev/weights-benchmarking.md) - [weights-benchmarking](./docs/dev/weights-benchmarking.md)
- [upgrade-substrate](./docs/dev/upgrade-substrate.md) - [upgrade-substrate](./docs/dev/upgrade-substrate.md)
- [test](./docs/test/)
- [replay-block](./docs/test/replay-block.md) - [replay-block](./docs/test/replay-block.md)
- [user](./docs/user/) - [user](./docs/user/) user documentation
- [autocompletion](./docs/user/autocompletion.md) - [autocompletion](./docs/user/autocompletion.md)
- [build-for-arm](./docs/user/build-for-arm.md) - [debian installation](./docs/user/installation_debian.md)
- [rpc](./docs/user/rpc.md) deploy a permanent ǦDev mirror node - [distance](./docs/user/distance.md)
- [smith](./docs/user/smith.md) deploy a permanent ǦDev validator node - [fees](./docs/user/fees.md)
- [packaging](./docs/packaging/) packaging
- [build-for-arm](./docs/packaging/build-for-arm.md) build for ARM architecture
- [build-debian](./docs/packaging/build-deb.md) build a native Debian package
- [docker](./docker/) docker-related documentation
- [end2end-tests](./end2end-tests/) automated end to end tests written with cucumber - [end2end-tests](./end2end-tests/) automated end to end tests written with cucumber
- [live-tests](./live-tests/) sanity checks to test the storage of a live chain - [live-tests](./live-tests/) sanity checks to test the storage of a live chain
...@@ -45,24 +59,23 @@ ...@@ -45,24 +59,23 @@
The easiest way is to use the docker image. The easiest way is to use the docker image.
Minimal command to deploy a **temporary** mirror peer: Minimal command to deploy a temporary mirror peer:
```docker ```docker
docker run -it -p9944:9944 -e DUNITER_CHAIN_NAME=gdev duniter/duniter-v2s:v0.4.0 --tmp --execution=Wasm docker run -it -p9944:9944 -e DUNITER_CHAIN_NAME=gdev duniter/duniter-v2s-gdev-800:latest
``` ```
To go further, read [How to deploy a permanent mirror node on ĞDev network](./docs/user/rpc.md). To go further, read [How to deploy a permanent mirror node on ĞDev network 🔗](https://duniter.org/wiki/duniter-v2/#run-a-mirror-node).
### Create your local blockchain ### Create your local blockchain
It can be useful to deploy your local blockchain, for instance to have a controlled environement It can be useful to deploy your local blockchain, for instance to have a controlled environment to develop/test an application that interacts with the blockchain.
to develop/test an application that interacts with the blockchain.
```docker ```docker
docker run -it -p9944:9944 duniter/duniter-v2s:v0.4.0 --tmp docker run -it -p9944:9944 duniter/duniter-v2s-gdev-800:latest
``` ```
Or use the `docker-compose.yml` at the root of this repository. Or use the [`docker-compose.yml`](./docker-compose.yml) at the root of this repository.
#### Control when your local blockchain should produce blocks #### Control when your local blockchain should produce blocks
...@@ -73,34 +86,9 @@ You can decide when to produce blocks with the cli option `--sealing` which has ...@@ -73,34 +86,9 @@ You can decide when to produce blocks with the cli option `--sealing` which has
- `--sealing=instant`: produce a block immediately upon receiving a transaction into the transaction pool - `--sealing=instant`: produce a block immediately upon receiving a transaction into the transaction pool
- `--sealing=manual`: produce a block upon receiving an RPC request (method `engine_createBlock`). - `--sealing=manual`: produce a block upon receiving an RPC request (method `engine_createBlock`).
### Autocompletion ### Shell autocompletion
See [autocompletion](./docs/user/autocompletion.md).
## Test
### Test a specific commit
At each commit on master, an image with the tag `debug-sha-********` is published, where `********`
corresponds to the first 8 hash characters of the commit.
Usage:
```docker
docker run -it -p9944:9944 --name duniter-v2s duniter/duniter-v2s:debug-sha-b836f1a6
```
Then open `https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944` in a browser.
Enable detailed logging:
```docker See [autocompletion](./docs/user/autocompletion.md) to generate shell autocompletion for duniter commands.
docker run -it -p9944:9944 --name duniter-v2s \
-e RUST_LOG=debug \
-e RUST_BACKTRACE=1 \
-lruntime=debug \
duniter/duniter-v2s:debug-sha-b836f1a6
```
## Contribute ## Contribute
...@@ -127,20 +115,11 @@ cargo build ...@@ -127,20 +115,11 @@ cargo build
Use Rust's native `cargo` command to build and launch the node: Use Rust's native `cargo` command to build and launch the node:
```sh ```sh
cargo run -- --dev --tmp cargo run -- --dev
``` ```
This will deploy a local blockchain with test accounts (Alice, Bob, etc) in the genesis. This will deploy a local blockchain with test accounts (Alice, Bob, etc) in the genesis.
Open `https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944` to watch and interact with your node.
## Single-Node Development Chain
This command will start the single-node development chain with persistent state:
```bash
./target/debug/duniter --dev --tmp
```
Then open `https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944` in a browser.
Start the development chain with detailed logging: Start the development chain with detailed logging:
...@@ -148,140 +127,11 @@ Start the development chain with detailed logging: ...@@ -148,140 +127,11 @@ Start the development chain with detailed logging:
RUST_LOG=debug RUST_BACKTRACE=1 ./target/debug/duniter -lruntime=debug --dev RUST_LOG=debug RUST_BACKTRACE=1 ./target/debug/duniter -lruntime=debug --dev
``` ```
## Multi-Node Local Testnet ## License
If you want to see the multi-node consensus algorithm in action, refer to
[our Start a Private Network tutorial](https://substrate.dev/docs/en/tutorials/start-a-private-network/).
### Purge previous local testnet
```
./target/debug/duniter purge-chain --base-path /tmp/alice --chain local
./target/debug/duniter purge-chain --base-path /tmp/bob --chain local
```
### Start Alice's node
```bash
./target/debug/duniter \
--base-path /tmp/alice \
--chain local \
--alice \
--port 30333 \
--ws-port 9945 \
--rpc-port 9933 \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--validator
```
### Start Bob's node
```bash See [LICENSE](./LICENSE)
./target/debug/duniter \
--base-path /tmp/bob \
--chain local \
--bob \
--port 30334 \
--ws-port 9946 \
--rpc-port 9934 \
--validator \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
```
## Project Structure
A Substrate project such as this consists of a number of components that are spread across a few
directories.
### Node
A blockchain node is an application that allows users to participate in a blockchain network.
Substrate-based blockchain nodes expose a number of capabilities:
- Networking: Substrate nodes use the [`libp2p`](https://libp2p.io/) networking stack to allow the
nodes in the network to communicate with one another.
- Consensus: Blockchains must have a way to come to
[consensus](https://substrate.dev/docs/en/knowledgebase/advanced/consensus) on the state of the
network. Substrate makes it possible to supply custom consensus engines and also ships with
several consensus mechanisms that have been built on top of
[Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html).
- RPC Server: A remote procedure call (RPC) server is used to interact with Substrate nodes.
There are several files in the `node` directory - take special note of the following:
- [`chain_spec.rs`](./node/src/chain_spec.rs): A
[chain specification](https://substrate.dev/docs/en/knowledgebase/integrate/chain-spec) is a
source code file that defines a Substrate chain's initial (genesis) state. Chain specifications
are useful for development and testing, and critical when architecting the launch of a
production chain. Take note of the `development_chain_spec` and `testnet_genesis` functions, which
are used to define the genesis state for the local development chain configuration. These
functions identify some
[well-known accounts](https://substrate.dev/docs/en/knowledgebase/integrate/subkey#well-known-keys)
and use them to configure the blockchain's initial state.
- [`service.rs`](./node/src/service.rs): This file defines the node implementation. Take note of
the libraries that this file imports and the names of the functions it invokes. In particular,
there are references to consensus-related topics, such as the
[longest chain rule](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#longest-chain-rule),
the [Babe](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#babe) block authoring
mechanism and the
[GRANDPA](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#grandpa) finality
gadget.
After the node has been [built](#build), refer to the embedded documentation to learn more about the
capabilities and configuration parameters that it exposes:
```shell
./target/debug/duniter --help
``` ```
### Runtime
In Substrate, the terms
"[runtime](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#runtime)" and
"[state transition function](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#stf-state-transition-function)"
are analogous - they refer to the core logic of the blockchain that is responsible for validating
blocks and executing the state changes they define. The Substrate project in this repository uses
the [FRAME](https://substrate.dev/docs/en/knowledgebase/runtime/frame) framework to construct a
blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules
called "pallets". At the heart of FRAME is a helpful
[macro language](https://substrate.dev/docs/en/knowledgebase/runtime/macros) that makes it easy to
create pallets and flexibly compose them to create blockchains that can address
[a variety of needs](https://www.substrate.io/substrate-users/).
Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this template and note
the following:
- This file configures several pallets to include in the runtime. Each pallet configuration is
defined by a code block that begins with `impl $PALLET_NAME::Config for Runtime`.
- The pallets are composed into a single runtime by way of the
[`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html)
macro, which is part of the core
[FRAME Support](https://substrate.dev/docs/en/knowledgebase/runtime/frame#support-library)
library.
### Pallets
The runtime in this project is constructed using many FRAME pallets that ship with the
[core Substrate repository](https://github.com/paritytech/substrate/tree/master/frame) and a
template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs) directory.
A FRAME pallet is compromised of a number of blockchain primitives:
- Storage: FRAME defines a rich set of powerful
[storage abstractions](https://substrate.dev/docs/en/knowledgebase/runtime/storage) that makes
it easy to use Substrate's efficient key-value database to manage the evolving state of a
blockchain.
- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched)
from outside of the runtime in order to update its state.
- Events: Substrate uses [events](https://substrate.dev/docs/en/knowledgebase/runtime/events) to
notify users of important changes in the runtime.
- Errors: When a dispatchable fails, it returns an error.
- Config: The `Config` configuration interface is used to define the types and parameters upon
which a FRAME pallet depends.
## License
CopyLeft 2021-2023 Axiom-Team CopyLeft 2021-2023 Axiom-Team
Some parts borrowed from Polkadot (Parity Technologies (UK) Ltd.) Some parts borrowed from Polkadot (Parity Technologies (UK) Ltd.)
...@@ -297,3 +147,4 @@ GNU Affero General Public License for more details. ...@@ -297,3 +147,4 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
```
[package]
edition.workspace = true
homepage.workspace = true
license.workspace = true
description = "Duniter client distance"
name = "dc-distance"
readme = "README.md"
version = "1.0.0"
repository.workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[features]
std = [
"frame-support/std",
"pallet-distance/std",
"sp-core/std",
"sp-distance/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"pallet-distance/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"pallet-distance/try-runtime",
"sp-distance/try-runtime",
"sp-runtime/try-runtime",
]
[dependencies]
frame-support = { workspace = true }
log = { workspace = true }
pallet-distance = { workspace = true }
sc-client-api = { workspace = true }
sp-core = { workspace = true }
sp-distance = { workspace = true }
sp-runtime = { workspace = true }
thiserror = { workspace = true }
# Distance Oracle Inherent Data Provider
You can find the autogenerated documentation at: [https://doc-duniter-org.ipns.pagu.re/dc_distance/index.html](https://doc-duniter-org.ipns.pagu.re/dc_distance/index.html).
// Copyright 2022 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
//! # Distance Oracle Inherent Data Provider
//!
//! This crate provides functionality for creating an **inherent data provider**
//! specifically designed for the "Distance Oracle".
//! The inherent data provider is responsible for fetching and delivering
//! computation results required for the runtime to process distance evaluations.
//!
//! ## Relationship with Distance Oracle
//!
//! The **distance-oracle** is responsible for computing distance evaluations,
//! storing the results to be read in the next period, and saving them to files.
//! These files are then read by **this inherent data provider**
//! to provide the required data to the runtime.
//!
//! ## Overview
//!
//! - Retrieves **period index** and **evaluation results** from the storage and file system.
//! - Determines whether the computation results for the current period have already been published.
//! - Reads and parses evaluation result files when available, providing the necessary data to the runtime.
use frame_support::pallet_prelude::*;
use sc_client_api::{ProvideUncles, StorageKey, StorageProvider};
use sp_runtime::{generic::BlockId, traits::Block as BlockT, AccountId32};
use std::path::PathBuf;
/// The file version that should match the distance oracle one.
/// This ensures that the smith avoids accidentally submitting invalid data
/// in case there are changes in logic between the runtime and the oracle,
/// thereby preventing potential penalties.
const VERSION_PREFIX: &str = "001-";
type IdtyIndex = u32;
#[derive(Debug, thiserror::Error)]
pub enum Error<B: BlockT> {
#[error("Could not retrieve the block hash for block id: {0:?}")]
NoHashForBlockId(BlockId<B>),
}
/// Create a new [`sp_distance::InherentDataProvider`] at the given block.
pub fn create_distance_inherent_data_provider<B, C, Backend>(
client: &C,
parent: B::Hash,
distance_dir: PathBuf,
owner_keys: &[sp_core::sr25519::Public],
) -> sp_distance::InherentDataProvider<IdtyIndex>
where
B: BlockT,
C: ProvideUncles<B> + StorageProvider<B, Backend>,
Backend: sc_client_api::Backend<B>,
IdtyIndex: Decode + Encode + PartialEq + TypeInfo,
{
// Retrieve the period_index from storage.
let period_index = client
.storage(
parent,
&StorageKey(
frame_support::storage::storage_prefix(b"Distance", b"CurrentPeriodIndex").to_vec(),
),
)
.ok()
.flatten()
.and_then(|raw| u32::decode(&mut &raw.0[..]).ok());
// Return early if the storage is inaccessible or the data is corrupted.
let period_index = match period_index {
Some(index) => index,
None => {
log::error!("🧙 [distance inherent] PeriodIndex decoding failed.");
return sp_distance::InherentDataProvider::<IdtyIndex>::new(None);
}
};
// Retrieve the published_results from storage.
let published_results = client
.storage(
parent,
&StorageKey(
frame_support::storage::storage_prefix(
b"Distance",
match period_index % 3 {
0 => b"EvaluationPool0",
1 => b"EvaluationPool1",
2 => b"EvaluationPool2",
_ => unreachable!("n<3"),
},
)
.to_vec(),
),
)
.ok()
.flatten()
.and_then(|raw| {
pallet_distance::EvaluationPool::<AccountId32, IdtyIndex>::decode(&mut &raw.0[..]).ok()
});
// Return early if the storage is inaccessible or the data is corrupted.
let published_results = match published_results {
Some(published_results) => published_results,
None => {
log::info!("🧙 [distance inherent] No published result at this block.");
return sp_distance::InherentDataProvider::<IdtyIndex>::new(None);
}
};
// Find the account associated with the BABE key that is in our owner keys.
let mut local_account = None;
for key in owner_keys {
// Session::KeyOwner is StorageMap<_, Twox64Concat, (KeyTypeId, Vec<u8>), AccountId32, OptionQuery>
// Slices (variable length) and array (fixed length) are encoded differently, so the `.as_slice()` is needed
let item_key = (sp_runtime::KeyTypeId(*b"babe"), key.0.as_slice()).encode();
let mut storage_key =
frame_support::storage::storage_prefix(b"Session", b"KeyOwner").to_vec();
storage_key.extend_from_slice(&sp_core::twox_64(&item_key));
storage_key.extend_from_slice(&item_key);
if let Some(raw_data) = client
.storage(parent, &StorageKey(storage_key))
.ok()
.flatten()
{
if let Ok(key_owner) = AccountId32::decode(&mut &raw_data.0[..]) {
local_account = Some(key_owner);
break;
} else {
log::warn!("🧙 [distance inherent] Cannot decode key owner value");
}
}
}
// Have we already published a result for this period?
if let Some(local_account) = local_account {
if published_results.evaluators.contains(&local_account) {
log::debug!("🧙 [distance inherent] Already published a result for this period");
return sp_distance::InherentDataProvider::<IdtyIndex>::new(None);
}
} else {
log::error!("🧙 [distance inherent] Cannot find our BABE owner key");
return sp_distance::InherentDataProvider::<IdtyIndex>::new(None);
}
// Read evaluation result from file, if it exists
log::debug!(
"🧙 [distance inherent] Reading evaluation result from file {:?}",
distance_dir.clone().join(period_index.to_string())
);
let evaluation_result = match std::fs::read(
distance_dir.join(VERSION_PREFIX.to_owned() + &period_index.to_string()),
) {
Ok(data) => data,
Err(e) => {
match e.kind() {
std::io::ErrorKind::NotFound => {
log::debug!("🧙 [distance inherent] Evaluation result file not found. Please ensure that the oracle version matches {}", VERSION_PREFIX);
}
_ => {
log::error!(
"🧙 [distance inherent] Cannot read distance evaluation result file: {e:?}"
);
}
}
return sp_distance::InherentDataProvider::<IdtyIndex>::new(None);
}
};
log::info!("🧙 [distance inherent] Providing evaluation result");
sp_distance::InherentDataProvider::<IdtyIndex>::new(Some(
sp_distance::ComputationResult::decode(&mut evaluation_result.as_slice()).unwrap(),
))
}
[package]
name = "distance-oracle"
version = "0.1.0"
authors.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true
[[bin]]
name = "distance-oracle"
required-features = ["standalone"]
[features]
default = ["standalone", "std"]
# Feature standalone is for CLI executable
standalone = ["clap", "tokio"]
# Feature std is needed
std = [
"codec/std",
"fnv/std",
"sp-core/std",
"sp-distance/std",
"sp-runtime/std",
]
try-runtime = ["sp-distance/try-runtime", "sp-runtime/try-runtime"]
[dependencies]
clap = { workspace = true, features = ["derive"], optional = true }
codec = { workspace = true }
fnv = { workspace = true }
log = { workspace = true }
rayon = { workspace = true }
simple_logger = { workspace = true }
sp-core = { workspace = true }
sp-distance = { workspace = true }
sp-runtime = { workspace = true }
subxt = { workspace = true, features = [
"native",
"jsonrpsee",
] }
tokio = { workspace = true, features = [
"rt-multi-thread",
"macros",
], optional = true }
[dev-dependencies]
bincode = { workspace = true }
dubp-wot = { workspace = true }
flate2 = { workspace = true, features = ["zlib-ng-compat"] }
# Distance Oracle
You can find the autogenerated documentation at: [https://doc-duniter-org.ipns.pagu.re/distance_oracle/index.html](https://doc-duniter-org.ipns.pagu.re/distance_oracle/index.html).
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
#![allow(clippy::type_complexity)]
use crate::runtime;
use log::debug;
pub type Client = subxt::OnlineClient<crate::RuntimeConfig>;
pub type AccountId = subxt::utils::AccountId32;
pub type IdtyIndex = u32;
pub type EvaluationPool =
runtime::runtime_types::pallet_distance::types::EvaluationPool<AccountId, IdtyIndex>;
pub type H256 = subxt::utils::H256;
pub async fn client(rpc_url: impl AsRef<str>) -> Client {
Client::from_insecure_url(rpc_url)
.await
.expect("Cannot create RPC client")
}
pub async fn parent_hash(client: &Client) -> H256 {
client
.blocks()
.at_latest()
.await
.expect("Cannot fetch latest block hash")
.hash()
}
pub async fn current_period_index(client: &Client, parent_hash: H256) -> u32 {
client
.storage()
.at(parent_hash)
.fetch(&runtime::storage().distance().current_period_index())
.await
.expect("Cannot fetch current pool index")
.unwrap_or_default()
}
pub async fn current_pool(
client: &Client,
parent_hash: H256,
current_pool_index: u32,
) -> Option<EvaluationPool> {
client
.storage()
.at(parent_hash)
.fetch(&match current_pool_index {
0 => {
debug!("Looking at Pool1 for pool index {}", current_pool_index);
runtime::storage().distance().evaluation_pool1()
}
1 => {
debug!("Looking at Pool2 for pool index {}", current_pool_index);
runtime::storage().distance().evaluation_pool2()
}
2 => {
debug!("Looking at Pool0 for pool index {}", current_pool_index);
runtime::storage().distance().evaluation_pool0()
}
_ => unreachable!("n<3"),
})
.await
.expect("Cannot fetch current pool")
}
pub async fn evaluation_block(client: &Client, parent_hash: H256) -> H256 {
client
.storage()
.at(parent_hash)
.fetch(&runtime::storage().distance().evaluation_block())
.await
.expect("Cannot fetch evaluation block")
.expect("No evaluation block")
}
pub async fn max_referee_distance(client: &Client) -> u32 {
client
.constants()
.at(&runtime::constants().distance().max_referee_distance())
.expect("Cannot fetch referee distance")
}
pub async fn member_iter(client: &Client, evaluation_block: H256) -> MemberIter {
MemberIter(
client
.storage()
.at(evaluation_block)
.iter(runtime::storage().membership().membership_iter())
.await
.expect("Cannot fetch memberships"),
)
}
pub struct MemberIter(
subxt::backend::StreamOfResults<
subxt::storage::StorageKeyValuePair<
subxt::storage::StaticAddress<
(),
runtime::runtime_types::sp_membership::MembershipData<u32>,
(),
(),
subxt::utils::Yes,
>,
>,
>,
);
impl MemberIter {
pub async fn next(&mut self) -> Result<Option<IdtyIndex>, subxt::error::Error> {
self.0
.next()
.await
.transpose()
.map(|i| i.map(|j| idty_id_from_storage_key(&j.key_bytes)))
}
}
pub async fn cert_iter(client: &Client, evaluation_block: H256) -> CertIter {
CertIter(
client
.storage()
.at(evaluation_block)
.iter(runtime::storage().certification().certs_by_receiver_iter())
.await
.expect("Cannot fetch certifications"),
)
}
pub struct CertIter(
subxt::backend::StreamOfResults<
subxt::storage::StorageKeyValuePair<
subxt::storage::StaticAddress<
(),
Vec<(u32, u32)>,
(),
subxt::utils::Yes,
subxt::utils::Yes,
>,
>,
>,
);
impl CertIter {
pub async fn next(
&mut self,
) -> Result<Option<(IdtyIndex, Vec<(IdtyIndex, u32)>)>, subxt::error::Error> {
self.0
.next()
.await
.transpose()
.map(|i| i.map(|j| (idty_id_from_storage_key(&j.key_bytes), j.value)))
}
}
fn idty_id_from_storage_key(storage_key: &[u8]) -> IdtyIndex {
u32::from_le_bytes(
storage_key[40..44]
.try_into()
.expect("Cannot convert StorageKey to IdtyIndex"),
)
}
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
//! # Distance Oracle
//!
//! The **Distance Oracle** is a standalone program designed to calculate the distances between identities in the Duniter Web of Trust (WoT). This process is computationally intensive and is therefore decoupled from the main runtime. It allows smith users to choose whether to run the oracle and provide results to the network.
//!
//! The **oracle** works in conjunction with the **Inherent Data Provider** and the **Distance Pallet** in the runtime to deliver periodic computation results. The **Inherent Data Provider** fetches and supplies these results to the runtime, ensuring that the necessary data for distance evaluations is available to be processed at the appropriate time in the runtime lifecycle.
//!
//! ## Structure
//!
//! The Distance Oracle is organized into the following modules:
//!
//! 1. **`/distance-oracle/`**: Contains the main binary for executing the distance computation.
//! 2. **`/primitives/distance/`**: Defines primitive types shared between the client and runtime.
//! 3. **`/client/distance/`**: Exposes the `create_distance_inherent_data_provider`, which feeds data into the runtime through the Inherent Data Provider.
//! 4. **`/pallets/distance/`**: A pallet that handles distance-related types, traits, storage, and hooks in the runtime, coordinating the interaction between the oracle, inherent data provider, and runtime.
//!
//! ## How it works
//! - The **Distance Pallet** adds an evaluation request at period `i` in the runtime.
//! - The **Distance Oracle** evaluates this request at period `i + 1`, computes the necessary results and stores them on disk.
//! - The **Inherent Data Provider** reads this evaluation result from disk at period `i + 2` and provides it to the runtime to perform the required operations.
//!
//! ## Usage
//!
//! ### Docker Integration
//!
//! To run the Distance Oracle, use the provided Docker setup. Refer to the [docker-compose.yml](../docker-compose.yml) file for an example configuration.
//!
//! Example Output:
//! ```text
//! 2023-12-09T14:45:05.942Z INFO [distance_oracle] Nothing to do: Pool does not exist
//! Waiting 1800 seconds before next execution...
//! ```
#[cfg(not(test))]
pub mod api;
#[cfg(test)]
pub mod mock;
#[cfg(test)]
mod tests;
#[cfg(test)]
pub use mock as api;
use api::{AccountId, EvaluationPool, IdtyIndex, H256};
use codec::Encode;
use fnv::{FnvHashMap, FnvHashSet};
use log::{debug, info, warn};
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use std::{io::Write, path::PathBuf};
/// The file version must match the version used by the inherent data provider.
/// This ensures that the smith avoids accidentally submitting invalid data
/// in case there are changes in logic between the runtime and the oracle,
/// thereby preventing potential penalties.
const VERSION_PREFIX: &str = "001-";
#[subxt::subxt(runtime_metadata_path = "../resources/metadata.scale")]
pub mod runtime {}
pub enum RuntimeConfig {}
impl subxt::config::Config for RuntimeConfig {
type AccountId = AccountId;
type Address = sp_runtime::MultiAddress<Self::AccountId, u32>;
type AssetId = ();
type ExtrinsicParams = subxt::config::substrate::SubstrateExtrinsicParams<Self>;
type Hash = subxt::utils::H256;
type Hasher = subxt::config::substrate::BlakeTwo256;
type Header =
subxt::config::substrate::SubstrateHeader<u32, subxt::config::substrate::BlakeTwo256>;
type Signature = sp_runtime::MultiSignature;
}
/// Represents a tipping amount.
#[derive(Copy, Clone, Debug, Default, Encode)]
pub struct Tip {
#[codec(compact)]
tip: u64,
}
impl Tip {
pub fn new(amount: u64) -> Self {
Tip { tip: amount }
}
}
impl From<u64> for Tip {
fn from(n: u64) -> Self {
Self::new(n)
}
}
/// Represents configuration parameters.
pub struct Settings {
pub evaluation_result_dir: PathBuf,
pub rpc_url: String,
}
impl Default for Settings {
fn default() -> Self {
Self {
evaluation_result_dir: PathBuf::from("/tmp/duniter/chains/gdev/distance"),
rpc_url: String::from("ws://127.0.0.1:9944"),
}
}
}
/// Runs the evaluation process, saves the results, and cleans up old files.
///
/// This function performs the following steps:
/// 1. Runs the evaluation task by invoking `compute_distance_evaluation`, which provides:
/// - The evaluation results.
/// - The current period index.
/// - The file path where the results should be stored.
/// 2. Saves the evaluation results to a file in the specified directory.
/// 3. Cleans up outdated evaluation files.
pub async fn run(client: &api::Client, settings: &Settings) {
let Some((evaluation, current_period_index, evaluation_result_path)) =
compute_distance_evaluation(client, settings).await
else {
return;
};
debug!("Saving distance evaluation result to file `{evaluation_result_path:?}`");
let mut evaluation_result_file = std::fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(&evaluation_result_path)
.unwrap_or_else(|e| {
panic!(
"Cannot open distance evaluation result file `{evaluation_result_path:?}`: {e:?}"
)
});
evaluation_result_file
.write_all(
&sp_distance::ComputationResult {
distances: evaluation,
}
.encode(),
)
.unwrap_or_else(|e| {
panic!(
"Cannot write distance evaluation result to file `{evaluation_result_path:?}`: {e:?}"
)
});
// When a new result is written, remove old results except for the current period used by the inherent logic and the next period that was just generated.
settings
.evaluation_result_dir
.read_dir()
.unwrap_or_else(|e| {
panic!(
"Cannot read distance evaluation result directory `{:?}`: {:?}",
settings.evaluation_result_dir, e
)
})
.flatten()
.filter_map(|entry| {
entry
.file_name()
.to_str()
.and_then(|name| {
name.split('-').last()?.parse::<u32>().ok().filter(|&pool| {
pool != current_period_index && pool != current_period_index + 1
})
})
.map(|_| entry.path())
})
.for_each(|path| {
std::fs::remove_file(&path)
.unwrap_or_else(|e| warn!("Cannot remove file `{:?}`: {:?}", path, e));
});
}
/// Evaluates distance for the current period and prepares results for storage.
///
/// This function performs the following steps:
/// 1. Prepares the evaluation context using `prepare_evaluation_context`. If the context is not
/// ready (e.g., no pending evaluations, or results already exist), it returns `None`.
/// 2. Evaluates distances for all identities in the evaluation pool.
/// 3. Returns the evaluation results, the current period index, and the path to store the results.
///
pub async fn compute_distance_evaluation(
client: &api::Client,
settings: &Settings,
) -> Option<(Vec<sp_runtime::Perbill>, u32, PathBuf)> {
let (evaluation_block, current_period_index, evaluation_pool, evaluation_result_path) =
prepare_evaluation_context(client, settings).await?;
info!("Evaluating distance for period {}", current_period_index);
let max_depth = api::max_referee_distance(client).await;
// member idty -> issued certs
let mut members = FnvHashMap::<IdtyIndex, u32>::default();
let mut members_iter = api::member_iter(client, evaluation_block).await;
while let Some(member_idty) = members_iter
.next()
.await
.expect("Cannot fetch next members")
{
members.insert(member_idty, 0);
}
let min_certs_for_referee = (members.len() as f32).powf(1. / (max_depth as f32)).ceil() as u32;
// idty -> received certs
let mut received_certs = FnvHashMap::<IdtyIndex, Vec<IdtyIndex>>::default();
let mut certs_iter = api::cert_iter(client, evaluation_block).await;
while let Some((receiver, issuers)) = certs_iter
.next()
.await
.expect("Cannot fetch next certification")
{
if (issuers.len() as u32) < min_certs_for_referee {
// This member is not referee
members.remove(&receiver);
}
for (issuer, _removable_on) in issuers.iter() {
if let Some(issued_certs) = members.get_mut(issuer) {
*issued_certs += 1;
}
}
received_certs.insert(
receiver,
issuers
.into_iter()
.map(|(issuer, _removable_on)| issuer)
.collect(),
);
}
// Only retain referees
members.retain(|_idty, issued_certs| *issued_certs >= min_certs_for_referee);
let referees = members;
let evaluation = evaluation_pool
.evaluations
.0
.as_slice()
.par_iter()
.map(|(idty, _)| distance_rule(&received_certs, &referees, max_depth, *idty))
.collect();
Some((evaluation, current_period_index, evaluation_result_path))
}
/// Prepares the context for the next evaluation task.
///
/// This function performs the following steps:
/// 1. Fetches the parent hash of the latest block from the API.
/// 2. Determines the current period index.
/// 3. Retrieves the evaluation pool for the current period.
/// - If the pool does not exist or is empty, it returns `None`.
/// 4. Checks if the evaluation result file for the next period already exists.
/// - If it exists, the task has already been completed, so the function returns `None`.
/// 5. Ensures the evaluation result directory is available, creating it if necessary.
/// 6. Retrieves the block number of the evaluation.
///
async fn prepare_evaluation_context(
client: &api::Client,
settings: &Settings,
) -> Option<(H256, u32, EvaluationPool, PathBuf)> {
let parent_hash = api::parent_hash(client).await;
let current_period_index = api::current_period_index(client, parent_hash).await;
// Fetch the pending identities
let Some(evaluation_pool) =
api::current_pool(client, parent_hash, current_period_index % 3).await
else {
info!("Nothing to do: Pool does not exist");
return None;
};
// Stop if nothing to evaluate
if evaluation_pool.evaluations.0.is_empty() {
info!("Nothing to do: Pool is empty");
return None;
}
// The result is saved in a file named `current_period_index + 1`.
// It will be picked up during the next period by the inherent.
let evaluation_result_path = settings
.evaluation_result_dir
.join(VERSION_PREFIX.to_owned() + &(current_period_index + 1).to_string());
// Stop if already evaluated
if evaluation_result_path
.try_exists()
.expect("Result path unavailable")
{
info!("Nothing to do: File already exists");
return None;
}
#[cfg(not(test))]
std::fs::create_dir_all(&settings.evaluation_result_dir).unwrap_or_else(|e| {
panic!(
"Cannot create distance evaluation result directory `{0:?}`: {e:?}",
settings.evaluation_result_dir
);
});
Some((
api::evaluation_block(client, parent_hash).await,
current_period_index,
evaluation_pool,
evaluation_result_path,
))
}
/// Recursively explores the certification graph to identify referees accessible within a given depth.
fn distance_rule_recursive(
received_certs: &FnvHashMap<IdtyIndex, Vec<IdtyIndex>>,
referees: &FnvHashMap<IdtyIndex, u32>,
idty: IdtyIndex,
accessible_referees: &mut FnvHashSet<IdtyIndex>,
known_idties: &mut FnvHashMap<IdtyIndex, u32>,
depth: u32,
) {
// Do not re-explore identities that have already been explored at least as deeply
match known_idties.entry(idty) {
std::collections::hash_map::Entry::Occupied(mut entry) => {
if *entry.get() >= depth {
return;
} else {
*entry.get_mut() = depth;
}
}
std::collections::hash_map::Entry::Vacant(entry) => {
entry.insert(depth);
}
}
// If referee, add it to the list
if referees.contains_key(&idty) {
accessible_referees.insert(idty);
}
// If reached the maximum distance, stop exploring
if depth == 0 {
return;
}
// Explore certifiers
for &certifier in received_certs.get(&idty).unwrap_or(&vec![]).iter() {
distance_rule_recursive(
received_certs,
referees,
certifier,
accessible_referees,
known_idties,
depth - 1,
);
}
}
/// Calculates the fraction of accessible referees to total referees for a given identity.
fn distance_rule(
received_certs: &FnvHashMap<IdtyIndex, Vec<IdtyIndex>>,
referees: &FnvHashMap<IdtyIndex, u32>,
depth: u32,
idty: IdtyIndex,
) -> sp_runtime::Perbill {
debug!("Evaluating distance for idty {}", idty);
let mut accessible_referees =
FnvHashSet::<IdtyIndex>::with_capacity_and_hasher(referees.len(), Default::default());
let mut known_idties =
FnvHashMap::<IdtyIndex, u32>::with_capacity_and_hasher(referees.len(), Default::default());
distance_rule_recursive(
received_certs,
referees,
idty,
&mut accessible_referees,
&mut known_idties,
depth,
);
let result = if referees.contains_key(&idty) {
sp_runtime::Perbill::from_rational(
accessible_referees.len() as u32 - 1,
referees.len() as u32 - 1,
)
} else {
sp_runtime::Perbill::from_rational(accessible_referees.len() as u32, referees.len() as u32)
};
info!(
"Distance for idty {}: {}/{} = {}%",
idty,
accessible_referees.len(),
referees.len(),
result.deconstruct() as f32 / 1_000_000_000f32 * 100f32
);
result
}
// Copyright 2023-2024 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use clap::Parser;
#[derive(Debug, clap::Parser)]
struct Cli {
#[clap(short = 'd', long, default_value = "/tmp/duniter/chains/gdev/distance")]
evaluation_result_dir: String,
/// Number of seconds between two evaluations (oneshot if absent)
#[clap(short = 'i', long)]
interval: Option<u64>,
/// Node used for fetching state
#[clap(short = 'u', long, default_value = "ws://127.0.0.1:9944")]
rpc_url: String,
/// Log level (off, error, warn, info, debug, trace)
#[clap(short = 'l', long, default_value = "info")]
log: log::LevelFilter,
}
#[tokio::main]
async fn main() {
let cli = Cli::parse();
simple_logger::SimpleLogger::new()
.with_level(cli.log)
.init()
.unwrap();
let client = distance_oracle::api::client(&cli.rpc_url).await;
let settings = distance_oracle::Settings {
evaluation_result_dir: cli.evaluation_result_dir.into(),
rpc_url: cli.rpc_url,
};
if let Some(duration) = cli.interval {
let mut interval = tokio::time::interval(std::time::Duration::from_secs(duration));
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
loop {
distance_oracle::run(&client, &settings).await;
interval.tick().await;
}
} else {
distance_oracle::run(&client, &settings).await;
}
}
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use crate::runtime::runtime_types::{
pallet_distance::median::MedianAcc, sp_arithmetic::per_things::Perbill,
};
use dubp_wot::{data::rusty::RustyWebOfTrust, WebOfTrust, WotId};
use std::collections::BTreeSet;
pub struct Client {
wot: RustyWebOfTrust,
pub pool_len: usize,
}
pub type AccountId = sp_runtime::AccountId32;
pub type IdtyIndex = u32;
pub type H256 = subxt::utils::H256;
pub struct EvaluationPool {
pub evaluations: (Vec<(IdtyIndex, MedianAcc<Perbill>)>,),
pub evaluators: BTreeSet<AccountId>,
}
pub async fn client(_rpc_url: impl AsRef<str>) -> Client {
unimplemented!()
}
pub fn client_from_wot(wot: RustyWebOfTrust) -> Client {
Client { wot, pool_len: 1 }
}
pub async fn parent_hash(_client: &Client) -> H256 {
Default::default()
}
pub async fn current_period_index(_client: &Client, _parent_hash: H256) -> u32 {
0
}
pub async fn current_pool(
client: &Client,
_parent_hash: H256,
_current_session: u32,
) -> Option<EvaluationPool> {
Some(EvaluationPool {
evaluations: (client
.wot
.get_enabled()
.into_iter()
.chain(client.wot.get_disabled().into_iter())
.zip(0..client.pool_len)
.map(|(wot_id, _)| {
(wot_id.0 as IdtyIndex, unsafe {
std::mem::transmute::<
(std::vec::Vec<()>, std::option::Option<u32>, i32),
MedianAcc<Perbill>,
>((Vec::<()>::new(), Option::<u32>::None, 0))
})
})
.collect(),),
evaluators: BTreeSet::new(),
})
}
pub async fn evaluation_block(_client: &Client, _parent_hash: H256) -> H256 {
Default::default()
}
pub async fn max_referee_distance(_client: &Client) -> u32 {
5
}
pub async fn member_iter(client: &Client, _evaluation_block: H256) -> MemberIter {
MemberIter(client.wot.get_enabled().into_iter())
}
pub struct MemberIter(std::vec::IntoIter<WotId>);
impl MemberIter {
pub async fn next(&mut self) -> Result<Option<IdtyIndex>, subxt::error::Error> {
Ok(self.0.next().map(|wot_id| wot_id.0 as u32))
}
}
pub async fn cert_iter(client: &Client, _evaluation_block: H256) -> CertIter {
CertIter(
client
.wot
.get_enabled()
.iter()
.chain(client.wot.get_disabled().iter())
.map(|wot_id| {
(
wot_id.0 as IdtyIndex,
client
.wot
.get_links_source(*wot_id)
.unwrap_or_default()
.into_iter()
.map(|wot_id| (wot_id.0 as IdtyIndex, 0))
.collect::<Vec<(IdtyIndex, u32)>>(),
)
})
.collect::<Vec<_>>()
.into_iter(),
)
}
pub struct CertIter(std::vec::IntoIter<(IdtyIndex, Vec<(IdtyIndex, u32)>)>);
impl CertIter {
pub async fn next(&mut self) -> Result<Option<(u32, Vec<(u32, u32)>)>, subxt::error::Error> {
Ok(self.0.next())
}
}
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use dubp_wot::{
data::rusty::RustyWebOfTrust, operations::distance::DistanceCalculator, WebOfTrust,
};
use flate2::read::ZlibDecoder;
use sp_runtime::Perbill;
use std::{fs::File, io::Read};
#[tokio::test]
#[ignore = "long to execute"]
async fn test_distance_against_v1() {
let wot = wot_from_v1_file();
let n = wot.size();
let min_certs_for_referee = (wot.get_enabled().len() as f32).powf(1. / 5.).ceil() as u32;
// Reference implementation
let ref_calculator = dubp_wot::operations::distance::RustyDistanceCalculator;
let t_a = std::time::Instant::now();
let ref_results: Vec<Perbill> = wot
.get_enabled()
.into_iter()
.chain(wot.get_disabled().into_iter())
.zip(0..n)
.map(|(i, _)| {
let result = ref_calculator
.compute_distance(
&wot,
dubp_wot::operations::distance::WotDistanceParameters {
node: i,
sentry_requirement: min_certs_for_referee,
step_max: 5,
x_percent: 0.8,
},
)
.unwrap();
Perbill::from_rational(result.success, result.sentries)
})
.collect();
println!("ref time: {}", t_a.elapsed().as_millis());
// Our implementation
let mut client = crate::api::client_from_wot(wot);
client.pool_len = n;
let t_a = std::time::Instant::now();
let results = crate::compute_distance_evaluation(&client, &Default::default())
.await
.unwrap();
println!("new time: {}", t_a.elapsed().as_millis());
assert_eq!(results.0.len(), n);
let mut errors: Vec<_> = results
.0
.iter()
.zip(ref_results.iter())
.map(|(r, r_ref)| r.deconstruct() as i64 - r_ref.deconstruct() as i64)
.collect();
errors.sort_unstable();
println!(
"Error: {:?} / {:?} / {:?} / {:?} / {:?} (min / 1Q / med / 3Q / max)",
errors[0],
errors[errors.len() / 4],
errors[errors.len() / 2],
errors[errors.len() * 3 / 4],
errors[errors.len() - 1]
);
let correct_results = results
.0
.iter()
.zip(ref_results.iter())
.map(|(r, r_ref)| (r == r_ref) as usize)
.sum::<usize>();
println!("Correct results: {correct_results} / {n}");
assert_eq!(correct_results, n);
}
fn wot_from_v1_file() -> RustyWebOfTrust {
let file = File::open("wot.deflate").expect("Cannot open wot.deflate");
let mut decompressor = ZlibDecoder::new(file);
let mut decompressed_bytes = Vec::new();
decompressor
.read_to_end(&mut decompressed_bytes)
.expect("Cannot decompress wot.deflate");
bincode::deserialize::<RustyWebOfTrust>(&decompressed_bytes).expect("Cannot decode wot.deflate")
}