From 0c3b5ccb09140ae079202794e9d9bc22ab2dd966 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 2 Nov 2021 15:18:31 -0400 Subject: [PATCH 01/52] checkpoint. Gonna try switching to preruntime digest first --- Cargo.lock | 360 +++++++++++++++---------- parachain-template/node/Cargo.toml | 1 + parachain-template/node/src/service.rs | 128 ++++++++- 3 files changed, 338 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 243f5f1e..019efb89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -456,7 +456,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "beefy-primitives", "fnv", @@ -484,7 +484,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -504,12 +504,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -1956,7 +1956,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", ] @@ -1974,7 +1974,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -1994,7 +1994,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "Inflector", "chrono", @@ -2020,7 +2020,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "bitflags", "frame-metadata", @@ -2077,6 +2077,7 @@ dependencies = [ "smallvec 1.7.0", "sp-arithmetic", "sp-core", + "sp-core-hashing-proc-macro", "sp-inherents", "sp-io", "sp-runtime", @@ -2090,7 +2091,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2102,7 +2103,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.1.0", @@ -2114,7 +2115,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "proc-macro2", "quote", @@ -2124,7 +2125,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "log", @@ -2141,7 +2142,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -2156,7 +2157,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "sp-api", @@ -2165,7 +2166,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "sp-api", @@ -4500,7 +4501,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4516,7 +4517,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4531,7 +4532,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4555,7 +4556,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4570,7 +4571,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4585,7 +4586,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "beefy-primitives", "frame-support", @@ -4601,7 +4602,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4626,7 +4627,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4663,7 +4664,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4680,7 +4681,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4696,7 +4697,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4716,7 +4717,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4733,7 +4734,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4756,7 +4757,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "enumflags2", "frame-benchmarking", @@ -4772,7 +4773,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4791,7 +4792,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4807,7 +4808,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4824,7 +4825,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -4842,7 +4843,7 @@ dependencies = [ [[package]] name = "pallet-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4858,7 +4859,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -4875,7 +4876,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4889,7 +4890,7 @@ dependencies = [ [[package]] name = "pallet-nicks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4903,7 +4904,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4920,7 +4921,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4934,7 +4935,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4948,7 +4949,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -4964,7 +4965,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -4985,7 +4986,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-election-provider-support", "frame-support", @@ -5006,7 +5007,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -5017,7 +5018,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -5046,7 +5047,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-benchmarking", "frame-support", @@ -5064,7 +5065,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -5082,7 +5083,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -5099,7 +5100,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5116,7 +5117,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5127,7 +5128,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -5143,7 +5144,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -5158,7 +5159,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-support", "frame-system", @@ -5232,6 +5233,7 @@ dependencies = [ "sc-cli", "sc-client-api", "sc-consensus", + "sc-consensus-manual-seal", "sc-executor", "sc-keystore", "sc-network", @@ -7343,7 +7345,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "env_logger 0.9.0", "jsonrpsee-proc-macros", @@ -7536,7 +7538,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "log", "sp-core", @@ -7547,7 +7549,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "derive_more", @@ -7574,7 +7576,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -7597,7 +7599,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -7613,7 +7615,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -7630,7 +7632,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -7641,7 +7643,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "chrono", "fdlimit", @@ -7679,7 +7681,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "fnv", "futures 0.3.17", @@ -7707,7 +7709,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "hash-db", "kvdb", @@ -7732,7 +7734,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "futures 0.3.17", @@ -7756,7 +7758,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "derive_more", @@ -7799,7 +7801,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "derive_more", "futures 0.3.17", @@ -7823,7 +7825,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "fork-tree", "parity-scale-codec", @@ -7833,10 +7835,44 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "sc-consensus-manual-seal" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" +dependencies = [ + "assert_matches", + "async-trait", + "derive_more", + "futures 0.3.17", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-transaction-pool", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "sp-timestamp", + "substrate-prometheus-endpoint", +] + [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "futures 0.3.17", @@ -7862,7 +7898,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "sc-client-api", "sp-authorship", @@ -7873,7 +7909,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "lazy_static", "libsecp256k1 0.6.0", @@ -7885,6 +7921,7 @@ dependencies = [ "sc-executor-wasmtime", "sp-api", "sp-core", + "sp-core-hashing-proc-macro", "sp-externalities", "sp-io", "sp-panic-handler", @@ -7899,7 +7936,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "derive_more", "environmental", @@ -7917,7 +7954,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "log", "parity-scale-codec", @@ -7933,7 +7970,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "cfg-if 1.0.0", "libc", @@ -7951,7 +7988,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "derive_more", @@ -7988,7 +8025,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "derive_more", "finality-grandpa", @@ -8012,7 +8049,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "ansi_term 0.12.1", "futures 0.3.17", @@ -8029,7 +8066,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "derive_more", @@ -8044,7 +8081,7 @@ dependencies = [ [[package]] name = "sc-light" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "hash-db", "parity-scale-codec", @@ -8062,7 +8099,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-std", "async-trait", @@ -8113,7 +8150,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -8129,7 +8166,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "bytes 1.1.0", "fnv", @@ -8157,7 +8194,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "libp2p", @@ -8170,7 +8207,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8179,7 +8216,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "hash-db", @@ -8210,7 +8247,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "jsonrpc-core", @@ -8235,7 +8272,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "jsonrpc-core", @@ -8252,7 +8289,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "directories", @@ -8316,7 +8353,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "log", "parity-scale-codec", @@ -8330,7 +8367,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -8352,7 +8389,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "chrono", "futures 0.3.17", @@ -8370,7 +8407,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "ansi_term 0.12.1", "atty", @@ -8401,7 +8438,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -8412,7 +8449,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "intervalier", @@ -8439,7 +8476,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "derive_more", "futures 0.3.17", @@ -8453,7 +8490,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "futures-timer 3.0.2", @@ -8878,7 +8915,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "hash-db", "log", @@ -8895,7 +8932,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "blake2-rfc", "proc-macro-crate 1.1.0", @@ -8907,7 +8944,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -8920,7 +8957,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "integer-sqrt", "num-traits", @@ -8935,7 +8972,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -8948,7 +8985,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "parity-scale-codec", @@ -8960,7 +8997,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "sp-api", @@ -8972,7 +9009,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "log", @@ -8990,7 +9027,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "futures 0.3.17", @@ -9009,7 +9046,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "merlin", @@ -9032,7 +9069,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -9043,7 +9080,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -9055,7 +9092,7 @@ dependencies = [ [[package]] name = "sp-core" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "base58", "bitflags", @@ -9084,6 +9121,7 @@ dependencies = [ "secrecy", "serde", "sha2 0.9.8", + "sp-core-hashing", "sp-debug-derive", "sp-externalities", "sp-runtime-interface", @@ -9099,10 +9137,34 @@ dependencies = [ "zeroize", ] +[[package]] +name = "sp-core-hashing" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" +dependencies = [ + "blake2-rfc", + "byteorder", + "sha2 0.9.8", + "sp-std", + "tiny-keccak", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing", + "syn", +] + [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "kvdb", "parking_lot 0.11.2", @@ -9111,7 +9173,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "proc-macro2", "quote", @@ -9121,7 +9183,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "environmental", "parity-scale-codec", @@ -9132,7 +9194,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "finality-grandpa", "log", @@ -9150,7 +9212,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -9164,7 +9226,7 @@ dependencies = [ [[package]] name = "sp-io" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "futures 0.3.17", "hash-db", @@ -9188,7 +9250,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "lazy_static", "sp-core", @@ -9199,7 +9261,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "derive_more", @@ -9216,7 +9278,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "zstd", ] @@ -9224,7 +9286,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -9239,7 +9301,7 @@ dependencies = [ [[package]] name = "sp-npos-elections-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", @@ -9250,7 +9312,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "sp-api", "sp-core", @@ -9260,7 +9322,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "backtrace", "lazy_static", @@ -9270,7 +9332,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "rustc-hash", "serde", @@ -9280,7 +9342,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "either", "hash256-std-hasher", @@ -9302,7 +9364,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -9319,7 +9381,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "Inflector", "proc-macro-crate 1.1.0", @@ -9331,7 +9393,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "serde", "serde_json", @@ -9340,7 +9402,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -9354,7 +9416,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "scale-info", @@ -9365,7 +9427,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "hash-db", "log", @@ -9388,12 +9450,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" [[package]] name = "sp-storage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9406,7 +9468,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "log", "sp-core", @@ -9419,7 +9481,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "futures-timer 3.0.2", @@ -9435,7 +9497,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "sp-std", @@ -9447,7 +9509,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "sp-api", "sp-runtime", @@ -9456,7 +9518,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "log", @@ -9472,7 +9534,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "hash-db", "memory-db", @@ -9487,7 +9549,7 @@ dependencies = [ [[package]] name = "sp-version" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9503,7 +9565,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -9514,7 +9576,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -9680,7 +9742,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "platforms", ] @@ -9688,7 +9750,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.17", @@ -9710,7 +9772,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-std", "derive_more", @@ -9724,7 +9786,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "async-trait", "futures 0.3.17", @@ -9751,7 +9813,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "ansi_term 0.12.1", "build-helper", @@ -10107,7 +10169,7 @@ dependencies = [ "chrono", "lazy_static", "matchers", - "parking_lot 0.11.2", + "parking_lot 0.9.0", "regex", "serde", "serde_json", @@ -10194,7 +10256,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#4b40c2aa05930a0aae5a7eb0c50a596a44eb6fb1" +source = "git+https://github.com/paritytech/substrate?branch=master#635c187e8f92a239772ffd70d7a445e073f8920f" dependencies = [ "jsonrpsee-ws-client", "log", diff --git a/parachain-template/node/Cargo.toml b/parachain-template/node/Cargo.toml index 9b95c922..2075a104 100644 --- a/parachain-template/node/Cargo.toml +++ b/parachain-template/node/Cargo.toml @@ -50,6 +50,7 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate ## Substrate Client Dependencies sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 78e0a12e..62e546b3 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -19,6 +19,7 @@ use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; use cumulus_primitives_core::ParaId; +use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider; // Substrate Imports use sc_executor::NativeElseWasmExecutor; @@ -29,6 +30,8 @@ use sp_api::ConstructRuntimeApi; use sp_keystore::SyncCryptoStorePtr; use sp_runtime::traits::BlakeTwo256; use substrate_prometheus_endpoint::Registry; +use sc_consensus_manual_seal::{run_instant_seal, InstantSealParams}; +use sp_core::H256; /// Native executor instance. pub struct TemplateRuntimeExecutor; @@ -56,7 +59,7 @@ pub fn new_partial( PartialComponents< TFullClient>, TFullBackend, - (), + sc_consensus::LongestChain, Block>, sc_consensus::DefaultImportQueue< Block, TFullClient>, @@ -117,6 +120,10 @@ where telemetry }); + // Although this will not be used by the parachain collator, it will be used by the instant seal + // And sovereign nodes, so we create it anyway. + let select_chain = sc_consensus::LongestChain::new(backend.clone()); + let transaction_pool = sc_transaction_pool::BasicPool::new_full( config.transaction_pool.clone(), config.role.is_authority().into(), @@ -144,7 +151,7 @@ where keystore_container, task_manager, transaction_pool, - select_chain: (), + select_chain, other: (telemetry, telemetry_worker_handle), }; @@ -403,3 +410,120 @@ pub async fn start_parachain_node( ) .await } + +/// Builds a new service for a full client. +pub fn start_instant_seal_node(config: Configuration) -> Result { + let sc_service::PartialComponents { + client, + backend, + mut task_manager, + import_queue, + keystore_container, + select_chain,//TODO this isn't used right? + transaction_pool, + other: (telemetry, _), + .. + } = new_partial(&config)?; + + let (network, network_status_sinks, network_starter) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: None, + block_announce_validator_builder: None, + warp_sync: None, + })?; + + if config.offchain_worker.enabled { + sc_service::build_offchain_workers( + &config, + task_manager.spawn_handle(), + client.clone(), + network.clone(), + ); + } + + let is_authority = config.role.is_authority(); + let prometheus_registry = config.prometheus_registry().cloned(); + + let rpc_extensions_builder = { + let client = client.clone(); + let transaction_pool = transaction_pool.clone(); + + Box::new(move |deny_unsafe, _| { + let deps = crate::rpc::FullDeps { + client: client.clone(), + pool: transaction_pool.clone(), + deny_unsafe, + }; + + Ok(crate::rpc::create_full(deps)) + }) + }; + + sc_service::spawn_tasks(sc_service::SpawnTasksParams { + network, + client: client.clone(), + keystore: keystore_container.sync_keystore(), + task_manager: &mut task_manager, + transaction_pool: transaction_pool.clone(), + rpc_extensions_builder, + on_demand: None, + remote_blockchain: None, + backend, + system_rpc_tx, + config, + telemetry, + })?; + + if is_authority { + let proposer = sc_basic_authorship::ProposerFactory::new( + task_manager.spawn_handle(), + client.clone(), + transaction_pool.clone(), + prometheus_registry.as_ref(), + ); + + let authorship_future = run_instant_seal(InstantSealParams { + block_import: client.clone(), + env: proposer, + client, + pool: transaction_pool.pool().clone(), + select_chain, + consensus_data_provider: None, + create_inherent_data_providers, + }); + + task_manager + .spawn_essential_handle() + .spawn_blocking("instant-seal", authorship_future); + }; + + network_starter.start_network(); + Ok(task_manager) +} + +//I got a pretty good start here, but I'm realizing that I shoould pivot away from inehrents sooner rather than later. +// I'm gonna check this in so I have it somewhere, but then sstart working on the inherent approach first. +fn create_inherent_data_providers(block: H256, _extra_args: ()) -> sp_inherents::CreateInherentDataProviders { + let author_id = crate::chain_spec::get_collator_keys_from_seed("Alice"); + + async move { + let time = sp_timestamp::InherentDataProvider::from_system_time(); + + // The nimbus runtime is shared among all nodes including the parachain node. + // Because this is not a parachain context, we need to mock the parachain inherent data provider. + let mocked_parachain = MockValidationDataInherentDataProvider { + current_para_block: 0, + relay_offset: 0, + relay_blocks_per_para_block: 0, + }; + + let author = nimbus_primitives::InherentDataProvider::(author_id); + + Ok((time, mocked_parachain, author)) + } +} \ No newline at end of file From 699f27d920e3246b3bbcb1115ae0615a9072c1ed Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 2 Nov 2021 16:23:44 -0400 Subject: [PATCH 02/52] pallet allows preruntime digests and validates at end of block --- pallets/author-inherent/src/lib.rs | 49 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 52a67ed8..c654af89 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -20,16 +20,14 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{ - traits::FindAuthor, +use frame_support::traits::FindAuthor; +use log::debug; +use nimbus_primitives::{ + AccountLookup, CanAuthor, EventHandler, SlotBeacon, INHERENT_IDENTIFIER, NIMBUS_ENGINE_ID, }; use parity_scale_codec::{Decode, Encode}; use sp_inherents::{InherentIdentifier, IsFatalError}; -use sp_runtime::{ - ConsensusEngineId, DigestItem, RuntimeString, RuntimeAppPublic, -}; -use log::debug; -use nimbus_primitives::{AccountLookup, CanAuthor, NIMBUS_ENGINE_ID, SlotBeacon, EventHandler, INHERENT_IDENTIFIER}; +use sp_runtime::{ConsensusEngineId, DigestItem, RuntimeAppPublic, RuntimeString}; mod exec; pub use exec::BlockExecutor; @@ -90,7 +88,6 @@ pub mod pallet { CannotBeAuthor, } - /// Author of current block. #[pallet::storage] pub type Author = StorageValue<_, T::AccountId, OptionQuery>; @@ -101,14 +98,23 @@ pub mod pallet { >::kill(); 0 } + + fn on_finalize(_: T::BlockNumber) { + // Because we still support the author inherent, we cannot ensure that some author has been + // set until on_finalize TODO Actually, maybe we could do this on post inherent.... Gotta look into that + // TODO this should be moved into `on_initialize` after support for the author inehrent is dropped entirely + assert!( + >::get().is_some(), + "Block invalid, no authorship information supplied." + ) + } } #[pallet::call] impl Pallet { /// Inherent to set the author of a block - #[pallet::weight((0, DispatchClass::Mandatory))] + #[pallet::weight(0)] pub fn set_author(origin: OriginFor, author: T::AuthorId) -> DispatchResult { - ensure_none(origin)?; ensure!(>::get().is_none(), Error::::AuthorAlreadySet); @@ -176,9 +182,21 @@ pub mod pallet { where I: 'a + IntoIterator, { - // We don't use the digests at all. - // This will only return the correct author _after_ the authorship inherent is processed. - >::get() + // We don't use the digests at all for two reasons: + // 1. We still support the author inherent which means the authorship info may not be available from the digests + // 2. We want to memoize the result so that we don't continually re-calculate it. + if let Some(author) = >::get() { + Some(author) + } else { + let digest = >::digest(); + let mut pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); + pre_runtime_digests + .find(|(id, _)| id == &NIMBUS_ENGINE_ID) + .map(|(_, mut data)| { + T::AccountId::decode(&mut data) + .expect("account encoded in preruntime digest must be valid") + }) + } } } @@ -225,7 +243,6 @@ impl InherentError { } } - #[cfg(test)] mod tests { use super::*; @@ -235,14 +252,14 @@ mod tests { assert_noop, assert_ok, parameter_types, traits::{OnFinalize, OnInitialize}, }; + use nimbus_primitives::NimbusId; + use sp_core::Public; use sp_core::H256; use sp_io::TestExternalities; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, }; - use nimbus_primitives::NimbusId; - use sp_core::Public; const TEST_AUTHOR_ID: [u8; 32] = [0u8; 32]; const BOGUS_AUTHOR_ID: [u8; 32] = [1u8; 32]; From ce3e0cc45a2b848c02d37b43664e51a83613510a Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 2 Nov 2021 21:33:48 -0400 Subject: [PATCH 03/52] remove incorrect comment --- parachain-template/node/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 62e546b3..853d496f 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -419,7 +419,7 @@ pub fn start_instant_seal_node(config: Configuration) -> Result Date: Tue, 2 Nov 2021 23:52:57 -0400 Subject: [PATCH 04/52] factor slot prediction into helper function, start sketching manual seal consensus data provider --- Cargo.lock | 1 + nimbus-consensus/Cargo.toml | 1 + nimbus-consensus/src/lib.rs | 164 +++++++++++++++---------- nimbus-consensus/src/manual_seal.rs | 56 +++++++++ parachain-template/node/src/service.rs | 53 +++++--- 5 files changed, 192 insertions(+), 83 deletions(-) create mode 100644 nimbus-consensus/src/manual_seal.rs diff --git a/Cargo.lock b/Cargo.lock index 019efb89..c722cfff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4249,6 +4249,7 @@ dependencies = [ "polkadot-client", "sc-client-api", "sc-consensus", + "sc-consensus-manual-seal", "sp-api", "sp-application-crypto", "sp-block-builder", diff --git a/nimbus-consensus/Cargo.toml b/nimbus-consensus/Cargo.toml index eb526ac8..406b0bbb 100644 --- a/nimbus-consensus/Cargo.toml +++ b/nimbus-consensus/Cargo.toml @@ -15,6 +15,7 @@ sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = " sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 5af440d2..35e035ea 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -33,6 +33,7 @@ use parking_lot::Mutex; use polkadot_client::ClientHandle; use sc_client_api::Backend; use sp_api::{ProvideRuntimeApi, BlockId, ApiExt}; +use sp_application_crypto::CryptoTypePublicPair; use sp_consensus::{ BlockOrigin, EnableProofRecording, Environment, ProofRecording, Proposal, Proposer, @@ -44,9 +45,11 @@ use std::{marker::PhantomData, sync::Arc, time::Duration}; use tracing::error; use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore}; use sp_core::crypto::Public; +//TODO Shouldn't this come from `std` and not need `sp-std` at all? use sp_std::convert::TryInto; use nimbus_primitives::{NimbusApi, NIMBUS_KEY_ID, NimbusId}; mod import_queue; +mod manual_seal; const LOG_TARGET: &str = "filtering-consensus"; @@ -153,6 +156,97 @@ where } } +/// Grabs any available nimbus key fro mthe keystore. +/// This may be useful in situations where you expect exactly one key +/// and intend to perform an operation with it regardless of whether it is +/// expected to be eligible. Concretely, this is used in the consensus worker +/// to implement the `skip_prediction` feature. +pub(crate) fn first_available_key(keystore: &dyn SyncCryptoStore) -> Option { + // Get allthe available keys + let available_keys = + SyncCryptoStore::keys(keystore, NIMBUS_KEY_ID) + .expect("keystore should return the keys it has"); + + // Print a more helpful message than "not eligible" when there are no keys at all. + if available_keys.is_empty() { + warn!(target: LOG_TARGET, "🔏 No Nimbus keys available. We will not be able to author."); + return None; + } + + Some(available_keys[1].clone()) +} + +/// Grab the first eligible nimbus key from the keystore +/// If multiple keys are eligible this function still only returns one +/// and makes no guarantees which one as that depends on the keystore's iterator behavior. +/// This is the standard way of determining which key to author with. +pub(crate) fn first_eligible_key(client: Arc, keystore: &dyn SyncCryptoStore, parent: &B::Header, slot_number: u32) -> Option +where + C: ProvideRuntimeApi, + C::Api: NimbusApi, +{ + // Get allthe available keys + let available_keys = + SyncCryptoStore::keys(keystore, NIMBUS_KEY_ID) + .expect("keystore should return the keys it has"); + + // Print a more helpful message than "not eligible" when there are no keys at all. + if available_keys.is_empty() { + warn!(target: LOG_TARGET, "🔏 No Nimbus keys available. We will not be able to author."); + return None; + } + + // Get `NimbusApi` version. + let api_version = client.runtime_api() + .api_version::>(&BlockId::Hash(parent.hash())) + .expect("Runtime api access to not error."); + + if api_version.is_none() { + tracing::error!( + target: LOG_TARGET, "Could not find `NimbusApi` version.", + ); + return None; + } + let api_version = api_version.unwrap(); + + // Iterate keys until we find an eligible one, or run out of candidates. + // If we are skipping prediction, then we author withthe first key we find. + // prediction skipping only really amkes sense when there is a single key in the keystore. + //TODO I think there is a nicer way to do this than handle the type_public_pair. We only use the .1 field + let maybe_key = available_keys.into_iter().find(|type_public_pair| { + + // Have to convert to a typed NimbusId to pass to the runtime API. Maybe this is a clue + // That I should be passing Vec across the wasm boundary? + if api_version >= 2 { + client.runtime_api().can_author( + &BlockId::Hash(parent.hash()), + NimbusId::from_slice(&type_public_pair.1), + slot_number, + parent, + ) + .expect("Author API should not return error") + } else { + #[allow(deprecated)] + client.runtime_api().can_author_before_version_2( + &BlockId::Hash(parent.hash()), + NimbusId::from_slice(&type_public_pair.1), + slot_number, + ) + .expect("Author API version 2 should not return error") + } + }); + + // If there are no eligible keys, print the log, and exit early. + if maybe_key.is_none() { + info!( + target: LOG_TARGET, + "🔮 Skipping candidate production because we are not eligible" + ); + } + + maybe_key +} + #[async_trait::async_trait] impl ParachainConsensus for NimbusConsensus @@ -179,74 +273,16 @@ where relay_parent: PHash, validation_data: &PersistedValidationData, ) -> Option> { - // Design decision: We will check the keystore for any available keys. Then we will iterate - // those keys until we find one that is eligible. If none are eligible, we skip this slot. - // If multiple are eligible, we only author with the first one. - - // Get allthe available keys - let available_keys = - SyncCryptoStore::keys(&*self.keystore, NIMBUS_KEY_ID) - .expect("keystore should return the keys it has"); - - // Print a more helpful message than "not eligible" when there are no keys at all. - if available_keys.is_empty() { - warn!(target: LOG_TARGET, "🔏 No Nimbus keys available. We will not be able to author."); - return None; - } - - let at = BlockId::Hash(parent.hash()); - // Get `NimbusApi` version. - let api_version = self.parachain_client.runtime_api() - .api_version::>(&at) - .expect("Runtime api access to not error."); - - if api_version.is_none() { - tracing::error!( - target: LOG_TARGET, "Could not find `NimbusApi` version.", - ); - return None; + let maybe_key = if self.skip_prediction { + first_available_key(&*self.keystore) } - let api_version = api_version.unwrap(); - - // Iterate keys until we find an eligible one, or run out of candidates. - // If we are skipping prediction, then we author withthe first key we find. - // prediction skipping only really amkes sense when there is a single key in the keystore. - let maybe_key = available_keys.into_iter().find(|type_public_pair| { - - // If we are not predicting, just return the first one we find. - self.skip_prediction || - - // Have to convert to a typed NimbusId to pass to the runtime API. Maybe this is a clue - // That I should be passing Vec across the wasm boundary? - if api_version >= 2 { - self.parachain_client.runtime_api().can_author( - &at, - NimbusId::from_slice(&type_public_pair.1), - validation_data.relay_parent_number, - parent, - ) - .expect("Author API should not return error") - } else { - #[allow(deprecated)] - self.parachain_client.runtime_api().can_author_before_version_2( - &at, - NimbusId::from_slice(&type_public_pair.1), - validation_data.relay_parent_number, - ) - .expect("Author API version 2 should not return error") - } - }); + else { + first_eligible_key::(self.parachain_client.clone(), &*self.keystore, parent, validation_data.relay_parent_number) + }; - // If there are no eligible keys, print the log, and exit early. let type_public_pair = match maybe_key { Some(p) => p, - None => { - info!( - target: LOG_TARGET, - "🔮 Skipping candidate production because we are not eligible" - ); - return None; - } + None => { return None; } }; let proposer_future = self.proposer_factory.lock().init(&parent); diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs new file mode 100644 index 00000000..621064fe --- /dev/null +++ b/nimbus-consensus/src/manual_seal.rs @@ -0,0 +1,56 @@ +use std::sync::Arc; +use sp_keystore::SyncCryptoStorePtr; +use sp_runtime::traits::{Block as BlockT, DigestFor}; +use sc_consensus::BlockImportParams; +use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; +use sp_api::{TransactionFor, ProvideRuntimeApi}; +use sp_inherents::InherentData; +use nimbus_primitives::{NimbusApi, NimbusId}; + +//TODO Do I need the generic B? I copied it from Babe impl in Substrate. +/// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus +pub struct NimbusManualSealConsensusDataProvider { + /// Shared reference to keystore + keystore: SyncCryptoStorePtr, + + /// Shared reference to the client + client: Arc, + + // Could have a skip_prediction field here if it becomes desireable +} + +impl ConsensusDataProvider for NimbusManualSealConsensusDataProvider +where + B: BlockT, + C: ProvideRuntimeApi + Send + Sync, + C::Api: NimbusApi, + { + type Transaction = TransactionFor; + + fn create_digest( + &self, + parent: &B::Header, + _inherents: &InherentData, + ) -> Result, Error> { + // Fetch first eligible key from keystore + let _maybe_key = crate::first_eligible_key::( + self.client.clone(), + &*self.keystore, + parent, + 0, //TODO Come up with some real slot number. Maybe just use our own block height + ); + + // If we're eligible, construct and the return the digest + todo!() + } + + // IDK WTF this is for yet. Maybe we won't need it :) + fn append_block_import( + &self, + _parent: &B::Header, + _params: &mut BlockImportParams, + _inherents: &InherentData, + ) -> Result<(), Error> { + todo!() + } +} diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 853d496f..5a30b9e7 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -476,7 +476,7 @@ pub fn start_instant_seal_node(config: Configuration) -> Result Result Result Result sp_inherents::CreateInherentDataProviders { - let author_id = crate::chain_spec::get_collator_keys_from_seed("Alice"); - - async move { - let time = sp_timestamp::InherentDataProvider::from_system_time(); - - // The nimbus runtime is shared among all nodes including the parachain node. - // Because this is not a parachain context, we need to mock the parachain inherent data provider. - let mocked_parachain = MockValidationDataInherentDataProvider { - current_para_block: 0, - relay_offset: 0, - relay_blocks_per_para_block: 0, - }; +// fn create_inherent_data_providers(block: H256, _extra_args: ()) -> sp_inherents::CreateInherentDataProviders { +// let author_id = crate::chain_spec::get_collator_keys_from_seed("Alice"); - let author = nimbus_primitives::InherentDataProvider::(author_id); +// async move { +// let time = sp_timestamp::InherentDataProvider::from_system_time(); + +// // The nimbus runtime is shared among all nodes including the parachain node. +// // Because this is not a parachain context, we need to mock the parachain inherent data provider. +// let mocked_parachain = MockValidationDataInherentDataProvider { +// current_para_block: 0, +// relay_offset: 0, +// relay_blocks_per_para_block: 0, +// }; + +// Ok((time, mocked_parachain)) +// } +// } - Ok((time, mocked_parachain, author)) - } -} \ No newline at end of file From 74eb50c4b4d5a37a5fd3bf66ef5c5c37112f13bd Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 2 Nov 2021 23:54:16 -0400 Subject: [PATCH 05/52] better message for future self --- nimbus-consensus/src/manual_seal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 621064fe..0e754f9f 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -51,6 +51,6 @@ where _params: &mut BlockImportParams, _inherents: &InherentData, ) -> Result<(), Error> { - todo!() + todo!("inside append block import. I guess we at least need something here.") } } From 48c187745fdb71285f0a77ae93bfb2b5e0523db9 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 00:00:32 -0400 Subject: [PATCH 06/52] preruntime digest interface --- nimbus-primitives/src/digests.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/nimbus-primitives/src/digests.rs b/nimbus-primitives/src/digests.rs index 272e6b29..18955b18 100644 --- a/nimbus-primitives/src/digests.rs +++ b/nimbus-primitives/src/digests.rs @@ -14,22 +14,38 @@ use sp_std::fmt::Debug; /// A digest item which is usable with aura consensus. pub trait CompatibleDigestItem: Sized { + /// Construct a pre-runtime digest from the given AuthorId + fn nimbus_pre_digest(author: NimbusId) -> Self; + + /// If this item is a nimbus pre-runtime digest, return the author + fn as_nimbus_pre_digest(&self) -> Option; + /// Construct a seal digest item from the given signature fn nimbus_seal(signature: NimbusSignature) -> Self; /// If this item is a nimbus seal, return the signature. fn as_nimbus_seal(&self) -> Option; + /// This will be deprecated in the future /// Construct a consensus digest from the given AuthorId fn nimbus_consensus_digest(author: NimbusId) -> Self; - /// If this item is a nimbus consensus digest, return the author + /// This will be deprecated in the future + /// If this item is a nimbus consensus digest, return the author fn as_nimbus_consensus_digest(&self) -> Option; } impl CompatibleDigestItem for DigestItem where Hash: Debug + Send + Sync + Eq + Clone + Codec + 'static { + fn nimbus_pre_digest(author: NimbusId) -> Self { + DigestItem::Consensus(NIMBUS_ENGINE_ID, author.encode()) + } + + fn as_nimbus_pre_digest(&self) -> Option { + self.pre_runtime_try_to(&NIMBUS_ENGINE_ID) + } + fn nimbus_seal(signature: NimbusSignature) -> Self { DigestItem::Seal(NIMBUS_ENGINE_ID, signature.encode()) } @@ -38,10 +54,13 @@ impl CompatibleDigestItem for DigestItem where self.seal_try_to(&NIMBUS_ENGINE_ID) } + // Remove this once deprecated fn nimbus_consensus_digest(author: NimbusId) -> Self { DigestItem::Consensus(NIMBUS_ENGINE_ID, author.encode()) } + // Remove this once deprecated. I don't think it is used anyway. + // Notice that it calls the pre_runtime helper function. fn as_nimbus_consensus_digest(&self) -> Option { self.pre_runtime_try_to(&NIMBUS_ENGINE_ID) } From f34d824e68c75791a0d2ab656cbbde8022530d7c Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 00:19:50 -0400 Subject: [PATCH 07/52] `create_digest` compiles --- nimbus-consensus/src/manual_seal.rs | 27 +++++++++++++++++++++------ nimbus-primitives/src/lib.rs | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 0e754f9f..80d085b0 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -1,11 +1,15 @@ use std::sync::Arc; use sp_keystore::SyncCryptoStorePtr; -use sp_runtime::traits::{Block as BlockT, DigestFor}; +use sp_runtime::{ + traits::{Block as BlockT, DigestFor}, + generic::{Digest, DigestItem}, +}; +use sp_core::crypto::Public; use sc_consensus::BlockImportParams; use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; use sp_api::{TransactionFor, ProvideRuntimeApi}; use sp_inherents::InherentData; -use nimbus_primitives::{NimbusApi, NimbusId}; +use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; //TODO Do I need the generic B? I copied it from Babe impl in Substrate. /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus @@ -33,15 +37,26 @@ where _inherents: &InherentData, ) -> Result, Error> { // Fetch first eligible key from keystore - let _maybe_key = crate::first_eligible_key::( + let maybe_key = crate::first_eligible_key::( self.client.clone(), &*self.keystore, parent, 0, //TODO Come up with some real slot number. Maybe just use our own block height - ); + ); - // If we're eligible, construct and the return the digest - todo!() + // If we aren't eligible, return an appropriate error + match maybe_key { + Some(key) => { + Ok(Digest{ + logs: vec![DigestItem::nimbus_pre_digest(NimbusId::from_slice(&key.1))], + }) + }, + None => { + todo!("Grrr how to return this fucking error!"); + // Err(Error::Other(Box::new(String::from("no nimbus keys available to manual seal")))) + }, + } + } // IDK WTF this is for yet. Maybe we won't need it :) diff --git a/nimbus-primitives/src/lib.rs b/nimbus-primitives/src/lib.rs index 8765b9cc..f2972448 100644 --- a/nimbus-primitives/src/lib.rs +++ b/nimbus-primitives/src/lib.rs @@ -30,6 +30,8 @@ use sp_runtime::traits::BlockNumberProvider; pub mod digests; mod inherents; +pub use digests::CompatibleDigestItem; + pub use inherents::{INHERENT_IDENTIFIER, InherentDataProvider}; /// The given account ID is the author of the current block. From 51040b027ea499d7ce010b61e4ad0ec820013ef7 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 00:32:43 -0400 Subject: [PATCH 08/52] service compiles --- parachain-template/node/src/service.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 5a30b9e7..126f3e10 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -31,7 +31,6 @@ use sp_keystore::SyncCryptoStorePtr; use sp_runtime::traits::BlakeTwo256; use substrate_prometheus_endpoint::Registry; use sc_consensus_manual_seal::{run_instant_seal, InstantSealParams}; -use sp_core::H256; /// Native executor instance. pub struct TemplateRuntimeExecutor; @@ -421,11 +420,10 @@ pub fn start_instant_seal_node(config: Configuration) -> Result(&config)?; - let (network, network_status_sinks, network_starter) = + let (network, system_rpc_tx, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, client: client.clone(), @@ -476,7 +474,7 @@ pub fn start_instant_seal_node(config: Configuration) -> Result Result Date: Wed, 3 Nov 2021 00:43:27 -0400 Subject: [PATCH 09/52] whoe service checks --- parachain-template/node/src/cli.rs | 3 +++ parachain-template/node/src/command.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/parachain-template/node/src/cli.rs b/parachain-template/node/src/cli.rs index 319893a0..64134f66 100644 --- a/parachain-template/node/src/cli.rs +++ b/parachain-template/node/src/cli.rs @@ -34,6 +34,9 @@ pub enum Subcommand { /// Revert the chain to a previous state. Revert(sc_cli::RevertCmd), + /// Run Instant Seal + RunInstantSeal, + /// The custom benchmark subcommmand benchmarking runtime pallets. #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] Benchmark(frame_benchmarking_cli::BenchmarkCmd), diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index 03594e2b..8d123364 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -242,6 +242,13 @@ pub fn run() -> Result<()> { You can enable it with `--features runtime-benchmarks`." .into()) }, + Some(Subcommand::RunInstantSeal) => { + let runner = cli.create_runner(&cli.run.normalize())?; + runner.run_node_until_exit(|config| async move { + crate::service::start_instant_seal_node(config) + .map_err(sc_cli::Error::Service) + }) + }, None => { let runner = cli.create_runner(&cli.run.normalize())?; From 3eea250c1e75fa3ad461a2f7032a2c8fa49594c7 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 01:05:20 -0400 Subject: [PATCH 10/52] allow running from cli --- parachain-template/node/src/cli.rs | 2 +- parachain-template/node/src/command.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/parachain-template/node/src/cli.rs b/parachain-template/node/src/cli.rs index 64134f66..fe5b1e58 100644 --- a/parachain-template/node/src/cli.rs +++ b/parachain-template/node/src/cli.rs @@ -35,7 +35,7 @@ pub enum Subcommand { Revert(sc_cli::RevertCmd), /// Run Instant Seal - RunInstantSeal, + RunInstantSeal(sc_cli::RunCmd), /// The custom benchmark subcommmand benchmarking runtime pallets. #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index 8d123364..2de84ad7 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -242,8 +242,8 @@ pub fn run() -> Result<()> { You can enable it with `--features runtime-benchmarks`." .into()) }, - Some(Subcommand::RunInstantSeal) => { - let runner = cli.create_runner(&cli.run.normalize())?; + Some(Subcommand::RunInstantSeal(run_cmd)) => { + let runner = cli.create_runner(run_cmd)?; runner.run_node_until_exit(|config| async move { crate::service::start_instant_seal_node(config) .map_err(sc_cli::Error::Service) From 67c18cd4ab8a81f3cd17dfcc55385d80e7f5b2d9 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 01:34:03 -0400 Subject: [PATCH 11/52] actually install our new manual seal consensus data provider --- nimbus-consensus/src/lib.rs | 1 + nimbus-consensus/src/manual_seal.rs | 5 +++-- pallets/author-inherent/src/lib.rs | 17 ++++++++++++++++- parachain-template/node/src/service.rs | 11 ++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 35e035ea..efdd2fe6 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -50,6 +50,7 @@ use sp_std::convert::TryInto; use nimbus_primitives::{NimbusApi, NIMBUS_KEY_ID, NimbusId}; mod import_queue; mod manual_seal; +pub use manual_seal::NimbusManualSealConsensusDataProvider; const LOG_TARGET: &str = "filtering-consensus"; diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 80d085b0..a89e3e7b 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -15,10 +15,10 @@ use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus pub struct NimbusManualSealConsensusDataProvider { /// Shared reference to keystore - keystore: SyncCryptoStorePtr, + pub keystore: SyncCryptoStorePtr, /// Shared reference to the client - client: Arc, + pub client: Arc, // Could have a skip_prediction field here if it becomes desireable } @@ -47,6 +47,7 @@ where // If we aren't eligible, return an appropriate error match maybe_key { Some(key) => { + println!("Found an eligible key: {:?}", key); Ok(Digest{ logs: vec![DigestItem::nimbus_pre_digest(NimbusId::from_slice(&key.1))], }) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index c654af89..15982204 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -95,7 +95,22 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_: T::BlockNumber) -> Weight { - >::kill(); + // Overwrite the author storage with whatever info we get from the preruntime digests. + // If there is a preruntime digest, this writes the new author information for this block. + // If there is no digest, this kills the storage so it is clear to be filled later by the inherent. + // We pass no digests because we know that the impl doesn't use them. + // TODO rethink the previous comment. If the interface expects us to pass the digests, let's just pass them. + // Otherwise they just get read in the implementation anyway which is also nonstandard. + match Self::find_author(sp_std::vec::Vec::new()) { + Some(author) => { + >::put(author); + }, + None => { + >::kill(); + }, + } + + //TODO Weight 0 } diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 126f3e10..5c5343d5 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -9,7 +9,7 @@ use parachain_template_runtime::{ }; use nimbus_consensus::{ - build_nimbus_consensus, BuildNimbusConsensusParams, + build_nimbus_consensus, BuildNimbusConsensusParams, NimbusManualSealConsensusDataProvider, }; // Cumulus Imports @@ -489,10 +489,15 @@ pub fn start_instant_seal_node(config: Configuration) -> Result Date: Wed, 3 Nov 2021 01:45:16 -0400 Subject: [PATCH 12/52] Handle no-key scenario --- nimbus-consensus/src/manual_seal.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index a89e3e7b..da2aa66a 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -53,8 +53,7 @@ where }) }, None => { - todo!("Grrr how to return this fucking error!"); - // Err(Error::Other(Box::new(String::from("no nimbus keys available to manual seal")))) + Err(Error::StringError(String::from("no nimbus keys available to manual seal"))) }, } @@ -67,6 +66,6 @@ where _params: &mut BlockImportParams, _inherents: &InherentData, ) -> Result<(), Error> { - todo!("inside append block import. I guess we at least need something here.") + Ok(()) } } From c97b9f4db283d680f5c9f050a510d3343422d353 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 13:11:29 -0400 Subject: [PATCH 13/52] Preruntime digest an no memoizing author account --- nimbus-primitives/src/digests.rs | 2 +- pallets/author-inherent/src/lib.rs | 59 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/nimbus-primitives/src/digests.rs b/nimbus-primitives/src/digests.rs index 18955b18..700326a2 100644 --- a/nimbus-primitives/src/digests.rs +++ b/nimbus-primitives/src/digests.rs @@ -39,7 +39,7 @@ impl CompatibleDigestItem for DigestItem where Hash: Debug + Send + Sync + Eq + Clone + Codec + 'static { fn nimbus_pre_digest(author: NimbusId) -> Self { - DigestItem::Consensus(NIMBUS_ENGINE_ID, author.encode()) + DigestItem::PreRuntime(NIMBUS_ENGINE_ID, author.encode()) } fn as_nimbus_pre_digest(&self) -> Option { diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 15982204..2c518b15 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -95,22 +95,25 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_: T::BlockNumber) -> Weight { - // Overwrite the author storage with whatever info we get from the preruntime digests. - // If there is a preruntime digest, this writes the new author information for this block. - // If there is no digest, this kills the storage so it is clear to be filled later by the inherent. - // We pass no digests because we know that the impl doesn't use them. - // TODO rethink the previous comment. If the interface expects us to pass the digests, let's just pass them. - // Otherwise they just get read in the implementation anyway which is also nonstandard. - match Self::find_author(sp_std::vec::Vec::new()) { - Some(author) => { - >::put(author); - }, - None => { - >::kill(); - }, + // Start by clearning out the previous block's author + >::kill(); + + // Now extract the author from the digest + let digest = >::digest(); + log::info!("In on_initialize. about to find author. all digests are:"); + log::info!("{:?}", digest); + + let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); + let author_from_digest = Self::find_author(pre_runtime_digests); + + //TODO this could be done with a .map on the previous line + // If we got an author id this way, store the account in pallet storage so we can + // confirm its existence in on_finalize + if let Some(author_account) = author_from_digest { + log::info!("About to store author in on_initialize"); + >::put(author_account); } - //TODO Weight 0 } @@ -193,25 +196,23 @@ pub mod pallet { } impl FindAuthor for Pallet { - fn find_author<'a, I>(_digests: I) -> Option + fn find_author<'a, I>(digests: I) -> Option where I: 'a + IntoIterator, { - // We don't use the digests at all for two reasons: - // 1. We still support the author inherent which means the authorship info may not be available from the digests - // 2. We want to memoize the result so that we don't continually re-calculate it. - if let Some(author) = >::get() { - Some(author) - } else { - let digest = >::digest(); - let mut pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); - pre_runtime_digests - .find(|(id, _)| id == &NIMBUS_ENGINE_ID) - .map(|(_, mut data)| { - T::AccountId::decode(&mut data) - .expect("account encoded in preruntime digest must be valid") - }) + for (id, mut data) in digests.into_iter() { + if id == NIMBUS_ENGINE_ID { + //TODO maybe I shouldn't be decoding manually here. Isn't this what the trait is for? + // let author_id = digest_item.as_nimbus_pre_digest().expect("account encoded in preruntime digest must be valid"); + // let author_account = T::AccountLookup::lookup_account(&author_id).expect("author_id should have an account mapped"); + // return Some(author_account); + + return Some(T::AccountId::decode(&mut data) + .expect("account encoded in preruntime digest must be valid")) + } } + + None } } From 1cf6eded9fb630bdb5be82e51f50134d9675f236 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 13:16:44 -0400 Subject: [PATCH 14/52] remove wrong comment. Better to follow aura --- pallets/author-inherent/src/lib.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 2c518b15..bd0a8aee 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -202,11 +202,6 @@ pub mod pallet { { for (id, mut data) in digests.into_iter() { if id == NIMBUS_ENGINE_ID { - //TODO maybe I shouldn't be decoding manually here. Isn't this what the trait is for? - // let author_id = digest_item.as_nimbus_pre_digest().expect("account encoded in preruntime digest must be valid"); - // let author_account = T::AccountLookup::lookup_account(&author_id).expect("author_id should have an account mapped"); - // return Some(author_account); - return Some(T::AccountId::decode(&mut data) .expect("account encoded in preruntime digest must be valid")) } From 2265da2ca99ad6394ee017efdc6c8cc16cff2030 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 13:18:52 -0400 Subject: [PATCH 15/52] prune commented inherent-related code --- parachain-template/node/src/service.rs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 5c5343d5..e179239f 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -524,24 +524,3 @@ pub fn start_instant_seal_node(config: Configuration) -> Result sp_inherents::CreateInherentDataProviders { -// let author_id = crate::chain_spec::get_collator_keys_from_seed("Alice"); - -// async move { -// let time = sp_timestamp::InherentDataProvider::from_system_time(); - -// // The nimbus runtime is shared among all nodes including the parachain node. -// // Because this is not a parachain context, we need to mock the parachain inherent data provider. -// let mocked_parachain = MockValidationDataInherentDataProvider { -// current_para_block: 0, -// relay_offset: 0, -// relay_blocks_per_para_block: 0, -// }; - -// Ok((time, mocked_parachain)) -// } -// } - From 5769f43a9cc2464a61152f7bbdaa1dabac1a65e2 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 14:44:01 -0400 Subject: [PATCH 16/52] Hack in fake signature in manual seal. --- nimbus-consensus/src/manual_seal.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index da2aa66a..29f7b378 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -9,7 +9,7 @@ use sc_consensus::BlockImportParams; use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; use sp_api::{TransactionFor, ProvideRuntimeApi}; use sp_inherents::InherentData; -use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; +use nimbus_primitives::{NimbusApi, NimbusId, NimbusSignature, CompatibleDigestItem}; //TODO Do I need the generic B? I copied it from Babe impl in Substrate. /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus @@ -59,13 +59,23 @@ where } - // IDK WTF this is for yet. Maybe we won't need it :) + // This is where we actually sign with the nimbus key and attach the seal fn append_block_import( &self, _parent: &B::Header, - _params: &mut BlockImportParams, + params: &mut BlockImportParams, _inherents: &InherentData, ) -> Result<(), Error> { + //TODO Get the header hash and sign it. This should be extracted in the consensus worker. + // Let's start by just inserting an invalid signature to see if we get the right error + use std::convert::TryInto; + let fake_signature = [0u8] + .repeat(64) + .try_into() + .expect("my fake data should have the right length"); + let sig_digest = as nimbus_primitives::digests::CompatibleDigestItem>::nimbus_seal(fake_signature); + params.post_digests.push(sig_digest + ); Ok(()) } } From aae5122bd9802012a455afd28bfd5440f0d3f8d3 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 14:59:37 -0400 Subject: [PATCH 17/52] unused import --- nimbus-consensus/src/manual_seal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 29f7b378..cf9d4494 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -9,7 +9,7 @@ use sc_consensus::BlockImportParams; use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; use sp_api::{TransactionFor, ProvideRuntimeApi}; use sp_inherents::InherentData; -use nimbus_primitives::{NimbusApi, NimbusId, NimbusSignature, CompatibleDigestItem}; +use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; //TODO Do I need the generic B? I copied it from Babe impl in Substrate. /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus From 1acb47fc2b02ac6c19c059994f924d7635d85af4 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 14:59:49 -0400 Subject: [PATCH 18/52] verifier supports both digest types --- nimbus-consensus/src/import_queue.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/nimbus-consensus/src/import_queue.rs b/nimbus-consensus/src/import_queue.rs index f770047b..bedede78 100644 --- a/nimbus-consensus/src/import_queue.rs +++ b/nimbus-consensus/src/import_queue.rs @@ -76,24 +76,20 @@ where debug!(target: crate::LOG_TARGET, "🪲 Signature according to verifier is {:?}", signature); - // Grab the digest from the runtime - //TODO use the trait. Maybe this code should move to the trait. - let consensus_digest = block_params.header + // Grab the author information from either the preruntime digest or the consensus digest + //TODO use the trait + let claimed_author = block_params.header .digest() .logs .iter() - .find(|digest| { + .find_map(|digest| { match *digest { - DigestItem::Consensus(id, _) if id == b"nmbs" => true, - _ => false, + DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + _ => None, } }) - .expect("A single consensus digest should be added by the runtime when executing the author inherent."); - - let claimed_author = match *consensus_digest { - DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => author_id.clone(), - _ => panic!("Expected consensus digest to contains author id bytes"), - }; + .expect("Expected one consensus or pre-runtime digest that contains author id bytes"); debug!(target: crate::LOG_TARGET, "🪲 Claimed Author according to verifier is {:?}", claimed_author); From e8caac9b9c93768cf107d7b8e5e8da600ee78265 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 15:08:13 -0400 Subject: [PATCH 19/52] duplicate code from verifier to executor wrapper See https://github.com/PureStake/nimbus/issues/14 about de-duplicating this code --- pallets/author-inherent/src/exec.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/pallets/author-inherent/src/exec.rs b/pallets/author-inherent/src/exec.rs index 5849f579..8eccccb3 100644 --- a/pallets/author-inherent/src/exec.rs +++ b/pallets/author-inherent/src/exec.rs @@ -57,34 +57,26 @@ where debug!(target: "executive", "In hacked Executive. digests after stripping {:?}", header.digest()); debug!(target: "executive", "The seal we got {:?}", seal); - // let sig = match seal { - // DigestItem::Seal(id, ref sig) if id == NIMBUS_ENGINE_ID => sig.clone(), - // _ => panic!("HeaderUnsealed"), - // }; let signature = seal.as_nimbus_seal().unwrap_or_else(||panic!("HeaderUnsealed")); debug!(target: "executive", "🪲 Header hash after popping digest {:?}", header.hash()); debug!(target: "executive", "🪲 Signature according to executive is {:?}", signature); - // Grab the digest from the runtime - //TODO use the CompatibleDigest trait. Maybe this code should move to the trait. - let consensus_digest = header + // Grab the author information from either the preruntime digest or the consensus digest + //TODO use the trait + let claimed_author = header .digest() .logs .iter() - .find(|digest| { + .find_map(|digest| { match *digest { - DigestItem::Consensus(id, _) if id == &NIMBUS_ENGINE_ID => true, - _ => false, + DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + _ => None, } }) - .expect("A single consensus digest should be added by the runtime when executing the author inherent."); - - let claimed_author = match *consensus_digest { - DigestItem::Consensus(id, ref author_id) if id == NIMBUS_ENGINE_ID => author_id.clone(), - _ => panic!("Expected consensus digest to contains author id bytes"), - }; + .expect("Expected one consensus or pre-runtime digest that contains author id bytes"); debug!(target: "executive", "🪲 Claimed Author according to executive is {:?}", claimed_author); From 2f3a9f483ae04d51eecab0ca4b3a1e8a62eb32a7 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 16:11:31 -0400 Subject: [PATCH 20/52] author inherent no longer required --- pallets/author-inherent/src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index bd0a8aee..f36178af 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -169,14 +169,6 @@ pub mod pallet { type Error = InherentError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn is_inherent_required(_: &InherentData) -> Result, Self::Error> { - // Return Ok(Some(_)) unconditionally because this inherent is required in every block - // If it is not found, throw an AuthorInherentRequired error. - Ok(Some(InherentError::Other( - sp_runtime::RuntimeString::Borrowed("AuthorInherentRequired"), - ))) - } - fn create_inherent(data: &InherentData) -> Option { let author_raw = data .get_data::(&INHERENT_IDENTIFIER); From 770820cb3625dd559bd9166224f674fe63dd8ab2 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 16:11:56 -0400 Subject: [PATCH 21/52] sign blocks in manual seal !! --- nimbus-consensus/src/lib.rs | 54 +++++++++++++++++------------ nimbus-consensus/src/manual_seal.rs | 34 ++++++++++++------ 2 files changed, 54 insertions(+), 34 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index efdd2fe6..3f14672b 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -40,7 +40,7 @@ use sp_consensus::{ }; use sc_consensus::{BlockImport, BlockImportParams}; use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; -use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT}; +use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT, DigestItemFor}; use std::{marker::PhantomData, sync::Arc, time::Duration}; use tracing::error; use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore}; @@ -248,6 +248,34 @@ where maybe_key } +pub(crate) fn seal_header(header: &B::Header, keystore: &dyn SyncCryptoStore, type_public_pair: &CryptoTypePublicPair) -> DigestItemFor +where + B: BlockT, +{ + let pre_hash = header.hash(); + + let raw_sig = SyncCryptoStore::sign_with( + &*keystore, + NIMBUS_KEY_ID, + type_public_pair, + pre_hash.as_ref(), + ) + .expect("Keystore should be able to sign") + .expect("We already checked that the key was present"); + + debug!( + target: LOG_TARGET, + "The signature is \n{:?}", raw_sig + ); + + let signature = raw_sig + .clone() + .try_into() + .expect("signature bytes produced by keystore should be right length"); + + as nimbus_primitives::digests::CompatibleDigestItem>::nimbus_seal(signature) +} + #[async_trait::async_trait] impl ParachainConsensus for NimbusConsensus @@ -319,27 +347,7 @@ where let (header, extrinsics) = block.clone().deconstruct(); - let pre_hash = header.hash(); - - let raw_sig = SyncCryptoStore::sign_with( - &*self.keystore, - NIMBUS_KEY_ID, - &type_public_pair, - pre_hash.as_ref(), - ) - .expect("Keystore should be able to sign") - .expect("We already checked that the key was present"); - - debug!( - target: LOG_TARGET, - "The signature is \n{:?}", raw_sig - ); - - let signature = raw_sig - .clone() - .try_into().ok()?; - - let sig_digest = as nimbus_primitives::digests::CompatibleDigestItem>::nimbus_seal(signature); + let sig_digest = seal_header::(&header, &*self.keystore, &type_public_pair); let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header.clone()); block_import_params.post_digests.push(sig_digest.clone()); @@ -353,7 +361,7 @@ where "🔖 Sealed block for proposal at {}. Hash now {:?}, previously {:?}.", *header.number(), block_import_params.post_hash(), - pre_hash, + header.hash(), ); if let Err(err) = self diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index cf9d4494..d878574a 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -7,7 +7,7 @@ use sp_runtime::{ use sp_core::crypto::Public; use sc_consensus::BlockImportParams; use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; -use sp_api::{TransactionFor, ProvideRuntimeApi}; +use sp_api::{TransactionFor, ProvideRuntimeApi, HeaderT}; use sp_inherents::InherentData; use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; @@ -66,16 +66,28 @@ where params: &mut BlockImportParams, _inherents: &InherentData, ) -> Result<(), Error> { - //TODO Get the header hash and sign it. This should be extracted in the consensus worker. - // Let's start by just inserting an invalid signature to see if we get the right error - use std::convert::TryInto; - let fake_signature = [0u8] - .repeat(64) - .try_into() - .expect("my fake data should have the right length"); - let sig_digest = as nimbus_primitives::digests::CompatibleDigestItem>::nimbus_seal(fake_signature); - params.post_digests.push(sig_digest - ); + + // We have to reconstruct the type-public pair which is only communicated through the pre-runtime digest + let claimed_author = params + .header + .digest() + .logs + .iter() + .find_map(|digest| { + match *digest { + // We do not support the older author inherent in manual seal + DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + _ => None, + } + }) + .expect("Expected one pre-runtime digest that contains author id bytes"); + + let nimbus_public = NimbusId::from_slice(&claimed_author); + + let sig_digest = crate::seal_header::(¶ms.header, &*self.keystore, &nimbus_public.into()); + + params.post_digests.push(sig_digest); + Ok(()) } } From 521e5cb122c6645cb1636c316417cdb5765cffbf Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 16:33:59 -0400 Subject: [PATCH 22/52] Hack import queue so it works in instant seal although it is now broken in parachain mode. --- nimbus-consensus/src/import_queue.rs | 33 +++++++++++++++++++++++++++- nimbus-consensus/src/manual_seal.rs | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/nimbus-consensus/src/import_queue.rs b/nimbus-consensus/src/import_queue.rs index bedede78..a6057ef2 100644 --- a/nimbus-consensus/src/import_queue.rs +++ b/nimbus-consensus/src/import_queue.rs @@ -148,6 +148,8 @@ where block_params.post_digests.push(seal); + block_params.fork_choice = Some(sc_consensus::ForkChoiceStrategy::LongestChain); + debug!(target: crate::LOG_TARGET, "🪲 Just finished verifier. posthash from params is {:?}", &block_params.post_hash()); Ok((block_params, None)) @@ -155,7 +157,7 @@ where } /// Start an import queue for a Cumulus collator that does not uses any special authoring logic. -pub fn import_queue( +pub fn parachain_import_queue( client: Arc, block_import: I, create_inherent_data_providers: CIDP, @@ -185,3 +187,32 @@ where registry, )) } + +pub fn import_queue( + client: Arc, + block_import: I, + create_inherent_data_providers: CIDP, + spawner: &impl sp_core::traits::SpawnEssentialNamed, + registry: Option<&substrate_prometheus_endpoint::Registry>, +) -> ClientResult> +where + I: BlockImport + Send + Sync + 'static, + I::Transaction: Send, + Client: ProvideRuntimeApi + Send + Sync + 'static, + >::Api: BlockBuilderApi, + CIDP: CreateInherentDataProviders + 'static, +{ + let verifier = Verifier { + client, + create_inherent_data_providers, + _marker: PhantomData, + }; + + Ok(BasicQueue::new( + verifier, + Box::new(block_import), + None, + spawner, + registry, + )) +} \ No newline at end of file diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index d878574a..f2b9564d 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -66,7 +66,7 @@ where params: &mut BlockImportParams, _inherents: &InherentData, ) -> Result<(), Error> { - + // We have to reconstruct the type-public pair which is only communicated through the pre-runtime digest let claimed_author = params .header From 912eb75bf4e9acf600eb71e4e7bde0716fca4579 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 16:35:09 -0400 Subject: [PATCH 23/52] prune some debugging logs --- nimbus-consensus/src/manual_seal.rs | 1 - pallets/author-inherent/src/lib.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index f2b9564d..76003540 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -47,7 +47,6 @@ where // If we aren't eligible, return an appropriate error match maybe_key { Some(key) => { - println!("Found an eligible key: {:?}", key); Ok(Digest{ logs: vec![DigestItem::nimbus_pre_digest(NimbusId::from_slice(&key.1))], }) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index f36178af..0c354a56 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -100,8 +100,6 @@ pub mod pallet { // Now extract the author from the digest let digest = >::digest(); - log::info!("In on_initialize. about to find author. all digests are:"); - log::info!("{:?}", digest); let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); let author_from_digest = Self::find_author(pre_runtime_digests); @@ -110,7 +108,6 @@ pub mod pallet { // If we got an author id this way, store the account in pallet storage so we can // confirm its existence in on_finalize if let Some(author_account) = author_from_digest { - log::info!("About to store author in on_initialize"); >::put(author_account); } From caf54d34fa8011f1e1abd14f142025d8fbcb72c1 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 23:26:29 -0400 Subject: [PATCH 24/52] NimbusBlockImport with optional parachain rules --- nimbus-consensus/src/import_queue.rs | 83 ++++++++++++++++++-------- parachain-template/node/src/command.rs | 3 +- parachain-template/node/src/service.rs | 6 +- 3 files changed, 63 insertions(+), 29 deletions(-) diff --git a/nimbus-consensus/src/import_queue.rs b/nimbus-consensus/src/import_queue.rs index a6057ef2..6d2b8e8e 100644 --- a/nimbus-consensus/src/import_queue.rs +++ b/nimbus-consensus/src/import_queue.rs @@ -157,12 +157,13 @@ where } /// Start an import queue for a Cumulus collator that does not uses any special authoring logic. -pub fn parachain_import_queue( +pub fn import_queue( client: Arc, block_import: I, create_inherent_data_providers: CIDP, spawner: &impl sp_core::traits::SpawnEssentialNamed, registry: Option<&substrate_prometheus_endpoint::Registry>, + parachain: bool, ) -> ClientResult> where I: BlockImport + Send + Sync + 'static, @@ -179,8 +180,9 @@ where Ok(BasicQueue::new( verifier, - Box::new(cumulus_client_consensus_common::ParachainBlockImport::new( + Box::new(NimbusBlockImport::new( block_import, + parachain, )), None, spawner, @@ -188,31 +190,60 @@ where )) } -pub fn import_queue( - client: Arc, - block_import: I, - create_inherent_data_providers: CIDP, - spawner: &impl sp_core::traits::SpawnEssentialNamed, - registry: Option<&substrate_prometheus_endpoint::Registry>, -) -> ClientResult> +/// Nimbus specific block import. +/// +/// Nimbus supports both parachain and non-parachain contexts. In the parachain +/// context, new blocks should not be imported as best. Cumulus's ParachainBlockImport +/// handles this correctly, but does not work in non-parachain contexts. +/// This block import has a field indicating whether we should apply parachain rules or not. +/// +/// There may be additional nimbus-specific logic here in the future, but for now it is +/// only the conditional parachain logic +pub struct NimbusBlockImport{ + inner: I, + parachain_context: bool, +} + +impl NimbusBlockImport { + /// Create a new instance. + pub fn new(inner: I, parachain_context: bool) -> Self { + Self{ + inner, + parachain_context, + } + } +} + +#[async_trait::async_trait] +impl BlockImport for NimbusBlockImport where - I: BlockImport + Send + Sync + 'static, - I::Transaction: Send, - Client: ProvideRuntimeApi + Send + Sync + 'static, - >::Api: BlockBuilderApi, - CIDP: CreateInherentDataProviders + 'static, + Block: BlockT, + I: BlockImport + Send, { - let verifier = Verifier { - client, - create_inherent_data_providers, - _marker: PhantomData, - }; + type Error = I::Error; + type Transaction = I::Transaction; - Ok(BasicQueue::new( - verifier, - Box::new(block_import), - None, - spawner, - registry, - )) + async fn check_block( + &mut self, + block: sc_consensus::BlockCheckParams, + ) -> Result { + self.inner.check_block(block).await + } + + async fn import_block( + &mut self, + mut block_import_params: sc_consensus::BlockImportParams, + cache: std::collections::HashMap>, + ) -> Result { + // If we are in the parachain context, best block is determined by the relay chain + // except during initial sync + if self.parachain_context { + block_import_params.fork_choice = Some(sc_consensus::ForkChoiceStrategy::Custom( + block_import_params.origin == sp_consensus::BlockOrigin::NetworkInitialSync, + )); + } + + // Now continue on to the rest of the import pipeline. + self.inner.import_block(block_import_params, cache).await + } } \ No newline at end of file diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index 2de84ad7..c6df62b8 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -126,7 +126,8 @@ macro_rules! construct_async_run { RuntimeApi, TemplateRuntimeExecutor, >( - &$config, + // We default to the non-parachain import queue and select chain. + &$config, false, )?; let task_manager = $components.task_manager; { $( $code )* }.map(|v| (v, task_manager)) diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index e179239f..2508962a 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -54,6 +54,7 @@ impl sc_executor::NativeExecutionDispatch for TemplateRuntimeExecutor { #[allow(clippy::type_complexity)] pub fn new_partial( config: &Configuration, + parachain: bool, ) -> Result< PartialComponents< TFullClient>, @@ -141,6 +142,7 @@ where }, &task_manager.spawn_essential_handle(), config.prometheus_registry().clone(), + parachain, )?; let params = PartialComponents { @@ -217,7 +219,7 @@ where let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::(¶chain_config)?; + let params = new_partial::(¶chain_config, true)?; let (mut telemetry, telemetry_worker_handle) = params.other; let relay_chain_full_node = @@ -421,7 +423,7 @@ pub fn start_instant_seal_node(config: Configuration) -> Result(&config)?; + } = new_partial::(&config, false)?; let (network, system_rpc_tx, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { From 3aecd84ed51b3b4d3fe6e9787affaf9578730a44 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 23:41:15 -0400 Subject: [PATCH 25/52] we can use std on the client-side --- Cargo.lock | 1 - nimbus-consensus/Cargo.toml | 1 - nimbus-consensus/src/lib.rs | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c722cfff..b0a29690 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4259,7 +4259,6 @@ dependencies = [ "sp-inherents", "sp-keystore", "sp-runtime", - "sp-std", "substrate-prometheus-endpoint", "tracing", ] diff --git a/nimbus-consensus/Cargo.toml b/nimbus-consensus/Cargo.toml index 406b0bbb..964e05db 100644 --- a/nimbus-consensus/Cargo.toml +++ b/nimbus-consensus/Cargo.toml @@ -19,7 +19,6 @@ sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", br substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" } # Polkadot dependencies polkadot-client = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 3f14672b..b66993c4 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -45,8 +45,7 @@ use std::{marker::PhantomData, sync::Arc, time::Duration}; use tracing::error; use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore}; use sp_core::crypto::Public; -//TODO Shouldn't this come from `std` and not need `sp-std` at all? -use sp_std::convert::TryInto; +use std::convert::TryInto; use nimbus_primitives::{NimbusApi, NIMBUS_KEY_ID, NimbusId}; mod import_queue; mod manual_seal; From c0867b04b7e30be4aea07f01973736b1fff59d0f Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 23:44:41 -0400 Subject: [PATCH 26/52] remove unnecessary generic --- nimbus-consensus/src/manual_seal.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 76003540..9508c622 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -11,9 +11,8 @@ use sp_api::{TransactionFor, ProvideRuntimeApi, HeaderT}; use sp_inherents::InherentData; use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; -//TODO Do I need the generic B? I copied it from Babe impl in Substrate. /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus -pub struct NimbusManualSealConsensusDataProvider { +pub struct NimbusManualSealConsensusDataProvider { /// Shared reference to keystore pub keystore: SyncCryptoStorePtr, @@ -23,7 +22,7 @@ pub struct NimbusManualSealConsensusDataProvider { // Could have a skip_prediction field here if it becomes desireable } -impl ConsensusDataProvider for NimbusManualSealConsensusDataProvider +impl ConsensusDataProvider for NimbusManualSealConsensusDataProvider where B: BlockT, C: ProvideRuntimeApi + Send + Sync, From 263a2866202a7b5dec12c3eae6b59245f2dd73b9 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 3 Nov 2021 23:56:34 -0400 Subject: [PATCH 27/52] indentation and comment --- nimbus-consensus/src/manual_seal.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 9508c622..26b05a28 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -40,7 +40,10 @@ where self.client.clone(), &*self.keystore, parent, - 0, //TODO Come up with some real slot number. Maybe just use our own block height + // For now we author all blocks in slot zero, which is consistent with how we are + // mocking the relay chain height which the runtime uses for slot beacon. + // This should improve. See https://github.com/PureStake/nimbus/issues/3 + 0, ); // If we aren't eligible, return an appropriate error From 8b7adb46e42aa7e788e1a18aba9901ac8f0cc2d1 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Thu, 4 Nov 2021 00:04:32 -0400 Subject: [PATCH 28/52] use constant instead of hard-coded nmbs --- nimbus-consensus/src/import_queue.rs | 6 +++--- nimbus-consensus/src/manual_seal.rs | 4 ++-- pallets/author-inherent/src/exec.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nimbus-consensus/src/import_queue.rs b/nimbus-consensus/src/import_queue.rs index 6d2b8e8e..5284f49e 100644 --- a/nimbus-consensus/src/import_queue.rs +++ b/nimbus-consensus/src/import_queue.rs @@ -32,7 +32,7 @@ use sp_runtime::{ traits::{Block as BlockT, Header as HeaderT}, DigestItem, }; -use nimbus_primitives::{NimbusId, NimbusPair, digests::CompatibleDigestItem}; +use nimbus_primitives::{NimbusId, NimbusPair, digests::CompatibleDigestItem, NIMBUS_ENGINE_ID}; use sp_application_crypto::{Pair as _, Public as _}; use log::debug; @@ -84,8 +84,8 @@ where .iter() .find_map(|digest| { match *digest { - DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), - DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + DigestItem::Consensus(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), + DigestItem::PreRuntime(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), _ => None, } }) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 26b05a28..6936198b 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -9,7 +9,7 @@ use sc_consensus::BlockImportParams; use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; use sp_api::{TransactionFor, ProvideRuntimeApi, HeaderT}; use sp_inherents::InherentData; -use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem}; +use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem, NIMBUS_ENGINE_ID}; /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus pub struct NimbusManualSealConsensusDataProvider { @@ -77,7 +77,7 @@ where .find_map(|digest| { match *digest { // We do not support the older author inherent in manual seal - DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + DigestItem::PreRuntime(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), _ => None, } }) diff --git a/pallets/author-inherent/src/exec.rs b/pallets/author-inherent/src/exec.rs index 8eccccb3..3e133052 100644 --- a/pallets/author-inherent/src/exec.rs +++ b/pallets/author-inherent/src/exec.rs @@ -71,8 +71,8 @@ where .iter() .find_map(|digest| { match *digest { - DigestItem::Consensus(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), - DigestItem::PreRuntime(id, ref author_id) if id == *b"nmbs" => Some(author_id.clone()), + DigestItem::Consensus(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), + DigestItem::PreRuntime(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), _ => None, } }) From c2ecc7d7daef686fb6c011577c8dc1a727104cb4 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Thu, 4 Nov 2021 00:07:26 -0400 Subject: [PATCH 29/52] code style: map instead of if let --- pallets/author-inherent/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 0c354a56..ceb6b823 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -102,14 +102,11 @@ pub mod pallet { let digest = >::digest(); let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); - let author_from_digest = Self::find_author(pre_runtime_digests); - - //TODO this could be done with a .map on the previous line - // If we got an author id this way, store the account in pallet storage so we can - // confirm its existence in on_finalize - if let Some(author_account) = author_from_digest { + Self::find_author(pre_runtime_digests).map(|author_account|{ + // If we got an author id this way, store the account in pallet storage so we can + // confirm its existence in on_finalize >::put(author_account); - } + }); 0 } From df49153f80f68f49f1b8b6f87de6b375697a7c0d Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Thu, 4 Nov 2021 02:18:23 -0400 Subject: [PATCH 30/52] assume relay chain slot beacon in manual seal for now --- nimbus-consensus/src/manual_seal.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 6936198b..d14b5728 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -10,6 +10,7 @@ use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; use sp_api::{TransactionFor, ProvideRuntimeApi, HeaderT}; use sp_inherents::InherentData; use nimbus_primitives::{NimbusApi, NimbusId, CompatibleDigestItem, NIMBUS_ENGINE_ID}; +use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER}; /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus pub struct NimbusManualSealConsensusDataProvider { @@ -33,8 +34,16 @@ where fn create_digest( &self, parent: &B::Header, - _inherents: &InherentData, + inherents: &InherentData, ) -> Result, Error> { + // Retrieve the relay chain block number to use as the slot number from the parachain inherent + let slot_number = inherents + .get_data::(&PARACHAIN_INHERENT_IDENTIFIER) + .expect("Parachain inherent should decode correctly") + .expect("Parachain inherent should be present because we are mocking it") + .validation_data + .relay_parent_number; + // Fetch first eligible key from keystore let maybe_key = crate::first_eligible_key::( self.client.clone(), @@ -43,7 +52,7 @@ where // For now we author all blocks in slot zero, which is consistent with how we are // mocking the relay chain height which the runtime uses for slot beacon. // This should improve. See https://github.com/PureStake/nimbus/issues/3 - 0, + slot_number, ); // If we aren't eligible, return an appropriate error From 20fe8b4aa0d2279ff96b53d56f75122b4d619e7c Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Fri, 12 Nov 2021 14:22:04 -0500 Subject: [PATCH 31/52] Actually checkvalidity and send notification when using preruntime digest --- pallets/author-inherent/src/lib.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index ceb6b823..f4bd5b76 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -105,20 +105,26 @@ pub mod pallet { Self::find_author(pre_runtime_digests).map(|author_account|{ // If we got an author id this way, store the account in pallet storage so we can // confirm its existence in on_finalize - >::put(author_account); + >::put(&author_account); + + //TODO, should we reuse the same trait that Pallet Authorship uses? + // Notify any other pallets that are listening (eg rewards) about the author + T::EventHandler::note_author(author_account); }); 0 } fn on_finalize(_: T::BlockNumber) { - // Because we still support the author inherent, we cannot ensure that some author has been - // set until on_finalize TODO Actually, maybe we could do this on post inherent.... Gotta look into that - // TODO this should be moved into `on_initialize` after support for the author inehrent is dropped entirely + //TODO this should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 + // In the meantime, it will allow Alan to more easily profile block authorship. + let author = >::get() + .expect("Block invalid, no authorship information supplied."); + assert!( - >::get().is_some(), - "Block invalid, no authorship information supplied." - ) + T::CanAuthor::can_author(&author, &T::SlotBeacon::slot()), + "Block invalid, supplied author is not eligible." + ); } } @@ -132,15 +138,10 @@ pub mod pallet { ensure!(>::get().is_none(), Error::::AuthorAlreadySet); debug!(target: "author-inherent", "Author was not already set"); - let slot = T::SlotBeacon::slot(); - debug!(target: "author-inherent", "Slot is {:?}", slot); - let account = T::AccountLookup::lookup_account(&author).ok_or( Error::::NoAccountId )?; - ensure!(T::CanAuthor::can_author(&account, &slot), Error::::CannotBeAuthor); - // Update storage Author::::put(&account); @@ -181,6 +182,9 @@ pub mod pallet { } } + //TODO Something is wrong here. Where did I map from nimbus id to accout id? + // I can see how it would have kind of "Worked" in the template node because I used the same sr25519 + // But how did this ever work in Moonbeam? impl FindAuthor for Pallet { fn find_author<'a, I>(digests: I) -> Option where From 8f232ac2f1785b682fb7adf5e6ce5e46e4fd84f2 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Fri, 12 Nov 2021 17:07:25 -0500 Subject: [PATCH 32/52] Typos from code review Co-authored-by: Amar Singh Co-authored-by: girazoki --- nimbus-consensus/src/lib.rs | 12 ++++++------ pallets/author-inherent/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index b66993c4..5fc86730 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -156,13 +156,13 @@ where } } -/// Grabs any available nimbus key fro mthe keystore. +/// Grabs any available nimbus key from the keystore. /// This may be useful in situations where you expect exactly one key /// and intend to perform an operation with it regardless of whether it is /// expected to be eligible. Concretely, this is used in the consensus worker /// to implement the `skip_prediction` feature. pub(crate) fn first_available_key(keystore: &dyn SyncCryptoStore) -> Option { - // Get allthe available keys + // Get all the available keys let available_keys = SyncCryptoStore::keys(keystore, NIMBUS_KEY_ID) .expect("keystore should return the keys it has"); @@ -185,7 +185,7 @@ where C: ProvideRuntimeApi, C::Api: NimbusApi, { - // Get allthe available keys + // Get all the available keys let available_keys = SyncCryptoStore::keys(keystore, NIMBUS_KEY_ID) .expect("keystore should return the keys it has"); @@ -210,8 +210,8 @@ where let api_version = api_version.unwrap(); // Iterate keys until we find an eligible one, or run out of candidates. - // If we are skipping prediction, then we author withthe first key we find. - // prediction skipping only really amkes sense when there is a single key in the keystore. + // If we are skipping prediction, then we author with the first key we find. + // prediction skipping only really makes sense when there is a single key in the keystore. //TODO I think there is a nicer way to do this than handle the type_public_pair. We only use the .1 field let maybe_key = available_keys.into_iter().find(|type_public_pair| { @@ -232,7 +232,7 @@ where NimbusId::from_slice(&type_public_pair.1), slot_number, ) - .expect("Author API version 2 should not return error") + .expect("Author API before version 2 should not return error") } }); diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index f4bd5b76..bca4ccce 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -95,7 +95,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_: T::BlockNumber) -> Weight { - // Start by clearning out the previous block's author + // Start by clearing out the previous block's author >::kill(); // Now extract the author from the digest From 36c0aec132bbda92821cf4e3a698737ca1541d4e Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Fri, 12 Nov 2021 17:07:41 -0500 Subject: [PATCH 33/52] Proper index Co-authored-by: Amar Singh --- nimbus-consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 5fc86730..8921a2a1 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -173,7 +173,7 @@ pub(crate) fn first_available_key(keystore: &dyn SyncCryptoStore) -> Option Date: Fri, 12 Nov 2021 14:42:10 -0500 Subject: [PATCH 34/52] Switch consensus worker from inherent to preruntime digest. Was it really that easy!? --- nimbus-consensus/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 8921a2a1..423c82ad 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -91,7 +91,7 @@ where RClient::Api: ParachainHost, RBackend: Backend, ParaClient: ProvideRuntimeApi, - CIDP: CreateInherentDataProviders, + CIDP: CreateInherentDataProviders, { /// Create a new instance of nimbus consensus. pub fn new( @@ -128,11 +128,10 @@ where parent: B::Hash, validation_data: &PersistedValidationData, relay_parent: PHash, - author_id: NimbusId, ) -> Option { let inherent_data_providers = self .create_inherent_data_providers - .create_inherent_data_providers(parent, (relay_parent, validation_data.clone(), author_id)) + .create_inherent_data_providers(parent, (relay_parent, validation_data.clone())) .await .map_err(|e| { tracing::error!( @@ -322,7 +321,11 @@ where ) .ok()?; - let inherent_data = self.inherent_data(parent.hash(),&validation_data, relay_parent, NimbusId::from_slice(&type_public_pair.1)).await?; + let inherent_data = self.inherent_data(parent.hash(),&validation_data, relay_parent).await?; + + let inherent_digests = vec![ + CompatibleDigestItem::nimbus_pre_digest(NimbusId::from_slice(&type_public_pair.1)), + ]; let Proposal { block, From fdebe92b9ffd45e36d14b33faad3c9228b3c03fa Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Fri, 12 Nov 2021 14:58:03 -0500 Subject: [PATCH 35/52] map from author id to account id in FindAuthor --- pallets/author-inherent/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index bca4ccce..4b782488 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -182,9 +182,6 @@ pub mod pallet { } } - //TODO Something is wrong here. Where did I map from nimbus id to accout id? - // I can see how it would have kind of "Worked" in the template node because I used the same sr25519 - // But how did this ever work in Moonbeam? impl FindAuthor for Pallet { fn find_author<'a, I>(digests: I) -> Option where @@ -192,8 +189,13 @@ pub mod pallet { { for (id, mut data) in digests.into_iter() { if id == NIMBUS_ENGINE_ID { - return Some(T::AccountId::decode(&mut data) - .expect("account encoded in preruntime digest must be valid")) + let author_id = T::AuthorId::decode(&mut data) + .expect("NimbusId encoded in preruntime digest must be valid"); + + let author_account = T::AccountLookup::lookup_account(&author_id) + .expect("No Account Mapped to this NimbusId"); + + return Some(author_account); } } @@ -253,7 +255,6 @@ mod tests { assert_noop, assert_ok, parameter_types, traits::{OnFinalize, OnInitialize}, }; - use nimbus_primitives::NimbusId; use sp_core::Public; use sp_core::H256; use sp_io::TestExternalities; From 807e72be3398fec3c4418d4cb0f8a43b0791395a Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Fri, 12 Nov 2021 15:53:38 -0500 Subject: [PATCH 36/52] more toward parachain consensus worker --- nimbus-consensus/src/lib.rs | 20 +++++++++++--------- parachain-template/node/src/service.rs | 8 +++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 423c82ad..67b9d5b4 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -46,7 +46,7 @@ use tracing::error; use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore}; use sp_core::crypto::Public; use std::convert::TryInto; -use nimbus_primitives::{NimbusApi, NIMBUS_KEY_ID, NimbusId}; +use nimbus_primitives::{NimbusApi, NIMBUS_KEY_ID, NimbusId, CompatibleDigestItem}; mod import_queue; mod manual_seal; pub use manual_seal::NimbusManualSealConsensusDataProvider; @@ -292,7 +292,7 @@ where >, ParaClient: ProvideRuntimeApi + Send + Sync, ParaClient::Api: NimbusApi, - CIDP: CreateInherentDataProviders, + CIDP: CreateInherentDataProviders, { async fn produce_candidate( &mut self, @@ -323,9 +323,11 @@ where let inherent_data = self.inherent_data(parent.hash(),&validation_data, relay_parent).await?; - let inherent_digests = vec![ - CompatibleDigestItem::nimbus_pre_digest(NimbusId::from_slice(&type_public_pair.1)), - ]; + let inherent_digests = sp_runtime::generic::Digest { + logs: vec![ + CompatibleDigestItem::nimbus_pre_digest(NimbusId::from_slice(&type_public_pair.1)), + ] + }; let Proposal { block, @@ -334,7 +336,7 @@ where } = proposer .propose( inherent_data, - Default::default(), + inherent_digests, //TODO: Fix this. Duration::from_millis(500), // Set the block limit to 50% of the maximum PoV size. @@ -441,7 +443,7 @@ where sc_client_api::StateBackendFor: sc_client_api::StateBackend>, ParaClient: ProvideRuntimeApi + Send + Sync + 'static, ParaClient::Api: NimbusApi, - CIDP: CreateInherentDataProviders + 'static, + CIDP: CreateInherentDataProviders + 'static, { NimbusConsensusBuilder::new( para_id, @@ -491,7 +493,7 @@ where BI: BlockImport + Send + Sync + 'static, RBackend: Backend + 'static, ParaClient: ProvideRuntimeApi + Send + Sync + 'static, - CIDP: CreateInherentDataProviders + 'static, + CIDP: CreateInherentDataProviders + 'static, { /// Create a new instance of the builder. fn new( @@ -545,7 +547,7 @@ where RBackend: Backend + 'static, ParaClient: ProvideRuntimeApi + Send + Sync + 'static, ParaClient::Api: NimbusApi, - CIDP: CreateInherentDataProviders + 'static, + CIDP: CreateInherentDataProviders + 'static, { type Output = Box>; diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 2508962a..46058a40 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -5,7 +5,7 @@ use std::sync::Arc; // Local Runtime Types use parachain_template_runtime::{ - opaque::Block, AccountId, Balance, Hash, Index as Nonce, RuntimeApi, NimbusId + opaque::Block, AccountId, Balance, Hash, Index as Nonce, RuntimeApi }; use nimbus_consensus::{ @@ -381,7 +381,7 @@ pub async fn start_parachain_node( keystore, skip_prediction: force_authoring, create_inherent_data_providers: - move |_, (relay_parent, validation_data, author_id)| { + move |_, (relay_parent, validation_data)| { let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client( relay_parent, @@ -399,9 +399,7 @@ pub async fn start_parachain_node( ) })?; - let author = nimbus_primitives::InherentDataProvider::(author_id); - - Ok((time, parachain_inherent, author)) + Ok((time, parachain_inherent)) } }, }, From f16dd8fc16a758346041cb9810cfb866ee886177 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 1 Dec 2021 13:32:46 -0500 Subject: [PATCH 37/52] Update nimbus-consensus/src/import_queue.rs --- nimbus-consensus/src/import_queue.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/nimbus-consensus/src/import_queue.rs b/nimbus-consensus/src/import_queue.rs index 5284f49e..6679166e 100644 --- a/nimbus-consensus/src/import_queue.rs +++ b/nimbus-consensus/src/import_queue.rs @@ -148,6 +148,7 @@ where block_params.post_digests.push(seal); + // The standard is to use the longest chain rule. This is overridden by the `NimbusBlockImport` in the parachain context. block_params.fork_choice = Some(sc_consensus::ForkChoiceStrategy::LongestChain); debug!(target: crate::LOG_TARGET, "🪲 Just finished verifier. posthash from params is {:?}", &block_params.post_hash()); From 03b39388d19b1a2cc8e2a5ce7d22d5359538dfbe Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 1 Dec 2021 13:50:14 -0500 Subject: [PATCH 38/52] inherent is a no-op --- pallets/author-inherent/src/lib.rs | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 4b782488..b0602d9f 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -103,8 +103,7 @@ pub mod pallet { let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); Self::find_author(pre_runtime_digests).map(|author_account|{ - // If we got an author id this way, store the account in pallet storage so we can - // confirm its existence in on_finalize + // Store the author so we can confirm eligibility after the inherents have executed >::put(&author_account); //TODO, should we reuse the same trait that Pallet Authorship uses? @@ -130,30 +129,13 @@ pub mod pallet { #[pallet::call] impl Pallet { - /// Inherent to set the author of a block + /// This inherent is now a no-op. The extrinsic remains to facilitate a smooth transition + /// for live chains. All nodes must begin including the pre-runtime digest before + /// this runtime goes live. #[pallet::weight(0)] pub fn set_author(origin: OriginFor, author: T::AuthorId) -> DispatchResult { ensure_none(origin)?; - ensure!(>::get().is_none(), Error::::AuthorAlreadySet); - debug!(target: "author-inherent", "Author was not already set"); - - let account = T::AccountLookup::lookup_account(&author).ok_or( - Error::::NoAccountId - )?; - - // Update storage - Author::::put(&account); - - // Add a consensus digest so the client-side worker can verify the block is signed by the right person. - frame_system::Pallet::::deposit_log(DigestItem::::Consensus( - NIMBUS_ENGINE_ID, - author.encode(), - )); - - // Notify any other pallets that are listening (eg rewards) about the author - T::EventHandler::note_author(account); - Ok(()) } } From 8c8ce30fe6b739a358ceb6f9a76e110a6c688ee7 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 1 Dec 2021 14:12:24 -0500 Subject: [PATCH 39/52] Revert "more toward parachain consensus worker" This reverts commit 807e72be3398fec3c4418d4cb0f8a43b0791395a. --- nimbus-consensus/src/lib.rs | 15 ++++++++------- parachain-template/node/src/service.rs | 8 +++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 08bba262..4deae57a 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -91,7 +91,7 @@ where RClient::Api: ParachainHost, RBackend: Backend, ParaClient: ProvideRuntimeApi, - CIDP: CreateInherentDataProviders, + CIDP: CreateInherentDataProviders, { /// Create a new instance of nimbus consensus. pub fn new( @@ -128,10 +128,11 @@ where parent: B::Hash, validation_data: &PersistedValidationData, relay_parent: PHash, + author_id: NimbusId, ) -> Option { let inherent_data_providers = self .create_inherent_data_providers - .create_inherent_data_providers(parent, (relay_parent, validation_data.clone())) + .create_inherent_data_providers(parent, (relay_parent, validation_data.clone(), author_id)) .await .map_err(|e| { tracing::error!( @@ -292,7 +293,7 @@ where >, ParaClient: ProvideRuntimeApi + Send + Sync, ParaClient::Api: AuthorFilterAPI, - CIDP: CreateInherentDataProviders, + CIDP: CreateInherentDataProviders, { async fn produce_candidate( &mut self, @@ -321,7 +322,7 @@ where ) .ok()?; - let inherent_data = self.inherent_data(parent.hash(),&validation_data, relay_parent).await?; + let inherent_data = self.inherent_data(parent.hash(),&validation_data, relay_parent, NimbusId::from_slice(&type_public_pair.1)).await?; let inherent_digests = sp_runtime::generic::Digest { logs: vec![ @@ -443,7 +444,7 @@ where sc_client_api::StateBackendFor: sc_client_api::StateBackend>, ParaClient: ProvideRuntimeApi + Send + Sync + 'static, ParaClient::Api: AuthorFilterAPI, - CIDP: CreateInherentDataProviders + 'static, + CIDP: CreateInherentDataProviders + 'static, { NimbusConsensusBuilder::new( para_id, @@ -493,7 +494,7 @@ where BI: BlockImport + Send + Sync + 'static, RBackend: Backend + 'static, ParaClient: ProvideRuntimeApi + Send + Sync + 'static, - CIDP: CreateInherentDataProviders + 'static, + CIDP: CreateInherentDataProviders + 'static, { /// Create a new instance of the builder. fn new( @@ -547,7 +548,7 @@ where RBackend: Backend + 'static, ParaClient: ProvideRuntimeApi + Send + Sync + 'static, ParaClient::Api: AuthorFilterAPI, - CIDP: CreateInherentDataProviders + 'static, + CIDP: CreateInherentDataProviders + 'static, { type Output = Box>; diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 46058a40..2508962a 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -5,7 +5,7 @@ use std::sync::Arc; // Local Runtime Types use parachain_template_runtime::{ - opaque::Block, AccountId, Balance, Hash, Index as Nonce, RuntimeApi + opaque::Block, AccountId, Balance, Hash, Index as Nonce, RuntimeApi, NimbusId }; use nimbus_consensus::{ @@ -381,7 +381,7 @@ pub async fn start_parachain_node( keystore, skip_prediction: force_authoring, create_inherent_data_providers: - move |_, (relay_parent, validation_data)| { + move |_, (relay_parent, validation_data, author_id)| { let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client( relay_parent, @@ -399,7 +399,9 @@ pub async fn start_parachain_node( ) })?; - Ok((time, parachain_inherent)) + let author = nimbus_primitives::InherentDataProvider::(author_id); + + Ok((time, parachain_inherent, author)) } }, }, From 9167b63f20fd3ff6bae92b1d5068d3b2c3a0f52d Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Wed, 1 Dec 2021 14:14:01 -0500 Subject: [PATCH 40/52] validators don't need backward compatability --- pallets/author-inherent/src/exec.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/author-inherent/src/exec.rs b/pallets/author-inherent/src/exec.rs index 3e133052..e9ca72df 100644 --- a/pallets/author-inherent/src/exec.rs +++ b/pallets/author-inherent/src/exec.rs @@ -71,7 +71,6 @@ where .iter() .find_map(|digest| { match *digest { - DigestItem::Consensus(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), DigestItem::PreRuntime(id, ref author_id) if id == NIMBUS_ENGINE_ID => Some(author_id.clone()), _ => None, } From 46eed0d3d3e7a61f08e68a4b94b57813416b8373 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 6 Dec 2021 15:41:36 -0500 Subject: [PATCH 41/52] Fix incorrect merge conflict resolution. Still detect NimbusApi --- nimbus-consensus/src/lib.rs | 146 +++++++++------------------- nimbus-consensus/src/manual_seal.rs | 3 +- 2 files changed, 47 insertions(+), 102 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 15105bd7..8dbdeebb 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -183,6 +183,7 @@ pub(crate) fn first_available_key(keystore: &dyn SyncCryptoStore) -> Option(client: Arc, keystore: &dyn SyncCryptoStore, parent: &B::Header, slot_number: u32) -> Option where C: ProvideRuntimeApi, + C::Api: NimbusApi, C::Api: AuthorFilterAPI, { // Get all the available keys @@ -194,46 +195,53 @@ where if available_keys.is_empty() { warn!(target: LOG_TARGET, "🔏 No Nimbus keys available. We will not be able to author."); return None; - } + }let at = BlockId::Hash(parent.hash()); - // Get `AuthorFilterAPI` version. - let api_version = client.runtime_api() - .api_version::>(&BlockId::Hash(parent.hash())) - .expect("Runtime api access to not error."); + // helper function for calling the various runtime apis and versions + let prediction_helper = |at, nimbus_id: NimbusId, slot: u32, parent| -> bool { - if api_version.is_none() { - tracing::error!( - target: LOG_TARGET, "Could not find `AuthorFilterAPI` version.", - ); - return None; - } - let api_version = api_version.unwrap(); + let has_nimbus_api = client + .runtime_api() + .has_api::>(at) + .expect("should be able to dynamically detect the api"); + + if has_nimbus_api { + NimbusApi::can_author(&*client.runtime_api(), at, nimbus_id, slot, parent) + .expect("NimbusAPI should not return error") + } else { + // There are two versions of the author filter, so we do that dynamically also. + let api_version = client.runtime_api() + .api_version::>(&at) + .expect("Runtime api access to not error.") + .expect("Should be able to detect author filter version"); + + if api_version >= 2 { + AuthorFilterAPI::can_author(&*client.runtime_api(), at, nimbus_id, slot, parent) + .expect("Author API should not return error") + } else { + #[allow(deprecated)] + client.runtime_api().can_author_before_version_2( + &at, + nimbus_id, + slot_number, + ) + .expect("Author API version 2 should not return error") + } + } + }; // Iterate keys until we find an eligible one, or run out of candidates. - // If we are skipping prediction, then we author with the first key we find. - // prediction skipping only really makes sense when there is a single key in the keystore. - //TODO I think there is a nicer way to do this than handle the type_public_pair. We only use the .1 field + // If we are skipping prediction, then we author withthe first key we find. + // prediction skipping only really amkes sense when there is a single key in the keystore. let maybe_key = available_keys.into_iter().find(|type_public_pair| { - // Have to convert to a typed NimbusId to pass to the runtime API. Maybe this is a clue // That I should be passing Vec across the wasm boundary? - if api_version >= 2 { - client.runtime_api().can_author( - &BlockId::Hash(parent.hash()), - NimbusId::from_slice(&type_public_pair.1), - slot_number, - parent, - ) - .expect("Author API should not return error") - } else { - #[allow(deprecated)] - client.runtime_api().can_author_before_version_2( - &BlockId::Hash(parent.hash()), - NimbusId::from_slice(&type_public_pair.1), - slot_number, - ) - .expect("Author API before version 2 should not return error") - } + prediction_helper( + &at, + NimbusId::from_slice(&type_public_pair.1), + slot_number, + parent, + ) }); // If there are no eligible keys, print the log, and exit early. @@ -297,84 +305,20 @@ where ParaClient::Api: NimbusApi, CIDP: CreateInherentDataProviders, { - async fn produce_candidate( + async fn produce_candidate( &mut self, parent: &B::Header, relay_parent: PHash, validation_data: &PersistedValidationData, ) -> Option> { - // Design decision: We will check the keystore for any available keys. Then we will iterate - // those keys until we find one that is eligible. If none are eligible, we skip this slot. - // If multiple are eligible, we only author with the first one. - - // Get all the available keys - let available_keys = - SyncCryptoStore::keys(&*self.keystore, NIMBUS_KEY_ID) - .expect("keystore should return the keys it has"); - - // Print a more helpful message than "not eligible" when there are no keys at all. - if available_keys.is_empty() { - warn!(target: LOG_TARGET, "🔏 No Nimbus keys available. We will not be able to author."); - return None; + + let maybe_key = if self.skip_prediction { + first_available_key(&*self.keystore) } else { first_eligible_key::(self.parachain_client.clone(), &*self.keystore, parent, validation_data.relay_parent_number) }; - let at = BlockId::Hash(parent.hash()); - - // helper function for calling the various runtime apis and versions - let prediction_helper = |at, nimbus_id: NimbusId, slot: u32, parent| -> bool { - - let has_nimbus_api = self - .parachain_client - .runtime_api() - .has_api::>(at) - .expect("should be able to dynamically detect the api"); - - if has_nimbus_api { - NimbusApi::can_author(&*self.parachain_client.runtime_api(), at, nimbus_id, slot, parent) - .expect("NimbusAPI should not return error") - } else { - // There are two versions of the author filter, so we do that dynamically also. - let api_version = self.parachain_client.runtime_api() - .api_version::>(&at) - .expect("Runtime api access to not error.") - .expect("Should be able to detect author filter version"); - - if api_version >= 2 { - AuthorFilterAPI::can_author(&*self.parachain_client.runtime_api(), at, nimbus_id, slot, parent) - .expect("Author API should not return error") - } else { - #[allow(deprecated)] - self.parachain_client.runtime_api().can_author_before_version_2( - &at, - nimbus_id, - slot, - ) - .expect("Author API version 2 should not return error") - } - } - }; - - // Iterate keys until we find an eligible one, or run out of candidates. - // If we are skipping prediction, then we author withthe first key we find. - // prediction skipping only really amkes sense when there is a single key in the keystore. - let maybe_key = available_keys.into_iter().find(|type_public_pair| { - - // If we are not predicting, just return the first one we find. - self.skip_prediction || - - // Have to convert to a typed NimbusId to pass to the runtime API. Maybe this is a clue - // That I should be passing Vec across the wasm boundary? - prediction_helper( - &at, - NimbusId::from_slice(&type_public_pair.1), - validation_data.relay_parent_number, - parent, - ) - }); - // If there are no eligible keys, print the log, and exit early. let type_public_pair = match maybe_key { Some(p) => p, diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 86591525..78e92356 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -9,7 +9,7 @@ use sc_consensus::BlockImportParams; use sc_consensus_manual_seal::{ConsensusDataProvider, Error}; use sp_api::{TransactionFor, ProvideRuntimeApi, HeaderT}; use sp_inherents::InherentData; -use nimbus_primitives::{AuthorFilterAPI, NimbusId, CompatibleDigestItem, NIMBUS_ENGINE_ID}; +use nimbus_primitives::{AuthorFilterAPI, NimbusApi, NimbusId, CompatibleDigestItem, NIMBUS_ENGINE_ID}; use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER}; /// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus @@ -27,6 +27,7 @@ impl ConsensusDataProvider for NimbusManualSealConsensusDataProvider where B: BlockT, C: ProvideRuntimeApi + Send + Sync, + C::Api: NimbusApi, C::Api: AuthorFilterAPI, { type Transaction = TransactionFor; From e2d949297feb99261d2d9100663d291c384855b5 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 6 Dec 2021 15:43:28 -0500 Subject: [PATCH 42/52] Add copyright to manual seal file. Hell Yeah CI! --- nimbus-consensus/src/manual_seal.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nimbus-consensus/src/manual_seal.rs b/nimbus-consensus/src/manual_seal.rs index 78e92356..fe8efff8 100644 --- a/nimbus-consensus/src/manual_seal.rs +++ b/nimbus-consensus/src/manual_seal.rs @@ -1,3 +1,19 @@ +// Copyright 2019-2021 PureStake Inc. +// This file is part of Nimbus. + +// Nimbus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Nimbus 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Nimbus. If not, see . + use std::sync::Arc; use sp_keystore::SyncCryptoStorePtr; use sp_runtime::{ From 9f65a4522e52a6ada4e4a30de2908c9a3debb37c Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 6 Dec 2021 15:48:30 -0500 Subject: [PATCH 43/52] Typo found by @girazoki --- nimbus-consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 8dbdeebb..f74dbecf 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -231,7 +231,7 @@ where }; // Iterate keys until we find an eligible one, or run out of candidates. - // If we are skipping prediction, then we author withthe first key we find. + // If we are skipping prediction, then we author with the first key we find. // prediction skipping only really amkes sense when there is a single key in the keystore. let maybe_key = available_keys.into_iter().find(|type_public_pair| { // Have to convert to a typed NimbusId to pass to the runtime API. Maybe this is a clue From 4eca377e02c4b995cb43154a655e4777398ef3d1 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 6 Dec 2021 15:49:53 -0500 Subject: [PATCH 44/52] stray space --- nimbus-consensus/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index f74dbecf..2802d639 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -305,7 +305,7 @@ where ParaClient::Api: NimbusApi, CIDP: CreateInherentDataProviders, { - async fn produce_candidate( + async fn produce_candidate( &mut self, parent: &B::Header, relay_parent: PHash, From 7e18518179a35ed6f54255ef52a002b31e268f26 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 6 Dec 2021 16:28:15 -0500 Subject: [PATCH 45/52] Single author in dev spec so that `run-instant-seal --dev` works with one node --- parachain-template/node/src/chain_spec.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/parachain-template/node/src/chain_spec.rs b/parachain-template/node/src/chain_spec.rs index b00c984e..270fe695 100644 --- a/parachain-template/node/src/chain_spec.rs +++ b/parachain-template/node/src/chain_spec.rs @@ -72,10 +72,6 @@ pub fn development_config(id: ParaId) -> ChainSpec { get_account_id_from_seed::("Alice"), get_collator_keys_from_seed("Alice"), ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), - ), ], vec![ get_account_id_from_seed::("Alice"), From 16171372f196e4558ddc2a0642437d1bf8442469 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 6 Dec 2021 16:29:18 -0500 Subject: [PATCH 46/52] warnings --- pallets/author-inherent/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 42b98e5d..0c076719 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -27,7 +27,7 @@ use nimbus_primitives::{ }; use parity_scale_codec::{Decode, Encode}; use sp_inherents::{InherentIdentifier, IsFatalError}; -use sp_runtime::{ConsensusEngineId, DigestItem, RuntimeAppPublic, RuntimeString}; +use sp_runtime::{ConsensusEngineId, RuntimeString}; mod exec; pub use exec::BlockExecutor; @@ -124,7 +124,7 @@ pub mod pallet { /// for live chains. All nodes must begin including the pre-runtime digest before /// this runtime goes live. #[pallet::weight(0)] - pub fn set_author(origin: OriginFor, author: NimbusId) -> DispatchResult { + pub fn set_author(origin: OriginFor, _author: NimbusId) -> DispatchResult { ensure_none(origin)?; Ok(()) From fe2315c902374d5bdcf4f2b8f0c6f2bf19c92d20 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 7 Dec 2021 09:26:03 -0500 Subject: [PATCH 47/52] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: girazoki Co-authored-by: Éloïs --- nimbus-consensus/src/lib.rs | 2 +- pallets/author-inherent/src/exec.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nimbus-consensus/src/lib.rs b/nimbus-consensus/src/lib.rs index 2802d639..f66b6e7b 100644 --- a/nimbus-consensus/src/lib.rs +++ b/nimbus-consensus/src/lib.rs @@ -232,7 +232,7 @@ where // Iterate keys until we find an eligible one, or run out of candidates. // If we are skipping prediction, then we author with the first key we find. - // prediction skipping only really amkes sense when there is a single key in the keystore. + // prediction skipping only really makes sense when there is a single key in the keystore. let maybe_key = available_keys.into_iter().find(|type_public_pair| { // Have to convert to a typed NimbusId to pass to the runtime API. Maybe this is a clue // That I should be passing Vec across the wasm boundary? diff --git a/pallets/author-inherent/src/exec.rs b/pallets/author-inherent/src/exec.rs index 32635afd..ccd45b4a 100644 --- a/pallets/author-inherent/src/exec.rs +++ b/pallets/author-inherent/src/exec.rs @@ -63,7 +63,7 @@ where debug!(target: "executive", "🪲 Signature according to executive is {:?}", signature); - // Grab the author information from either the preruntime digest or the consensus digest + // Grab the author information from the preruntime digest //TODO use the trait let claimed_author = header .digest() @@ -75,7 +75,7 @@ where _ => None, } }) - .expect("Expected one consensus or pre-runtime digest that contains author id bytes"); + .expect("Expected pre-runtime digest that contains author id bytes"); debug!(target: "executive", "🪲 Claimed Author according to executive is {:?}", claimed_author); From 05097c5601bfbedaf318e814bd662beac5331eb5 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 7 Dec 2021 09:32:32 -0500 Subject: [PATCH 48/52] better weight in `on_initialize` --- pallets/author-inherent/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 0c076719..ad8de70c 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -102,7 +102,7 @@ pub mod pallet { T::EventHandler::note_author(author_account); }); - 0 + T::DbWeight::get().write * 2 } fn on_finalize(_: T::BlockNumber) { From b0dd22cf07d9da656d7a50b6d8958e5d4bddd0fe Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 7 Dec 2021 14:18:57 -0500 Subject: [PATCH 49/52] thoughts about the legacy author inherent --- pallets/author-inherent/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index ad8de70c..c70c3aeb 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -127,6 +127,14 @@ pub mod pallet { pub fn set_author(origin: OriginFor, _author: NimbusId) -> DispatchResult { ensure_none(origin)?; + //TODO Consider asserting that the data included here matches the preruntime digest. + // + // I don't believe the runtime is any more correct by asserting that. This data + // is now just grafitti. + // + // But from a practical standpoint, there are no good usecases for inserting different + // data, and there is some risk of offchain tools or indexers getting confused. + Ok(()) } } From 75e256d10187167d547aaa5e404dcbef7c08b92e Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 7 Dec 2021 14:35:20 -0500 Subject: [PATCH 50/52] sketch kick-off inherent in pallet --- pallets/author-inherent/src/lib.rs | 36 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index c70c3aeb..dd07dc67 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -104,18 +104,6 @@ pub mod pallet { T::DbWeight::get().write * 2 } - - fn on_finalize(_: T::BlockNumber) { - //TODO this should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 - // In the meantime, it will allow Alan to more easily profile block authorship. - let author = >::get() - .expect("Block invalid, no authorship information supplied."); - - assert!( - T::CanAuthor::can_author(&author, &T::SlotBeacon::slot()), - "Block invalid, supplied author is not eligible." - ); - } } #[pallet::call] @@ -123,7 +111,9 @@ pub mod pallet { /// This inherent is now a no-op. The extrinsic remains to facilitate a smooth transition /// for live chains. All nodes must begin including the pre-runtime digest before /// this runtime goes live. - #[pallet::weight(0)] + /// + /// The weight is increased for economic security and as an incentive mechanism to upgrade nodes. + #[pallet::weight(10 * T::DbWeight::get().write)] pub fn set_author(origin: OriginFor, _author: NimbusId) -> DispatchResult { ensure_none(origin)?; @@ -137,6 +127,26 @@ pub mod pallet { Ok(()) } + + + /// This inherent is a workaround to run code after the "real" inherents have executed, + /// but before transactions are executed. + /// This this should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 + /// TODO better weight. For now we jsut set a somewhat soncervative fudge factor + #[pallet::weight(10 * T::DbWeight::get().write)] + pub fn kick_off_authorship_validation(origin: OriginFor) -> DispatchResult { + ensure_none(origin)?; + + let author = >::get() + .expect("Block invalid, no authorship information supplied in preruntime digest."); + + assert!( + T::CanAuthor::can_author(&author, &T::SlotBeacon::slot()), + "Block invalid, supplied author is not eligible." + ); + + Ok(()) + } } #[pallet::inherent] From c3cf4b1ef5037a7b6583121213531a796e80ad20 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 7 Dec 2021 14:39:29 -0500 Subject: [PATCH 51/52] fees --- pallets/author-inherent/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index dd07dc67..62cd26a6 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -133,8 +133,8 @@ pub mod pallet { /// but before transactions are executed. /// This this should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 /// TODO better weight. For now we jsut set a somewhat soncervative fudge factor - #[pallet::weight(10 * T::DbWeight::get().write)] - pub fn kick_off_authorship_validation(origin: OriginFor) -> DispatchResult { + #[pallet::weight((10 * T::DbWeight::get().write, DispatchClass::Mandatory))] + pub fn kick_off_authorship_validation(origin: OriginFor) -> DispatchResultWithPostInfo { ensure_none(origin)?; let author = >::get() @@ -145,7 +145,7 @@ pub mod pallet { "Block invalid, supplied author is not eligible." ); - Ok(()) + Ok(Pays::No.into()) } } From ffb03c0614af1d3649fe52423ba99d98035baf74 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 7 Dec 2021 15:08:05 -0500 Subject: [PATCH 52/52] Update the inherent extrinsics --- pallets/author-inherent/src/lib.rs | 45 ++++++++---------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 62cd26a6..70d1f9b7 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -21,7 +21,6 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::traits::FindAuthor; -use log::debug; use nimbus_primitives::{ AccountLookup, CanAuthor, EventHandler, SlotBeacon, INHERENT_IDENTIFIER, NIMBUS_ENGINE_ID, NimbusId, }; @@ -108,27 +107,6 @@ pub mod pallet { #[pallet::call] impl Pallet { - /// This inherent is now a no-op. The extrinsic remains to facilitate a smooth transition - /// for live chains. All nodes must begin including the pre-runtime digest before - /// this runtime goes live. - /// - /// The weight is increased for economic security and as an incentive mechanism to upgrade nodes. - #[pallet::weight(10 * T::DbWeight::get().write)] - pub fn set_author(origin: OriginFor, _author: NimbusId) -> DispatchResult { - ensure_none(origin)?; - - //TODO Consider asserting that the data included here matches the preruntime digest. - // - // I don't believe the runtime is any more correct by asserting that. This data - // is now just grafitti. - // - // But from a practical standpoint, there are no good usecases for inserting different - // data, and there is some risk of offchain tools or indexers getting confused. - - Ok(()) - } - - /// This inherent is a workaround to run code after the "real" inherents have executed, /// but before transactions are executed. /// This this should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 @@ -155,21 +133,22 @@ pub mod pallet { type Error = InherentError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(data: &InherentData) -> Option { - let author_raw = data - .get_data::(&INHERENT_IDENTIFIER); - - debug!("In create_inherent (runtime side). data is"); - debug!("{:?}", author_raw); - - let author = author_raw - .expect("Gets and decodes authorship inherent data")?; + fn is_inherent_required(_: &InherentData) -> Result, Self::Error> { + // Return Ok(Some(_)) unconditionally because this inherent is required in every block + // If it is not found, throw an AuthorInherentRequired error. + Ok(Some(InherentError::Other( + sp_runtime::RuntimeString::Borrowed("Inherent required to manually initiate author validation"), + ))) + } - Some(Call::set_author{author}) + // Regardless of whether the client is still supplying the author id, + // we will create the new empty-payload inherent extrinsic. + fn create_inherent(_data: &InherentData) -> Option { + Some(Call::kick_off_authorship_validation{}) } fn is_inherent(call: &Self::Call) -> bool { - matches!(call, Call::set_author{..}) + matches!(call, Call::kick_off_authorship_validation{..}) } }