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

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
Show changes
Showing
with 5255 additions and 958 deletions
# docker-compose.yml template for running a Duniter smith node
# for more doc, see https://duniter.org/wiki/duniter-v2/
services:
# duniter smith node
duniter-v2s-smith:
container_name: duniter-v2s-smith
image: duniter/duniter-v2s-gdev-800:latest
ports:
# RPC API of a smith node should not be exposed publicly!
- 127.0.0.1:9944:9944
# public p2p endpoint
- 30333:30333
environment:
DUNITER_NODE_NAME: duniter_smith
DUNITER_CHAIN_NAME: gdev
DUNITER_VALIDATOR: true
DUNITER_PRUNING_PROFILE: light
DUNITER_PUBLIC_ADDR: /dns/your.domain.name/tcp/30333
DUNITER_LISTEN_ADDR: /ip4/0.0.0.0/tcp/30333
volumes:
- duniter-smith-data:/var/lib/duniter
# distance oracle
distance-oracle:
container_name: distance-oracle
# choose the version of the image here
image: duniter/duniter-v2s-gdev:latest
entrypoint: docker-distance-entrypoint
environment:
ORACLE_RPC_URL: ws://duniter-v2s-smith:9944
ORACLE_RESULT_DIR: /var/lib/duniter/chains/gdev/distance/
ORACLE_EXECUTION_INTERVAL: 1800
ORACLE_LOG_LEVEL: info
volumes:
- duniter-smith-data:/var/lib/duniter
volumes:
duniter-smith-data:
# this template is used in /scripts/create-live-network.sh script
version: "3.5"
services:
duniter-rpc:
image: duniter/duniter-v2s:DUNITER_IMAGE_TAG
restart: unless-stopped
ports:
- "9944:9944"
- "30333:30333"
volumes:
- ./duniter-rpc/:/var/lib/duniter/
environment:
- DUNITER_CHAIN_NAME=/var/lib/duniter/CURRENCY-raw.json
command:
- "--bootnodes"
- "/dns/duniter-validator/tcp/30333/p2p/VALIDATOR_NODE_KEY"
duniter-validator:
image: duniter/duniter-v2s:DUNITER_IMAGE_TAG
restart: unless-stopped
ports:
- "127.0.0.1:9945:9944"
- "30334:30333"
volumes:
- ./duniter-validator/:/var/lib/duniter/
environment:
- DUNITER_CHAIN_NAME=/var/lib/duniter/CURRENCY-raw.json
- DUNITER_VALIDATOR=true
command:
- "--bootnodes"
- "/dns/duniter-rpc/tcp/30333/p2p/RPC_NODE_KEY"
......@@ -21,27 +21,60 @@ function ternary () {
fi
}
# Define chain name at the beginning
# with #274 we could have default given in network branch
DUNITER_CHAIN_NAME="${DUNITER_CHAIN_NAME:-dev}"
case "$DUNITER_CHAIN_NAME" in
dev)
chain=(--dev)
;;
*)
chain=(--chain "$DUNITER_CHAIN_NAME")
;;
esac
# Node name will appear on network
DUNITER_NODE_NAME="${DUNITER_NODE_NAME:-$DUNITER_INSTANCE_NAME}"
if [ -n "$DUNITER_NODE_NAME" ]; then
set -- "$@" --name "$DUNITER_NODE_NAME"
fi
# Path of key file. Should be generated below if not present before starting Duniter
_DUNITER_KEY_FILE=/var/lib/duniter/node.key
set -- "$@" --node-key-file "$_DUNITER_KEY_FILE"
# Generate node.key if not existing (chain name is required)
if [ ! -f "$_DUNITER_KEY_FILE" ]; then
echo "Generating node key file '$_DUNITER_KEY_FILE'..."
duniter key generate-node-key --file "$_DUNITER_KEY_FILE"
duniter key generate-node-key --file "$_DUNITER_KEY_FILE" "${chain[@]}"
else
echo "Node key file '$_DUNITER_KEY_FILE' exists."
fi
# Log peer ID
_DUNITER_PEER_ID="$(duniter key inspect-node-key --file "$_DUNITER_KEY_FILE")"
echo "Node peer ID is '$_DUNITER_PEER_ID'."
# Define public address (with dns, correct port and protocol for instance)
if [ -n "$DUNITER_PUBLIC_ADDR" ]; then
set -- "$@" --public-addr "$DUNITER_PUBLIC_ADDR"
fi
# Define public RPC endpoint (gossiped on the network)
if [ -n "$DUNITER_PUBLIC_RPC" ]; then
set -- "$@" --public-rpc "$DUNITER_PUBLIC_RPC"
fi
# Define public Squid endpoint (gossiped on the network)
if [ -n "$DUNITER_PUBLIC_SQUID" ]; then
set -- "$@" --public-squid "$DUNITER_PUBLIC_SQUID"
fi
# Define public endpoints from JSON file (gossiped on the network)
if [ -n "$DUNITER_PUBLIC_ENDPOINTS" ]; then
set -- "$@" --public-endpoints "$DUNITER_PUBLIC_ENDPOINTS"
fi
# Define listen address (inside docker)
if [ -n "$DUNITER_LISTEN_ADDR" ]; then
set -- "$@" --listen-addr "$DUNITER_LISTEN_ADDR"
fi
......@@ -49,6 +82,7 @@ fi
DUNITER_RPC_CORS="${DUNITER_RPC_CORS:-all}"
set -- "$@" --rpc-cors "$DUNITER_RPC_CORS"
# In case of validator, unsafe rpc methods are needed (like rotate_key) and should not be exposed publicly
DUNITER_VALIDATOR=$(boolean "${DUNITER_VALIDATOR:-false}")
if [ "$DUNITER_VALIDATOR" = true ]; then
set -- "$@" --rpc-methods Unsafe --validator
......@@ -64,6 +98,7 @@ if [ "$DUNITER_DISABLE_TELEMETRY" = true ]; then
set -- "$@" --no-telemetry
fi
# Set pruning profile
DUNITER_PRUNING_PROFILE="${DUNITER_PRUNING_PROFILE:-default}"
case "$DUNITER_PRUNING_PROFILE" in
default)
......@@ -79,16 +114,9 @@ case "$DUNITER_PRUNING_PROFILE" in
;;
esac
DUNITER_CHAIN_NAME="${DUNITER_CHAIN_NAME:-dev}"
case "$DUNITER_CHAIN_NAME" in
dev)
chain=(--dev)
;;
*)
chain=(--chain "$DUNITER_CHAIN_NAME")
;;
esac
# Set main command
# Since we are inside docker, we can bind to all interfaces.
# User will bind port to host interface or set reverse proxy when needed.
set -- "$@" \
"${chain[@]}" \
-d /var/lib/duniter --unsafe-rpc-external
......
......@@ -3,7 +3,7 @@
This functional documentation presents how wallets can interact with the blockchain.
It is intended to complete the [runtime calls documentation](./runtime-calls.md) in a runtime-specific way to fit the real needs of wallet developers.
Only ĞDev is covered for now.
NOTE : a more detailed doc is available at <https://duniter.org/wiki/duniter-v2/doc/>
## Notations
......@@ -11,26 +11,27 @@ Only ĞDev is covered for now.
## Account existence
An account exists if and only if it contains at least the existential deposit (2 ĞD).
An account exists if and only if it contains at least the existential deposit (`balances.existentialDeposit` = 1 ĞD).
## Become member
Only use `identity` pallet. The `membership` calls are disabled.
Only use `identity` pallet.
1. The account that wants to gain membership needs to exists.
1. Any account that already has membership and respects the identity creation period can create an identity for another account, using `identity.createIdentity`.
1. The account has to confirm its identity with a name, using `identity.confirmIdentity`. The name must be ASCII alphanumeric, punctuation or space characters: ``/^[-!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-Z0-9 ]{3,64}$/`` (additionally, trailing spaces and double spaces are forbidden, as a phishing countermeasure). If the name is already used, the call will fail.
1. The account has to confirm its identity with a name, using `identity.confirmIdentity`. The name must be ASCII alphanumeric, punctuation or space characters: `` /^[-!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-Z0-9 ]{3,64}$/ `` (additionally, trailing spaces and double spaces are forbidden, as a phishing countermeasure). If the name is already used, the call will fail.
1. 4 different member accounts must certify the account using `cert.addCert`.
1. The distance evaluation must be requested for the pending identity using `distance.evaluateDistance`.
1. 3 sessions later, if the distance rule is respected, `identity.validateIdentity` can be called.
1. The distance evaluation must be requested for the pending identity using `distance.requestDistanceEvaluation`.
1. 3 distance sessions later, if the distance rule is respected, identity is validated automatically.
## Change key
A member can request a key change via the `identity.change_onwner_key` call. It needs the following SCALE encoded (see SCALE encoding section below) payload:
* The new owner key payload prefix (rust definition: `b"icok"`)
* the genesis block hash. (rust type `[u8; 32]` (`H256`))
* The identity index (rust type `u64`)
* The old key (rust type `u64`)
- The new owner key payload prefix (rust definition: `b"icok"`)
- the genesis block hash. (rust type `[u8; 32]` (`H256`))
- The identity index (rust type `u64`)
- The old key (rust type `u64`)
This payload must be signed with the new key.
......@@ -43,9 +44,10 @@ This feature is useful in case the user has lost their private key since the rev
### Generate the revocation payload
The revocation needs this SCALE encoded (see SCALE encoding section below) payload:
* The revocation payload prefix (rust definition: `b"revo"`)
* The identity index (rust type `u64`)
* the genesis block hash. (rust type `[u8; 32]` (`H256`))
- The revocation payload prefix (rust definition: `b"revo"`)
- The identity index (rust type `u64`)
- the genesis block hash. (rust type `[u8; 32]` (`H256`))
This payload must be signed with the corresponding revocation key.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -13,7 +13,7 @@ This walkthrough is based on the following video (french), don't hesitate to rec
If you are on a debian based system, you can install the required packages with:
```bash
sudo apt install cmake pkg-config libssl-dev git build-essential clang libclang-dev curl
sudo apt install cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler
```
Else, look at the corresponding section in the [system setup documentation](./setup.md).
......
# How to replay a block
WARN: try-runtime is not properly implemented
You can use `try-runtime` subcommand to replay a block against a real state from a live network.
1. Checkout the git tag of the runtime version at the block you want to replay
......
# Upgrade Substrate
# Polkadot Upgrade Guide
We need to keep up to date with Substrate. Here is an empirical guide.
ParityTech frequently releases upgrades of the polkadot-sdk. For each upgrade, Duniter should be upgraded following the instructions below. These instructions are based on upgrading from version 1.8.0 to 1.9.0.
Let's say for the example that we want to upgrade from `v0.9.26` to `v0.9.32`.
## 1. Upgrade the duniter-polkadot-sdk
## Upgrade Substrate fork
1. Checkout the latest Substrate Polkadot branch `polkadot-v0.9.xy` in [our Substrate](https://github.com/duniter/substrate/)
2. Create a new branch `duniter-substrate-v0.9.xy`
3. Cherry-pick `3ad5e1a1fdac5398d4911272a34e1f16c1bdd8f0`, `87ef489034ca2b15c4f30da387e06b1f6716d9a2` and `c36ab4f32454318a47777b24b6533c44121fc10b`
4. Run `cargo check` to check the cherry-picking
* Clone the repository: `git clone git@github.com:duniter/duniter-polkadot-sdk.git`
* Set the upstream repository: `git remote add upstream git@github.com:paritytech/polkadot-sdk.git`
* Fetch the latest released version: `git fetch --tag polkadot-v1.9.0`
* Create a new branch: `git checkout -b duniter-polkadot-v1.9.0`
* Rebase the branch, keeping only specific commits: "fix treasury benchmarks when no SpendOrigin", "allow manual seal to produce non-empty blocks with BABE", "add custom pallet-balance GenesisConfig", and "remove pallet-balances upgrade_account extrinsic", "remove all paritytech sdk dependencies".
* Push the new branch: `git push`
## Upgrade Subxt fork
## 2. Upgrade repository
1. Checkout the currently used branch in [our Subxt fork](https://github.com/duniter/subxt), e.g. `duniter-substrate-v0.9.26`
2. Create a new branch `duniter-substrate-v0.9.32`
3. Fetch the [upstream repository](https://github.com/paritytech/subxt)
4. Rebase on an upstream stable branch matching the wanted version
* In the `Cargo.toml` file of Duniter, change the version number from 1.8.0 to 1.9.0 for all polkadot-sdk dependencies. Also, change the version for Subxt. `find . -type f -name "Cargo.toml" -exec sed -i'' -e 's/polkadot-v1.8.0\/polkadot-v1.9.0/g' {} +`.
* Upgrade the version number of all crateio dependencies to ensure compatibility with those used in the polkadot-sdk, see the node template at: [Node Template](https://github.com/paritytech/polkadot-sdk/blob/master/templates/solochain/node/Cargo.toml) (choose the correct branch/tag).
## Upgrade Duniter
At this point, two cases may arise:
1. Replace `duniter-substrate-v0.9.26` with `duniter-substrate-v0.9.32` in `Cargo.toml`
2. Update the `rust-toolchain` file according to [Polkadot release notes](https://github.com/paritytech/polkadot/releases)
* Tip: To save storage space on your machine, do `rm target -r` after changing the rust toolchain version and before re-building the project with the new version.
3. While needed, iterate `cargo check`, `cargo update` and upgrading dependencies to match substrate's dependencies
4. Fix errors in Duniter code
* You may need to check how Polkadot is doing by searching in [their repo](https://github.com/paritytech/polkadot). Luckily, the project structure and Substrate patterns are close enough to ours.
* Some errors may happen due to two semver-incompatible versions of a same crate being used. To check this, use `cargo tree -i <crate>`. Update the dependency accordingly, then do `cargo update`.
5. As always, don't forget to `clippy` once you're done with the errors.
6. Test benchmarking:
`cargo run --features runtime-benchmarks -- benchmark overhead --chain=dev --execution=wasm --wasm-execution=interpreted-i-know-what-i-do --weight-path=. --warmup=10 --repeat=100`
\ No newline at end of file
1. If the upgrade only adds some types and minor changes, add the types in the pallet configuration, replace the offending `WeightInfo`, and delete the corresponding weights files until they can be regenerated.
2. If there are many breaking changes, it is recommended to break down the process:
* Start by correcting errors on individual pallets using `cargo check -p my_pallet` to identify and rectify any errors. Then, test using `cargo test -p my_pallet` and benchmark using `cargo test -p my_pallet --feature runtime-benchmark`.
* After correcting all pallets, fix the runtimes using the same approach: check for trait declarations added or removed in each pallet configuration, and use `cargo check -p runtime`, `cargo test -p runtime`, and `cargo test -p runtime --feature runtime-benchmark`.
* Repeat this process with the node part, the distance-oracle, all the tests, xtask, and the client.
* Conclude the process by executing all benchmarks using the command `scripts/run_all_benchmarks.sh`.
## 4. Troubleshooting
As Duniter may sometimes be the only chain implementing advanced features, such as manual sealing, not many references can be found. However, the following projects may be useful:
* Node template for general up-to-date implementation: [Node Template](https://github.com/paritytech/polkadot-sdk/tree/master/templates)
* Acala: [Acala](https://github.com/AcalaNetwork/Acala), which also uses manual sealing add a similar node implementation.
......@@ -2,14 +2,18 @@
When voting for a runtime upgrade, you should check that the proposed hash actually corresponds to the published code you reviewed. Otherwise, a malicious runtime upgrade could be advertised as a legitimate one.
```docker
```sh
mkdir runtime/gdev/target
chmod o+w runtime/gdev/target
# Workaround see !239
echo -e "[toolchain]\nchannel = \"1.74.0\"\ncomponents = [ \"rust-std\", \"rust-src\" ]" > runtime/gdev/rust-toolchain.toml
docker run \
-i \
--rm \
-e PACKAGE=gdev-runtime \
-e RUNTIME_DIR=runtime/gdev \
-v $PWD:/build \
paritytech/srtool:1.60.0 build --app --json -cM
paritytech/srtool:1.74.0-0.13.0 build --app --json -cM
```
Then, the runtime wasm bytecode is generated in this location:
......@@ -19,5 +23,6 @@ runtime/gdev/target/srtool/release/wbuild/gdev-runtime/gdev_runtime.compact.comp
```
To compare it to last official :
- download it here : https://git.duniter.org/nodes/rust/duniter-v2s/-/releases
- compare `sha256sum` of it and of the one you've built
# How to Build Duniter-V2S Debian Package
Compile packages for native integration for Debian-based systems.
## With Docker (on any system)
1. Install Docker and Docker Buildx.
2. Use the `scripts/build-deb.sh` script.
3. The `.deb` packages will be located in the `target/debian` folder.
## Without Docker (on a Debian-based system)
1. Install the necessary dependencies:
```sh
sudo apt-get install -y clang cmake protobuf-compiler libssl-dev
```
2. Compile the project:
```sh
cargo build --release
```
3. Install `cargo-deb`:
```sh
cargo install cargo-deb
```
4. Build the Duniter node `.deb` package:
```sh
cargo deb --no-build -p duniter
```
5. The `.deb` package will be located in the `target/debian` folder.
# How to Build the Duniter RPM Package
1. Install dependencies:
```sh
# Fedora
sudo dnf install clang cmake protobuf-compiler openssl-devel
```
2. Compile the project:
```sh
cargo build --release
```
3. Install `cargo-generate-rpm`:
```sh
cargo install cargo-generate-rpm
```
4. Build the package:
```sh
cargo generate-rpm -p node
```
5. The `.rpm` package will be located in the `target/generate-rpm` folder.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.