From b92947f793ecc9b2fc20bab6a560922898f93d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lo=C3=AFs?= <c@elo.tf> Date: Sat, 15 Jan 2022 01:32:49 +0100 Subject: [PATCH] chore: replace AURA by BABE --- Cargo.lock | 408 +++++++++++++++-------------- Cargo.toml | 3 +- README.md | 2 +- node/Cargo.toml | 13 +- node/src/chain_spec.rs | 8 +- node/src/chain_spec/gdev.rs | 27 +- node/src/chain_spec/gtest.rs | 245 ++++++++++------- node/src/command.rs | 3 +- node/src/service.rs | 176 ++++++++----- node/src/service/client.rs | 24 +- pallets/certification/src/lib.rs | 2 - pallets/certification/src/tests.rs | 4 - pallets/identity/src/types.rs | 38 ++- runtime/common/Cargo.toml | 16 ++ runtime/common/src/constants.rs | 12 +- runtime/common/src/entities.rs | 6 + runtime/common/src/lib.rs | 42 +++ runtime/g1/Cargo.toml | 46 +++- runtime/g1/src/lib.rs | 191 +++++++++++--- runtime/g1/src/parameters.rs | 12 +- runtime/gdev/Cargo.toml | 19 +- runtime/gdev/src/lib.rs | 54 +++- runtime/gtest/Cargo.toml | 45 +++- runtime/gtest/src/lib.rs | 192 ++++++++++++-- runtime/gtest/src/parameters.rs | 12 +- 25 files changed, 1087 insertions(+), 513 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62bfb7f2e..c5f7eb3da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,14 +855,17 @@ dependencies = [ "frame-system", "pallet-certification", "pallet-identity", + "pallet-session", "pallet-ud-accounts-storage", "parity-scale-codec", "scale-info", "serde", "smallvec", "sp-arithmetic", + "sp-consensus-babe", "sp-core", "sp-runtime", + "sp-staking", "sp-std", ] @@ -1412,8 +1415,9 @@ dependencies = [ "sc-cli", "sc-client-api", "sc-consensus", - "sc-consensus-aura", + "sc-consensus-babe", "sc-consensus-manual-seal", + "sc-consensus-uncles", "sc-executor", "sc-finality-grandpa", "sc-keystore", @@ -1425,10 +1429,11 @@ dependencies = [ "sc-transaction-pool-api", "serde_json", "sp-api", + "sp-authority-discovery", "sp-block-builder", "sp-blockchain", "sp-consensus", - "sp-consensus-aura", + "sp-consensus-babe", "sp-core", "sp-finality-grandpa", "sp-inherents", @@ -1698,7 +1703,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", ] @@ -1716,7 +1721,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -1737,7 +1742,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "Inflector", "chrono", @@ -1763,7 +1768,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -1791,7 +1796,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "bitflags", "frame-metadata", @@ -1820,7 +1825,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -1832,7 +1837,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.0", @@ -1844,7 +1849,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "proc-macro2", "quote", @@ -1854,7 +1859,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "log", @@ -1871,7 +1876,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-benchmarking", "frame-support", @@ -1886,7 +1891,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "sp-api", @@ -2083,14 +2088,18 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "hex-literal", - "pallet-aura", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", "pallet-balances", "pallet-certification", "pallet-grandpa", "pallet-identity", + "pallet-im-online", "pallet-multisig", - "pallet-randomness-collective-flip", + "pallet-offences", "pallet-scheduler", + "pallet-session", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -2104,8 +2113,9 @@ dependencies = [ "smallvec", "sp-api", "sp-arithmetic", + "sp-authority-discovery", "sp-block-builder", - "sp-consensus-aura", + "sp-consensus-babe", "sp-core", "sp-inherents", "sp-offchain", @@ -2135,13 +2145,12 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "hex-literal", - "pallet-aura", + "pallet-babe", "pallet-balances", "pallet-certification", "pallet-grandpa", "pallet-identity", "pallet-multisig", - "pallet-randomness-collective-flip", "pallet-scheduler", "pallet-sudo", "pallet-transaction-payment", @@ -2154,8 +2163,9 @@ dependencies = [ "serde", "sp-api", "sp-arithmetic", + "sp-authority-discovery", "sp-block-builder", - "sp-consensus-aura", + "sp-consensus-babe", "sp-core", "sp-inherents", "sp-offchain", @@ -2320,14 +2330,18 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "hex-literal", - "pallet-aura", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", "pallet-balances", "pallet-certification", "pallet-grandpa", "pallet-identity", + "pallet-im-online", "pallet-multisig", - "pallet-randomness-collective-flip", + "pallet-offences", "pallet-scheduler", + "pallet-session", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -2341,8 +2355,9 @@ dependencies = [ "smallvec", "sp-api", "sp-arithmetic", + "sp-authority-discovery", "sp-block-builder", - "sp-consensus-aura", + "sp-consensus-babe", "sp-core", "sp-inherents", "sp-offchain", @@ -4388,17 +4403,17 @@ dependencies = [ ] [[package]] -name = "pallet-aura" +name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", - "pallet-timestamp", + "pallet-session", "parity-scale-codec", "scale-info", "sp-application-crypto", - "sp-consensus-aura", + "sp-authority-discovery", "sp-runtime", "sp-std", ] @@ -4406,7 +4421,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -4418,10 +4433,34 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-babe" +version = "4.0.0-dev" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-babe", + "sp-consensus-vrf", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4453,7 +4492,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4489,10 +4528,29 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-im-online" +version = "4.0.0-dev" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" +dependencies = [ + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -4504,23 +4562,25 @@ dependencies = [ ] [[package]] -name = "pallet-randomness-collective-flip" +name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", + "log", + "pallet-balances", "parity-scale-codec", - "safe-mix", "scale-info", "sp-runtime", + "sp-staking", "sp-std", ] [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -4535,7 +4595,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -4556,7 +4616,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -4570,7 +4630,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4588,7 +4648,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -4605,7 +4665,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -4622,7 +4682,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -4668,7 +4728,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-support", "frame-system", @@ -5570,15 +5630,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.3.3" @@ -5671,15 +5722,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "safe-mix" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" -dependencies = [ - "rustc_version 0.2.3", -] - [[package]] name = "salsa20" version = "0.9.0" @@ -5701,7 +5743,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "log", "sp-core", @@ -5712,7 +5754,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "futures-timer 3.0.2", @@ -5735,7 +5777,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -5751,7 +5793,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -5768,7 +5810,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -5779,7 +5821,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "chrono", "fdlimit", @@ -5817,7 +5859,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "fnv", "futures 0.3.19", @@ -5845,7 +5887,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "hash-db", "kvdb", @@ -5870,7 +5912,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "futures 0.3.19", @@ -5891,39 +5933,10 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sc-consensus-aura" -version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" -dependencies = [ - "async-trait", - "derive_more", - "futures 0.3.19", - "log", - "parity-scale-codec", - "sc-block-builder", - "sc-client-api", - "sc-consensus", - "sc-consensus-slots", - "sc-telemetry", - "sp-api", - "sp-application-crypto", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", -] - [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "derive_more", @@ -5966,7 +5979,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "fork-tree", "parity-scale-codec", @@ -5979,7 +5992,7 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "assert_matches", "async-trait", @@ -6013,7 +6026,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "futures 0.3.19", @@ -6035,10 +6048,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "sc-consensus-uncles" +version = "0.10.0-dev" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" +dependencies = [ + "sc-client-api", + "sp-authorship", + "sp-runtime", + "thiserror", +] + [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "lazy_static", "libsecp256k1", @@ -6066,7 +6090,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "derive_more", "environmental", @@ -6084,7 +6108,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "log", "parity-scale-codec", @@ -6100,7 +6124,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "cfg-if 1.0.0", "libc", @@ -6118,7 +6142,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "derive_more", @@ -6155,7 +6179,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "ansi_term 0.12.1", "futures 0.3.19", @@ -6172,7 +6196,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "derive_more", @@ -6187,7 +6211,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-std", "async-trait", @@ -6238,7 +6262,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "futures-timer 3.0.2", @@ -6254,7 +6278,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "bytes 1.1.0", "fnv", @@ -6282,7 +6306,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "libp2p", @@ -6295,7 +6319,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -6304,7 +6328,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "hash-db", @@ -6335,7 +6359,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "jsonrpc-core", @@ -6360,7 +6384,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "jsonrpc-core", @@ -6377,7 +6401,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "directories", @@ -6441,7 +6465,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "log", "parity-scale-codec", @@ -6455,7 +6479,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "chrono", "futures 0.3.19", @@ -6473,7 +6497,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "ansi_term 0.12.1", "atty", @@ -6504,7 +6528,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -6515,7 +6539,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "intervalier", @@ -6542,7 +6566,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "derive_more", "futures 0.3.19", @@ -6556,7 +6580,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "futures-timer 3.0.2", @@ -6703,15 +6727,6 @@ dependencies = [ "semver-parser 0.7.0", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - [[package]] name = "semver" version = "0.11.0" @@ -6966,7 +6981,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "hash-db", "log", @@ -6983,7 +6998,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "blake2-rfc", "proc-macro-crate 1.1.0", @@ -6995,7 +7010,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "scale-info", @@ -7008,7 +7023,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "integer-sqrt", "num-traits", @@ -7020,10 +7035,23 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sp-authority-discovery" +version = "4.0.0-dev" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-runtime", + "sp-std", +] + [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "parity-scale-codec", @@ -7035,7 +7063,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "sp-api", @@ -7047,7 +7075,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "log", @@ -7065,7 +7093,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "futures 0.3.19", @@ -7081,28 +7109,10 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sp-consensus-aura" -version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" -dependencies = [ - "async-trait", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-application-crypto", - "sp-consensus", - "sp-consensus-slots", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "merlin", @@ -7125,7 +7135,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "scale-info", @@ -7137,7 +7147,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -7149,7 +7159,7 @@ dependencies = [ [[package]] name = "sp-core" version = "4.1.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "base58", "bitflags", @@ -7197,7 +7207,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "blake2-rfc", "byteorder", @@ -7210,7 +7220,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "proc-macro2", "quote", @@ -7221,7 +7231,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "kvdb", "parking_lot", @@ -7230,7 +7240,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "proc-macro2", "quote", @@ -7240,7 +7250,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.10.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "environmental", "parity-scale-codec", @@ -7251,7 +7261,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "finality-grandpa", "log", @@ -7269,7 +7279,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -7283,7 +7293,7 @@ dependencies = [ [[package]] name = "sp-io" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "futures 0.3.19", "hash-db", @@ -7307,7 +7317,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "lazy_static", "sp-core", @@ -7318,7 +7328,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.10.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "derive_more", @@ -7335,7 +7345,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "zstd", ] @@ -7343,7 +7353,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "sp-api", "sp-core", @@ -7353,7 +7363,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "backtrace", "lazy_static", @@ -7363,7 +7373,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "rustc-hash", "serde", @@ -7373,7 +7383,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "either", "hash256-std-hasher", @@ -7396,7 +7406,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "4.1.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -7413,7 +7423,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "Inflector", "proc-macro-crate 1.1.0", @@ -7425,7 +7435,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "serde", "serde_json", @@ -7434,7 +7444,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "scale-info", @@ -7448,7 +7458,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "scale-info", @@ -7459,7 +7469,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.10.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "hash-db", "log", @@ -7482,12 +7492,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" [[package]] name = "sp-storage" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -7500,7 +7510,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "log", "sp-core", @@ -7513,7 +7523,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "futures-timer 3.0.2", @@ -7529,7 +7539,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "sp-std", @@ -7541,7 +7551,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "sp-api", "sp-runtime", @@ -7550,7 +7560,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-trait", "log", @@ -7566,7 +7576,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "4.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "hash-db", "memory-db", @@ -7581,7 +7591,7 @@ dependencies = [ [[package]] name = "sp-version" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -7598,7 +7608,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -7609,7 +7619,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "4.1.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "impl-trait-for-tuples", "log", @@ -7737,7 +7747,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "platforms", ] @@ -7745,7 +7755,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.19", @@ -7767,7 +7777,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "async-std", "derive_more", @@ -7781,7 +7791,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#f8ab3365a7feb0558c86899bd1d0a1ea249587a2" +source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#104c497435848265e58eeeea7b82c63b2f7ee13c" dependencies = [ "ansi_term 0.12.1", "build-helper", diff --git a/Cargo.toml b/Cargo.toml index 9b796d044..26ec9b382 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ members = [ 'pallets/universal-dividend', 'runtime/common', 'runtime/gdev', - 'runtime/gtest' + 'runtime/gtest', + 'runtime/g1' ] # The list of dependencies below (which can be both direct and indirect dependencies) are crates diff --git a/README.md b/README.md index 01d32b7f6..0a05860e0 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ There are several files in the `node` directory - take special note of the follo 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 [Aura](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#aura) block authoring + 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. diff --git a/node/Cargo.toml b/node/Cargo.toml index 1df3d4884..878d85357 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -86,7 +86,8 @@ branch = 'duniter-monthly-2022-01' git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.sc-consensus-aura] +[dependencies.babe] +package = "sc-consensus-babe" git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -94,6 +95,10 @@ branch = 'duniter-monthly-2022-01' git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sc-consensus-uncles] +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sc-executor] features = ['wasmtime'] git = 'https://github.com/librelois/substrate.git' @@ -136,6 +141,10 @@ branch = 'duniter-monthly-2022-01' git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sp-authority-discovery] +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sp-block-builder] git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -148,7 +157,7 @@ branch = 'duniter-monthly-2022-01' git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.sp-consensus-aura] +[dependencies.sp-consensus-babe] git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index e160f97c7..243830090 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -18,8 +18,7 @@ pub mod g1; pub mod gdev; pub mod gtest; -use common_runtime::IdtyIndex; -use common_runtime::{entities::IdtyName, AccountId, Signature}; +use common_runtime::{AccountId, IdtyIndex, Signature}; use sp_core::{Pair, Public}; use sp_runtime::traits::{IdentifyAccount, Verify}; use std::collections::BTreeMap; @@ -70,8 +69,3 @@ fn clique_wot( } certs_by_issuer } - -/// Create a fake IdtyName (for dev and testnet) -fn idty_name(u8_: u8) -> IdtyName { - IdtyName(vec![u8_]) -} diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index 33f4294bd..5e458c803 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -34,12 +34,9 @@ const TOKEN_SYMBOL: &str = "ÄžD"; // The URL for the telemetry server. // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; -/// Generate an Aura authority key. -pub fn authority_keys_from_seed(s: &str) -> (sp_consensus_aura::sr25519::AuthorityId, GrandpaId) { - ( - get_from_seed::<sp_consensus_aura::sr25519::AuthorityId>(s), - get_from_seed::<GrandpaId>(s), - ) +/// Generate an authority keys. +pub fn get_authority_keys_from_seed(s: &str) -> GrandpaId { + get_from_seed::<GrandpaId>(s) } pub fn development_chain_spec() -> Result<ChainSpec, String> { @@ -54,13 +51,13 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { move || { devnet_genesis( wasm_binary, - // Initial PoA authorities - vec![authority_keys_from_seed("Alice")], + // Initial authorities + vec![get_authority_keys_from_seed("Alice")], // Inital identities btreemap![ - idty_name(1) => get_account_id_from_seed::<sr25519::Public>("Alice"), - idty_name(2) => get_account_id_from_seed::<sr25519::Public>("Bob"), - idty_name(3) => get_account_id_from_seed::<sr25519::Public>("Charlie"), + IdtyName::from("Alice") => get_account_id_from_seed::<sr25519::Public>("Alice"), + IdtyName::from("Bob") => get_account_id_from_seed::<sr25519::Public>("Bob"), + IdtyName::from("Charlie") => get_account_id_from_seed::<sr25519::Public>("Charlie"), ], // Sudo account get_account_id_from_seed::<sr25519::Public>("Alice"), @@ -90,7 +87,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { fn devnet_genesis( wasm_binary: &[u8], - initial_authorities: Vec<(sp_consensus_aura::sr25519::AuthorityId, GrandpaId)>, + initial_authorities: Vec<GrandpaId>, initial_identities: BTreeMap<IdtyName, AccountId>, root_key: AccountId, _enable_println: bool, @@ -104,10 +101,7 @@ fn devnet_genesis( balances: Default::default(), }, grandpa: GrandpaConfig { - authorities: initial_authorities - .iter() - .map(|x| (x.1.clone(), 1)) - .collect(), + authorities: initial_authorities.iter().map(|x| (x.clone(), 1)).collect(), }, sudo: SudoConfig { // Assign network admin rights. @@ -137,7 +131,6 @@ fn devnet_genesis( initial_identities.len(), gdev_runtime::parameters::ValidityPeriod::get(), ), - phantom: std::marker::PhantomData, }, ud_accounts_storage: UdAccountsStorageConfig { ud_accounts: initial_identities.values().cloned().collect(), diff --git a/node/src/chain_spec/gtest.rs b/node/src/chain_spec/gtest.rs index f509baa06..b03b4b0d4 100644 --- a/node/src/chain_spec/gtest.rs +++ b/node/src/chain_spec/gtest.rs @@ -15,19 +15,29 @@ // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. use super::*; +use common_runtime::constants::*; use common_runtime::entities::IdtyName; use gtest_runtime::{ - AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, IdentityConfig, IdtyRight, - IdtyValue, StrongCertConfig, SudoConfig, SystemConfig, UdAccountsStorageConfig, - UniversalDividendConfig, WASM_BINARY, + opaque::SessionKeys, AccountId, BabeConfig, BalancesConfig, GenesisConfig, IdentityConfig, + IdtyRight, IdtyValue, ImOnlineId, SessionConfig, StrongCertConfig, SudoConfig, SystemConfig, + UdAccountsStorageConfig, UniversalDividendConfig, WASM_BINARY, }; use maplit::btreemap; use sc_service::ChainType; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; use sp_core::sr25519; use sp_finality_grandpa::AuthorityId as GrandpaId; use std::collections::BTreeMap; +pub type AuthorityKeys = ( + AccountId, + BabeId, + GrandpaId, + ImOnlineId, + AuthorityDiscoveryId, +); + pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>; const TOKEN_DECIMALS: usize = 2; @@ -35,13 +45,93 @@ const TOKEN_SYMBOL: &str = "ÄžT"; // The URL for the telemetry server. // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; -/// Generate an Aura authority key. -pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { - (get_from_seed::<AuraId>(s), get_from_seed::<GrandpaId>(s)) +/// Generate an authority keys. +pub fn get_authority_keys_from_seed(s: &str) -> AuthorityKeys { + ( + get_account_id_from_seed::<sr25519::Public>(s), + get_from_seed::<BabeId>(s), + get_from_seed::<GrandpaId>(s), + get_from_seed::<ImOnlineId>(s), + get_from_seed::<AuthorityDiscoveryId>(s), + ) +} + +fn devnet_genesis( + wasm_binary: &[u8], + initial_authorities: Vec<AuthorityKeys>, + initial_identities: BTreeMap<IdtyName, AccountId>, + root_key: AccountId, + _enable_println: bool, +) -> GenesisConfig { + GenesisConfig { + system: SystemConfig { + // Add Wasm runtime to storage. + code: wasm_binary.to_vec(), + }, + authority_discovery: Default::default(), + balances: BalancesConfig { + // Configure endowed accounts with initial balance of INITIAL_BALANCE. + balances: Vec::with_capacity(0), + }, + babe: BabeConfig { + authorities: Vec::with_capacity(0), + epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG), + }, + grandpa: Default::default(), + im_online: Default::default(), + session: SessionConfig { + keys: initial_authorities + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys(x.1.clone(), x.2.clone(), x.3.clone(), x.4.clone()), + ) + }) + .collect::<Vec<_>>(), + }, + sudo: SudoConfig { + // Assign network admin rights. + key: Some(root_key), + }, + identity: IdentityConfig { + identities: initial_identities + .iter() + .map(|(name, account)| IdtyValue { + name: name.clone(), + expire_on: gtest_runtime::MaxInactivityPeriod::get(), + owner_key: account.clone(), + removable_on: 0, + renewable_on: gtest_runtime::StrongCertRenewablePeriod::get(), + rights: vec![ + (IdtyRight::CreateIdty, None), + (IdtyRight::StrongCert, None), + (IdtyRight::Ud, None), + ], + status: gtest_runtime::IdtyStatus::Validated, + data: Default::default(), + }) + .collect(), + }, + strong_cert: StrongCertConfig { + certs_by_issuer: clique_wot( + initial_identities.len(), + gdev_runtime::parameters::ValidityPeriod::get(), + ), + }, + ud_accounts_storage: UdAccountsStorageConfig { + ud_accounts: initial_identities.values().cloned().collect(), + }, + universal_dividend: UniversalDividendConfig { + first_ud: 1_000, + initial_monetary_mass: 0, + }, + } } pub fn development_chain_spec() -> Result<ChainSpec, String> { - let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + let wasm_binary = WASM_BINARY.ok_or_else(|| "wasm not available".to_string())?; Ok(ChainSpec::from_genesis( // Name @@ -53,12 +143,12 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { devnet_genesis( wasm_binary, // Initial PoA authorities - vec![authority_keys_from_seed("Alice")], + vec![get_authority_keys_from_seed("Alice")], // Inital identities btreemap![ - idty_name(1) => get_account_id_from_seed::<sr25519::Public>("Alice"), - idty_name(2) => get_account_id_from_seed::<sr25519::Public>("Bob"), - idty_name(3) => get_account_id_from_seed::<sr25519::Public>("Charlie"), + IdtyName::from("Alice") => get_account_id_from_seed::<sr25519::Public>("Alice"), + IdtyName::from("Bob") => get_account_id_from_seed::<sr25519::Public>("Bob"), + IdtyName::from("Charlie") => get_account_id_from_seed::<sr25519::Public>("Charlie"), ], // Sudo account get_account_id_from_seed::<sr25519::Public>("Alice"), @@ -86,8 +176,18 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { )) } -pub fn local_testnet_config() -> Result<ChainSpec, String> { - let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; +pub fn local_testnet_config(authorities_count: usize) -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "wasm not available".to_string())?; + + let mut authorities = vec![ + get_authority_keys_from_seed("Alice"), + get_authority_keys_from_seed("Bob"), + get_authority_keys_from_seed("Charlie"), + get_authority_keys_from_seed("Dave"), + get_authority_keys_from_seed("Eve"), + get_authority_keys_from_seed("Ferdie"), + ]; + authorities.truncate(authorities_count); Ok(ChainSpec::from_genesis( // Name @@ -98,19 +198,16 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> { move || { testnet_genesis( wasm_binary, - // Initial PoA authorities - vec![ - authority_keys_from_seed("Alice"), - authority_keys_from_seed("Bob"), - ], + // Initial authorities + authorities.clone(), // Initial identities btreemap![ - idty_name(1) => get_account_id_from_seed::<sr25519::Public>("Alice"), - idty_name(2) => get_account_id_from_seed::<sr25519::Public>("Bob"), - idty_name(3) => get_account_id_from_seed::<sr25519::Public>("Charlie"), - idty_name(4) => get_account_id_from_seed::<sr25519::Public>("Dave"), - idty_name(5) => get_account_id_from_seed::<sr25519::Public>("Eve"), - idty_name(6) => get_account_id_from_seed::<sr25519::Public>("Ferdie"), + IdtyName::from("Alice") => get_account_id_from_seed::<sr25519::Public>("Alice"), + IdtyName::from("Bob") => get_account_id_from_seed::<sr25519::Public>("Bob"), + IdtyName::from("Charlie") => get_account_id_from_seed::<sr25519::Public>("Charlie"), + IdtyName::from("Dave") => get_account_id_from_seed::<sr25519::Public>("Dave"), + IdtyName::from("Eve") => get_account_id_from_seed::<sr25519::Public>("Eve"), + IdtyName::from("Ferdie") => get_account_id_from_seed::<sr25519::Public>("Ferdie"), ], // Sudo account get_account_id_from_seed::<sr25519::Public>("Alice"), @@ -138,74 +235,23 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> { )) } -fn devnet_genesis( - wasm_binary: &[u8], - initial_authorities: Vec<(AuraId, GrandpaId)>, - initial_identities: BTreeMap<IdtyName, AccountId>, - root_key: AccountId, - _enable_println: bool, -) -> GenesisConfig { - GenesisConfig { - system: SystemConfig { - // Add Wasm runtime to storage. - code: wasm_binary.to_vec(), - }, - balances: BalancesConfig { - // Configure endowed accounts with initial balance of INITIAL_BALANCE. - balances: Vec::with_capacity(0), - }, - aura: AuraConfig { - authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), - }, - grandpa: GrandpaConfig { - authorities: initial_authorities - .iter() - .map(|x| (x.1.clone(), 1)) - .collect(), - }, - sudo: SudoConfig { - // Assign network admin rights. - key: Some(root_key), - }, - identity: IdentityConfig { - identities: initial_identities - .iter() - .map(|(name, account)| IdtyValue { - name: name.clone(), - expire_on: gtest_runtime::MaxInactivityPeriod::get(), - owner_key: account.clone(), - removable_on: 0, - renewable_on: gtest_runtime::StrongCertRenewablePeriod::get(), - rights: vec![ - (IdtyRight::CreateIdty, None), - (IdtyRight::StrongCert, None), - (IdtyRight::Ud, None), - ], - status: gtest_runtime::IdtyStatus::Validated, - data: Default::default(), - }) - .collect(), - }, - strong_cert: StrongCertConfig { - certs_by_issuer: clique_wot( - initial_identities.len(), - gtest_runtime::parameters::ValidityPeriod::get(), - ), - phantom: std::marker::PhantomData, - }, - ud_accounts_storage: UdAccountsStorageConfig { - ud_accounts: initial_identities.values().cloned().collect(), - }, - universal_dividend: UniversalDividendConfig { - first_ud: 1_000, - initial_monetary_mass: 0, - }, +fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + authority_discovery: AuthorityDiscoveryId, +) -> SessionKeys { + SessionKeys { + babe, + grandpa, + im_online, + authority_discovery, } } fn testnet_genesis( wasm_binary: &[u8], - initial_authorities: Vec<(AuraId, GrandpaId)>, + initial_authorities: Vec<AuthorityKeys>, initial_identities: BTreeMap<IdtyName, AccountId>, root_key: AccountId, _enable_println: bool, @@ -215,18 +261,28 @@ fn testnet_genesis( // Add Wasm runtime to storage. code: wasm_binary.to_vec(), }, + authority_discovery: Default::default(), balances: BalancesConfig { // Configure endowed accounts with initial balance of INITIAL_BALANCE. balances: Vec::with_capacity(0), }, - aura: AuraConfig { - authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), + babe: BabeConfig { + authorities: Vec::with_capacity(0), + epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG), }, - grandpa: GrandpaConfig { - authorities: initial_authorities + grandpa: Default::default(), + im_online: Default::default(), + session: SessionConfig { + keys: initial_authorities .iter() - .map(|x| (x.1.clone(), 1)) - .collect(), + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + session_keys(x.1.clone(), x.2.clone(), x.3.clone(), x.4.clone()), + ) + }) + .collect::<Vec<_>>(), }, sudo: SudoConfig { // Assign network admin rights. @@ -256,7 +312,6 @@ fn testnet_genesis( initial_identities.len(), gdev_runtime::parameters::ValidityPeriod::get(), ), - phantom: std::marker::PhantomData, }, ud_accounts_storage: UdAccountsStorageConfig { ud_accounts: initial_identities.values().cloned().collect(), diff --git a/node/src/command.rs b/node/src/command.rs index 435f883c1..afd99c53c 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -50,7 +50,8 @@ impl SubstrateCli for Cli { Ok(match id { "dev" | "gdev" => Box::new(chain_spec::gdev::development_chain_spec()?), "gtest_dev" => Box::new(chain_spec::gtest::development_chain_spec()?), - "local" | "gtest_local" => Box::new(chain_spec::gtest::local_testnet_config()?), + "local" | "gtest_local" => Box::new(chain_spec::gtest::local_testnet_config(2)?), + "local4" | "gtest_local4" => Box::new(chain_spec::gtest::local_testnet_config(4)?), // Specs provided as json specify which runtime to use in their file name. For example, // `g1-custom.json` uses the g1 runtime. // `gdev-workshop.json` uses the gdev runtime. diff --git a/node/src/service.rs b/node/src/service.rs index a95eabe90..bde26bb6b 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -23,15 +23,12 @@ use async_io::Timer; use common_runtime::Block; use futures::{Stream, StreamExt}; use sc_client_api::ExecutorProvider; -use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams}; pub use sc_executor::NativeElseWasmExecutor; use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; -use sp_consensus::SlotData; -use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_core::H256; use sp_runtime::traits::BlakeTwo256; use std::{sync::Arc, time::Duration}; @@ -182,6 +179,13 @@ pub fn new_chain_ops( } } +type FullGrandpaBlockImport<RuntimeApi, Executor> = sc_finality_grandpa::GrandpaBlockImport< + FullBackend, + Block, + FullClient<RuntimeApi, Executor>, + FullSelectChain, +>; + #[allow(clippy::type_complexity)] pub fn new_partial<RuntimeApi, Executor>( config: &Configuration, @@ -194,12 +198,15 @@ pub fn new_partial<RuntimeApi, Executor>( sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, Executor>>, sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>, ( - sc_finality_grandpa::GrandpaBlockImport< - FullBackend, - Block, - FullClient<RuntimeApi, Executor>, - FullSelectChain, - >, + Option<( + babe::BabeBlockImport< + Block, + FullClient<RuntimeApi, Executor>, + FullGrandpaBlockImport<RuntimeApi, Executor>, + >, + babe::BabeLink<Block>, + )>, + FullGrandpaBlockImport<RuntimeApi, Executor>, sc_finality_grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>, Option<Telemetry>, ), @@ -271,37 +278,47 @@ where telemetry.as_ref().map(|x| x.handle()), )?; - let import_queue = if consensus_manual { - sc_consensus_manual_seal::import_queue( - Box::new(grandpa_block_import.clone()), - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), + let justification_import = grandpa_block_import.clone(); + + let (babe_setup_opt, import_queue) = if consensus_manual { + ( + None, + sc_consensus_manual_seal::import_queue( + Box::new(grandpa_block_import.clone()), + &task_manager.spawn_essential_handle(), + config.prometheus_registry(), + ), ) } else { - let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); - sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams { - block_import: grandpa_block_import.clone(), - justification_import: Some(Box::new(grandpa_block_import.clone())), - client: client.clone(), - create_inherent_data_providers: move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + let babe_config = babe::Config::get(&*client)?; + let (babe_block_import, babe_link) = + babe::block_import(babe_config, grandpa_block_import.clone(), client.clone())?; + let slot_duration = babe_link.config().slot_duration(); + ( + Some((babe_block_import.clone(), babe_link.clone())), + babe::import_queue( + babe_link, + babe_block_import, + Some(Box::new(justification_import)), + client.clone(), + select_chain.clone(), + move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_duration( *timestamp, slot_duration, ); - Ok((timestamp, slot)) - }, - spawner: &task_manager.spawn_essential_handle(), - can_author_with: sp_consensus::CanAuthorWithNativeVersion::new( - client.executor().clone(), - ), - registry: config.prometheus_registry(), - check_for_equivocation: Default::default(), - telemetry: telemetry.as_ref().map(|x| x.handle()), - })? + Ok((timestamp, slot)) + }, + &task_manager.spawn_essential_handle(), + config.prometheus_registry(), + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + telemetry.as_ref().map(|x| x.handle()), + )?, + ) }; Ok(sc_service::PartialComponents { @@ -312,7 +329,12 @@ where keystore_container, select_chain, transaction_pool, - other: (grandpa_block_import, grandpa_link, telemetry), + other: ( + babe_setup_opt, + grandpa_block_import, + grandpa_link, + telemetry, + ), }) } @@ -345,7 +367,7 @@ where mut keystore_container, select_chain, transaction_pool, - other: (block_import, grandpa_link, mut telemetry), + other: (babe_setup_opt, block_import, grandpa_link, mut telemetry), } = new_partial::<RuntimeApi, Executor>(&config, sealing_opt.is_some())?; if let Some(url) = &config.keystore_remote { @@ -456,61 +478,81 @@ where create_inherent_data_providers: move |_, ()| async move { Ok(()) }, }), ); - } else { - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let raw_slot_duration = slot_duration.slot_duration(); + } else if let Some((babe_block_import, babe_link)) = babe_setup_opt { let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>( - StartAuraParams { - slot_duration, - client: client.clone(), - select_chain, - block_import, - proposer_factory, - create_inherent_data_providers: move |_, ()| async move { + let client_clone = client.clone(); + let slot_duration = babe_link.config().slot_duration(); + let babe_config = babe::BabeParams { + keystore: keystore_container.sync_keystore(), + client: client.clone(), + select_chain, + block_import: babe_block_import, + env: proposer_factory, + sync_oracle: network.clone(), + justification_sync_link: network.clone(), + create_inherent_data_providers: move |parent, ()| { + let client_clone = client_clone.clone(); + + async move { + let uncles = sc_consensus_uncles::create_uncles_inherent_data_provider( + &*client_clone, + parent, + )?; + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( - *timestamp, - raw_slot_duration, - ); - - Ok((timestamp, slot)) - }, - force_authoring, - backoff_authoring_blocks, - keystore: keystore_container.sync_keystore(), - can_author_with, - sync_oracle: network.clone(), - justification_sync_link: network.clone(), - block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), - max_block_proposal_slot_portion: None, - telemetry: telemetry.as_ref().map(|x| x.handle()), + sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot, uncles)) + } }, - )?; + force_authoring, + backoff_authoring_blocks, + babe_link, + can_author_with, + block_proposal_slot_portion: babe::SlotProportion::new(2f32 / 3f32), + max_block_proposal_slot_portion: None, + telemetry: telemetry.as_ref().map(|x| x.handle()), + }; + let babe = babe::start_babe(babe_config)?; - // the AURA authoring task is considered essential, i.e. if it + // the BABE authoring task is considered essential, i.e. if it // fails we take down the service with it. task_manager.spawn_essential_handle().spawn_blocking( - "aura", + "babe", Some("block-authoring"), - aura, + babe, ); + } else { + panic!("We must have babe or manual seal") } } let rpc_extensions_builder = { let client = client.clone(); + //let keystore = keystore_container.sync_keystore(); let pool = transaction_pool.clone(); + //let select_chain = select_chain.clone(); + //let chain_spec = config.chain_spec.cloned_box(); Box::new(move |deny_unsafe, _| { let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), + //select_chain: select_chain.clone(), + //chain_spec: chain_spec.cloned_box(), deny_unsafe, + /*babe: crate::rpc::BabeDeps { + babe_config: babe_config.clone(), + shared_epoch_changes: shared_epoch_changes.clone(), + keystore: keystore.clone(), + },*/ command_sink_opt: command_sink_opt.clone(), }; diff --git a/node/src/service/client.rs b/node/src/service/client.rs index dcb19336f..8015cd2f3 100644 --- a/node/src/service/client.rs +++ b/node/src/service/client.rs @@ -233,32 +233,34 @@ impl sp_blockchain::HeaderBackend<Block> for Client { /// This trait has no methods or associated type. It is a concise marker for all the trait bounds /// that it contains. pub trait RuntimeApiCollection: - sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> + pallet_grandpa::fg_primitives::GrandpaApi<Block> + + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> + sp_api::ApiExt<Block> + + sp_authority_discovery::AuthorityDiscoveryApi<Block> + sp_block_builder::BlockBuilder<Block> - + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index> - + pallet_grandpa::fg_primitives::GrandpaApi<Block> - + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> + sp_api::Metadata<Block> - + sp_consensus_aura::AuraApi<Block, sp_consensus_aura::sr25519::AuthorityId> + + sp_consensus_babe::BabeApi<Block> + sp_offchain::OffchainWorkerApi<Block> + sp_session::SessionKeys<Block> + + sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> + + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index> where <Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>, { } impl<Api> RuntimeApiCollection for Api where - Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> + Api: pallet_grandpa::fg_primitives::GrandpaApi<Block> + + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> + sp_api::ApiExt<Block> + + sp_authority_discovery::AuthorityDiscoveryApi<Block> + sp_block_builder::BlockBuilder<Block> - + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index> - + pallet_grandpa::fg_primitives::GrandpaApi<Block> - + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> + sp_api::Metadata<Block> - + sp_consensus_aura::AuraApi<Block, sp_consensus_aura::sr25519::AuthorityId> + + sp_consensus_babe::BabeApi<Block> + sp_offchain::OffchainWorkerApi<Block> - + sp_session::SessionKeys<Block>, + + sp_session::SessionKeys<Block> + + sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> + + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>, <Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>, { } diff --git a/pallets/certification/src/lib.rs b/pallets/certification/src/lib.rs index e34885898..6bdba417b 100644 --- a/pallets/certification/src/lib.rs +++ b/pallets/certification/src/lib.rs @@ -88,7 +88,6 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig<T: Config<I>, I: 'static = ()> { pub certs_by_issuer: BTreeMap<T::IdtyIndex, BTreeMap<T::IdtyIndex, T::BlockNumber>>, - pub phantom: PhantomData<I>, } #[cfg(feature = "std")] @@ -96,7 +95,6 @@ pub mod pallet { fn default() -> Self { Self { certs_by_issuer: Default::default(), - phantom: Default::default(), } } } diff --git a/pallets/certification/src/tests.rs b/pallets/certification/src/tests.rs index c04490749..7c50f5768 100644 --- a/pallets/certification/src/tests.rs +++ b/pallets/certification/src/tests.rs @@ -26,7 +26,6 @@ use sp_std::collections::btree_map::BTreeMap; fn test_must_receive_cert_before_can_issue() { new_test_ext(DefaultCertificationConfig { certs_by_issuer: BTreeMap::new(), - phantom: core::marker::PhantomData, }) .execute_with(|| { assert_eq!( @@ -53,7 +52,6 @@ fn test_genesis_build() { 1 => 3, ], ], - phantom: core::marker::PhantomData, }) .execute_with(|| { run_to_block(1); @@ -114,7 +112,6 @@ fn test_genesis_build() { fn test_cert_period() { new_test_ext(DefaultCertificationConfig { certs_by_issuer: btreemap![0 => btreemap![1 => 10]], - phantom: core::marker::PhantomData, }) .execute_with(|| { assert_eq!( @@ -137,7 +134,6 @@ fn test_cert_period() { fn test_renewable_period() { new_test_ext(DefaultCertificationConfig { certs_by_issuer: btreemap![0 => btreemap![1 => 10]], - phantom: core::marker::PhantomData, }) .execute_with(|| { run_to_block(CertPeriod::get()); diff --git a/pallets/identity/src/types.rs b/pallets/identity/src/types.rs index f1b361b36..147cbd1ab 100644 --- a/pallets/identity/src/types.rs +++ b/pallets/identity/src/types.rs @@ -23,11 +23,39 @@ use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_std::vec::Vec; -#[cfg_attr(feature = "std", derive(Deserialize, Serialize))] -#[derive( - Encode, Decode, Default, Clone, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, TypeInfo, -)] -pub struct IdtyName(pub sp_std::vec::Vec<u8>); +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug)] +pub struct IdtyName(pub Vec<u8>); + +impl scale_info::TypeInfo for IdtyName { + type Identity = str; + + fn type_info() -> scale_info::Type { + Self::Identity::type_info() + } +} + +#[cfg(feature = "std")] +impl From<&str> for IdtyName { + fn from(s: &str) -> Self { + Self(s.as_bytes().to_vec()) + } +} + +#[cfg(feature = "std")] +impl serde::Serialize for IdtyName { + fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { + std::str::from_utf8(&self.0) + .map_err(|e| serde::ser::Error::custom(format!("{:?}", e)))? + .serialize(serializer) + } +} + +#[cfg(feature = "std")] +impl<'de> serde::Deserialize<'de> for IdtyName { + fn deserialize<D: serde::Deserializer<'de>>(de: D) -> Result<Self, D::Error> { + Ok(Self(String::deserialize(de)?.as_bytes().to_vec())) + } +} #[cfg_attr(feature = "std", derive(Deserialize, Serialize))] #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 798430382..f359a7cd6 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -54,6 +54,12 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.pallet-session] +default-features = false +features = ["historical"] +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.serde] version = "1.0.101" optional = true @@ -64,6 +70,11 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sp-consensus-babe] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sp-core] default-features = false git = 'https://github.com/librelois/substrate.git' @@ -74,6 +85,11 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sp-staking] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sp-std] default-features = false git = 'https://github.com/librelois/substrate.git' diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index 94f2f7f2b..dfa64dee2 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -20,7 +20,7 @@ use sp_runtime::Perbill; /// This determines the average expected block time that we are targeting. /// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. /// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked -/// up by `pallet_aura` to implement `fn slot_duration()`. +/// up by `pallet_babe` to implement `fn slot_duration()`. /// /// Change this to adjust the block time. pub const MILLISECS_PER_BLOCK: u64 = 6000; @@ -39,3 +39,13 @@ pub const MONTHS: BlockNumber = (SECS_PER_YEAR / (12 * SECS_PER_BLOCK)) as Block pub const YEARS: BlockNumber = (SECS_PER_YEAR / SECS_PER_BLOCK) as BlockNumber; pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + +// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. +pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); + +/// The BABE epoch configuration at genesis. +pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = + sp_consensus_babe::BabeEpochConfiguration { + c: PRIMARY_PROBABILITY, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots, + }; diff --git a/runtime/common/src/entities.rs b/runtime/common/src/entities.rs index 5cd00143d..a61f16519 100644 --- a/runtime/common/src/entities.rs +++ b/runtime/common/src/entities.rs @@ -53,3 +53,9 @@ impl pallet_identity::traits::IdtyRight for IdtyRight { pub struct IdtyData { pub can_create_on: BlockNumber, } + +#[cfg_attr(feature = "std", derive(Deserialize, Serialize))] +#[derive( + Encode, Decode, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, TypeInfo, +)] +pub struct ValidatorFullIdentification; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 9b4926138..6f15bcaeb 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -67,3 +67,45 @@ impl pallet_identity::traits::IdtyNameValidator for IdtyNameValidatorImpl { idty_name.0.len() >= 3 && idty_name.0.len() <= 64 } } + +pub struct FullIdentificationOfImpl; +impl sp_runtime::traits::Convert<AccountId, Option<entities::ValidatorFullIdentification>> + for FullIdentificationOfImpl +{ + fn convert(_: AccountId) -> Option<entities::ValidatorFullIdentification> { + Some(entities::ValidatorFullIdentification) + } +} + +/// The implementation of SessionManager traits +/// For the moment, the implementation does nothing, which means that the set of authorities +/// remains eternally the same as the one defined in the chain spec. +// TODO: When we will have implemented the smith sub-wot, we will have to fill this implementation +// with a real logic based on the smith sub-wot. +pub struct SessionManagerImpl; +use crate::entities::ValidatorFullIdentification; +use sp_staking::SessionIndex; +impl pallet_session::SessionManager<AccountId> for SessionManagerImpl { + fn new_session(_new_index: SessionIndex) -> Option<sp_std::vec::Vec<AccountId>> { + None + } + fn start_session(_start_index: SessionIndex) {} + fn end_session(_end_index: SessionIndex) {} +} + +impl pallet_session::historical::SessionManager<AccountId, ValidatorFullIdentification> + for SessionManagerImpl +{ + fn new_session( + _new_index: SessionIndex, + ) -> Option<sp_std::vec::Vec<(AccountId, ValidatorFullIdentification)>> { + None + } + fn new_session_genesis( + new_index: SessionIndex, + ) -> Option<sp_std::vec::Vec<(AccountId, ValidatorFullIdentification)>> { + <Self as pallet_session::historical::SessionManager<_, _>>::new_session(new_index) + } + fn start_session(_start_index: SessionIndex) {} + fn end_session(_end_index: SessionIndex) {} +} diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml index 9cfd06582..bd7f9bcaa 100644 --- a/runtime/g1/Cargo.toml +++ b/runtime/g1/Cargo.toml @@ -32,12 +32,15 @@ std = [ 'frame-support/std', 'frame-system-rpc-runtime-api/std', 'frame-system/std', - 'pallet-aura/std', + 'pallet-authority-discovery/std', + 'pallet-babe/std', 'pallet-balances/std', 'pallet-certification/std', - 'pallet-identity/std', 'pallet-grandpa/std', - 'pallet-randomness-collective-flip/std', + 'pallet-identity/std', + 'pallet-im-online/std', + 'pallet-multisig/std', + 'pallet-session/std', 'pallet-sudo/std', 'pallet-universal-dividend/std', 'pallet-timestamp/std', @@ -48,7 +51,7 @@ std = [ 'sp-api/std', 'sp-arithmetic/std', 'sp-block-builder/std', - 'sp-consensus-aura/std', + 'sp-consensus-babe/std', 'sp-core/std', 'sp-inherents/std', 'sp-offchain/std', @@ -111,7 +114,17 @@ branch = 'duniter-monthly-2022-01' optional = true version = '0.3.1' -[dependencies.pallet-aura] +[dependencies.pallet-authority-discovery] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + +[dependencies.pallet-authorship] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + +[dependencies.pallet-babe] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -126,12 +139,17 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.pallet-multisig] +[dependencies.pallet-im-online] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.pallet-randomness-collective-flip] +[dependencies.pallet-offences] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + +[dependencies.pallet-multisig] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -141,6 +159,12 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.pallet-session] +default-features = false +features = ["historical"] +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.pallet-sudo] default-features = false git = 'https://github.com/librelois/substrate.git' @@ -166,6 +190,7 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' + [dependencies.serde] version = "1.0.101" optional = true @@ -184,12 +209,17 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sp-authority-discovery] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sp-block-builder] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.sp-consensus-aura] +[dependencies.sp-consensus-babe] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 822b91855..87ade7be1 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -27,18 +27,20 @@ pub mod parameters; pub use self::parameters::*; pub use common_runtime::{ constants::*, - entities::{IdtyData, IdtyRight}, - AccountId, Address, Balance, BlockNumber, Hash, Header, IdtyIndex, IdtyNameValidatorImpl, - Index, Signature, + entities::{IdtyData, IdtyRight, ValidatorFullIdentification}, + AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, Hash, Header, IdtyIndex, + IdtyNameValidatorImpl, Index, Signature, }; pub use pallet_balances::Call as BalancesCall; pub use pallet_identity::{IdtyStatus, IdtyValue}; +pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use pallet_session::historical as session_historical; pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::CurrencyAdapter; pub use pallet_universal_dividend; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -pub use sp_runtime::{Perbill, Permill}; +pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::{ authorizations::{AddStrongCertOrigin, DelStrongCertOrigin, EnsureIdtyCallAllowedImpl}, @@ -47,16 +49,17 @@ use common_runtime::{ OnRightKeyChangeHandler, }, providers::IdtyDataProvider, + SessionManagerImpl, }; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor}; +use sp_core::OpaqueMetadata; +use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - transaction_validity::{TransactionSource, TransactionValidity}, + transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; use sp_std::prelude::*; @@ -75,17 +78,14 @@ pub use frame_support::{ StorageValue, }; -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. pub mod opaque { use super::*; - impl_opaque_keys! { pub struct SessionKeys { - pub aura: Aura, pub grandpa: Grandpa, + pub babe: Babe, + pub im_online: ImOnline, + pub authority_discovery: AuthorityDiscovery, } } } @@ -127,20 +127,89 @@ parameter_types! { pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u16 = 42; + pub const UncleGenerations: u32 = 0; } // Configure FRAME pallets to include in runtime. common_runtime::pallets_config! { - impl pallet_randomness_collective_flip::Config for Runtime {} - impl pallet_aura::Config for Runtime { - type AuthorityId = sp_consensus_aura::sr25519::AuthorityId; - type DisabledValidators = (); - type MaxAuthorities = frame_support::pallet_prelude::ConstU32<32>; + impl pallet_authority_discovery::Config for Runtime { + type MaxAuthorities = MaxAuthorities; + } + impl pallet_authorship::Config for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>; + type UncleGenerations = UncleGenerations; + type FilterUncle = (); + type EventHandler = ImOnline; + } + impl pallet_babe::Config for Runtime { + type EpochDuration = EpochDuration; + type ExpectedBlockTime = ExpectedBlockTime; + + // session module is the trigger + type EpochChangeTrigger = pallet_babe::ExternalTrigger; + + type DisabledValidators = Session; + + type KeyOwnerProofSystem = Historical; + + type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<( + KeyTypeId, + pallet_babe::AuthorityId, + )>>::Proof; + + type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<( + KeyTypeId, + pallet_babe::AuthorityId, + )>>::IdentificationTuple; + + type HandleEquivocation = + pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>; + + type WeightInfo = (); + + type MaxAuthorities = MaxAuthorities; + } + parameter_types! { + pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); + pub const MaxKeys: u32 = 10_000; + pub const MaxPeerInHeartbeats: u32 = 10_000; + pub const MaxPeerDataEncodingSize: u32 = 1_000; + } + impl pallet_im_online::Config for Runtime { + type AuthorityId = ImOnlineId; + type Event = Event; + type ValidatorSet = Historical; + type NextSessionRotation = Babe; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; + type WeightInfo = (); + type MaxKeys = MaxKeys; + type MaxPeerInHeartbeats = MaxPeerInHeartbeats; + type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; + } + impl pallet_offences::Config for Runtime { + type Event = Event; + type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>; + type OnOffenceHandler = (); + } + impl pallet_session::Config for Runtime { + type Event = Event; + type ValidatorId = AccountId; + type ValidatorIdOf = sp_runtime::traits::ConvertInto; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, SessionManagerImpl>; + type SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders; + type Keys = opaque::SessionKeys; + type WeightInfo = (); + } + impl pallet_session::historical::Config for Runtime { + type FullIdentification = ValidatorFullIdentification; + type FullIdentificationOf = FullIdentificationOfImpl; } impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type OnTimestampSet = Aura; + type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; type WeightInfo = (); } @@ -161,8 +230,8 @@ construct_runtime!( System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1, - // Must be before session. - Aura: pallet_aura::{Pallet, Config<T>} = 2, + // Babe must be before session. + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 2, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, @@ -171,8 +240,13 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32, // Consensus support. - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event} = 10, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 11, + Authorship: pallet_authorship::{Pallet, Call, Storage} = 10, + Offences: pallet_offences::{Pallet, Storage, Event} = 11, + Historical: session_historical::{Pallet} = 12, + Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 13, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event} = 14, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 15, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 16, // Governance stuff. Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, @@ -180,7 +254,7 @@ construct_runtime!( // Cunning utilities. Utility: pallet_utility::{Pallet, Call, Event} = 30, - // Money creation + // Universal dividend. UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40, UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 41, @@ -216,6 +290,14 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime +where + Call: From<C>, +{ + type Extrinsic = UncheckedExtrinsic; + type OverarchingCall = Call; +} + // All of our runtimes share most of their Runtime API implementations. // We use a macro to implement this common part and add runtime-specific additional implementations. // This macro expands to : @@ -227,13 +309,62 @@ pub type Executive = frame_executive::Executive< // } // ``` common_runtime::runtime_apis! { - impl sp_consensus_aura::AuraApi<Block, sp_consensus_aura::sr25519::AuthorityId> for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime { + fn authorities() -> Vec<sp_authority_discovery::AuthorityId> { + AuthorityDiscovery::authorities() + } + } + + impl sp_consensus_babe::BabeApi<Block> for Runtime { + fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration { + // The choice of `c` parameter (where `1 - c` represents the + // probability of a slot being empty), is done in accordance to the + // slot duration and expected target block time, for safely + // resisting network delays of maximum two seconds. + // <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results> + sp_consensus_babe::BabeGenesisConfiguration { + slot_duration: Babe::slot_duration(), + epoch_length: EpochDuration::get(), + c: BABE_GENESIS_EPOCH_CONFIG.c, + genesis_authorities: Babe::authorities().to_vec(), + randomness: Babe::randomness(), + allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + } + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + Babe::current_epoch_start() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + Babe::current_epoch() + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + Babe::next_epoch() } - fn authorities() -> Vec<sp_consensus_aura::sr25519::AuthorityId> { - Aura::authorities().into_inner() + fn generate_key_ownership_proof( + _slot: sp_consensus_babe::Slot, + authority_id: sp_consensus_babe::AuthorityId, + ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> { + use codec::Encode; + + Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) + } + + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>, + key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + let key_owner_proof = key_owner_proof.decode()?; + + Babe::submit_unsigned_equivocation_report( + equivocation_proof, + key_owner_proof, + ) } } } diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs index 6cdd3c1c3..6da85f34d 100644 --- a/runtime/g1/src/parameters.rs +++ b/runtime/g1/src/parameters.rs @@ -19,14 +19,22 @@ use common_runtime::{Balance, BlockNumber}; use frame_support::parameter_types; use sp_arithmetic::Permill; +// Authority discovery +parameter_types! { + pub const MaxAuthorities: u32 = 100; +} + // Timestamp parameter_types! { pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } -// Consensus +// Babe +pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = 4 * HOURS; parameter_types! { - pub const MaxAuthorities: u32 = 100; + pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64; + pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; + pub const ReportLongevity: u64 = 168 * EpochDuration::get(); } // Balances diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index ac7ad5828..b2976ee1e 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -33,13 +33,12 @@ std = [ 'frame-support/std', 'frame-system-rpc-runtime-api/std', 'frame-system/std', - 'pallet-aura/std', + 'pallet-babe/std', 'pallet-balances/std', 'pallet-certification/std', 'pallet-identity/std', 'pallet-grandpa/std', 'pallet-multisig/std', - 'pallet-randomness-collective-flip/std', 'pallet-sudo/std', 'pallet-universal-dividend/std', 'pallet-transaction-payment-rpc-runtime-api/std', @@ -49,7 +48,7 @@ std = [ 'sp-api/std', 'sp-arithmetic/std', 'sp-block-builder/std', - 'sp-consensus-aura/std', + 'sp-consensus-babe/std', 'sp-core/std', 'sp-inherents/std', 'sp-offchain/std', @@ -112,7 +111,7 @@ branch = 'duniter-monthly-2022-01' optional = true version = '0.3.1' -[dependencies.pallet-aura] +[dependencies.pallet-babe] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -132,11 +131,6 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.pallet-randomness-collective-flip] -default-features = false -git = 'https://github.com/librelois/substrate.git' -branch = 'duniter-monthly-2022-01' - [dependencies.pallet-scheduler] default-features = false git = 'https://github.com/librelois/substrate.git' @@ -177,12 +171,17 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sp-authority-discovery] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sp-block-builder] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.sp-consensus-aura] +[dependencies.sp-consensus-babe] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index badbc7991..0ad45d4aa 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -74,10 +74,6 @@ pub use frame_support::{ StorageValue, }; -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. pub mod opaque { use super::*; @@ -129,8 +125,6 @@ parameter_types! { // Configure FRAME pallets to include in runtime. common_runtime::pallets_config! { - impl pallet_randomness_collective_flip::Config for Runtime {} - impl pallet_sudo::Config for Runtime { type Event = Event; type Call = Call; @@ -153,7 +147,6 @@ construct_runtime!( // Consensus support. Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event} = 10, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 11, // Governance stuff. Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, @@ -208,13 +201,50 @@ pub type Executive = frame_executive::Executive< // } // ``` common_runtime::runtime_apis! { - impl sp_consensus_aura::AuraApi<Block, sp_consensus_aura::sr25519::AuthorityId> for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(0) + impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime { + fn authorities() -> Vec<sp_authority_discovery::AuthorityId> { + unimplemented!() + } + } + + impl sp_consensus_babe::BabeApi<Block> for Runtime { + fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration { + unimplemented!() + // TODO: we should return a value or see how can force the client to not call this API + /*sp_consensus_babe::BabeGenesisConfiguration { + slot_duration: 0, + epoch_length: 0, + c: BABE_GENESIS_EPOCH_CONFIG.c, + genesis_authorities: vec![], + randomness: Babe::randomness(), + allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + }*/ + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + unimplemented!() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + unimplemented!() + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + unimplemented!() + } + + fn generate_key_ownership_proof( + _slot: sp_consensus_babe::Slot, + _authority_id: sp_consensus_babe::AuthorityId, + ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> { + unimplemented!() } - fn authorities() -> Vec<sp_consensus_aura::sr25519::AuthorityId> { - vec![] + fn submit_report_equivocation_unsigned_extrinsic( + _equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>, + _key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + unimplemented!() } } } diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml index 53cf56620..a45efe501 100644 --- a/runtime/gtest/Cargo.toml +++ b/runtime/gtest/Cargo.toml @@ -32,12 +32,15 @@ std = [ 'frame-support/std', 'frame-system-rpc-runtime-api/std', 'frame-system/std', - 'pallet-aura/std', + 'pallet-authority-discovery/std', + 'pallet-babe/std', 'pallet-balances/std', 'pallet-certification/std', - 'pallet-identity/std', 'pallet-grandpa/std', - 'pallet-randomness-collective-flip/std', + 'pallet-identity/std', + 'pallet-im-online/std', + 'pallet-multisig/std', + 'pallet-session/std', 'pallet-sudo/std', 'pallet-universal-dividend/std', 'pallet-timestamp/std', @@ -48,7 +51,7 @@ std = [ 'sp-api/std', 'sp-arithmetic/std', 'sp-block-builder/std', - 'sp-consensus-aura/std', + 'sp-consensus-babe/std', 'sp-core/std', 'sp-inherents/std', 'sp-offchain/std', @@ -111,7 +114,17 @@ branch = 'duniter-monthly-2022-01' optional = true version = '0.3.1' -[dependencies.pallet-aura] +[dependencies.pallet-authority-discovery] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + +[dependencies.pallet-authorship] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + +[dependencies.pallet-babe] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -126,12 +139,17 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.pallet-multisig] +[dependencies.pallet-im-online] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + +[dependencies.pallet-offences] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.pallet-randomness-collective-flip] +[dependencies.pallet-multisig] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' @@ -141,6 +159,12 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.pallet-session] +default-features = false +features = ["historical"] +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.pallet-sudo] default-features = false git = 'https://github.com/librelois/substrate.git' @@ -185,12 +209,17 @@ default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' +[dependencies.sp-authority-discovery] +default-features = false +git = 'https://github.com/librelois/substrate.git' +branch = 'duniter-monthly-2022-01' + [dependencies.sp-block-builder] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' -[dependencies.sp-consensus-aura] +[dependencies.sp-consensus-babe] default-features = false git = 'https://github.com/librelois/substrate.git' branch = 'duniter-monthly-2022-01' diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index d1d02aa77..87a0429f6 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -27,18 +27,20 @@ pub mod parameters; pub use self::parameters::*; pub use common_runtime::{ constants::*, - entities::{IdtyData, IdtyRight}, - AccountId, Address, Balance, BlockNumber, Hash, Header, IdtyIndex, IdtyNameValidatorImpl, - Index, Signature, + entities::{IdtyData, IdtyRight, ValidatorFullIdentification}, + AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, Hash, Header, IdtyIndex, + IdtyNameValidatorImpl, Index, Signature, }; pub use pallet_balances::Call as BalancesCall; pub use pallet_identity::{IdtyStatus, IdtyValue}; +pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use pallet_session::historical as session_historical; pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::CurrencyAdapter; pub use pallet_universal_dividend; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -pub use sp_runtime::{Perbill, Permill}; +pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::{ authorizations::{AddStrongCertOrigin, DelStrongCertOrigin, EnsureIdtyCallAllowedImpl}, @@ -47,13 +49,17 @@ use common_runtime::{ OnRightKeyChangeHandler, }, providers::IdtyDataProvider, + SessionManagerImpl, }; use frame_system::EnsureRoot; use pallet_grandpa::fg_primitives; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor}; +use sp_core::OpaqueMetadata; +use sp_runtime::traits::{ + AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys, +}; +use sp_runtime::transaction_validity::TransactionPriority; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, transaction_validity::{TransactionSource, TransactionValidity}, @@ -75,17 +81,14 @@ pub use frame_support::{ StorageValue, }; -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. pub mod opaque { use super::*; - impl_opaque_keys! { pub struct SessionKeys { - pub aura: Aura, pub grandpa: Grandpa, + pub babe: Babe, + pub im_online: ImOnline, + pub authority_discovery: AuthorityDiscovery, } } } @@ -127,20 +130,89 @@ parameter_types! { pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u16 = 42; + pub const UncleGenerations: u32 = 0; } // Configure FRAME pallets to include in runtime. common_runtime::pallets_config! { - impl pallet_randomness_collective_flip::Config for Runtime {} - impl pallet_aura::Config for Runtime { - type AuthorityId = sp_consensus_aura::sr25519::AuthorityId; - type DisabledValidators = (); - type MaxAuthorities = frame_support::pallet_prelude::ConstU32<32>; + impl pallet_authority_discovery::Config for Runtime { + type MaxAuthorities = MaxAuthorities; + } + impl pallet_authorship::Config for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>; + type UncleGenerations = UncleGenerations; + type FilterUncle = (); + type EventHandler = ImOnline; + } + impl pallet_babe::Config for Runtime { + type EpochDuration = EpochDuration; + type ExpectedBlockTime = ExpectedBlockTime; + + // session module is the trigger + type EpochChangeTrigger = pallet_babe::ExternalTrigger; + + type DisabledValidators = Session; + + type KeyOwnerProofSystem = Historical; + + type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<( + KeyTypeId, + pallet_babe::AuthorityId, + )>>::Proof; + + type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<( + KeyTypeId, + pallet_babe::AuthorityId, + )>>::IdentificationTuple; + + type HandleEquivocation = + pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>; + + type WeightInfo = (); + + type MaxAuthorities = MaxAuthorities; + } + parameter_types! { + pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); + pub const MaxKeys: u32 = 10_000; + pub const MaxPeerInHeartbeats: u32 = 10_000; + pub const MaxPeerDataEncodingSize: u32 = 1_000; + } + impl pallet_im_online::Config for Runtime { + type AuthorityId = ImOnlineId; + type Event = Event; + type ValidatorSet = Historical; + type NextSessionRotation = Babe; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; + type WeightInfo = (); + type MaxKeys = MaxKeys; + type MaxPeerInHeartbeats = MaxPeerInHeartbeats; + type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; + } + impl pallet_offences::Config for Runtime { + type Event = Event; + type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>; + type OnOffenceHandler = (); + } + impl pallet_session::Config for Runtime { + type Event = Event; + type ValidatorId = AccountId; + type ValidatorIdOf = ConvertInto; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, SessionManagerImpl>; + type SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders; + type Keys = opaque::SessionKeys; + type WeightInfo = (); + } + impl pallet_session::historical::Config for Runtime { + type FullIdentification = ValidatorFullIdentification; + type FullIdentificationOf = FullIdentificationOfImpl; } impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type OnTimestampSet = Aura; + type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; type WeightInfo = (); } @@ -161,16 +233,23 @@ construct_runtime!( System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1, - // Must be before session. - Aura: pallet_aura::{Pallet, Config<T>} = 2, + // Babe must be before session. + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 2, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, + + // Money management Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 5, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32, // Consensus support. - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event} = 10, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 11, + Authorship: pallet_authorship::{Pallet, Call, Storage} = 10, + Offences: pallet_offences::{Pallet, Storage, Event} = 11, + Historical: session_historical::{Pallet} = 12, + Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 13, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event} = 14, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 15, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 16, // Governance stuff. Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, @@ -214,6 +293,14 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime +where + Call: From<C>, +{ + type Extrinsic = UncheckedExtrinsic; + type OverarchingCall = Call; +} + // All of our runtimes share most of their Runtime API implementations. // We use a macro to implement this common part and add runtime-specific additional implementations. // This macro expands to : @@ -225,13 +312,62 @@ pub type Executive = frame_executive::Executive< // } // ``` common_runtime::runtime_apis! { - impl sp_consensus_aura::AuraApi<Block, sp_consensus_aura::sr25519::AuthorityId> for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime { + fn authorities() -> Vec<sp_authority_discovery::AuthorityId> { + AuthorityDiscovery::authorities() } + } + + impl sp_consensus_babe::BabeApi<Block> for Runtime { + fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration { + // The choice of `c` parameter (where `1 - c` represents the + // probability of a slot being empty), is done in accordance to the + // slot duration and expected target block time, for safely + // resisting network delays of maximum two seconds. + // <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results> + sp_consensus_babe::BabeGenesisConfiguration { + slot_duration: Babe::slot_duration(), + epoch_length: EpochDuration::get(), + c: BABE_GENESIS_EPOCH_CONFIG.c, + genesis_authorities: Babe::authorities().to_vec(), + randomness: Babe::randomness(), + allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + } + } + + fn current_epoch_start() -> sp_consensus_babe::Slot { + Babe::current_epoch_start() + } + + fn current_epoch() -> sp_consensus_babe::Epoch { + Babe::current_epoch() + } + + fn next_epoch() -> sp_consensus_babe::Epoch { + Babe::next_epoch() + } + + fn generate_key_ownership_proof( + _slot: sp_consensus_babe::Slot, + authority_id: sp_consensus_babe::AuthorityId, + ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> { + use codec::Encode; + + Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) + .map(|p| p.encode()) + .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) + } + + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>, + key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, + ) -> Option<()> { + let key_owner_proof = key_owner_proof.decode()?; - fn authorities() -> Vec<sp_consensus_aura::sr25519::AuthorityId> { - Aura::authorities().into_inner() + Babe::submit_unsigned_equivocation_report( + equivocation_proof, + key_owner_proof, + ) } } } diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs index 8c3f78b74..b10456344 100644 --- a/runtime/gtest/src/parameters.rs +++ b/runtime/gtest/src/parameters.rs @@ -19,14 +19,22 @@ use common_runtime::{Balance, BlockNumber}; use frame_support::parameter_types; use sp_arithmetic::Permill; +// Authority discovery +parameter_types! { + pub const MaxAuthorities: u32 = 32; +} + // Timestamp parameter_types! { pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } -// Consensus +// Babe +pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = HOURS; parameter_types! { - pub const MaxAuthorities: u32 = 32; + pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64; + pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; + pub const ReportLongevity: u64 = 168 * EpochDuration::get(); } // Balances -- GitLab