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
Commits on Source (32)
Showing
with 2356 additions and 1771 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"
tu = "test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests"
tb = "test --features runtime-benchmarks -p"
xtask = "run --package xtask --"
......@@ -158,7 +158,7 @@ tests_debug:
DUNITER_BINARY_PATH: "../build/duniter"
DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT: "20"
script:
- cargo test --workspace --exclude duniter-end2end-tests
- cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests
- cargo cucumber -i balance*
- cargo cucumber -i monetary*
- cargo cucumber -i transfer*
......@@ -182,7 +182,7 @@ tests_release:
DUNITER_BINARY_PATH: "../build/duniter"
DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT: "20"
script:
- cargo test --workspace --exclude duniter-end2end-tests
- cargo test --workspace --exclude duniter-end2end-tests --exclude duniter-live-tests
- cargo cucumber -i balance*
- cargo cucumber -i monetary*
- cargo cucumber -i transfer*
......
......@@ -88,25 +88,6 @@
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'pallet-ud-accounts-storage'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=pallet-ud-accounts-storage"
],
"filter": {
"name": "pallet-ud-accounts-storage",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
......
This diff is collapsed.
......@@ -2,12 +2,12 @@
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 = '2018'
edition = "2021"
homepage = 'https://substrate.dev'
license = 'AGPL-3.0'
name = 'duniter'
repository = 'https://git.duniter.org/nodes/rust/duniter-v2s'
version = '0.1.0'
version = '0.3.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
......@@ -23,12 +23,12 @@ g1 = ["g1-runtime"]
gdev = ["gdev-runtime"]
gtest = ["gtest-runtime"]
runtime-benchmarks = [
'g1-runtime',
'g1-runtime/runtime-benchmarks',
#'g1-runtime',
#'g1-runtime/runtime-benchmarks',
'gdev-runtime',
'gdev-runtime/runtime-benchmarks',
'gtest-runtime',
'gtest-runtime/runtime-benchmarks',
#'gtest-runtime',
#'gtest-runtime/runtime-benchmarks',
]
try-runtime = [
"g1-runtime/try-runtime",
......@@ -40,16 +40,16 @@ try-runtime = [
[build-dependencies]
clap = { version = "3.0" }
#clap_complete = { version = "3.0" }
substrate-build-script-utils = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02' }
substrate-build-script-utils = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.26' }
[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/librelois/substrate.git", branch = "duniter-monthly-2022-02", features = ["wasmtime"] }
sc-service = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02", features = ["wasmtime"] }
sp-trie = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02", features = ["memory-tracker"] }
sc-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26", default-features = false, features = ["wasmtime"] }
sc-service = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26", default-features = false, features = ["wasmtime"] }
sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26", features = ["memory-tracker"] }
[dependencies]
......@@ -67,56 +67,59 @@ clap = { version = "3.0", features = ["derive"] }
clap_complete = { version = "3" }
futures = { version = "0.3.1", features = ["compat"] }
hex = "0.4.3"
jsonrpc-core = '18.0.0'
jsonrpsee = { version = "0.14.0", 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.26"
# substrate dependencies
frame-benchmarking = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
frame-benchmarking-cli = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
pallet-grandpa = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
pallet-transaction-payment-rpc = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-basic-authorship = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-chain-spec = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-cli = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-client-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-consensus = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
babe = { package = "sc-consensus-babe", git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
manual-seal = { package = "sc-consensus-manual-seal", git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-consensus-uncles = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-executor = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-finality-grandpa = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-keystore = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-network = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-rpc-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-service = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-telemetry = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-transaction-pool = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sc-transaction-pool-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-api = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-authority-discovery = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-block-builder = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-blockchain = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-consensus = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-consensus-babe = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-core = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-finality-grandpa = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-io = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-offchain = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-keystore = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-runtime = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-session = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-storage = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-timestamp = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-transaction-pool = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
sp-trie = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
substrate-frame-rpc-system = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
try-runtime-cli = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02", optional = true }
frame-benchmarking = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
frame-benchmarking-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
pallet-grandpa = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
pallet-transaction-payment-rpc = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-basic-authorship = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-chain-spec = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26", default-features = false }
sc-client-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-consensus = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
babe = { package = "sc-consensus-babe", git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
manual-seal = { package = "sc-consensus-manual-seal", git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-consensus-uncles = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-executor = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-finality-grandpa = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-keystore = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-network = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-rpc-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-service = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26", default-features = false }
sc-telemetry = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-transaction-pool = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sc-transaction-pool-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-api = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-authority-discovery = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-block-builder = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-blockchain = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-consensus = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-consensus-babe = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-core = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-finality-grandpa = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-inherents = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-io = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-offchain = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-keyring = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-keystore = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-runtime = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-session = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-storage = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-timestamp = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-transaction-pool = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
substrate-frame-rpc-system = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
try-runtime-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26", optional = true }
[workspace]
resolver = "2"
......@@ -130,8 +133,8 @@ members = [
'pallets/duniter-wot',
'pallets/identity',
'pallets/membership',
'pallets/oneshot-account',
'pallets/authority-members',
'pallets/ud-accounts-storage',
'pallets/universal-dividend',
'pallets/upgrade-origin',
'primitives/membership',
......@@ -204,4 +207,4 @@ panic = "unwind"
[patch.crates-io]
# rw-stream-sink has not been updated for 2 years and uses a too old version of pin-project (v0.4.28)
# For the project to compile, we have to patch this dependency to force the use of pin-project v1.x
rw-stream-sink = { git = "https://github.com/librelois/rw-stream-sink", branch = "master" }
#rw-stream-sink = { git = "https://github.com/librelois/rw-stream-sink", branch = "master" }
......@@ -2,7 +2,7 @@ version: "3.4"
services:
duniter-rpc:
image: duniter/duniter-v2s:v0.1.0
image: duniter/duniter-v2s:v0.2.0
restart: unless-stopped
ports:
# telemetry
......@@ -19,8 +19,6 @@ services:
environment:
- DUNITER_CHAIN_NAME=gdev
command:
- "--execution"
- "Wasm"
- "--node-key-file"
- "/var/lib/duniter/node.key"
- "--public-addr"
......
......@@ -2,7 +2,7 @@ version: "3.4"
services:
duniter-rpc:
image: duniter/duniter-v2s:v0.1.0
image: duniter/duniter-v2s:v0.2.0
restart: unless-stopped
ports:
# telemetry
......@@ -19,18 +19,17 @@ services:
environment:
- DUNITER_CHAIN_NAME=gdev
command:
- "--execution=Wasm"
- "--node-key-file=/var/lib/duniter/node.key"
- "--public-addr"
# SERVER_DOMAIN should be replaced by a domain name that point on your server
#
# The PEER_ID should be replaced by the output of this command:
# docker run --rm -it --entrypoint -v $PWD/duniter-rpc/:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.1.0 key generate-node-key --file /var/lib/duniter/node-key.txt
# docker run --rm -it --entrypoint -v $PWD/duniter-rpc/:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.2.0 key generate-node-key --file /var/lib/duniter/node.key
- "/dns/${SERVER_DOMAIN?SERVER_DOMAIN should be set}/tcp/30333/p2p/${PEER_ID?PEER_ID should be set}"
- "--rpc-cors=all"
duniter-validator:
image: duniter/duniter-v2s:v0.1.0
image: duniter/duniter-v2s:v0.2.0
restart: unless-stopped
ports:
# telemetry
......@@ -47,13 +46,13 @@ services:
environment:
- DUNITER_CHAIN_NAME=gdev
command:
- "--execution=Wasm"
- "--node-key-file=/var/lib/duniter/node.key"
- "--public-addr"
- "--pruning=14400"
# SERVER_DOMAIN should be replaced by a domain name that point on your server
#
# The PEER_ID should be replaced by the output of this command:
# docker run --rm -it --entrypoint -v $PWD/duniter-rpc/:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.1.0 key generate-node-key --file /var/lib/duniter/node-key.txt
# The VALIDATOR_PEER_ID should be replaced by the output of this command:
# docker run --rm -it --entrypoint -v $PWD/duniter-rpc/:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.2.0 key generate-node-key --file /var/lib/duniter/node.key
- "/dns/${SERVER_DOMAIN?SERVER_DOMAIN should be set}/tcp/30333/p2p/${VALIDATOR_PEER_ID?VALIDATOR_PEER_ID should be set}"
- "--rpc-cors=all"
- "--rpc-methods=Unsafe"
......
......@@ -15,12 +15,12 @@ RUN dpkg --add-architecture armhf && \
libssl-dev:armhf
# Install nightly with armv7 and w32-u-u
RUN rustup install nightly-2021-11-12-x86_64-unknown-linux-gnu && \
RUN rustup install nightly-2022-04-20-x86_64-unknown-linux-gnu && \
rustup target add armv7-unknown-linux-gnueabihf --toolchain \
nightly-2021-11-12-x86_64-unknown-linux-gnu && \
nightly-2022-04-20-x86_64-unknown-linux-gnu && \
rustup target add wasm32-unknown-unknown --toolchain \
nightly-2021-11-12-x86_64-unknown-linux-gnu && \
cargo +nightly-2021-11-12-x86_64-unknown-linux-gnu install --git \
nightly-2022-04-20-x86_64-unknown-linux-gnu && \
cargo +nightly-2022-04-20-x86_64-unknown-linux-gnu install --git \
https://github.com/alexcrichton/wasm-gc --force
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER arm-linux-gnueabihf-gcc
......
# How to benchmarks weights of a Call/Hook/Pallet
1. Create the benchmarking tests, see commit 31057e37be471e3f27d18c63818d57cc907b4b4f for a
complete real example.
2. Run the benchmark test on your local machine:
`cargo test -p <pallet> --features runtime-benchmarks`
3. If the benchmark tests compiles and pass, compile the binary with benchmarks on your local
machine: `cargo build --release --features runtime-benchmarks`
4. Run the benchmarks on your local machine (to test if it work mith a real runtime). The command
is: `duniter benchmark pallet --chain=CURRENCY-dev --steps=50 --repeat=20 --pallet=pallet_universal_dividend --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=.`
5. If it work, use the generated file content to create or update the `WeightInfo` trait and the `()` dummy implementation. Then use the `WeightInfo` tarit in the real code of the pallet. See 79e0fd4bf3b0579279fc957da5e2fdfc6d8a17fa for a
complete real example.
6. Redo steps `3.` and `4.` on the reference machine.
7. Put the generated file on `runtime/common/src/weights` and use it in the runtimes configuration.
See cee7c3b2763ba402e807f126534d9cd39a8bd025 for a complete real example.
Note 1: You Must replace `CURRENCY` by the currency type, or for ĞDev use directly `--chain=dev`.
Note2. If the reference machine not support wasmtime, you should replace `--wasm-execution=compiled`
by `--wasm-execution=interpreted-i-know-what-i-do`.
## What the reference machine is?
For now (06/2022), it's a `Raspberry Pi 4 Model B - 4GB` with an SSD connected via USB3.
To cross-compile the benchmarks binary for armv7:
```
./scripts/cross-build-arm.sh --features runtime-benchmarks
```
The cross compiled binary is generated here: `target/armv7-unknown-linux-gnueabihf/release/duniter`
......@@ -5,7 +5,7 @@
### Duniter part
- Add this docker-compose on your server :
[docker/compose/gdev-rpc.docker-compose.yml](https://git.duniter.org/nodes/rust/duniter-v2s/-/blob/master/docker/compose/gdev-rpc.docker-compose.yml)
[docker/compose/gdev-rpc.docker-compose.yml](https://git.duniter.org/nodes/rust/duniter-v2s/-/blob/master/docker/compose/gdev-mirror.docker-compose.yml)
- Rename the file : `mv gdev-mirror.docker-compose.yml docker-compose.yml`
- In the same folder, create a `.env` file that defime environment variables `SERVER_DOMAIN` and `PEER_ID`:
```
......@@ -13,7 +13,7 @@ SERVER_DOMAIN=YOUR_DOMAIN
PEER_ID=YOUR_PEER_ID
```
Your `PEER_ID` shoud be generated with this command: `docker run --rm -it --entrypoint duniter -v $PWD:/var/lib/duniter/ duniter/duniter-v2s:v0.1.0 key generate-node-key --file /var/lib/duniter/node.key`
Your `PEER_ID` shoud be generated with this command: `docker run --rm -it --entrypoint duniter -v $PWD:/var/lib/duniter/ duniter/duniter-v2s:v0.2.0 key generate-node-key --file /var/lib/duniter/node.key`
- If you have write access errors run in docker-compose.yml folder : `chmod o+rwX -R .`
- `docker-compose up -d` to start your node
......
......@@ -8,8 +8,8 @@
[docker/compose/gdev-validator.docker-compose.yml](https://git.duniter.org/nodes/rust/duniter-v2s/-/blob/master/docker/compose/gdev-validator.docker-compose.yml)
- Create a `.env` file that define environment variables `SERVER_DOMAIN`, `PEER_ID` and `VALIDATOR_PEER_ID`:
- `SERVER_DOMAIN`: a domain name that point on your server
- `PEER_ID`: Your rpc node peer id, shoud be generated with this command: `docker run --rm -it --entrypoint -v $PWD:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.1.0 key generate-node-key --file /var/lib/duniter/rpc-node.key`
- `VALIDATOR_PEER_ID`: Your validator node peer id, shoud be generated with this command: `docker run --rm -it --entrypoint -v $PWD:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.1.0 key generate-node-key --file /var/lib/duniter/validator-node.key`
- `PEER_ID`: Your rpc node peer id, shoud be generated with this command: `docker run --rm -it --entrypoint -v $PWD:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.2.0 key generate-node-key --file /var/lib/duniter/rpc-node.key`
- `VALIDATOR_PEER_ID`: Your validator node peer id, shoud be generated with this command: `docker run --rm -it --entrypoint -v $PWD:/var/lib/duniter/ duniter duniter/duniter-v2s:v0.2.0 key generate-node-key --file /var/lib/duniter/validator-node.key`
Note: duniter-rpc PEER_ID and duniter-validator PEER_ID isn't the same.
- If you have write access errors run in docker-compose.yml folder : `chmod o+rwX -R .`
- `docker-compose up -d` to start your node
......
[package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>']
description = 'duniter end2end tests.'
edition = '2018'
edition = "2021"
homepage = 'https://substrate.dev'
license = 'AGPL-3.0'
name = 'duniter-end2end-tests'
......@@ -15,12 +15,13 @@ clap = { version = "3.0", features = ["derive"] }
ctrlc = "3.2.2"
cucumber = "0.11"
env_logger = "0.9.0"
hex = "0.4"
notify = "4.0"
parity-scale-codec = "2.3.1"
parity-scale-codec = "3.1.5"
portpicker = "0.1.1"
serde_json = "1.0.64"
sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-02" }
subxt = { git = 'https://github.com/librelois/subxt.git', branch = 'duniter-monthly-2022-02' }
sp-keyring = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.26" }
subxt = { git = 'https://github.com/duniter/subxt.git', branch = 'duniter-substrate-v0.9.26' }
tokio = { version = "1.15.0", features = ["macros"] }
[[test]]
......
......@@ -3,5 +3,6 @@
Feature: Certification
Scenario: Dave certifies Alice
When 2 blocks later
When dave certifies alice
Then alice should be certified by dave
Feature: Oneshot account
Scenario: Simple oneshot consumption
When alice sends 7 ĞD to oneshot dave
Then alice should have 3 ĞD
Then dave should have oneshot 7 ĞD
When oneshot dave consumes into account bob
Then dave should have oneshot 0 ĞD
Then bob should have 1699 cĞD
Then bob should have oneshot 0 ĞD
Scenario: Double oneshot consumption
When alice sends 7 ĞD to oneshot dave
Then alice should have 3 ĞD
Then dave should have oneshot 7 ĞD
When oneshot dave consumes 4 ĞD into account bob and the rest into oneshot charlie
Then dave should have oneshot 0 ĞD
Then bob should have 14 ĞD
Then bob should have oneshot 0 ĞD
Then charlie should have 10 ĞD
Then charlie should have oneshot 299 cĞD
{
"first_ud": 1000,
"first_ud_reeval": 100,
"genesis_parameters": {
"genesis_certs_expire_on": 100000,
"genesis_certs_min_received": 2,
"genesis_memberships_expire_on": 100000,
"genesis_smith_certs_expire_on": 100000,
"genesis_smith_certs_min_received": 2,
"genesis_smith_memberships_expire_on": 100000
},
"identities": {
"Alice": {
"balance": 1000,
......@@ -23,22 +31,18 @@
"cert_period": 15,
"cert_max_by_issuer": 10,
"cert_min_received_cert_to_issue_cert": 2,
"cert_renewable_period": 50,
"cert_validity_period": 1000,
"idty_confirm_period": 40,
"idty_creation_period": 50,
"membership_period": 1000,
"membership_renewable_period": 50,
"pending_membership_period": 500,
"ud_creation_period": 10,
"ud_reeval_period": 100,
"smith_cert_period": 15,
"smith_cert_max_by_issuer": 8,
"smith_cert_min_received_cert_to_issue_cert": 2,
"smith_cert_renewable_period": 50,
"smith_cert_validity_period": 1000,
"smith_membership_period": 1000,
"smith_membership_renewable_period": 20,
"smith_pending_membership_period": 500,
"smiths_wot_first_cert_issuable_on": 20,
"smiths_wot_min_cert_for_membership": 2,
......@@ -57,5 +61,6 @@
"certs": ["Alice", "Bob"]
}
},
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"technical_committee": ["Alice", "Bob", "Charlie"]
}
{
"first_ud": 1000,
"first_ud_reeval": 100,
"genesis_parameters": {
"genesis_certs_expire_on": 100000,
"genesis_certs_min_received": 2,
"genesis_memberships_expire_on": 100000,
"genesis_smith_certs_expire_on": 100000,
"genesis_smith_certs_min_received": 2,
"genesis_smith_memberships_expire_on": 100000
},
"identities": {
"Alice": {
"balance": 1000,
"certs": ["Bob", "Charlie", "Dave"],
"certs": ["Bob", "Charlie"],
"pubkey": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
},
"Bob": {
"balance": 1000,
"certs": ["Alice", "Charlie", "Dave"],
"certs": ["Alice", "Charlie"],
"pubkey": "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
},
"Charlie": {
......@@ -19,31 +27,27 @@
},
"Dave": {
"balance": 1000,
"certs": [],
"certs": ["Alice", "Bob"],
"pubkey": "5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy"
}
},
"parameters": {
"babe_epoch_duration": 30,
"cert_period": 15,
"cert_period": 2,
"cert_max_by_issuer": 10,
"cert_min_received_cert_to_issue_cert": 2,
"cert_renewable_period": 50,
"cert_validity_period": 1000,
"idty_confirm_period": 40,
"idty_creation_period": 50,
"membership_period": 1000,
"membership_renewable_period": 50,
"pending_membership_period": 500,
"ud_creation_period": 10,
"ud_reeval_period": 100,
"smith_cert_period": 15,
"smith_cert_max_by_issuer": 8,
"smith_cert_min_received_cert_to_issue_cert": 2,
"smith_cert_renewable_period": 50,
"smith_cert_validity_period": 1000,
"smith_membership_period": 1000,
"smith_membership_renewable_period": 20,
"smith_pending_membership_period": 500,
"smiths_wot_first_cert_issuable_on": 20,
"smiths_wot_min_cert_for_membership": 2,
......@@ -62,5 +66,6 @@
"certs": ["Alice", "Bob"]
}
},
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"technical_committee": ["Alice", "Bob", "Charlie"]
}
......@@ -14,30 +14,30 @@
// 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/>.
use super::node_runtime::runtime_types::gdev_runtime;
use super::node_runtime::runtime_types::pallet_balances;
use super::gdev;
use super::gdev::runtime_types::pallet_balances;
use super::*;
use sp_keyring::AccountKeyring;
use subxt::{sp_runtime::MultiAddress, PairSigner};
use subxt::{ext::sp_runtime::MultiAddress, tx::PairSigner};
pub async fn set_balance(
api: &Api,
client: &Client,
who: AccountKeyring,
amount: u64,
) -> Result<()> {
pub async fn set_balance(client: &Client, who: AccountKeyring, amount: u64) -> Result<()> {
let _events = create_block_with_extrinsic(
client,
api.tx()
.sudo()
.sudo(gdev_runtime::Call::Balances(
pallet_balances::pallet::Call::set_balance {
who: MultiAddress::Id(who.to_account_id()),
new_free: amount,
new_reserved: 0,
},
))
.create_signed(&PairSigner::new(SUDO_ACCOUNT.pair()), ())
client
.tx()
.create_signed(
&gdev::tx()
.sudo()
.sudo(gdev::runtime_types::gdev_runtime::Call::Balances(
pallet_balances::pallet::Call::set_balance {
who: MultiAddress::Id(who.to_account_id()),
new_free: amount,
new_reserved: 0,
},
)),
&PairSigner::new(SUDO_ACCOUNT.pair()),
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
......@@ -46,7 +46,6 @@ pub async fn set_balance(
}
pub async fn transfer(
api: &Api,
client: &Client,
from: AccountKeyring,
amount: u64,
......@@ -57,10 +56,15 @@ pub async fn transfer(
let _events = create_block_with_extrinsic(
client,
api.tx()
.balances()
.transfer(to.clone().into(), amount)
.create_signed(&from, ())
client
.tx()
.create_signed(
&gdev::tx()
.universal_dividend()
.transfer_ud(to.clone().into(), amount),
&from,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
......@@ -68,21 +72,19 @@ pub async fn transfer(
Ok(())
}
pub async fn transfer_all(
api: &Api,
client: &Client,
from: AccountKeyring,
to: AccountKeyring,
) -> Result<()> {
pub async fn transfer_all(client: &Client, from: AccountKeyring, to: AccountKeyring) -> Result<()> {
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
client,
api.tx()
.balances()
.transfer_all(to.clone().into(), false)
.create_signed(&from, ())
client
.tx()
.create_signed(
&gdev::tx().balances().transfer_all(to.clone().into(), false),
&from,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
......@@ -91,7 +93,6 @@ pub async fn transfer_all(
}
pub async fn transfer_ud(
api: &Api,
client: &Client,
from: AccountKeyring,
amount: u64,
......@@ -102,10 +103,15 @@ pub async fn transfer_ud(
let _events = create_block_with_extrinsic(
client,
api.tx()
.universal_dividend()
.transfer_ud(to.clone().into(), amount)
.create_signed(&from, ())
client
.tx()
.create_signed(
&gdev::tx()
.universal_dividend()
.transfer_ud(to.clone().into(), amount),
&from,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
......
......@@ -14,27 +14,37 @@
// 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/>.
use super::node_runtime::runtime_types::gdev_runtime;
use super::node_runtime::runtime_types::pallet_certification;
use super::gdev;
use super::gdev::runtime_types::pallet_certification;
use super::*;
use sp_keyring::AccountKeyring;
use subxt::{sp_runtime::MultiAddress, PairSigner};
use subxt::{ext::sp_runtime::MultiAddress, tx::PairSigner};
pub async fn certify(
api: &Api,
client: &Client,
from: AccountKeyring,
to: AccountKeyring,
) -> Result<()> {
let from = PairSigner::new(from.pair());
pub async fn certify(client: &Client, from: AccountKeyring, to: AccountKeyring) -> Result<()> {
let signer = PairSigner::new(from.pair());
let from = from.to_account_id();
let to = to.to_account_id();
let issuer_index = client
.storage()
.fetch(&gdev::storage().identity().identity_index_of(&from), None)
.await?
.unwrap();
let receiver_index = client
.storage()
.fetch(&gdev::storage().identity().identity_index_of(&to), None)
.await?
.unwrap();
let _events = create_block_with_extrinsic(
client,
api.tx()
.cert()
.add_cert(to)
.create_signed(&from, ())
client
.tx()
.create_signed(
&gdev::tx().cert().add_cert(issuer_index, receiver_index),
&signer,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
......
......@@ -18,25 +18,60 @@
pub mod balances;
pub mod cert;
pub mod oneshot;
#[subxt::subxt(runtime_metadata_path = "../resources/metadata.scale")]
pub mod node_runtime {}
pub mod gdev {}
use anyhow::anyhow;
use parity_scale_codec::Encode;
use serde_json::Value;
use sp_keyring::AccountKeyring;
use std::io::prelude::*;
use std::path::PathBuf;
use std::process::Command;
use std::str::FromStr;
use subxt::ext::{sp_core, sp_runtime};
use subxt::rpc::{rpc_params, ClientT, SubscriptionClientT};
use subxt::{ClientBuilder, DefaultConfig, DefaultExtra};
use subxt::tx::BaseExtrinsicParamsBuilder;
pub type Api = node_runtime::RuntimeApi<DefaultConfig, DefaultExtra<DefaultConfig>>;
pub type Client = subxt::Client<DefaultConfig>;
pub type Client = subxt::OnlineClient<GdevConfig>;
pub type Event = gdev::Event;
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
pub type TransactionProgress<'client> =
subxt::TransactionProgress<'client, DefaultConfig, node_runtime::DispatchError>;
pub type SignedSubmittableExtrinsic = subxt::tx::SignedSubmittableExtrinsic<GdevConfig, Client>;
pub type TxProgress = subxt::tx::TxProgress<GdevConfig, Client>;
pub enum GdevConfig {}
impl subxt::config::Config for GdevConfig {
type Index = u32;
type BlockNumber = u32;
type Hash = sp_core::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = sp_runtime::AccountId32;
type Address = sp_runtime::MultiAddress<Self::AccountId, u32>;
type Header = sp_runtime::generic::Header<Self::BlockNumber, sp_runtime::traits::BlakeTwo256>;
type Signature = sp_runtime::MultiSignature;
type Extrinsic = sp_runtime::OpaqueExtrinsic;
type ExtrinsicParams = subxt::tx::BaseExtrinsicParams<Self, Tip>;
}
#[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)
}
}
pub const SUDO_ACCOUNT: AccountKeyring = AccountKeyring::Alice;
......@@ -56,7 +91,7 @@ struct FullNode {
ws_port: u16,
}
pub async fn spawn_node(maybe_genesis_conf_file: Option<PathBuf>) -> (Api, Client, Process) {
pub async fn spawn_node(maybe_genesis_conf_file: Option<PathBuf>) -> (Client, Process) {
println!("maybe_genesis_conf_file={:?}", maybe_genesis_conf_file);
let duniter_binary_path = std::env::var("DUNITER_BINARY_PATH").unwrap_or_else(|_| {
if std::path::Path::new(DUNITER_DOCKER_PATH).exists() {
......@@ -75,14 +110,11 @@ pub async fn spawn_node(maybe_genesis_conf_file: Option<PathBuf>) -> (Api, Clien
&duniter_binary_path,
maybe_genesis_conf_file,
);
let client = ClientBuilder::new()
.set_url(format!("ws://127.0.0.1:{}", ws_port))
.build()
let client = Client::from_url(format!("ws://127.0.0.1:{}", ws_port))
.await
.expect("fail to connect to node");
let api = client.clone().to_runtime_api::<Api>();
(api, client, process)
(client, process)
}
pub async fn create_empty_block(client: &Client) -> Result<()> {
......@@ -98,14 +130,18 @@ pub async fn create_empty_block(client: &Client) -> Result<()> {
pub async fn create_block_with_extrinsic(
client: &Client,
extrinsic: subxt::UncheckedExtrinsic<DefaultConfig, DefaultExtra<DefaultConfig>>,
) -> Result<subxt::TransactionEvents<DefaultConfig>> {
// Get a hash of the extrinsic (we'll need this later).
extrinsic: SignedSubmittableExtrinsic,
) -> Result<subxt::tx::TxEvents<GdevConfig>> {
/*// Get a hash of the extrinsic (we'll need this later).
use subxt::sp_runtime::traits::Hash as _;
let ext_hash = <DefaultConfig as subxt::Config>::Hashing::hash_of(&extrinsic);
let ext_hash = <GdevConfig as subxt::Config>::Hashing::hash_of(&encoded_extrinsic);
// Submit and watch for transaction progress.
let sub = client.rpc().watch_extrinsic(extrinsic).await?;
let watcher = TransactionProgress::new(sub, client, ext_hash);
let sub = client.rpc().submit_extrinsic(encoded_extrinsic).await?;
let watcher = TxProgress::new(sub, client, ext_hash);*/
println!("extrinsic encoded: {}", hex::encode(extrinsic.encoded()));
let watcher = extrinsic.submit_and_watch().await?;
// Create a non-empty block
let _: Value = client
......
// Copyright 2021 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/>.
use super::gdev;
use super::gdev::runtime_types::pallet_balances;
use super::gdev::runtime_types::pallet_oneshot_account;
use super::*;
use sp_keyring::AccountKeyring;
use subxt::{
ext::sp_runtime::{AccountId32, MultiAddress},
tx::PairSigner,
};
pub enum Account {
Normal(AccountKeyring),
Oneshot(AccountKeyring),
}
impl Account {
fn to_account_id(
&self,
) -> pallet_oneshot_account::types::Account<MultiAddress<AccountId32, ()>> {
match self {
Account::Normal(account) => {
pallet_oneshot_account::types::Account::Normal(account.to_account_id().into())
}
Account::Oneshot(account) => {
pallet_oneshot_account::types::Account::Oneshot(account.to_account_id().into())
}
}
}
}
pub async fn create_oneshot_account(
client: &Client,
from: AccountKeyring,
amount: u64,
to: AccountKeyring,
) -> Result<()> {
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
client,
client
.tx()
.create_signed(
&gdev::tx()
.oneshot_account()
.create_oneshot_account(to.into(), amount),
&from,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
Ok(())
}
pub async fn consume_oneshot_account(
client: &Client,
from: AccountKeyring,
to: Account,
) -> Result<()> {
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
client,
client
.tx()
.create_signed(
&gdev::tx().oneshot_account().consume_oneshot_account(0, to),
&from,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
Ok(())
}
#[allow(clippy::too_many_arguments)]
pub async fn consume_oneshot_account_with_remaining(
client: &Client,
from: AccountKeyring,
amount: u64,
to: Account,
remaining_to: Account,
) -> Result<()> {
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let remaining_to = remaining_to.to_account_id();
let _events = create_block_with_extrinsic(
client,
client
.tx()
.create_signed(
&gdev::tx()
.oneshot_account()
.consume_oneshot_account_with_remaining(0, to, remaining_to, amount),
&from,
BaseExtrinsicParamsBuilder::new(),
)
.await?,
)
.await?;
Ok(())
}