mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31: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::error;
|
||||
pub use cli::{display_role, error};
|
||||
|
||||
/// 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>;
|
||||
@@ -98,7 +98,7 @@ pub fn run<W>(worker: W, version: cli::VersionInfo) -> error::Result<()> where
|
||||
info!(" by {}, 2017-2019", version.author);
|
||||
info!("Chain specification: {}", config.chain_spec.name());
|
||||
info!("Node name: {}", config.name);
|
||||
info!("Roles: {:?}", config.roles);
|
||||
info!("Roles: {}", display_role(&config));
|
||||
config.custom = worker.configuration();
|
||||
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
|
||||
match config.roles {
|
||||
|
||||
@@ -40,15 +40,14 @@ use client::{
|
||||
runtime_api as client_api, impl_runtime_apis,
|
||||
};
|
||||
use sr_primitives::{
|
||||
create_runtime_str, generic, impl_opaque_keys, key_types,
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
ApplyResult, Permill, Perbill, RuntimeDebug,
|
||||
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
|
||||
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
|
||||
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension},
|
||||
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys},
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
||||
use babe_primitives::{AuthorityId as BabeId};
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use version::NativeVersion;
|
||||
use substrate_primitives::OpaqueMetadata;
|
||||
@@ -256,27 +255,14 @@ parameter_types! {
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
// !!!!!!!!!!!!!
|
||||
// WARNING!!!!!! SEE NOTE BELOW BEFORE TOUCHING THIS CODE
|
||||
// !!!!!!!!!!!!!
|
||||
type SessionHandlers = (Grandpa, Babe, ImOnline, Parachains);
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
#[id(key_types::GRANDPA)]
|
||||
pub grandpa: GrandpaId,
|
||||
#[id(key_types::BABE)]
|
||||
pub babe: BabeId,
|
||||
#[id(key_types::IM_ONLINE)]
|
||||
pub im_online: ImOnlineId,
|
||||
#[id(parachain::PARACHAIN_KEY_TYPE_ID)]
|
||||
pub parachain_validator: parachain::ValidatorId,
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub parachain_validator: Parachains,
|
||||
}
|
||||
}
|
||||
// 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! {
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
|
||||
@@ -284,7 +270,7 @@ parameter_types! {
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
type OnSessionEnding = Staking;
|
||||
type SessionHandler = SessionHandlers;
|
||||
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
|
||||
type ShouldEndSession = Babe;
|
||||
type Event = Event;
|
||||
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> {
|
||||
type Key = ValidatorId;
|
||||
|
||||
@@ -902,13 +906,14 @@ mod tests {
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use substrate_trie::NodeCodec;
|
||||
use sr_primitives::{
|
||||
Perbill,
|
||||
Perbill, curve::PiecewiseLinear, testing::{UintAuthorityId, Header},
|
||||
traits::{BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize},
|
||||
testing::{UintAuthorityId, Header},
|
||||
curve::PiecewiseLinear,
|
||||
};
|
||||
use primitives::{
|
||||
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorId, Info as ParaInfo, Scheduling},
|
||||
parachain::{
|
||||
CandidateReceipt, HeadData, ValidityAttestation, ValidatorId, Info as ParaInfo,
|
||||
Scheduling,
|
||||
},
|
||||
BlockNumber,
|
||||
};
|
||||
use crate::constants::time::*;
|
||||
@@ -940,6 +945,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 4 * 1024 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
@@ -968,7 +974,7 @@ mod tests {
|
||||
type OnSessionEnding = ();
|
||||
type Keys = UintAuthorityId;
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type SessionHandler = ();
|
||||
type SessionHandler = session::TestSessionHandler;
|
||||
type Event = ();
|
||||
type SelectInitialValidators = staking::Module<Self>;
|
||||
type ValidatorId = u64;
|
||||
|
||||
@@ -688,7 +688,7 @@ mod tests {
|
||||
type OnSessionEnding = ();
|
||||
type Keys = UintAuthorityId;
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type SessionHandler = ();
|
||||
type SessionHandler = session::TestSessionHandler;
|
||||
type Event = ();
|
||||
type SelectInitialValidators = ();
|
||||
type ValidatorId = u64;
|
||||
|
||||
@@ -150,6 +150,11 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
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);
|
||||
|
||||
// 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()),
|
||||
);
|
||||
|
||||
if is_authority {
|
||||
if participates_in_consensus {
|
||||
let availability_store = {
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -264,7 +269,9 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
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())
|
||||
} else {
|
||||
None
|
||||
@@ -275,7 +282,9 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 512,
|
||||
name: Some(name),
|
||||
observer_enabled: false,
|
||||
keystore,
|
||||
is_authority,
|
||||
};
|
||||
|
||||
let enable_grandpa = !disable_grandpa;
|
||||
|
||||
Reference in New Issue
Block a user