mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
Minimal switch of substrate-node to GRANDPA /Aura (#1128)
* add beginnings of SRML grandpa library * get srml-grandpa compiling * tests for srml-grandpa * add optional session integration to grandpa SRML * start integration into node runtime * Allow extracting pending change from header digest * Make it compile on wasm * make tests compile again * Move Authority Key fetching into service, simplify service factory construction * Generalize Authority Consensus Setup system * Add Authority Setup Docs * Allow CLI params to be extensible - move params to structopts - split parsing and default command execution - add custom config to node - extended parsing of custom config - extending params via structop's flatten * Minor fixes on cli extension params: - added docs - re-add actual app name, rather than node-name - make strategy and subcommand optional * better cli params * synchronize GRANDPA and normal node authorities * Implement grandpa::network for gossip consensus * run_grandpa in Node * Fix missed merge error * Integrate grandpa import queue * more specific type def * link up linkhalf and import block * make grandpa future send * get compiling * Fix new params convention and license header * get it running * rebuild node runtime WASM * change logging level * Update node/cli/src/params.rs Co-Authored-By: rphmeier <rphmeier@gmail.com> * Update node/cli/src/params.rs Co-Authored-By: rphmeier <rphmeier@gmail.com> * Update node/cli/src/lib.rs Co-Authored-By: rphmeier <rphmeier@gmail.com> * Update node/runtime/src/lib.rs Co-Authored-By: rphmeier <rphmeier@gmail.com> * Update node/cli/src/lib.rs Co-Authored-By: rphmeier <rphmeier@gmail.com> * Clean up and Fixme for mutable config * Move GrandpaService Integration into grandpa, feature gated but on per default * Fixing grandpa runtime module test * Update wasm runtime hashes for tests * GRANDPA: use post-header hash when logging scheduled changes * add an extra bit of logging to authorities * fixing missing constrain * remove old code * move `NewAuthorities` to an event in srml-grandpa * fix node-executor tests to use grandpa log * Remove GossipConsensus from tests, use newly provided sync-feature, fixes tests * Update to latest wasm runtimes * address grumbles * address grumbles * only derive deserialize when using std * Clean up use of Deserialize
This commit is contained in:
committed by
GitHub
parent
84da9d4a02
commit
11fe84a742
@@ -23,6 +23,7 @@ srml-contract = { path = "../../srml/contract" }
|
||||
srml-council = { path = "../../srml/council" }
|
||||
srml-democracy = { path = "../../srml/democracy" }
|
||||
srml-executive = { path = "../../srml/executive" }
|
||||
srml-grandpa = { path = "../../srml/grandpa" }
|
||||
sr-primitives = { path = "../../core/sr-primitives" }
|
||||
srml-session = { path = "../../srml/session" }
|
||||
srml-staking = { path = "../../srml/staking" }
|
||||
@@ -46,6 +47,7 @@ std = [
|
||||
"srml-council/std",
|
||||
"srml-democracy/std",
|
||||
"srml-executive/std",
|
||||
"srml-grandpa/std",
|
||||
"sr-primitives/std",
|
||||
"srml-session/std",
|
||||
"srml-staking/std",
|
||||
|
||||
@@ -47,6 +47,7 @@ extern crate srml_contract as contract;
|
||||
extern crate srml_council as council;
|
||||
extern crate srml_democracy as democracy;
|
||||
extern crate srml_executive as executive;
|
||||
extern crate srml_grandpa as grandpa;
|
||||
extern crate srml_session as session;
|
||||
extern crate srml_staking as staking;
|
||||
extern crate srml_system as system;
|
||||
@@ -56,7 +57,6 @@ extern crate srml_upgrade_key as upgrade_key;
|
||||
#[macro_use]
|
||||
extern crate sr_version as version;
|
||||
extern crate node_primitives;
|
||||
extern crate substrate_finality_grandpa_primitives;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use codec::{Encode, Decode};
|
||||
@@ -65,6 +65,7 @@ use substrate_primitives::u32_trait::{_2, _4};
|
||||
use node_primitives::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, SessionKey, Signature
|
||||
};
|
||||
use grandpa::fg_primitives::{runtime::GrandpaApi, ScheduledChange, id::*};
|
||||
#[cfg(feature = "std")]
|
||||
use node_primitives::Block as GBlock;
|
||||
use client::{block_builder::api::runtime::*, runtime_api::{runtime::*, id::*}};
|
||||
@@ -85,7 +86,6 @@ use council::seats as council_seats;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use version::NativeVersion;
|
||||
use substrate_primitives::OpaqueMetadata;
|
||||
use substrate_finality_grandpa_primitives::{runtime::GrandpaApi, ScheduledChange};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use runtime_primitives::BuildStorage;
|
||||
@@ -109,7 +109,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
apis: apis_vec!([
|
||||
(BLOCK_BUILDER, 1),
|
||||
(TAGGED_TRANSACTION_QUEUE, 1),
|
||||
(METADATA, 1)
|
||||
(METADATA, 1),
|
||||
(GRANDPA_API, 1),
|
||||
]),
|
||||
};
|
||||
|
||||
@@ -165,7 +166,7 @@ impl Convert<AccountId, SessionKey> for SessionKeyConversion {
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
type ConvertAccountIdToSessionKey = SessionKeyConversion;
|
||||
type OnSessionChange = Staking;
|
||||
type OnSessionChange = (Staking, grandpa::SyncedAuthorities<Runtime>);
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
@@ -209,6 +210,12 @@ impl upgrade_key::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
type SessionKey = SessionKey;
|
||||
type Log = Log;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey>) where
|
||||
Block = Block,
|
||||
@@ -225,6 +232,7 @@ construct_runtime!(
|
||||
CouncilVoting: council_voting,
|
||||
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin},
|
||||
CouncilSeats: council_seats::{Config<T>},
|
||||
Grandpa: grandpa::{Module, Storage, Config<T>, Log(), Event<T>},
|
||||
Treasury: treasury,
|
||||
Contract: contract::{Module, Call, Config<T>, Event<T>},
|
||||
UpgradeKey: upgrade_key,
|
||||
@@ -463,15 +471,23 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl GrandpaApi<Block> for ClientWithApi {
|
||||
fn grandpa_pending_change(_digest: DigestFor<Block>)
|
||||
-> Option<ScheduledChange<NumberFor<Block>>> {
|
||||
unimplemented!("Robert, where is the impl?")
|
||||
impl GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_pending_change(digest: DigestFor<Block>)
|
||||
-> Option<ScheduledChange<NumberFor<Block>>>
|
||||
{
|
||||
for log in digest.logs.iter().filter_map(|l| match l {
|
||||
Log(InternalLog::grandpa(grandpa_signal)) => Some(grandpa_signal),
|
||||
_=> None
|
||||
}) {
|
||||
if let Some(change) = Grandpa::scrape_digest_change(log) {
|
||||
return Some(change);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn grandpa_authorities() -> Vec<(SessionKey, u64)> {
|
||||
unimplemented!("Robert, where is the impl?")
|
||||
Grandpa::grandpa_authorities()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+20
-1
@@ -513,6 +513,7 @@ dependencies = [
|
||||
"srml-council 0.1.0",
|
||||
"srml-democracy 0.1.0",
|
||||
"srml-executive 0.1.0",
|
||||
"srml-grandpa 0.1.0",
|
||||
"srml-session 0.1.0",
|
||||
"srml-staking 0.1.0",
|
||||
"srml-support 0.1.0",
|
||||
@@ -521,7 +522,6 @@ dependencies = [
|
||||
"srml-treasury 0.1.0",
|
||||
"srml-upgrade-key 0.1.0",
|
||||
"substrate-client 0.1.0",
|
||||
"substrate-finality-grandpa-primitives 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
]
|
||||
|
||||
@@ -1061,6 +1061,25 @@ dependencies = [
|
||||
"srml-system 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "srml-grandpa"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 0.1.0",
|
||||
"sr-primitives 0.1.0",
|
||||
"sr-std 0.1.0",
|
||||
"srml-session 0.1.0",
|
||||
"srml-support 0.1.0",
|
||||
"srml-system 0.1.0",
|
||||
"substrate-finality-grandpa-primitives 0.1.0",
|
||||
"substrate-primitives 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "srml-metadata"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -12,7 +12,6 @@ safe-mix = { version = "1.0", default-features = false }
|
||||
parity-codec-derive = { version = "2.1" }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { path = "../../../core/primitives", default-features = false }
|
||||
substrate-finality-grandpa-primitives = { path = "../../../core/finality-grandpa/primitives", default-features = false }
|
||||
substrate-client = { path = "../../../core/client", default-features = false }
|
||||
sr-std = { path = "../../../core/sr-std", default-features = false }
|
||||
srml-support = { path = "../../../srml/support", default-features = false }
|
||||
@@ -29,6 +28,7 @@ srml-system = { path = "../../../srml/system", default-features = false }
|
||||
srml-timestamp = { path = "../../../srml/timestamp", default-features = false }
|
||||
srml-treasury = { path = "../../../srml/treasury", default-features = false }
|
||||
srml-upgrade-key = { path = "../../../srml/upgrade-key", default-features = false }
|
||||
srml-grandpa = { path = "../../../srml/grandpa", default-features = false }
|
||||
sr-version = { path = "../../../core/sr-version", default-features = false }
|
||||
node-primitives = { path = "../../primitives", default-features = false }
|
||||
|
||||
@@ -39,8 +39,8 @@ std = [
|
||||
"parity-codec/std",
|
||||
"substrate-primitives/std",
|
||||
"substrate-client/std",
|
||||
"substrate-finality-grandpa-primitives/std",
|
||||
"sr-std/std",
|
||||
"sr-primitives/std",
|
||||
"srml-support/std",
|
||||
"srml-balances/std",
|
||||
"srml-consensus/std",
|
||||
@@ -48,13 +48,13 @@ std = [
|
||||
"srml-council/std",
|
||||
"srml-democracy/std",
|
||||
"srml-executive/std",
|
||||
"sr-primitives/std",
|
||||
"srml-session/std",
|
||||
"srml-staking/std",
|
||||
"srml-system/std",
|
||||
"srml-timestamp/std",
|
||||
"srml-treasury/std",
|
||||
"srml-upgrade-key/std",
|
||||
"srml-grandpa/std",
|
||||
"sr-version/std",
|
||||
"node-primitives/std",
|
||||
]
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user