From a6469127675076a9bdf144c85ada1d35f5048390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Eng=C3=A9libert?= <tuxmain@zettascript.org> Date: Tue, 6 Jun 2023 18:35:54 +0200 Subject: [PATCH] wip --- Cargo.lock | 799 ++++++++++-------- Cargo.toml | 27 +- client/distance/Cargo.toml | 51 ++ client/distance/src/lib.rs | 146 ++++ distance-oracle/Cargo.toml | 31 + distance-oracle/src/lib.rs | 267 ++++++ distance-oracle/src/main.rs | 23 + docs/api/manual.md | 3 + .../cucumber-features/distance.feature | 24 + end2end-tests/tests/common/distance.rs | 41 + end2end-tests/tests/common/mod.rs | 31 +- end2end-tests/tests/cucumber_tests.rs | 91 +- node/src/service.rs | 63 +- pallets/authority-members/src/lib.rs | 7 +- pallets/distance/Cargo.toml | 85 ++ pallets/distance/src/lib.rs | 441 ++++++++++ pallets/distance/src/median.rs | 143 ++++ pallets/distance/src/types.rs | 63 ++ pallets/duniter-wot/Cargo.toml | 6 +- pallets/duniter-wot/src/lib.rs | 12 +- pallets/duniter-wot/src/traits.rs | 27 + primitives/distance/Cargo.toml | 67 ++ primitives/distance/src/lib.rs | 110 +++ resources/metadata.scale | Bin 131109 -> 132872 bytes runtime/common/Cargo.toml | 30 +- runtime/common/src/handlers.rs | 6 +- runtime/common/src/pallets_config.rs | 15 + runtime/common/src/providers.rs | 14 + runtime/gdev/Cargo.toml | 24 +- runtime/gdev/src/lib.rs | 1 + 30 files changed, 2244 insertions(+), 404 deletions(-) create mode 100644 client/distance/Cargo.toml create mode 100644 client/distance/src/lib.rs create mode 100644 distance-oracle/Cargo.toml create mode 100644 distance-oracle/src/lib.rs create mode 100644 distance-oracle/src/main.rs create mode 100644 end2end-tests/cucumber-features/distance.feature create mode 100644 end2end-tests/tests/common/distance.rs create mode 100644 pallets/distance/Cargo.toml create mode 100644 pallets/distance/src/lib.rs create mode 100644 pallets/distance/src/median.rs create mode 100644 pallets/distance/src/types.rs create mode 100644 pallets/duniter-wot/src/traits.rs create mode 100644 primitives/distance/Cargo.toml create mode 100644 primitives/distance/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d00e4ff66..45bd3257e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.27.0", + "gimli 0.27.1", ] [[package]] @@ -313,9 +313,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.60" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3" +checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" dependencies = [ "proc-macro2", "quote", @@ -337,9 +337,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" [[package]] name = "atty" @@ -369,7 +369,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.30.0", + "object 0.30.3", "rustc-demangle", ] @@ -397,6 +397,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + [[package]] name = "base64ct" version = "1.5.3" @@ -554,11 +560,12 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.17" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +checksum = "b7f0778972c64420fdedc63f09919c8a88bda7b25135357fd25a5d9f3257e832" dependencies = [ "memchr", + "serde", ] [[package]] @@ -572,9 +579,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-slice-cast" @@ -602,15 +609,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "camino" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" dependencies = [ "serde", ] @@ -639,9 +646,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -763,13 +770,13 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.30" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656ad1e55e23d287773f7d8192c300dc715c3eeded93b3da651d11c42cfd74d2" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ "bitflags", - "clap_derive 4.0.21", - "clap_lex 0.3.0", + "clap_derive 4.1.0", + "clap_lex 0.3.1", "is-terminal", "once_cell", "strsim", @@ -778,11 +785,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.0.6" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3c9eae0de7bf8e3f904a5e40612b21fb2e2e566456d177809a48b892d24da" +checksum = "3d6540eedc41f8a5a76cf3d8d458057dcdf817be4158a55b5f861f7a5483de75" dependencies = [ - "clap 4.0.30", + "clap 4.1.4", ] [[package]] @@ -791,7 +798,7 @@ version = "3.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" dependencies = [ - "heck 0.4.0", + "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", @@ -800,11 +807,11 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.0.21" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" dependencies = [ - "heck 0.4.0", + "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", @@ -822,9 +829,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" dependencies = [ "os_str_bytes", ] @@ -854,9 +861,9 @@ dependencies = [ [[package]] name = "comfy-table" -version = "6.1.3" +version = "6.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e621e7e86c46fd8a14c32c6ae3cb95656621b4743a27d0cffedb831d46e7ad21" +checksum = "6e7b787b0dc42e8111badfdbe4c3059158ccb2db8780352fa1b01e8ccf45cc4d" dependencies = [ "strum", "strum_macros", @@ -878,6 +885,7 @@ dependencies = [ "pallet-balances", "pallet-certification", "pallet-collective", + "pallet-distance", "pallet-duniter-account", "pallet-duniter-wot", "pallet-grandpa", @@ -905,6 +913,7 @@ dependencies = [ "sp-arithmetic", "sp-consensus-babe", "sp-core", + "sp-distance", "sp-membership", "sp-runtime", "sp-staking", @@ -914,25 +923,24 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" dependencies = [ "crossbeam-utils", ] [[package]] name = "console" -version = "0.15.2" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" dependencies = [ "encode_unicode", "lazy_static", "libc", - "terminal_size", "unicode-width", - "winapi 0.3.9", + "windows-sys 0.42.0", ] [[package]] @@ -1219,7 +1227,7 @@ version = "3.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1631ca6e3c59112501a9d87fd86f21591ff77acd31331e8a73f8d80a65bbdd71" dependencies = [ - "nix 0.26.1", + "nix 0.26.2", "windows-sys 0.42.0", ] @@ -1237,7 +1245,7 @@ dependencies = [ "cucumber-expressions", "derive_more", "either", - "futures 0.3.25", + "futures 0.3.26", "gherkin", "globwalk", "inventory", @@ -1305,9 +1313,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-pre.5" +version = "4.0.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67bc65846be335cb20f4e52d49a437b773a2c1fdb42b19fc84e79e6f6771536f" +checksum = "8da00a7a9a4eb92a0a0f8e75660926d48f0d0f3c537e455c457bcdaa1e16b1ac" dependencies = [ "cfg-if 1.0.0", "fiat-crypto", @@ -1319,9 +1327,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.85" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" +checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" dependencies = [ "cc", "cxxbridge-flags", @@ -1331,9 +1339,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.85" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" +checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" dependencies = [ "cc", "codespan-reporting", @@ -1346,15 +1354,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.85" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" +checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" [[package]] name = "cxxbridge-macro" -version = "1.0.85" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" +checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" dependencies = [ "proc-macro2", "quote", @@ -1422,6 +1430,23 @@ dependencies = [ "syn", ] +[[package]] +name = "dc-distance" +version = "1.0.0" +dependencies = [ + "frame-support", + "log", + "pallet-distance", + "parity-scale-codec", + "sc-client-api", + "scale-info", + "sp-core", + "sp-distance", + "sp-keystore", + "sp-runtime", + "thiserror", +] + [[package]] name = "der" version = "0.5.1" @@ -1529,6 +1554,20 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "distance-oracle" +version = "0.1.0" +dependencies = [ + "clap 4.1.4", + "parity-scale-codec", + "rayon", + "sp-core", + "sp-distance", + "sp-runtime", + "subxt", + "tokio", +] + [[package]] name = "dns-parser" version = "0.8.0" @@ -1562,13 +1601,15 @@ name = "duniter" version = "0.3.0" dependencies = [ "async-io", - "clap 4.0.30", + "clap 4.1.4", "clap_complete", "common-runtime", + "dc-distance", + "distance-oracle", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", - "futures 0.3.25", + "futures 0.3.26", "g1-runtime", "gdev-runtime", "gtest-runtime", @@ -1613,6 +1654,7 @@ dependencies = [ "sp-consensus", "sp-consensus-babe", "sp-core", + "sp-distance", "sp-finality-grandpa", "sp-inherents", "sp-io", @@ -1641,7 +1683,7 @@ dependencies = [ "clap 3.2.23", "ctrlc", "cucumber", - "env_logger", + "env_logger 0.9.3", "hex", "notify", "parity-scale-codec", @@ -1716,9 +1758,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ "signature", ] @@ -1753,9 +1795,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -1783,9 +1825,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ "cfg-if 1.0.0", ] @@ -1796,7 +1838,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ - "heck 0.4.0", + "heck 0.4.1", "proc-macro2", "quote", "syn", @@ -1815,6 +1857,19 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "environmental" version = "1.1.4" @@ -1864,7 +1919,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", ] [[package]] @@ -1937,11 +1992,11 @@ checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" [[package]] name = "file-per-thread-logger" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e16290574b39ee41c71aeb90ae960c504ebaf1e2a1c87bd52aa56ed6e1a02f" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger", + "env_logger 0.10.0", "log", ] @@ -1959,12 +2014,12 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22349c6a11563a202d95772a68e0fcf56119e74ea8a2a19cf2301460fcd0df5" +checksum = "e24e6c429951433ccb7c87fd528c60084834dcd14763182c1f83291bcde24c34" dependencies = [ "either", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "log", "num-traits", @@ -2086,7 +2141,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.0.30", + "clap 4.1.4", "comfy-table", "frame-benchmarking", "frame-support", @@ -2349,9 +2404,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" dependencies = [ "futures-channel", "futures-core", @@ -2364,9 +2419,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" dependencies = [ "futures-core", "futures-sink", @@ -2374,15 +2429,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" dependencies = [ "futures-core", "futures-task", @@ -2392,9 +2447,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" [[package]] name = "futures-lite" @@ -2413,9 +2468,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -2435,15 +2490,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-timer" @@ -2453,9 +2508,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures 0.1.31", "futures-channel", @@ -2570,6 +2625,7 @@ dependencies = [ "pallet-balances", "pallet-certification", "pallet-collective", + "pallet-distance", "pallet-duniter-account", "pallet-duniter-test-parameters", "pallet-duniter-wot", @@ -2605,6 +2661,7 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-vrf", "sp-core", + "sp-distance", "sp-finality-grandpa", "sp-inherents", "sp-io", @@ -2734,15 +2791,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" +checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" [[package]] name = "globset" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ "aho-corasick", "bstr", @@ -2764,9 +2821,9 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" dependencies = [ "futures-channel", "futures-core", @@ -2981,9 +3038,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -3099,9 +3156,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" dependencies = [ "bytes", "futures-channel", @@ -3220,7 +3277,7 @@ dependencies = [ "async-io", "core-foundation", "fnv", - "futures 0.3.25", + "futures 0.3.26", "if-addrs", "ipnet", "log", @@ -3231,11 +3288,10 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.18" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" +checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" dependencies = [ - "crossbeam-utils", "globset", "lazy_static", "log", @@ -3349,12 +3405,12 @@ checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" [[package]] name = "io-lifetimes" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" dependencies = [ "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -3386,9 +3442,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" [[package]] name = "is-terminal" @@ -3397,8 +3453,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" dependencies = [ "hermit-abi 0.2.6", - "io-lifetimes 1.0.3", - "rustix 0.36.5", + "io-lifetimes 1.0.5", + "rustix 0.36.7", "windows-sys 0.42.0", ] @@ -3428,9 +3484,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -3743,9 +3799,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.138" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libm" @@ -3766,7 +3822,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec878fda12ebec479186b3914ebc48ff180fa4c51847e11a1a68bf65249e02c1" dependencies = [ "bytes", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "getrandom 0.2.8", "instant", @@ -3804,7 +3860,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "instant", "lazy_static", @@ -3833,7 +3889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2322c9fb40d99101def6a01612ee30500c89abbbecb6297b3cd252903a4c1720" dependencies = [ "async-std-resolver", - "futures 0.3.25", + "futures 0.3.26", "libp2p-core", "log", "parking_lot 0.12.1", @@ -3848,7 +3904,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf9a121f699e8719bda2e6e9e9b6ddafc6cff4602471d6481c1067930ccb29b" dependencies = [ "asynchronous-codec", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "libp2p-core", "libp2p-swarm", @@ -3873,7 +3929,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "instant", "libp2p-core", @@ -3899,7 +3955,7 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures 0.3.25", + "futures 0.3.26", "if-watch", "libp2p-core", "libp2p-swarm", @@ -3932,7 +3988,7 @@ checksum = "692664acfd98652de739a8acbb0a0d670f1d67190a49be6b4395e22c37337d89" dependencies = [ "asynchronous-codec", "bytes", - "futures 0.3.25", + "futures 0.3.26", "libp2p-core", "log", "nohash-hasher", @@ -3950,7 +4006,7 @@ checksum = "048155686bd81fe6cb5efdef0c6290f25ad32a0a42e8f4f72625cf6a505a206f" dependencies = [ "bytes", "curve25519-dalek 3.2.0", - "futures 0.3.25", + "futures 0.3.26", "lazy_static", "libp2p-core", "log", @@ -3970,7 +4026,7 @@ version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7228b9318d34689521349a86eb39a3c3a802c9efc99a0568062ffb80913e3f91" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "instant", "libp2p-core", @@ -3988,7 +4044,7 @@ checksum = "8827af16a017b65311a410bb626205a9ad92ec0473967618425039fa5231adc1" dependencies = [ "async-trait", "bytes", - "futures 0.3.25", + "futures 0.3.26", "instant", "libp2p-core", "libp2p-swarm", @@ -4006,7 +4062,7 @@ checksum = "46d13df7c37807965d82930c0e4b04a659efcb6cca237373b206043db5398ecf" dependencies = [ "either", "fnv", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "instant", "libp2p-core", @@ -4024,7 +4080,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0eddc4497a8b5a506013c40e8189864f9c3a00db2b25671f428ae9007f3ba32" dependencies = [ - "heck 0.4.0", + "heck 0.4.1", "quote", "syn", ] @@ -4036,7 +4092,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9839d96761491c6d3e238e70554b856956fca0ab60feb9de2cd08eed4473fa92" dependencies = [ "async-io", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "if-watch", "libc", @@ -4051,7 +4107,7 @@ version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a17b5b8e7a73e379e47b1b77f8a82c4721e97eca01abcd18e9cd91a23ca6ce97" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -4066,7 +4122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3758ae6f89b2531a24b6d9f5776bda6a626b60a57600d7185d43dfa75ca5ecc4" dependencies = [ "either", - "futures 0.3.25", + "futures 0.3.26", "futures-rustls", "libp2p-core", "log", @@ -4084,7 +4140,7 @@ version = "0.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6874d66543c4f7e26e3b8ca9a6bead351563a13ab4fafd43c7927f7c0d6c12" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "libp2p-core", "log", "parking_lot 0.12.1", @@ -4099,7 +4155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64", + "base64 0.13.1", "digest 0.9.0", "hmac-drbg", "libsecp256k1-core", @@ -4296,9 +4352,9 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" @@ -4321,7 +4377,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" dependencies = [ - "rustix 0.36.5", + "rustix 0.36.7", ] [[package]] @@ -4531,9 +4587,9 @@ dependencies = [ [[package]] name = "multihash-derive" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -4556,7 +4612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ "bytes", - "futures 0.3.25", + "futures 0.3.26", "log", "pin-project", "smallvec", @@ -4658,9 +4714,9 @@ dependencies = [ [[package]] name = "netlink-packet-utils" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25af9cf0dc55498b7bd94a1508af7a78706aa0ab715a73c5169273e03c84845e" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" dependencies = [ "anyhow", "byteorder", @@ -4675,7 +4731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ "bytes", - "futures 0.3.25", + "futures 0.3.26", "log", "netlink-packet-core", "netlink-sys", @@ -4685,13 +4741,13 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b654097027250401127914afb37cb1f311df6610a9891ff07a757e94199027" +checksum = "260e21fbb6f3d253a14df90eb0000a6066780a15dd901a7519ce02d77a94985b" dependencies = [ "async-io", "bytes", - "futures 0.3.25", + "futures 0.3.26", "libc", "log", ] @@ -4715,9 +4771,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -4739,9 +4795,9 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", @@ -4749,9 +4805,9 @@ dependencies = [ [[package]] name = "nom_locate" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37794436ca3029a3089e0b95d42da1f0b565ad271e4d3bb4bad0c7bb70b10605" +checksum = "b1e299bf5ea7b212e811e71174c5d1a5d065c4c0ad0c8691ecb1f97e3e66025e" dependencies = [ "bytecount", "memchr", @@ -4806,9 +4862,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] @@ -4879,18 +4935,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +checksum = "2be1598bf1c313dcdd12092e3f1920f463462525a21b7b4e11b4168353d0123e" dependencies = [ "proc-macro2", "quote", @@ -4911,20 +4967,20 @@ dependencies = [ [[package]] name = "object" -version = "0.30.0" +version = "0.30.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" dependencies = [ - "parking_lot_core 0.9.5", + "parking_lot_core 0.9.7", ] [[package]] @@ -5141,6 +5197,27 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-distance" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-authority-members", + "pallet-authorship", + "pallet-certification", + "pallet-identity", + "pallet-membership", + "pallet-session", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-distance", + "sp-inherents", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-duniter-account" version = "3.0.0" @@ -5196,6 +5273,7 @@ dependencies = [ "frame-support", "frame-system", "pallet-certification", + "pallet-distance", "pallet-identity", "pallet-membership", "parity-scale-codec", @@ -5606,9 +5684,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.2.1" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +checksum = "c3840933452adf7b3b9145e27086a5a3376c619dca1a21b1e5a5af0d54979bed" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -5621,9 +5699,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5702,7 +5780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.5", + "parking_lot_core 0.9.7", ] [[package]] @@ -5721,15 +5799,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.5" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -5791,9 +5869,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0" +checksum = "4ab62d2fa33726dbe6321cc97ef96d8cde531e3eeaf858a058de53a8a6d40d8f" dependencies = [ "thiserror", "ucd-trie", @@ -5801,9 +5879,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.5.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc078600d06ff90d4ed238f0119d84ab5d43dbaad278b0e33a8820293b32344" +checksum = "8bf026e2d0581559db66d837fe5242320f525d85c76283c61f4d51a1238d65ea" dependencies = [ "pest", "pest_generator", @@ -5811,9 +5889,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a1af60b1c4148bb269006a750cff8e2ea36aff34d2d96cf7be0b14d1bed23c" +checksum = "2b27bd18aa01d91c8ed2b61ea23406a676b42d82609c6e2581fba42f0c15f17f" dependencies = [ "pest", "pest_meta", @@ -5824,13 +5902,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.5.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec8605d59fc2ae0c6c1aefc0c7c7a9769732017c0ce07f7a9cfffa7b4404f20" +checksum = "9f02b677c1859756359fc9983c2e56a0237f18624a3789528804406b7e915e5d" dependencies = [ "once_cell", "pest", - "sha1", + "sha2 0.10.6", ] [[package]] @@ -5974,9 +6052,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" -version = "2.1.4" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54fc5dc63ed3bbf19494623db4f3af16842c0d975818e469022d09e53f0aa05" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", "float-cmp", @@ -6004,9 +6082,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c8992a85d8e93a28bdf76137db888d3874e3b230dee5ed8bebac4c9f7617773" +checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" dependencies = [ "proc-macro2", "syn", @@ -6027,11 +6105,10 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "once_cell", "thiserror", "toml", ] @@ -6062,9 +6139,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" dependencies = [ "unicode-ident", ] @@ -6108,9 +6185,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c01db6702aa05baa3f57dec92b8eeeeb4cb19e894e73996b32a4093289e54592" +checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698" dependencies = [ "bytes", "prost-derive", @@ -6118,12 +6195,12 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb5320c680de74ba083512704acb90fe00f28f79207286a848e730c45dd73ed6" +checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e" dependencies = [ "bytes", - "heck 0.4.0", + "heck 0.4.1", "itertools", "lazy_static", "log", @@ -6153,9 +6230,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8842bad1a5419bca14eac663ba798f6bc19c413c2fdceb5f3ba3b0932d96720" +checksum = "8bda8c0881ea9f722eb9629376db3d0b903b462477c1aafcb0566610ac28ac5d" dependencies = [ "anyhow", "itertools", @@ -6166,9 +6243,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "017f79637768cde62820bc2d4fe0e45daaa027755c323ad077767c6c5f173091" +checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788" dependencies = [ "bytes", "prost", @@ -6323,9 +6400,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -6333,9 +6410,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -6397,9 +6474,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -6426,7 +6503,7 @@ name = "remote-externalities" version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "env_logger", + "env_logger 0.9.3", "log", "parity-scale-codec", "serde", @@ -6449,11 +6526,11 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.13" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" dependencies = [ - "base64", + "base64 0.21.0", "bytes", "encoding_rs", "futures-core", @@ -6538,7 +6615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" dependencies = [ "async-global-executor", - "futures 0.3.25", + "futures 0.3.26", "log", "netlink-packet-route", "netlink-proto", @@ -6608,13 +6685,13 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" +checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" dependencies = [ "bitflags", "errno", - "io-lifetimes 1.0.3", + "io-lifetimes 1.0.5", "libc", "linux-raw-sys 0.1.4", "windows-sys 0.42.0", @@ -6622,9 +6699,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.7" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", @@ -6646,11 +6723,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.0", ] [[package]] @@ -6677,7 +6754,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "pin-project", "static_assertions", ] @@ -6713,7 +6790,7 @@ name = "sc-basic-authorship" version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "log", "parity-scale-codec", @@ -6782,9 +6859,9 @@ source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9 dependencies = [ "array-bytes", "chrono", - "clap 4.0.30", + "clap 4.1.4", "fdlimit", - "futures 0.3.25", + "futures 0.3.26", "libp2p", "log", "names", @@ -6821,7 +6898,7 @@ version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "fnv", - "futures 0.3.25", + "futures 0.3.26", "hash-db", "log", "parity-scale-codec", @@ -6873,7 +6950,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "libp2p", "log", @@ -6897,7 +6974,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "log", "parity-scale-codec", "sc-block-builder", @@ -6927,7 +7004,7 @@ source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9 dependencies = [ "async-trait", "fork-tree", - "futures 0.3.25", + "futures 0.3.26", "log", "merlin", "num-bigint 0.2.6", @@ -6982,7 +7059,7 @@ source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9 dependencies = [ "assert_matches", "async-trait", - "futures 0.3.25", + "futures 0.3.26", "jsonrpsee 0.15.1", "log", "parity-scale-codec", @@ -7015,7 +7092,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "log", "parity-scale-codec", @@ -7133,7 +7210,7 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "log", "parity-scale-codec", @@ -7169,7 +7246,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "ansi_term", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "log", "parity-util-mem", @@ -7209,7 +7286,7 @@ dependencies = [ "either", "fnv", "fork-tree", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "ip_network", "libp2p", @@ -7248,7 +7325,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "cid", - "futures 0.3.25", + "futures 0.3.26", "libp2p", "log", "prost", @@ -7270,7 +7347,7 @@ dependencies = [ "async-trait", "bitflags", "bytes", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "libp2p", "linked_hash_set", @@ -7294,7 +7371,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "ahash", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "libp2p", "log", @@ -7312,7 +7389,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "array-bytes", - "futures 0.3.25", + "futures 0.3.26", "libp2p", "log", "parity-scale-codec", @@ -7334,7 +7411,7 @@ source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9 dependencies = [ "array-bytes", "fork-tree", - "futures 0.3.25", + "futures 0.3.26", "libp2p", "log", "lru 0.7.8", @@ -7363,7 +7440,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "array-bytes", - "futures 0.3.25", + "futures 0.3.26", "hex", "libp2p", "log", @@ -7384,7 +7461,7 @@ dependencies = [ "array-bytes", "bytes", "fnv", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "hyper", "hyper-rustls", @@ -7411,7 +7488,7 @@ name = "sc-peerset" version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "libp2p", "log", "sc-utils", @@ -7433,7 +7510,7 @@ name = "sc-rpc" version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "hash-db", "jsonrpsee 0.15.1", "log", @@ -7463,7 +7540,7 @@ name = "sc-rpc-api" version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "jsonrpsee 0.15.1", "log", "parity-scale-codec", @@ -7486,7 +7563,7 @@ name = "sc-rpc-server" version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "jsonrpsee 0.15.1", "log", "serde_json", @@ -7499,7 +7576,7 @@ name = "sc-rpc-spec-v2" version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "hex", "jsonrpsee 0.15.1", "parity-scale-codec", @@ -7521,7 +7598,7 @@ dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "hash-db", "jsonrpsee 0.15.1", @@ -7603,7 +7680,7 @@ name = "sc-sysinfo" version = "6.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "libc", "log", "rand 0.7.3", @@ -7623,7 +7700,7 @@ version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "chrono", - "futures 0.3.25", + "futures 0.3.26", "libp2p", "log", "parking_lot 0.12.1", @@ -7683,7 +7760,7 @@ version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "linked-hash-map", "log", @@ -7710,7 +7787,7 @@ version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "log", "serde", "sp-blockchain", @@ -7723,7 +7800,7 @@ name = "sc-utils" version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "lazy_static", "log", @@ -7799,12 +7876,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -7886,9 +7962,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9512ffd81e3a3503ed401f79c33168b9148c75038956039166cd750eaa037c3" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys", ] @@ -7913,9 +7989,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.7.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ "bitflags", "core-foundation", @@ -7926,9 +8002,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" dependencies = [ "core-foundation-sys", "libc", @@ -7960,18 +8036,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.151" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.151" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -8023,17 +8099,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.6", -] - [[package]] name = "sha2" version = "0.8.2" @@ -8159,14 +8224,14 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774d05a3edae07ce6d68ea6984f3c05e9bba8927e3dd591e3b479e5b03213d0d" +checksum = "12ba5f4d4ff12bdb6a169ed51b7c48c0e0ac4b0b4b31012b2571e97d78d3201d" dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-pre.5", + "curve25519-dalek 4.0.0-rc.0", "rand_core 0.6.4", "ring", "rustc_version", @@ -8190,10 +8255,10 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "flate2", - "futures 0.3.25", + "futures 0.3.26", "httparse", "log", "rand 0.8.5", @@ -8300,7 +8365,7 @@ name = "sp-blockchain" version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "log", "lru 0.7.8", "parity-scale-codec", @@ -8319,7 +8384,7 @@ version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "log", "parity-scale-codec", @@ -8412,7 +8477,7 @@ dependencies = [ "byteorder", "dyn-clonable", "ed25519-zebra", - "futures 0.3.25", + "futures 0.3.26", "hash-db", "hash256-std-hasher", "impl-serde", @@ -8490,6 +8555,21 @@ dependencies = [ "syn", ] +[[package]] +name = "sp-distance" +version = "3.0.0" +dependencies = [ + "async-trait", + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-inherents", + "sp-runtime", + "sp-std", + "thiserror", +] + [[package]] name = "sp-externalities" version = "0.12.0" @@ -8539,7 +8619,7 @@ version = "6.0.0" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "bytes", - "futures 0.3.25", + "futures 0.3.26", "hash-db", "libsecp256k1", "log", @@ -8576,7 +8656,7 @@ version = "0.12.0" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "merlin", "parity-scale-codec", "parking_lot 0.12.1", @@ -8934,9 +9014,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.36.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d92659e7d18d82b803824a9ba5a6022cff101c3491d027c1c1d8d30e749284" +checksum = "e40c020d72bc0a9c5660bb71e4a6fdef081493583062c474740a7d59f55f0e7b" dependencies = [ "Inflector", "num-format", @@ -9021,7 +9101,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck 0.4.0", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -9055,7 +9135,7 @@ version = "4.0.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.25", + "futures 0.3.26", "jsonrpsee 0.15.1", "log", "parity-scale-codec", @@ -9127,7 +9207,7 @@ dependencies = [ "bitvec", "derivative", "frame-metadata", - "futures 0.3.25", + "futures 0.3.26", "getrandom 0.2.8", "hex", "jsonrpsee 0.16.2", @@ -9153,7 +9233,7 @@ source = "git+https://github.com/duniter/subxt.git?branch=duniter-substrate-v0.9 dependencies = [ "darling", "frame-metadata", - "heck 0.4.0", + "heck 0.4.1", "hex", "jsonrpsee 0.16.2", "parity-scale-codec", @@ -9293,9 +9373,9 @@ dependencies = [ [[package]] name = "tera" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d4685e72cb35f0eb74319c8fe2d3b61e93da5609841cde2cb87fcc3bea56d20" +checksum = "3df578c295f9ec044ff1c829daf31bb7581d5b3c2a7a3d87419afe1f2531438c" dependencies = [ "globwalk", "lazy_static", @@ -9309,23 +9389,13 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "termtree" version = "0.4.0" @@ -9432,15 +9502,15 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.23.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", @@ -9453,7 +9523,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -9516,9 +9586,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] @@ -9683,16 +9753,16 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" source = "git+https://github.com/duniter/substrate?branch=duniter-substrate-v0.9.32#7f8b8db65b441ce1d1b2ffb26ebde314b54e117c" dependencies = [ - "clap 4.0.30", + "clap 4.1.4", "frame-try-runtime", "log", "parity-scale-codec", @@ -9726,7 +9796,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "digest 0.10.6", "rand 0.8.5", "static_assertions", @@ -9828,9 +9898,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" [[package]] name = "unicode-ident" @@ -9849,9 +9919,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" @@ -10010,9 +10080,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -10020,9 +10090,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", @@ -10035,9 +10105,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -10047,9 +10117,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -10057,9 +10127,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -10070,9 +10140,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasm-gc-api" @@ -10100,7 +10170,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "js-sys", "parking_lot 0.11.2", "pin-utils", @@ -10195,7 +10265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcd849399d17d2270141cfe47fa0d91ee52d5f8ea9b98cf7ddde0d53e5f79882" dependencies = [ "anyhow", - "base64", + "base64 0.13.1", "bincode", "directories-next", "file-per-thread-logger", @@ -10323,9 +10393,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" dependencies = [ "js-sys", "wasm-bindgen", @@ -10361,9 +10431,9 @@ dependencies = [ [[package]] name = "which" -version = "4.3.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ "either", "libc", @@ -10452,19 +10522,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] name = "windows_aarch64_msvc" @@ -10480,9 +10574,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" @@ -10498,9 +10592,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" @@ -10516,9 +10610,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" @@ -10534,15 +10628,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" @@ -10558,9 +10652,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "winreg" @@ -10606,7 +10700,7 @@ name = "xtask" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.0.30", + "clap 4.1.4", "frame-metadata", "graphql_client", "hex", @@ -10630,7 +10724,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "log", "nohash-hasher", "parking_lot 0.12.1", @@ -10686,10 +10780,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.4+zstd.1.5.2" +version = "2.0.6+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fa202f2ef00074143e219d15b62ffc317d17cc33909feac471c044087cad7b0" +checksum = "68a3f9792c0c3dc6c165840a75f47ae1f4da402c2d006881129579f6597e801b" dependencies = [ "cc", "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 0896f98b8..16f852337 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,10 +32,10 @@ runtime-benchmarks = [ 'sc-client-db/runtime-benchmarks', ] try-runtime = [ - #"g1-runtime/try-runtime", - "gdev-runtime/try-runtime", - #"gtest-runtime/try-runtime", - "try-runtime-cli" + #"g1-runtime/try-runtime", + "gdev-runtime/try-runtime", + #"gtest-runtime/try-runtime", + "try-runtime-cli", ] [build-dependencies] @@ -48,19 +48,28 @@ rusty-hook = "^0.11.2" # Dependencies for specific targets [target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies] -sc-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false, features = ["wasmtime"] } -sc-service = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false, features = ["wasmtime"] } -sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", features = ["memory-tracker"] } +sc-cli = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false, features = [ + "wasmtime", +] } +sc-service = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", default-features = false, features = [ + "wasmtime", +] } +sp-trie = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.32", features = [ + "memory-tracker", +] } [dependencies] # local dependencies common-runtime = { path = 'runtime/common' } +dc-distance = { path = 'client/distance' } +distance-oracle = { path = 'distance-oracle', optional = true } g1-runtime = { path = 'runtime/g1', optional = true } gdev-runtime = { path = 'runtime/gdev', optional = true } gtest-runtime = { path = 'runtime/gtest', optional = true } pallet-certification = { path = 'pallets/certification' } pallet-oneshot-account = { path = 'pallets/oneshot-account' } +sp-distance = { path = 'primitives/distance' } sp-membership = { path = 'primitives/membership' } # crates.io dependencies @@ -131,9 +140,12 @@ try-runtime-cli = { git = "https://github.com/duniter/substrate", branch = "duni resolver = "2" members = [ + 'client/distance', + 'distance-oracle', 'end2end-tests', 'live-tests', 'pallets/certification', + 'pallets/distance', 'pallets/duniter-test-parameters', 'pallets/duniter-test-parameters/macro', 'pallets/duniter-wot', @@ -144,6 +156,7 @@ members = [ 'pallets/universal-dividend', 'pallets/upgrade-origin', 'primitives/membership', + 'primitives/distance', 'runtime/common', 'runtime/gdev', 'xtask', diff --git a/client/distance/Cargo.toml b/client/distance/Cargo.toml new file mode 100644 index 000000000..27f16c31e --- /dev/null +++ b/client/distance/Cargo.toml @@ -0,0 +1,51 @@ +[package] +authors = ['tuxmain <tuxmain@zettascript.org>'] +description = 'Duniter client distance' +edition = '2021' +homepage = 'https://duniter.org' +license = 'AGPL-3.0' +name = 'dc-distance' +readme = 'README.md' +repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' +version = '1.0.0' + +[dependencies] + +pallet-distance = { path = "../../pallets/distance" } +sp-distance = { path = "../../primitives/distance" } + +log = "0.4" +thiserror = "1.0.30" + +# substrate +scale-info = { version = "2.1.1", features = ["derive"] } + +[dependencies.codec] +features = ['derive'] +package = 'parity-scale-codec' +version = '3.1.5' + +[dependencies.frame-support] +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sc-client-api] +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-core] +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-keystore] +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-runtime] +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +### DOC ### + +[package.metadata.docs.rs] +targets = ['x86_64-unknown-linux-gnu'] diff --git a/client/distance/src/lib.rs b/client/distance/src/lib.rs new file mode 100644 index 000000000..433ed07f9 --- /dev/null +++ b/client/distance/src/lib.rs @@ -0,0 +1,146 @@ +// Copyright 2022 Axiom-Team +// +// This file is part of Substrate-Libre-Currency. +// +// Substrate-Libre-Currency is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Substrate-Libre-Currency is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. + +use codec::{Decode, Encode}; +use frame_support::pallet_prelude::*; +use sc_client_api::{ProvideUncles, StorageKey, StorageProvider}; +use scale_info::TypeInfo; +//use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; +use sp_runtime::{generic::BlockId, traits::Block as BlockT, AccountId32 /*, KeyTypeId*/}; +use std::path::PathBuf; + +type IdtyIndex = u32; + +#[derive(Debug, thiserror::Error)] +pub enum Error<B: BlockT> { + #[error("Could not retrieve the block hash for block id: {0:?}")] + NoHashForBlockId(BlockId<B>), +} + +/// Create a new [`sp_distance::InherentDataProvider`] at the given block. +pub fn create_distance_inherent_data_provider<B, C, Backend /*, ValidatorId*/>( + client: &C, + parent: B::Hash, + distance_dir: PathBuf, + owner_keys: &[sp_core::sr25519::Public], +) -> Result<sp_distance::InherentDataProvider<IdtyIndex>, sc_client_api::blockchain::Error> +where + B: BlockT, + C: ProvideUncles<B> + StorageProvider<B, Backend>, + Backend: sc_client_api::Backend<B>, + IdtyIndex: Decode + Encode + PartialEq + TypeInfo, + //ValidatorId: Decode, +{ + let &[owner_key] = owner_keys else { + return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new( + None + )) + }; + let owner_key = sp_runtime::AccountId32::new(owner_key.0); + + // TODO: + // * dc_distance::create_distance_inherent_data_provider(client_clone, parent, distance_dir) + // * est-ce qu'on a déjà publié un résultat ce round + // * avec storage provider dans client_clone: + // * récupérer liste des forgerons ayant publié résultat ce round + // * palette session: dans KeyOwner: récupérer notre clé forgeron à partir d'une de nos session_keys + // * sinon, pour quel round on veut un résultat + // * current_round_index dans storage provider (ou session index) + + let session_index = client + .storage( + &parent, + &StorageKey( + frame_support::storage::storage_prefix(b"Session", b"CurrentIndex").to_vec(), + ), + ) + .expect("CurrentIndex is Err") + .map_or(0, |raw| { + u32::decode(&mut &raw.0[..]).expect("cannot decode CurrentIndex") + }); + + let published_results = client + .storage( + &parent, + &StorageKey( + frame_support::storage::storage_prefix( + b"Distance", + match session_index % 3 { + 0 => b"StoragePublishedResults1", + 1 => b"StoragePublishedResults2", + 2 => b"StoragePublishedResults0", + _ => unreachable!("n%3<3"), + }, + ) + .to_vec(), + ), + )? + .map_or_else(Default::default, |raw| { + pallet_distance::EvaluationPool::< + AccountId32, + IdtyIndex, + ConstU32<100>, // TODO document this limit + ConstU32<100>, + >::decode(&mut &raw.0[..]) + .expect("cannot decode EvaluationPool") + }); + + // Have we already published a result for this session? + for evaluator in published_results.1.iter() { + if evaluator == &owner_key { + return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None)); + } + } + + // Read evaluation result from file, if it exists + let evaluation_result = match std::fs::read(distance_dir.join(session_index.to_string())) { + Ok(data) => data, + Err(e) => { + match e.kind() { + std::io::ErrorKind::NotFound => {} + _ => { + log::error!("Cannot read distance evaluation result file: {e:?}"); + } + } + return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None)); + } + }; + + /*let owner_key = ValidatorId::decode( + &mut &client + .storage( + &parent, + &StorageKey( + frame_support::storage::storage_prefix(b"Session", b"OwnerKey").to_vec(), + ), + )? + .expect("no Session::OwnerKey") + .0[..], + ) + .expect("cannot decode ValidatorId");*/ + + // TODO pour trouver session key: voir keystore + // node/src/command/key.rs + // Trouver la bonne clé avec SyncCryptoStore::sr25519_public_keys + // Trouver l'IdtyId correspondant + // Le metttre dans un OnceCell<IdtyId> + // Note : si l'IdtyId forgeron change sans redémarrer le nœud, les inhérents seront invalides + + Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new( + //distance_dir, + Some(sp_distance::ComputationResult::decode(&mut evaluation_result.as_slice()).unwrap()), + )) +} diff --git a/distance-oracle/Cargo.toml b/distance-oracle/Cargo.toml new file mode 100644 index 000000000..8869a5fc6 --- /dev/null +++ b/distance-oracle/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "distance-oracle" +version = "0.1.0" +authors = ["tuxmain <tuxmain@zettascript.org>"] +repository = "https://git.duniter.org/nodes/rust/duniter-v2s" +license = "AGPL-3.0-only" +edition = "2021" + +[dependencies] +sp-distance = { path = "../primitives/distance" } + +codec = { package = "parity-scale-codec", version = "3.1.5" } +rayon = "1.7.0" +sp-core = { git = "https://github.com/duniter/substrate.git", branch = "duniter-substrate-v0.9.32" } +sp-runtime = { git = "https://github.com/duniter/substrate.git", branch = "duniter-substrate-v0.9.32" } +subxt = { git = 'https://github.com/duniter/subxt.git', branch = "duniter-substrate-v0.9.32" } + +# standalone only +clap = { version = "4.0", features = ["derive"], optional = true } +tokio = { version = "1.15.0", features = [ + "rt-multi-thread", + "macros", +], optional = true } + +[features] +default = ["standalone"] +standalone = ["clap", "tokio"] + +[[bin]] +name = "distance-oracle" +required-features = ["standalone"] diff --git a/distance-oracle/src/lib.rs b/distance-oracle/src/lib.rs new file mode 100644 index 000000000..87af5b506 --- /dev/null +++ b/distance-oracle/src/lib.rs @@ -0,0 +1,267 @@ +use codec::Encode; +use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::collections::{HashMap, HashSet}; +use std::io::Write; +use std::path::PathBuf; +use subxt::ext::sp_runtime::Perbill; +use subxt::storage::StorageKey; + +pub struct Settings { + pub evaluation_result_dir: PathBuf, + pub min_certs_for_referee: u32, + pub rpc_url: String, +} + +impl Default for Settings { + fn default() -> Self { + Self { + evaluation_result_dir: PathBuf::from("/tmp/duniter/chains/gdev/distance"), + min_certs_for_referee: 2, + rpc_url: String::from("ws://127.0.0.1:9944"), + } + } +} + +#[subxt::subxt(runtime_metadata_path = "../resources/metadata.scale")] +pub mod gdev {} + +pub type Client = subxt::OnlineClient<GdevConfig>; + +pub enum GdevConfig {} +impl subxt::config::Config for GdevConfig { + type Index = u32; + type BlockNumber = u32; + type Hash = sp_core::H256; + type Hashing = subxt::ext::sp_runtime::traits::BlakeTwo256; + type AccountId = subxt::ext::sp_runtime::AccountId32; + type Address = subxt::ext::sp_runtime::MultiAddress<Self::AccountId, u32>; + type Header = subxt::ext::sp_runtime::generic::Header< + Self::BlockNumber, + subxt::ext::sp_runtime::traits::BlakeTwo256, + >; + type Signature = subxt::ext::sp_runtime::MultiSignature; + type ExtrinsicParams = subxt::tx::BaseExtrinsicParams<Self, Tip>; +} + +#[derive(Copy, Clone, Debug, Default, Encode)] +pub struct Tip { + #[codec(compact)] + tip: u64, +} + +impl Tip { + pub fn new(amount: u64) -> Self { + Tip { tip: amount } + } +} + +impl From<u64> for Tip { + fn from(n: u64) -> Self { + Self::new(n) + } +} + +type IdtyIndex = u32; + +/*#[tokio::main] +async fn main() { + run().await +}*/ + +pub async fn run(settings: Settings) { + let client = Client::from_url(settings.rpc_url).await.unwrap(); + + let parent_hash = client + .storage() + .fetch(&gdev::storage().system().parent_hash(), None) + .await + .unwrap() + .unwrap(); + + let current_session = client + .storage() + .fetch( + &gdev::storage().session().current_index(), + Some(parent_hash), + ) + .await + .unwrap() + .unwrap_or_default(); + + // Fetch the pending identities + let Some(evaluation_pool) = client + .storage() + .fetch( + &match current_session % 3 { + 0 => gdev::storage().distance().evaluation_pool1(), + 1 => gdev::storage().distance().evaluation_pool2(), + 2 => gdev::storage().distance().evaluation_pool0(), + _ => unreachable!("n%3<3"), + }, + Some(parent_hash), + ) + .await + .unwrap() else { + println!("Pool does not exist"); + return + }; + + // Stop if nothing to evaluate + if evaluation_pool.0 .0.is_empty() { + println!("Pool is empty"); + return; + } + + let evaluation_result_path = settings + .evaluation_result_dir + .join((current_session + 1).to_string()); + + // Stop if already evaluated + if evaluation_result_path.try_exists().unwrap() { + println!("File already exists"); + return; + } + + let evaluation_block = client + .storage() + .fetch( + &gdev::storage().distance().evaluation_block(), + Some(parent_hash), + ) + .await + .unwrap() + .unwrap(); + + std::fs::create_dir_all(settings.evaluation_result_dir).unwrap(); + + // member idty -> issued certs + let mut members = HashMap::<IdtyIndex, u32>::new(); + + let mut members_iter = client + .storage() + .iter( + gdev::storage().membership().membership(0), + 100, + Some(evaluation_block), + ) + .await + .unwrap(); + while let Some((member_idty, _membership_expire)) = members_iter.next().await.unwrap() { + members.insert(idty_id_from_storage_key(&member_idty), 0); + } + + // idty -> received certs + let mut received_certs = HashMap::<IdtyIndex, Vec<IdtyIndex>>::new(); + + let mut certs_iter = client + .storage() + .iter( + gdev::storage().cert().certs_by_receiver(0), + 100, + Some(evaluation_block), + ) + .await + .unwrap(); + while let Some((receiver, issuers)) = certs_iter.next().await.unwrap() { + let receiver = idty_id_from_storage_key(&receiver); + // Update members' issued certs count + if issuers.len() as u32 >= settings.min_certs_for_referee { + for (issuer, _removable_on) in issuers.iter() { + if let Some(issued_certs) = members.get_mut(issuer) { + *issued_certs += 1; + } + } + } else { + // This member is not referee + members.remove(&receiver); + } + received_certs.insert( + receiver, + issuers + .into_iter() + .map(|(issuer, _removable_on)| issuer) + .collect(), + ); + } + + // Only retain referees + // TODO benchmark: can it be faster? (maybe using drain_filter) + members.retain(|_idty, issued_certs| *issued_certs >= settings.min_certs_for_referee); + let referees = members; + + let evaluation: Vec<Perbill> = evaluation_pool + .0 + .0 + .into_par_iter() + .map(|(idty, _)| { + Perbill::from_rational( + distance_rule( + &received_certs, + &referees, + settings.min_certs_for_referee, + idty, + ), + referees.len() as u32, + ) + }) + .collect(); + + let mut evaluation_result_file = std::fs::OpenOptions::new() + .write(true) + .create_new(true) + .open(evaluation_result_path) + .unwrap(); + evaluation_result_file + .write( + &sp_distance::ComputationResult { + distances: evaluation, + } + .encode(), + ) + .unwrap(); +} + +fn distance_rule_recursive( + received_certs: &HashMap<IdtyIndex, Vec<IdtyIndex>>, + referees: &HashMap<IdtyIndex, u32>, + idty: IdtyIndex, + accessible_referees: &mut std::collections::HashSet<IdtyIndex>, + depth: u32, +) { + if referees.contains_key(&idty) { + accessible_referees.insert(idty); + } + if depth == 0 { + return; + } + for &certifier in received_certs.get(&idty).expect("unreachable").iter() { + distance_rule_recursive( + received_certs, + referees, + certifier, + accessible_referees, + depth - 1, + ); + } +} + +fn distance_rule( + received_certs: &HashMap<IdtyIndex, Vec<IdtyIndex>>, + referees: &HashMap<IdtyIndex, u32>, + depth: u32, + idty: IdtyIndex, +) -> u32 { + let mut accessible_referees = HashSet::<u32>::new(); + distance_rule_recursive( + received_certs, + referees, + idty, + &mut accessible_referees, + depth + 1, + ); + accessible_referees.len() as u32 +} + +fn idty_id_from_storage_key(storage_key: &StorageKey) -> IdtyIndex { + u32::from_le_bytes(storage_key.as_ref()[40..44].try_into().unwrap()) +} diff --git a/distance-oracle/src/main.rs b/distance-oracle/src/main.rs new file mode 100644 index 000000000..7d6e222b1 --- /dev/null +++ b/distance-oracle/src/main.rs @@ -0,0 +1,23 @@ +use clap::Parser; + +#[derive(Debug, clap::Parser)] +struct Cli { + #[clap(short = 'd', long, default_value = "/tmp/duniter/chains/gdev/distance")] + evaluation_result_dir: String, + #[clap(short = 'c', long, default_value = "2")] + min_certs_for_referee: u32, + #[clap(short = 'u', long, default_value = "ws://127.0.0.1:9944")] + rpc_url: String, +} + +#[tokio::main] +async fn main() { + let cli = Cli::parse(); + + distance_oracle::run(distance_oracle::Settings { + evaluation_result_dir: cli.evaluation_result_dir.into(), + min_certs_for_referee: cli.min_certs_for_referee, + rpc_url: cli.rpc_url, + }) + .await; +} diff --git a/docs/api/manual.md b/docs/api/manual.md index 6ef23fce5..0b9a91eb7 100644 --- a/docs/api/manual.md +++ b/docs/api/manual.md @@ -20,6 +20,9 @@ Only use `identity` pallet. The `membership` calls are disabled. 1. The account that wants to gain membership needs to exists. 1. Any account that already has membership and respects the identity creation period can create an identity for another account, using `identity.createIdentity`. 1. The account has to confirm its identity with a name, using `identity.confirmIdentity`. The name must be ASCII alphanumeric, punctuation or space characters: ``/^[-!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-Z0-9 ]{3,64}$/`` (additionally, trailing spaces and double spaces are forbidden, as a phishing countermeasure). If the name is already used, the call will fail. +1. 4 different member accounts must certify the account using `cert.addCert`. +1. The distance evaluation must be requested for the pending identity using `distance.evaluateDistance`. +1. 3 sessions later, if the distance rule is respected, `identity.validateIdentity` can be called. ## Change key diff --git a/end2end-tests/cucumber-features/distance.feature b/end2end-tests/cucumber-features/distance.feature new file mode 100644 index 000000000..9cc18d514 --- /dev/null +++ b/end2end-tests/cucumber-features/distance.feature @@ -0,0 +1,24 @@ +Feature: Distance + + Scenario: Alice certifies Eve + When alice sends 6 ĞD to dave + When 15 blocks later + When alice creates identity for dave + Then dave identity should be created + Then dave should be certified by alice + When dave confirms his identity with pseudo "dave" + Then dave identity should be confirmed + When bob certifies dave + Then dave should be certified by bob + When alice requests distance evaluation for dave + Then dave should have distance result in 2 sessions + When 30 blocks later + Then dave should have distance result in 1 session + When distance oracle runs + Then dave should have distance result in 1 session + When 30 blocks later + Then dave should have distance result in 0 session + Then dave should have distance ok + When alice validates dave identity + When 3 blocks later + Then dave identity should be validated diff --git a/end2end-tests/tests/common/distance.rs b/end2end-tests/tests/common/distance.rs new file mode 100644 index 000000000..6c792700d --- /dev/null +++ b/end2end-tests/tests/common/distance.rs @@ -0,0 +1,41 @@ +// Copyright 2023 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +use super::gdev; +use super::gdev::runtime_types::pallet_identity; +use super::*; +use crate::DuniterWorld; +use sp_keyring::AccountKeyring; +use subxt::tx::PairSigner; + +pub async fn request_evaluation(client: &Client, from: AccountKeyring, to: u32) -> Result<()> { + let from = PairSigner::new(from.pair()); + + let _events = create_block_with_extrinsic( + client, + client + .tx() + .create_signed( + &gdev::tx().distance().evaluate_distance(to), + &from, + BaseExtrinsicParamsBuilder::new(), + ) + .await?, + ) + .await?; + + Ok(()) +} diff --git a/end2end-tests/tests/common/mod.rs b/end2end-tests/tests/common/mod.rs index 56ccdea5d..2ff94d982 100644 --- a/end2end-tests/tests/common/mod.rs +++ b/end2end-tests/tests/common/mod.rs @@ -18,6 +18,7 @@ pub mod balances; pub mod cert; +pub mod distance; pub mod identity; pub mod oneshot; @@ -85,6 +86,7 @@ impl Process { } } +pub const DISTANCE_ORACLE_LOCAL_PATH: &str = "../target/debug/distance-oracle"; const DUNITER_DOCKER_PATH: &str = "/usr/local/bin/duniter"; const DUNITER_LOCAL_PATH: &str = "../target/debug/duniter"; @@ -94,7 +96,7 @@ struct FullNode { ws_port: u16, } -pub async fn spawn_node(maybe_genesis_conf_file: Option<PathBuf>) -> (Client, Process) { +pub async fn spawn_node(maybe_genesis_conf_file: Option<PathBuf>) -> (Client, Process, u16) { println!("maybe_genesis_conf_file={:?}", maybe_genesis_conf_file); let duniter_binary_path = std::env::var("DUNITER_BINARY_PATH").unwrap_or_else(|_| { if std::path::Path::new(DUNITER_DOCKER_PATH).exists() { @@ -117,7 +119,7 @@ pub async fn spawn_node(maybe_genesis_conf_file: Option<PathBuf>) -> (Client, Pr .await .expect("fail to connect to node"); - (client, process) + (client, process, ws_port) } pub async fn create_empty_block(client: &Client) -> Result<()> { @@ -173,6 +175,9 @@ fn spawn_full_node( let log_file_path = format!("duniter-v2s-{}.log", ws_port); let log_file = std::fs::File::create(&log_file_path).expect("fail to create log file"); + // Clean previous data + std::fs::remove_dir_all("/tmp/duniter-cucumber").ok(); + // Command let process = Process( Command::new(duniter_binary_path) @@ -180,13 +185,14 @@ fn spawn_full_node( [ "--no-telemetry", "--no-prometheus", - "--tmp", "--port", &p2p_port.to_string(), "--rpc-port", &rpc_port.to_string(), "--ws-port", &ws_port.to_string(), + "--base-path", + "/tmp/duniter-cucumber", ] .iter() .chain(args), @@ -249,3 +255,22 @@ fn wait_until_log_line(expected_log_line: &str, log_file_path: &str, timeout: st } } } + +pub fn spawn_distance_oracle(distance_oracle_binary_path: &str, duniter_rpc_port: u16) { + Command::new(distance_oracle_binary_path) + .args( + [ + "-u", + &format!("ws://127.0.0.1:{duniter_rpc_port}"), + "-d", + "/tmp/duniter-cucumber/chains/gdev/distance", + "-c", + "2", + ] + .iter(), + ) + .spawn() + .expect("failed to spawn distance oracle") + .wait() + .unwrap(); +} diff --git a/end2end-tests/tests/cucumber_tests.rs b/end2end-tests/tests/cucumber_tests.rs index 094932d4b..21e0a8be5 100644 --- a/end2end-tests/tests/cucumber_tests.rs +++ b/end2end-tests/tests/cucumber_tests.rs @@ -120,12 +120,17 @@ impl World for DuniterWorld { struct DuniterWorldInner { client: Client, process: Process, + ws_port: u16, } impl DuniterWorldInner { async fn new(maybe_genesis_conf_file: Option<PathBuf>) -> Self { - let (client, process) = spawn_node(maybe_genesis_conf_file).await; - DuniterWorldInner { client, process } + let (client, process, ws_port) = spawn_node(maybe_genesis_conf_file).await; + DuniterWorldInner { + client, + process, + ws_port, + } } fn kill(&mut self) { self.process.kill(); @@ -322,6 +327,28 @@ async fn validate_identity(world: &mut DuniterWorld, from: String, to: String) - common::identity::validate_identity(world.client(), from, to).await } +#[when(regex = r#"([a-zA-Z]+) requests distance evaluation for ([a-zA-Z]+)"#)] +async fn request_distance_evaluation( + world: &mut DuniterWorld, + from: String, + to: String, +) -> Result<()> { + // input names to keyrings + let from = AccountKeyring::from_str(&from).expect("unknown from"); + let to: u32 = common::identity::get_identity_index(world, to).await?; + + common::distance::request_evaluation(world.client(), from, to).await +} + +#[when(regex = r#"distance oracle runs"#)] +async fn run_distance_oracle(world: &mut DuniterWorld) -> Result<()> { + common::spawn_distance_oracle( + common::DISTANCE_ORACLE_LOCAL_PATH, + world.inner.as_ref().unwrap().ws_port, + ); + Ok(()) +} + // ===== then ==== #[then(regex = r"([a-zA-Z]+) should have (\d+) (ĞD|cĞD)")] @@ -437,6 +464,66 @@ async fn should_be_certified_by( } } +#[then(regex = r"([a-zA-Z]+) should have distance result in (\d+) sessions?")] +async fn should_have_distance_result_in_sessions( + world: &mut DuniterWorld, + who: String, + sessions: u32, +) -> Result<()> { + assert!(sessions < 3, "Session number must be < 3"); + + let who = AccountKeyring::from_str(&who).unwrap().to_account_id(); + + let idty_id = world + .read(&gdev::storage().identity().identity_index_of(&who)) + .await? + .unwrap(); + + let current_session = world + .read(&gdev::storage().session().current_index()) + .await? + .unwrap_or_default(); + + let pool = world + .read(&match (current_session + sessions) % 3 { + 0 => gdev::storage().distance().evaluation_pool0(), + 1 => gdev::storage().distance().evaluation_pool1(), + 2 => gdev::storage().distance().evaluation_pool2(), + _ => unreachable!("n%3<3"), + }) + .await + .unwrap() + .ok_or_else(|| anyhow::anyhow!("given pool is empty"))?; + + for (sample_idty, _) in pool.0 .0 { + if sample_idty == idty_id { + return Ok(()); + } + } + + Err(anyhow::anyhow!("no evaluation in given pool").into()) +} + +#[then(regex = r"([a-zA-Z]+) should have distance ok")] +async fn should_have_distance_ok(world: &mut DuniterWorld, who: String) -> Result<()> { + let who = AccountKeyring::from_str(&who).unwrap().to_account_id(); + + let idty_id = world + .read(&gdev::storage().identity().identity_index_of(&who)) + .await? + .unwrap(); + + if world + .read(&gdev::storage().distance().distance_ok_identities(&idty_id)) + .await? + .unwrap() + { + Ok(()) + } else { + Err(anyhow::anyhow!("no evaluation in given pool").into()) + } +} + use gdev::runtime_types::pallet_identity::types::IdtyStatus; // status from string diff --git a/node/src/service.rs b/node/src/service.rs index 6562b6584..1d5daf8aa 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -31,7 +31,7 @@ use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_core::H256; use sp_runtime::traits::BlakeTwo256; -use std::{sync::Arc, time::Duration}; +use std::{path::PathBuf, sync::Arc, time::Duration}; type FullClient<RuntimeApi, Executor> = sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>; @@ -309,7 +309,7 @@ where Some(Box::new(justification_import)), client.clone(), select_chain.clone(), - move |_, ()| async move { + move |_parent, ()| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = @@ -429,6 +429,15 @@ where let enable_grandpa = !config.disable_grandpa; let prometheus_registry = config.prometheus_registry().cloned(); + let distance_dir = config.base_path.as_ref().map_or_else( + || PathBuf::from("/tmp"), + |base_path| { + base_path + .config_dir(config.chain_spec.id()) + .join("distance") + }, + ); // TODO improve this + let mut command_sink_opt = None; if role.is_authority() { let proposer_factory = sc_basic_authorship::ProposerFactory::new( @@ -439,6 +448,9 @@ where telemetry.as_ref().map(|x| x.handle()), ); + let sync_cryptostore_ptr = keystore_container.sync_keystore(); + let client = client.clone(); + if sealing.is_manual_consensus() { let commands_stream: Box<dyn Stream<Item = EngineCommand<H256>> + Send + Sync + Unpin> = match sealing { @@ -489,7 +501,6 @@ where ) .expect("failed to create BabeConsensusDataProvider"); - let client_clone = client.clone(); task_manager.spawn_essential_handle().spawn_blocking( "manual-seal", Some("block-authoring"), @@ -501,8 +512,14 @@ where commands_stream, select_chain, consensus_data_provider: Some(Box::new(babe_consensus_data_provider)), - create_inherent_data_providers: move |_, _| { - let client = client_clone.clone(); + create_inherent_data_providers: move |parent, _| { + let client = client.clone(); + let distance_dir = distance_dir.clone(); + let babe_owner_keys = + std::sync::Arc::new(sp_keystore::SyncCryptoStore::sr25519_public_keys( + sync_cryptostore_ptr.as_ref(), + sp_runtime::KeyTypeId(*b"babe"), + )); async move { let timestamp = manual_seal::consensus::timestamp::SlotTimestampProvider::new_babe( @@ -512,13 +529,21 @@ where let babe = sp_consensus_babe::inherents::InherentDataProvider::new( timestamp.slot(), ); - Ok((timestamp, babe)) + let distance = + dc_distance::create_distance_inherent_data_provider::< + Block, + FullClient<RuntimeApi, Executor>, + FullBackend, + //common_runtime::AccountId, + >( + &*client, parent, distance_dir, &babe_owner_keys.clone() + )?; + Ok((timestamp, babe, distance)) } }, }), ); } else { - let client_clone = client.clone(); let slot_duration = babe_link.config().slot_duration(); let babe_config = babe::BabeParams { keystore: keystore_container.sync_keystore(), @@ -529,12 +554,19 @@ where sync_oracle: network.clone(), justification_sync_link: network.clone(), create_inherent_data_providers: move |parent, ()| { - let client_clone = client_clone.clone(); + // This closure is called during each block generation. + + let client = client.clone(); + let distance_dir = distance_dir.clone(); + let babe_owner_keys = + std::sync::Arc::new(sp_keystore::SyncCryptoStore::sr25519_public_keys( + sync_cryptostore_ptr.as_ref(), + sp_runtime::KeyTypeId(*b"babe"), + )); async move { let uncles = sc_consensus_uncles::create_uncles_inherent_data_provider( - &*client_clone, - parent, + &*client, parent, )?; let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); @@ -545,7 +577,16 @@ where slot_duration, ); - Ok((slot, timestamp, uncles)) + let distance = dc_distance::create_distance_inherent_data_provider::< + Block, + FullClient<RuntimeApi, Executor>, + FullBackend, + //common_runtime::AccountId, + >( + &*client, parent, distance_dir, &babe_owner_keys.clone() + )?; + + Ok((slot, timestamp, uncles, distance)) } }, force_authoring, diff --git a/pallets/authority-members/src/lib.rs b/pallets/authority-members/src/lib.rs index d4f299c36..4f855eae6 100644 --- a/pallets/authority-members/src/lib.rs +++ b/pallets/authority-members/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::type_complexity)] +pub mod impls; pub mod traits; mod types; pub mod weights; @@ -30,17 +31,15 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -pub mod impls; pub use impls::*; - pub use pallet::*; +pub use sp_staking::SessionIndex; +pub use traits::*; pub use types::*; pub use weights::WeightInfo; -use self::traits::*; use frame_support::traits::Get; use sp_runtime::traits::Convert; -use sp_staking::SessionIndex; use sp_std::prelude::*; #[frame_support::pallet] diff --git a/pallets/distance/Cargo.toml b/pallets/distance/Cargo.toml new file mode 100644 index 000000000..fe00b84a5 --- /dev/null +++ b/pallets/distance/Cargo.toml @@ -0,0 +1,85 @@ +[package] +authors = ['tuxmain <tuxmain@zettascript.org>'] +description = 'FRAME pallet distance.' +edition = '2021' +homepage = 'https://duniter.org' +license = 'AGPL-3.0' +name = 'pallet-distance' +readme = 'README.md' +repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' +version = '1.0.0' + +[features] +default = ['std'] +std = [ + 'codec/std', + 'frame-support/std', + 'frame-system/std', + 'pallet-session/std', + 'sp-core/std', + 'sp-distance/std', + 'sp-runtime/std', + 'sp-std/std', +] + +[dependencies] + +pallet-authority-members = { path = "../authority-members", default-features = false } +pallet-certification = { path = "../certification", default-features = false } +pallet-identity = { path = "../identity", default-features = false } +pallet-membership = { path = "../membership", default-features = false } +sp-distance = { path = "../../primitives/distance", default-features = false } + +# substrate +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } + +[dependencies.codec] +default-features = false +features = ['derive'] +package = 'parity-scale-codec' +version = '3.1.5' + +[dependencies.frame-support] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.frame-system] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.pallet-authorship] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.pallet-session] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-core] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-inherents] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-runtime] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-std] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +### DOC ### + +[package.metadata.docs.rs] +targets = ['x86_64-unknown-linux-gnu'] diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs new file mode 100644 index 000000000..85e551b7a --- /dev/null +++ b/pallets/distance/src/lib.rs @@ -0,0 +1,441 @@ +// Copyright 2022 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +#![cfg_attr(not(feature = "std"), no_std)] + +mod median; +mod types; + +use median::*; +pub use pallet::*; +pub use types::*; + +use frame_support::traits::StorageVersion; +use pallet_authority_members::SessionIndex; +use sp_distance::{InherentError, INHERENT_IDENTIFIER}; +use sp_inherents::{InherentData, InherentIdentifier}; +use sp_std::convert::TryInto; + +type IdtyIndex = u32; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + use sp_runtime::Perbill; + + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + #[pallet::storage_version(STORAGE_VERSION)] + #[pallet::without_storage_info] + pub struct Pallet<T, I = ()>(PhantomData<(T, I)>); + #[pallet::config] + pub trait Config<I: 'static = ()>: + frame_system::Config + + pallet_authorship::Config + + pallet_certification::Config<I, IdtyIndex = IdtyIndex> + + pallet_identity::Config<IdtyIndex = IdtyIndex> + + pallet_session::Config + { + /// Number of sessions before starting a new computation + type FinalityLag: Get<u32>; + /// Duration of a computation (in sessions) + type ComputationMaxDelay: Get<u32>; + /// Maximum number of identities to be evaluated in a session + type MaxEvaluationsPerSession: Get<u32>; + /// Maximum number of evaluators in a session + type MaxEvaluatorsPerSession: Get<u32>; + /// Minimum ratio of accessible referees + type MinAccessibleReferees: Get<Perbill>; + /// Because this pallet emits events, it depends on the runtime's definition of an event. + type RuntimeEvent: From<Event<Self, I>> + + IsType<<Self as frame_system::Config>::RuntimeEvent>; + } + + // STORAGE // + + pub type EvaluationPool< + AccountId, + IdtyIndex, + MaxEvaluationsPerSession, + MaxEvaluatorsPerSession, + > = ( + BoundedVec<(IdtyIndex, MedianAcc<Perbill>), MaxEvaluationsPerSession>, + BoundedVec<AccountId, MaxEvaluatorsPerSession>, + ); + + #[pallet::storage] + pub type EvaluationPool0<T: Config<I>, I: 'static = ()> = StorageValue< + _, + EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + >, + ValueQuery, + >; + #[pallet::storage] + pub type EvaluationPool1<T: Config<I>, I: 'static = ()> = StorageValue< + _, + EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + >, + ValueQuery, + >; + #[pallet::storage] + pub type EvaluationPool2<T: Config<I>, I: 'static = ()> = StorageValue< + _, + EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + >, + ValueQuery, + >; + + #[pallet::storage] + pub type EvaluationBlock<T: Config<I>, I: 'static = ()> = + StorageValue<_, <T as frame_system::Config>::Hash, ValueQuery>; + + // TODO replace bool by nothing or smth else + // TODO remove identity from this storage when membership obtained or after schedule or after some event (cert?) + #[pallet::storage] + #[pallet::getter(fn distance_ok_identities)] + pub type DistanceOkIdentities<T: Config<I>, I: 'static = ()> = StorageMap< + _, + Twox64Concat, + <T as pallet_certification::Config<I>>::IdtyIndex, + bool, + ValueQuery, + >; + + // session_index % 3: + // storage_id + 0 => pending + // storage_id + 1 => receives results + // storage_id + 2 => receives new identities + // (this avoids problems for session_index < 3) + + // EVENTS // + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event<T: Config<I>, I: 'static = ()> { + /// Outdistanced + /// [idty] + Outdistanced { + idty: <T as pallet_certification::Config<I>>::IdtyIndex, + }, + /// Distance OK + /// [idty] + DistanceOk { + idty: <T as pallet_certification::Config<I>>::IdtyIndex, + }, + } + + // ERRORS // + + #[pallet::error] + pub enum Error<T, I = ()> { + IdentityNotInEvaluation, + IdtyNotFound, + NonEligibleForEvaluation, + QueueFull, + TooManyEvaluators, + UnauthorizedIdentity, + WrongResultLength, + } + + #[pallet::hooks] + impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {} + + // CALLS // + + #[pallet::call] + impl<T: Config<I>, I: 'static> Pallet<T, I> { + /// Request an identity to be evaluated + #[pallet::weight(1_000_000_000)] + pub fn evaluate_distance( + origin: OriginFor<T>, + idty_index: <T as pallet_certification::Config<I>>::IdtyIndex, + ) -> DispatchResultWithPostInfo { + let _who = ensure_signed(origin)?; + // TODO check whether origin is authorized to request evaluation + + Pallet::<T, I>::do_evaluate_distance(idty_index)?; + Ok(().into()) + } + + /// (Inherent) Push an evaluation result to the pool + #[pallet::weight(1_000_000_000)] + pub fn update_evaluation( + origin: OriginFor<T>, + computation_result: ComputationResult, /*<<T as pallet_identity::Config>::IdtyIndex>*/ + ) -> DispatchResult { + ensure_none(origin)?; + //assert!(!DidUpdate::<T>::exists(), "At most one distance computation result can be submitted per block"); + + // TODO is it better to read and only write when needed, or to write in all cases, even if nothing is actually written? + + Pallet::<T, I>::mutate_current_pool( + pallet_session::CurrentIndex::<T>::get().wrapping_add(1), + |result_pool| { + ensure!( + computation_result.distances.len() == result_pool.0.len(), + Error::<T, I>::WrongResultLength + ); + + result_pool + .1 + .try_push( + pallet_authorship::Pallet::<T>::author() + .expect("Block author is needed to update distance evaluation"), + ) + .map_err(|_| Error::<T, I>::TooManyEvaluators)?; + + for (distance_value, (_identity, median_acc)) in computation_result + .distances + .into_iter() + .zip(result_pool.0.iter_mut()) + { + median_acc.push(distance_value); + /*try_mutate::<_, _, Error<T, I>, _>( + identity, + |median_acc| { + median_acc + .as_mut() + .ok_or(Error::<T, I>::IdentityNotInEvaluation)? + .push(result); + Ok(()) + }, + )?;*/ + } + + Ok(()) + }, + ) + } + } + + // PUBLIC FUNCTIONS // + + impl<T: Config<I>, I: 'static> Pallet<T, I> { + pub fn get_computation_metadata( + ) -> Option<ComputationMetadata /*<<T as frame_system::Config>::Hash>*/> { + None + } + /*pub fn publish_computation_result( + _computation_result: ComputationResult<<T as pallet_identity::Config>::IdtyIndex>, + ) { + }*/ + + pub fn do_evaluate_distance( + idty_index: <T as pallet_certification::Config<I>>::IdtyIndex, + ) -> Result<(), DispatchError> { + // TODO (maybe) check whether identity is already in queue + + Pallet::<T, I>::mutate_current_pool( + pallet_session::CurrentIndex::<T>::get(), + |current_pool| { + ensure!( + current_pool.0.len() + < (<T as Config<I>>::MaxEvaluationsPerSession::get() as usize), + Error::<T, I>::QueueFull + ); + + ensure!( + pallet_identity::Identities::<T>::contains_key(idty_index), + Error::<T, I>::IdtyNotFound + ); + + current_pool + .0 + .try_push((idty_index, median::MedianAcc::new())) + .map_err(|_| Error::<T, I>::QueueFull)?; + + Ok(()) + }, + ) + } + } + + // INTERNAL FUNCTIONS // + + impl<T: Config<I>, I: 'static> Pallet<T, I> { + /// Mutate the evaluation pool containing the results to be applied on this session. + fn mutate_current_pool< + R, + F: FnOnce( + &mut EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + >, + ) -> R, + >( + index: SessionIndex, + f: F, + ) -> R { + match index % 3 { + 0 => EvaluationPool2::<T, I>::mutate(f), + 1 => EvaluationPool0::<T, I>::mutate(f), + 2 => EvaluationPool1::<T, I>::mutate(f), + _ => panic!("index % 3 < 3"), + } + } + + /// Take the evaluation pool containing the results to be applied on this session. + fn take_current_pool( + index: SessionIndex, + ) -> EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + > { + match index % 3 { + 0 => EvaluationPool2::<T, I>::take(), + 1 => EvaluationPool0::<T, I>::take(), + 2 => EvaluationPool1::<T, I>::take(), + _ => panic!("index % 3 < 3"), + } + } + + /*/// Mutate the evaluation pool containing the results to be applied on the next session. + fn mutate_result_pool< + R, + F: FnOnce( + &mut EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + >, + ) -> R, + >( + index: SessionIndex, + f: F, + ) -> R { + (match index % 3 { + 0 => EvaluationPool1::<T, I>::mutate, + 1 => EvaluationPool2::<T, I>::mutate, + 2 => EvaluationPool0::<T, I>::mutate, + _ => panic!("index % 3 < 3"), + })(f) + }*/ + } + + impl<T: Config<I>, I: 'static> pallet_authority_members::OnNewSession for Pallet<T, I> { + fn on_new_session(index: SessionIndex) -> Weight { + EvaluationBlock::<T, I>::set(frame_system::Pallet::<T>::parent_hash()); + + // Apply the results from the current pool (which was previous session's result pool) + // We take the results so the pool is left empty for the new session. + let current_pool: EvaluationPool< + <T as frame_system::Config>::AccountId, + <T as pallet_certification::Config<I>>::IdtyIndex, + <T as Config<I>>::MaxEvaluationsPerSession, + <T as Config<I>>::MaxEvaluatorsPerSession, + > = Pallet::<T, I>::take_current_pool(index); + for (idty, median_acc) in current_pool.0.into_iter() { + if let Some(median_result) = median_acc.get_median() { + let median = match median_result { + MedianResult::One(m) => m, + MedianResult::Two(m1, m2) => m1 + (m2 - m1) / 2, // Avoid overflow (since max is 1) + }; + if median >= T::MinAccessibleReferees::get() { + Self::deposit_event(Event::DistanceOk { idty }); + DistanceOkIdentities::<T, I>::insert(idty, true); + } else { + Self::deposit_event(Event::Outdistanced { idty }); + } + } + } + + // TODO roll between the 3 states simultaneously + /*match index % 3 { + 0 => { + /*EvaluationQueue::<T, I>::drain() + .zip(0..<T as Config<I>>::MaxEvaluationsPerSession::get()) + .map(|((identity, _), _)| identity) + .for_each(|identity| { + EvaluatedIdentities::<T, I>::insert(identity, MedianAcc::new()) + });*/ + Pallet::get_open_pool(index) + .0 + .into_iter() + .for_each(|identity| { + Pallet::get_result_pool(index) + .0 + .try_push((identity, MedianAcc::new())) + .expect("unreachable") + }); + } + 1 => {} + 2 => { + for (_identity, median_acc) in + Pallet::get_result_pool(index).0.into_iter() + { + if let Some(median_result) = median_acc.get_median() { + let median = match median_result { + MedianResult::One(m) => m, + MedianResult::Two(m1, m2) => m1 + (m2 - m1) / 2, // Avoid overflow (since max is 1) + }; + if median >= T::MinAccessibleReferees::get() { + todo!(); + } else { + todo!(); + } + } + } + } + _ => unreachable!("index % 3 < 3"), + }*/ + Weight::zero() + } + } + + #[pallet::inherent] + impl<T: Config<I>, I: 'static> ProvideInherent for Pallet<T, I> { + type Call = Call<T, I>; + type Error = InherentError; + + const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; + + fn create_inherent(data: &InherentData) -> Option<Self::Call> { + data.get_data::<ComputationResult/*<<T as pallet_identity::Config>::IdtyIndex>*/>( + &INHERENT_IDENTIFIER, + ) + .expect("Distance inherent data not correctly encoded") + .map(|inherent_data| { + Call::update_evaluation { + computation_result: inherent_data, + }}) + } + fn is_inherent(call: &Self::Call) -> bool { + matches!(call, Self::Call::update_evaluation { .. }) + } + } +} diff --git a/pallets/distance/src/median.rs b/pallets/distance/src/median.rs new file mode 100644 index 000000000..065efb311 --- /dev/null +++ b/pallets/distance/src/median.rs @@ -0,0 +1,143 @@ +// Copyright 2022 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +use frame_support::pallet_prelude::*; +use sp_std::{cmp::Ordering, vec::Vec}; + +#[derive(Clone, Debug, Decode, Default, Encode, TypeInfo)] +pub struct MedianAcc<T: Clone + Decode + Encode + Ord + TypeInfo> { + samples: Vec<(T, u32)>, + median_index: Option<u32>, + median_subindex: u32, +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum MedianResult<T: Clone + Ord> { + One(T), + Two(T, T), +} + +impl<T: Clone + Decode + Encode + Ord + TypeInfo> MedianAcc<T> { + pub fn new() -> Self { + Self { + samples: Vec::new(), + median_index: None, + median_subindex: 0, + } + } + + pub fn push(&mut self, sample: T) { + if let Some(median_index) = &mut self.median_index { + match self + .samples + .binary_search_by_key(&sample, |(s, _n)| s.clone()) + { + Ok(sample_index) => { + self.samples.get_mut(sample_index).expect("unreachable").1 += 1; + match (sample_index as u32).cmp(median_index) { + Ordering::Greater => { + if self.median_subindex + == self + .samples + .get(*median_index as usize) + .expect("unreachable") + .1 + * 2 + - 1 + { + self.median_subindex = 0; + *median_index += 1; + } else { + self.median_subindex += 1; + } + } + Ordering::Equal => { + self.median_subindex += 1; + } + Ordering::Less => { + if self.median_subindex == 0 { + *median_index -= 1; + self.median_subindex = self + .samples + .get(*median_index as usize) + .expect("unreachable") + .1 + * 2 + - 1; + } else { + self.median_subindex -= 1; + } + } + } + } + Err(sample_index) => { + self.samples.insert(sample_index, (sample, 1)); + if *median_index as usize >= sample_index { + if self.median_subindex == 0 { + self.median_subindex = self + .samples + .get(*median_index as usize) + .expect("unreachable") + .1 + * 2 + - 1; + } else { + self.median_subindex -= 1; + *median_index += 1; + } + } else if self.median_subindex + == self + .samples + .get(*median_index as usize) + .expect("unreachable") + .1 + * 2 + - 1 + { + self.median_subindex = 0; + *median_index += 1; + } else { + self.median_subindex += 1; + } + } + } + } else { + self.samples.push((sample, 1)); + self.median_index = Some(0); + } + } + + pub fn get_median(&self) -> Option<MedianResult<T>> { + self.median_index.map(|median_index| { + let (median_sample, median_n) = self + .samples + .get(median_index as usize) + .expect("unreachable"); + if self.median_subindex == median_n * 2 - 1 { + MedianResult::Two( + median_sample.clone(), + self.samples + .get(median_index as usize + 1) + .expect("unreachable") + .0 + .clone(), + ) + } else { + MedianResult::One(median_sample.clone()) + } + }) + } +} diff --git a/pallets/distance/src/types.rs b/pallets/distance/src/types.rs new file mode 100644 index 000000000..6eecd2513 --- /dev/null +++ b/pallets/distance/src/types.rs @@ -0,0 +1,63 @@ +// Copyright 2022 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +//use crate::median::MedianAcc; + +pub use sp_distance::ComputationResult; + +use codec::{Decode, Encode}; +use frame_support::pallet_prelude::*; +use sp_inherents::IsFatalError; +//use sp_runtime::Perbill; +//use sp_std::vec::Vec; + +#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)] +pub struct ComputationMetadata /*<Hash>*/ { + //pub block_hash: Hash, +} + +// TODO solve this! -> MaxEncodedLen +/*#[derive(Encode, Decode, TypeInfo)] +pub struct PublishedResults<IdtyIndex, MaxEvaluationsPerSession, MaxEvaluatorsPerSession> { + pub distances: BoundedVec< + ( + IdtyIndex, + MedianAcc<Perbill>, + ), + MaxEvaluationsPerSession, + >, + pub evaluators: BoundedVec<IdtyIndex, MaxEvaluatorsPerSession>, +} + +impl<IdtyIndex, MaxEvaluationsPerSession, MaxEvaluatorsPerSession> Default for PublishedResults<IdtyIndex, MaxEvaluationsPerSession, MaxEvaluatorsPerSession> { + fn default() -> Self { + Self { + distances: Default::default(), + evaluators: Default::default(), + } + } +}*/ + +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] +pub enum InherentError { + Foo, +} + +impl IsFatalError for InherentError { + fn is_fatal_error(&self) -> bool { + false + } +} diff --git a/pallets/duniter-wot/Cargo.toml b/pallets/duniter-wot/Cargo.toml index 252e9e8a4..1af0bcfa9 100644 --- a/pallets/duniter-wot/Cargo.toml +++ b/pallets/duniter-wot/Cargo.toml @@ -18,6 +18,7 @@ std = [ 'frame-system/std', 'frame-benchmarking/std', 'pallet-certification/std', + 'pallet-distance/std', 'pallet-identity/std', 'pallet-membership/std', 'serde', @@ -32,11 +33,14 @@ try-runtime = ['frame-support/try-runtime'] [dependencies] pallet-certification = { path = "../certification", default-features = false } pallet-identity = { path = "../identity", default-features = false } +pallet-distance = { path = "../distance", default-features = false } pallet-membership = { path = "../membership", default-features = false } sp-membership = { path = "../../primitives/membership", default-features = false } # substrate -scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +scale-info = { version = "2.1.1", default-features = false, features = [ + "derive", +] } [dependencies.codec] default-features = false diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 50a41c70b..b52fd00c7 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -23,11 +23,15 @@ mod mock; #[cfg(test)] mod tests; +pub mod traits; + /*#[cfg(feature = "runtime-benchmarks")] mod benchmarking;*/ pub use pallet::*; +use traits::*; + use frame_support::dispatch::UnfilteredDispatchable; use frame_support::pallet_prelude::*; use frame_system::RawOrigin; @@ -60,6 +64,8 @@ pub mod pallet { + pallet_identity::Config<IdtyIndex = IdtyIndex> + pallet_membership::Config<I, IdtyId = IdtyIndex> { + /// Distance evaluation provider + type IsDistanceOk: IsDistanceOk<IdtyIndex>; #[pallet::constant] type FirstIssuableOn: Get<Self::BlockNumber>; #[pallet::constant] @@ -242,7 +248,8 @@ impl<T: Config<I>, I: 'static> sp_membership::traits::CheckMembershipCallAllowed fn check_idty_allowed_to_claim_membership(idty_index: &IdtyIndex) -> Result<(), DispatchError> { let idty_cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(idty_index); ensure!( - idty_cert_meta.received_count >= T::MinCertForMembership::get(), + idty_cert_meta.received_count >= T::MinCertForMembership::get() + && T::IsDistanceOk::is_distance_ok(idty_index), Error::<T, I>::IdtyNotAllowedToClaimMembership ); Ok(()) @@ -252,7 +259,8 @@ impl<T: Config<I>, I: 'static> sp_membership::traits::CheckMembershipCallAllowed fn check_idty_allowed_to_renew_membership(idty_index: &IdtyIndex) -> Result<(), DispatchError> { if let Some(idty_value) = pallet_identity::Pallet::<T>::identity(idty_index) { ensure!( - idty_value.status == IdtyStatus::Validated, + idty_value.status == IdtyStatus::Validated + && T::IsDistanceOk::is_distance_ok(idty_index), Error::<T, I>::IdtyNotAllowedToRenewMembership ); } else { diff --git a/pallets/duniter-wot/src/traits.rs b/pallets/duniter-wot/src/traits.rs new file mode 100644 index 000000000..7c3d7b220 --- /dev/null +++ b/pallets/duniter-wot/src/traits.rs @@ -0,0 +1,27 @@ +// Copyright 2023 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +pub trait IsDistanceOk<IdtyId> { + fn is_distance_ok(idty_id: &IdtyId) -> bool; +} + +pub struct DistanceAlwaysOk; + +impl<IdtyId> IsDistanceOk<IdtyId> for DistanceAlwaysOk { + fn is_distance_ok(_idty_id: &IdtyId) -> bool { + true + } +} diff --git a/primitives/distance/Cargo.toml b/primitives/distance/Cargo.toml new file mode 100644 index 000000000..f8ff3e5f3 --- /dev/null +++ b/primitives/distance/Cargo.toml @@ -0,0 +1,67 @@ +[package] +authors = ['librelois <c@elo.tf>'] +description = 'primitives for pallet distance.' +edition = "2021" +homepage = 'https://duniter.org' +license = 'AGPL-3.0' +name = 'sp-distance' +readme = 'README.md' +repository = 'https://git.duniter.org/nodes/rust/duniter-v2s' +version = '3.0.0' + +[features] +default = ['std'] +std = [ + 'async-trait', + 'codec/std', + 'frame-support/std', + 'serde', + 'sp-inherents/std', + 'sp-runtime/std', + 'sp-std/std', + 'thiserror' +] +try-runtime = ['frame-support/try-runtime'] + +[dependencies] +async-trait = { version = "0.1.50", optional = true } +thiserror = { version = "1.0.30", optional = true } + +# substrate +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } + +[dependencies.codec] +default-features = false +features = ['derive'] +package = 'parity-scale-codec' +version = "3.1.5" + +[dependencies.frame-support] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.serde] +version = "1.0.101" +optional = true +features = ["derive"] + +[dependencies.sp-inherents] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-runtime] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +[dependencies.sp-std] +default-features = false +git = 'https://github.com/duniter/substrate' +branch = 'duniter-substrate-v0.9.32' + +### DOC ### + +[package.metadata.docs.rs] +targets = ['x86_64-unknown-linux-gnu'] diff --git a/primitives/distance/src/lib.rs b/primitives/distance/src/lib.rs new file mode 100644 index 000000000..997224181 --- /dev/null +++ b/primitives/distance/src/lib.rs @@ -0,0 +1,110 @@ +// Copyright 2023 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +//! Defines types and traits for users of pallet distance. + +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::type_complexity)] + +use codec::{Decode, Encode}; +use frame_support::RuntimeDebug; +use scale_info::TypeInfo; +//#[cfg(feature = "std")] +//use serde::{Deserialize, Serialize}; +use sp_inherents::{InherentData, InherentIdentifier, IsFatalError}; +use sp_runtime::Perbill; +use sp_std::vec::Vec; +#[cfg(feature = "std")] +use std::marker::PhantomData; + +pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"distanc0"; + +#[derive(Clone, Decode, Encode, PartialEq, RuntimeDebug, TypeInfo)] +pub struct ComputationResult { + pub distances: Vec<Perbill>, +} + +#[derive(Encode, sp_runtime::RuntimeDebug)] +#[cfg_attr(feature = "std", derive(Decode, thiserror::Error))] +pub enum InherentError { + #[cfg_attr(feature = "std", error("InvalidComputationResultFile"))] + InvalidComputationResultFile, +} + +impl IsFatalError for InherentError { + fn is_fatal_error(&self) -> bool { + match self { + InherentError::InvalidComputationResultFile => false, + } + } +} + +impl InherentError { + #[cfg(feature = "std")] + pub fn try_from(id: &InherentIdentifier, mut data: &[u8]) -> Option<Self> { + if id == &INHERENT_IDENTIFIER { + <InherentError as codec::Decode>::decode(&mut data).ok() + } else { + None + } + } +} + +#[cfg(feature = "std")] +pub struct InherentDataProvider<IdtyIndex: Decode + Encode + PartialEq + TypeInfo> { + computation_result: Option<ComputationResult>, + _p: PhantomData<IdtyIndex>, +} + +#[cfg(feature = "std")] +impl<IdtyIndex: Decode + Encode + PartialEq + TypeInfo> InherentDataProvider<IdtyIndex> { + pub fn new(computation_result: Option<ComputationResult>) -> Self { + Self { + computation_result, + _p: PhantomData, + } + } +} + +#[cfg(feature = "std")] +#[async_trait::async_trait] +impl<IdtyIndex: Decode + Encode + PartialEq + TypeInfo + Send + Sync> + sp_inherents::InherentDataProvider for InherentDataProvider<IdtyIndex> +{ + fn provide_inherent_data( + &self, + inherent_data: &mut InherentData, + ) -> Result<(), sp_inherents::Error> { + if let Some(computation_result) = &self.computation_result { + inherent_data.put_data(INHERENT_IDENTIFIER, computation_result)?; + } + Ok(()) + } + + async fn try_handle_error( + &self, + identifier: &InherentIdentifier, + error: &[u8], + ) -> Option<Result<(), sp_inherents::Error>> { + if *identifier != INHERENT_IDENTIFIER { + return None; + } + + Some(Err(sp_inherents::Error::Application(Box::from( + InherentError::try_from(&INHERENT_IDENTIFIER, error)?, + )))) + } +} diff --git a/resources/metadata.scale b/resources/metadata.scale index 6c236f8d95a610f8b1044687302dd08fea17a14d..c5d992edbe02769551ed0a8ba738d79232bccfbe 100644 GIT binary patch delta 7815 zcmZ45z|qmi!JeC1lE}x)x{>`UGo$b1x6HDPfs?seG#Lvvo3g00$SSyG7MCREC8x45 zh%z$1DM-x8NiB&_fe23KXO|R%vQw?BJo6w*4ec0oCMV_!GfGa*=Llq!oqUiZl2LK8 zG^a76?qq*XOBPc`#)iqY9+H!natblpPTs+(!{|EsDW@8v=Vl(R*M<T%sMe%T{$M6r z&tc$SS^~2yg@sWdGo_?bfbob;h(cnq0#rwGYEemMT4r)$NoIbYm6daTURq|lji;TR zm6c~oNu_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nk;P6VpeVnhk`Y32$bfj6sl|+pEUXNv z)0_V=?qMvQ?(mn<5;P!bxxMx;V+)I5D~r8MXh~*HW=SOj<6S03$LT^$OrDIL(_@&J z(inTEA7)}QV4OJp3lo!z$VVndS4J6w0BC>SDL*e|>UJMyCT&K>nbRv+m?kq$ozBC` z6vjArdon8%D`Wja7RRM5ED9d5vMnmLC_flHyttO7!vQQBT#%X^mReMtnV+|jMZf|q z7E%Ef*~%hd02Xmi%}XuLEZ)hY08!zaUsRF^a`Rpm1r4wYaLIX;r9%hIgOp>;7g;){ P^RHl(WWCDLagqf9t^gU^ diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 4a7412e77..bb74d5ea4 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -8,11 +8,11 @@ edition = "2021" [features] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", 'frame-support/runtime-benchmarks', 'frame-system-benchmarking/runtime-benchmarks', 'frame-system/runtime-benchmarks', - "pallet-babe/runtime-benchmarks", + "pallet-babe/runtime-benchmarks", 'pallet-balances/runtime-benchmarks', 'pallet-certification/runtime-benchmarks', 'pallet-collective/runtime-benchmarks', @@ -38,6 +38,7 @@ std = [ 'pallet-babe/std', 'pallet-balances/std', 'pallet-certification/std', + 'pallet-distance/std', 'pallet-duniter-account/std', 'pallet-duniter-wot/std', 'pallet-grandpa/std', @@ -50,27 +51,29 @@ std = [ 'pallet-scheduler/std', 'pallet-timestamp/std', 'pallet-treasury/std', - 'pallet-universal-dividend/std', - "serde/std", - "serde_derive", + 'pallet-universal-dividend/std', + "serde/std", + "serde_derive", 'sp-arithmetic/std', 'sp-core/std', + 'sp-distance/std', 'sp-membership/std', 'sp-runtime/std', 'sp-std/std', 'sp-weights/std', ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "pallet-babe/try-runtime", - "pallet-grandpa/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-babe/try-runtime", + "pallet-grandpa/try-runtime", ] [dependencies] duniter-primitives = { path = '../../primitives/duniter', default-features = false } pallet-authority-members = { path = '../../pallets/authority-members', default-features = false } pallet-certification = { path = '../../pallets/certification', default-features = false } +pallet-distance = { path = "../../pallets/distance", default-features = false } pallet-duniter-account = { path = '../../pallets/duniter-account', default-features = false } pallet-duniter-wot = { path = '../../pallets/duniter-wot', default-features = false } pallet-identity = { path = '../../pallets/identity', default-features = false } @@ -80,12 +83,17 @@ pallet-provide-randomness = { path = '../../pallets/provide-randomness', default pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-session-benchmarking = { path = '../../pallets/session-benchmarking', default-features = false } +sp-distance = { path = '../../primitives/distance', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false } # Crates.io -codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"], default-features = false } +codec = { package = "parity-scale-codec", version = "3.1.5", features = [ + "derive", +], default-features = false } log = { version = "0.4.14", default-features = false } -scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +scale-info = { version = "2.1.1", default-features = false, features = [ + "derive", +] } serde = { version = "1.0.101", default-features = false } serde_derive = { version = "1.0.101", optional = true } smallvec = "1.6.1" diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index 95a6ccabd..e573fec14 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -28,11 +28,11 @@ use sp_runtime::traits::IsMember; pub struct OnNewSessionHandler<Runtime>(core::marker::PhantomData<Runtime>); impl<Runtime> pallet_authority_members::traits::OnNewSession for OnNewSessionHandler<Runtime> where - Runtime: pallet_provide_randomness::Config, + Runtime: pallet_provide_randomness::Config + pallet_distance::Config<Instance1>, { - fn on_new_session(_index: sp_staking::SessionIndex) -> Weight { + fn on_new_session(index: sp_staking::SessionIndex) -> Weight { pallet_provide_randomness::Pallet::<Runtime>::on_new_epoch(); - Weight::zero() + pallet_distance::Pallet::<Runtime, Instance1>::on_new_session(index) } } diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index f289dfac1..3833ba992 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -432,6 +432,7 @@ macro_rules! pallets_config { use frame_support::instances::Instance1; impl pallet_duniter_wot::Config<Instance1> for Runtime { type FirstIssuableOn = WotFirstCertIssuableOn; + type IsDistanceOk = common_runtime::providers::MainWotIsDistanceOk<Runtime, Instance1>; type IsSubWot = frame_support::traits::ConstBool<false>; type MinCertForMembership = WotMinCertForMembership; type MinCertForCreateIdtyRight = WotMinCertForCreateIdtyRight; @@ -481,12 +482,26 @@ macro_rules! pallets_config { type WeightInfo = common_runtime::weights::pallet_certification_cert::WeightInfo<Runtime>; type ValidityPeriod = ValidityPeriod; } + parameter_types! { + pub const MinAccessibleReferees: Perbill = Perbill::from_percent(80); + } + impl pallet_distance::Config<Instance1> for Runtime { + //type IdtyIndex: IdtyIndex; + type FinalityLag = frame_support::traits::ConstU32<1>; + type ComputationMaxDelay = frame_support::traits::ConstU32<1>; + //type QueueSize = frame_support::traits::ConstU32<800>; + type MaxEvaluationsPerSession = frame_support::traits::ConstU32<100>; + type MaxEvaluatorsPerSession = frame_support::traits::ConstU32<100>;// TODO <= number of blocks per session + type MinAccessibleReferees = MinAccessibleReferees; + type RuntimeEvent = RuntimeEvent; + } // SMITHS SUB-WOT // use frame_support::instances::Instance2; impl pallet_duniter_wot::Config<Instance2> for Runtime { type FirstIssuableOn = SmithWotFirstCertIssuableOn; + type IsDistanceOk = pallet_duniter_wot::traits::DistanceAlwaysOk; type IsSubWot = frame_support::traits::ConstBool<true>; type MinCertForMembership = SmithWotMinCertForMembership; type MinCertForCreateIdtyRight = frame_support::traits::ConstU32<0>; diff --git a/runtime/common/src/providers.rs b/runtime/common/src/providers.rs index 4582513b9..7bcfd6d74 100644 --- a/runtime/common/src/providers.rs +++ b/runtime/common/src/providers.rs @@ -106,3 +106,17 @@ where } } } + +pub struct MainWotIsDistanceOk<T, I>(PhantomData<(T, I)>); + +impl<T, I> + pallet_duniter_wot::traits::IsDistanceOk<<T as pallet_certification::Config<I>>::IdtyIndex> + for MainWotIsDistanceOk<T, I> +where + T: pallet_distance::Config<I>, + I: 'static, +{ + fn is_distance_ok(idty_id: &<T as pallet_certification::Config<I>>::IdtyIndex) -> bool { + pallet_distance::Pallet::<T, I>::distance_ok_identities(idty_id) + } +} diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index 8c8fd7788..71b927566 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -50,7 +50,7 @@ runtime-benchmarks = [ ] std = [ 'codec/std', - 'common-runtime/std', + 'common-runtime/std', 'frame-executive/std', 'frame-support/std', 'frame-system-rpc-runtime-api/std', @@ -64,6 +64,7 @@ std = [ 'pallet-balances/std', 'pallet-certification/std', 'pallet-collective/std', + 'pallet-distance/std', 'pallet-duniter-test-parameters/std', 'pallet-duniter-account/std', 'pallet-duniter-wot/std', @@ -74,10 +75,10 @@ std = [ 'pallet-provide-randomness/std', 'pallet-im-online/std', 'pallet-multisig/std', - "pallet-offences/std", + "pallet-offences/std", 'pallet-preimage/std', 'pallet-proxy/std', - "pallet-scheduler/std", + "pallet-scheduler/std", 'pallet-session/std', 'pallet-sudo/std', 'pallet-universal-dividend/std', @@ -87,14 +88,15 @@ std = [ 'pallet-transaction-payment/std', 'pallet-treasury/std', 'pallet-utility/std', - "serde/std", - "serde_derive", + "serde/std", + "serde_derive", 'sp-api/std', 'sp-arithmetic/std', 'sp-authority-discovery/std', 'sp-block-builder/std', 'sp-consensus-babe/std', 'sp-core/std', + 'sp-distance/std', 'sp-inherents/std', 'sp-offchain/std', 'sp-membership/std', @@ -138,6 +140,7 @@ sp-keyring = { git = 'https://github.com/duniter/substrate', branch = 'duniter-s common-runtime = { path = "../common", default-features = false } pallet-authority-members = { path = '../../pallets/authority-members', default-features = false } pallet-certification = { path = '../../pallets/certification', default-features = false } +pallet-distance = { path = "../../pallets/distance", default-features = false } pallet-duniter-test-parameters = { path = '../../pallets/duniter-test-parameters', default-features = false } pallet-duniter-account = { path = '../../pallets/duniter-account', default-features = false } pallet-duniter-wot = { path = '../../pallets/duniter-wot', default-features = false } @@ -149,13 +152,18 @@ pallet-provide-randomness = { path = '../../pallets/provide-randomness', default pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-session-benchmarking = { path = '../../pallets/session-benchmarking', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } +sp-distance = { path = '../../primitives/distance', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false } # crates.io -codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"], default-features = false } +codec = { package = "parity-scale-codec", version = "3.1.5", features = [ + "derive", +], default-features = false } log = { version = "0.4.17", default-features = false } hex-literal = { version = '0.3.1', optional = true } -scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +scale-info = { version = "2.1.1", default-features = false, features = [ + "derive", +] } serde = { version = "1.0.101", default-features = false } serde_derive = { version = "1.0.101", optional = true } @@ -164,7 +172,7 @@ frame-try-runtime = { git = 'https://github.com/duniter/substrate', branch = 'du frame-executive = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } frame-support = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } frame-system = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } -frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false} +frame-system-rpc-runtime-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } pallet-atomic-swap = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } pallet-authority-discovery = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } pallet-authorship = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.32', default-features = false } diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 770191a20..261d27292 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -336,6 +336,7 @@ construct_runtime!( Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>} = 41, Membership: pallet_membership::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, Cert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, + Distance: pallet_distance::<Instance1>::{Pallet, Call, Storage, Event<T>, Inherent} = 44, // Smith Sub-Wot SmithSubWot: pallet_duniter_wot::<Instance2>::{Pallet} = 50, -- GitLab