mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Update Substrate (#514)
* Update Substrate * Attempt a fix * Update substrate again * Fix compilation * update substrate add support for sentry * Fixes tests
This commit is contained in:
Generated
+150
-153
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ pub use service::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub use cli::{VersionInfo, IntoExit, NoCustom};
|
pub use cli::{VersionInfo, IntoExit, NoCustom};
|
||||||
pub use cli::error;
|
pub use cli::{display_role, error};
|
||||||
|
|
||||||
/// Abstraction over an executor that lets you spawn tasks in the background.
|
/// Abstraction over an executor that lets you spawn tasks in the background.
|
||||||
pub type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
|
pub type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
|
||||||
@@ -98,7 +98,7 @@ pub fn run<W>(worker: W, version: cli::VersionInfo) -> error::Result<()> where
|
|||||||
info!(" by {}, 2017-2019", version.author);
|
info!(" by {}, 2017-2019", version.author);
|
||||||
info!("Chain specification: {}", config.chain_spec.name());
|
info!("Chain specification: {}", config.chain_spec.name());
|
||||||
info!("Node name: {}", config.name);
|
info!("Node name: {}", config.name);
|
||||||
info!("Roles: {:?}", config.roles);
|
info!("Roles: {}", display_role(&config));
|
||||||
config.custom = worker.configuration();
|
config.custom = worker.configuration();
|
||||||
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
|
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
|
||||||
match config.roles {
|
match config.roles {
|
||||||
|
|||||||
@@ -40,15 +40,14 @@ use client::{
|
|||||||
runtime_api as client_api, impl_runtime_apis,
|
runtime_api as client_api, impl_runtime_apis,
|
||||||
};
|
};
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
create_runtime_str, generic, impl_opaque_keys, key_types,
|
create_runtime_str, generic, impl_opaque_keys,
|
||||||
ApplyResult, Permill, Perbill, RuntimeDebug,
|
ApplyResult, Permill, Perbill, RuntimeDebug,
|
||||||
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
|
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
|
||||||
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
|
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
|
||||||
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension},
|
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys},
|
||||||
};
|
};
|
||||||
use version::RuntimeVersion;
|
use version::RuntimeVersion;
|
||||||
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
||||||
use babe_primitives::{AuthorityId as BabeId};
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
use version::NativeVersion;
|
use version::NativeVersion;
|
||||||
use substrate_primitives::OpaqueMetadata;
|
use substrate_primitives::OpaqueMetadata;
|
||||||
@@ -256,27 +255,14 @@ parameter_types! {
|
|||||||
pub const Offset: BlockNumber = 0;
|
pub const Offset: BlockNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!!!!!!!!!!!!
|
|
||||||
// WARNING!!!!!! SEE NOTE BELOW BEFORE TOUCHING THIS CODE
|
|
||||||
// !!!!!!!!!!!!!
|
|
||||||
type SessionHandlers = (Grandpa, Babe, ImOnline, Parachains);
|
|
||||||
impl_opaque_keys! {
|
impl_opaque_keys! {
|
||||||
pub struct SessionKeys {
|
pub struct SessionKeys {
|
||||||
#[id(key_types::GRANDPA)]
|
pub grandpa: Grandpa,
|
||||||
pub grandpa: GrandpaId,
|
pub babe: Babe,
|
||||||
#[id(key_types::BABE)]
|
pub im_online: ImOnline,
|
||||||
pub babe: BabeId,
|
pub parachain_validator: Parachains,
|
||||||
#[id(key_types::IM_ONLINE)]
|
|
||||||
pub im_online: ImOnlineId,
|
|
||||||
#[id(parachain::PARACHAIN_KEY_TYPE_ID)]
|
|
||||||
pub parachain_validator: parachain::ValidatorId,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
|
|
||||||
// The number and order of items in `SessionHandler` *MUST* be the same number and order of keys in
|
|
||||||
// `SessionKeys`.
|
|
||||||
// TODO: Introduce some structure to tie these together to make it a bit less of a footgun. This
|
|
||||||
// should be easy, since OneSessionHandler trait provides the `Key` as an associated type. #2858
|
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
|
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
|
||||||
@@ -284,7 +270,7 @@ parameter_types! {
|
|||||||
|
|
||||||
impl session::Trait for Runtime {
|
impl session::Trait for Runtime {
|
||||||
type OnSessionEnding = Staking;
|
type OnSessionEnding = Staking;
|
||||||
type SessionHandler = SessionHandlers;
|
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
|
||||||
type ShouldEndSession = Babe;
|
type ShouldEndSession = Babe;
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Keys = SessionKeys;
|
type Keys = SessionKeys;
|
||||||
|
|||||||
@@ -842,6 +842,10 @@ impl<T: Trait> Module<T> {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Trait> sr_primitives::BoundToRuntimeAppPublic for Module<T> {
|
||||||
|
type Public = ValidatorId;
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||||
type Key = ValidatorId;
|
type Key = ValidatorId;
|
||||||
|
|
||||||
@@ -902,13 +906,14 @@ mod tests {
|
|||||||
use substrate_primitives::{H256, Blake2Hasher};
|
use substrate_primitives::{H256, Blake2Hasher};
|
||||||
use substrate_trie::NodeCodec;
|
use substrate_trie::NodeCodec;
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
Perbill,
|
Perbill, curve::PiecewiseLinear, testing::{UintAuthorityId, Header},
|
||||||
traits::{BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize},
|
traits::{BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize},
|
||||||
testing::{UintAuthorityId, Header},
|
|
||||||
curve::PiecewiseLinear,
|
|
||||||
};
|
};
|
||||||
use primitives::{
|
use primitives::{
|
||||||
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorId, Info as ParaInfo, Scheduling},
|
parachain::{
|
||||||
|
CandidateReceipt, HeadData, ValidityAttestation, ValidatorId, Info as ParaInfo,
|
||||||
|
Scheduling,
|
||||||
|
},
|
||||||
BlockNumber,
|
BlockNumber,
|
||||||
};
|
};
|
||||||
use crate::constants::time::*;
|
use crate::constants::time::*;
|
||||||
@@ -940,6 +945,7 @@ mod tests {
|
|||||||
pub const MaximumBlockLength: u32 = 4 * 1024 * 1024;
|
pub const MaximumBlockLength: u32 = 4 * 1024 * 1024;
|
||||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl system::Trait for Test {
|
impl system::Trait for Test {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
@@ -968,7 +974,7 @@ mod tests {
|
|||||||
type OnSessionEnding = ();
|
type OnSessionEnding = ();
|
||||||
type Keys = UintAuthorityId;
|
type Keys = UintAuthorityId;
|
||||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionHandler = ();
|
type SessionHandler = session::TestSessionHandler;
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type SelectInitialValidators = staking::Module<Self>;
|
type SelectInitialValidators = staking::Module<Self>;
|
||||||
type ValidatorId = u64;
|
type ValidatorId = u64;
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ mod tests {
|
|||||||
type OnSessionEnding = ();
|
type OnSessionEnding = ();
|
||||||
type Keys = UintAuthorityId;
|
type Keys = UintAuthorityId;
|
||||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionHandler = ();
|
type SessionHandler = session::TestSessionHandler;
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type SelectInitialValidators = ();
|
type SelectInitialValidators = ();
|
||||||
type ValidatorId = u64;
|
type ValidatorId = u64;
|
||||||
|
|||||||
@@ -150,6 +150,11 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
let disable_grandpa = config.disable_grandpa;
|
let disable_grandpa = config.disable_grandpa;
|
||||||
let name = config.name.clone();
|
let name = config.name.clone();
|
||||||
|
|
||||||
|
// sentry nodes announce themselves as authorities to the network
|
||||||
|
// and should run the same protocols authorities do, but it should
|
||||||
|
// never actively participate in any consensus process.
|
||||||
|
let participates_in_consensus = is_authority && !config.sentry_mode;
|
||||||
|
|
||||||
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
||||||
|
|
||||||
// Dht event channel from the network to the authority discovery module. Use
|
// Dht event channel from the network to the authority discovery module. Use
|
||||||
@@ -204,7 +209,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
(is_known, client.clone()),
|
(is_known, client.clone()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_authority {
|
if participates_in_consensus {
|
||||||
let availability_store = {
|
let availability_store = {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@@ -264,7 +269,9 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
service.spawn_essential_task(babe);
|
service.spawn_essential_task(babe);
|
||||||
}
|
}
|
||||||
|
|
||||||
let keystore = if is_authority {
|
// if the node isn't actively participating in consensus then it doesn't
|
||||||
|
// need a keystore, regardless of which protocol we use below.
|
||||||
|
let keystore = if participates_in_consensus {
|
||||||
Some(service.keystore())
|
Some(service.keystore())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -275,7 +282,9 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
gossip_duration: Duration::from_millis(333),
|
gossip_duration: Duration::from_millis(333),
|
||||||
justification_period: 512,
|
justification_period: 512,
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
|
observer_enabled: false,
|
||||||
keystore,
|
keystore,
|
||||||
|
is_authority,
|
||||||
};
|
};
|
||||||
|
|
||||||
let enable_grandpa = !disable_grandpa;
|
let enable_grandpa = !disable_grandpa;
|
||||||
|
|||||||
Reference in New Issue
Block a user