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:
Gavin Wood
2019-10-29 22:00:12 +01:00
committed by GitHub
parent 16e0e4afd1
commit 0168e2f0fe
6 changed files with 182 additions and 184 deletions
+7 -21
View File
@@ -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;
+11 -5
View File
@@ -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;
+1 -1
View File
@@ -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;