mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
Update to Substrate master (#176)
* Update to master This introduces a new type `CollatorId`, currently just `SessionKey` but which would forseeably change to its own thing. It seems to work like this (despite there being a lot of the new-incompatible `AccountId` replaced). No idea if it does anything sensible, though. * Cleanups * Fix tests * Remove commented code * Specify commit hash * Remove commented code * Correct version * Update runtime/Cargo.toml Co-Authored-By: gavofyork <github@gavwood.com> * PairT instead of _Pair * Update lock file * Remove rev causing upset
This commit is contained in:
@@ -78,8 +78,8 @@ mod claims;
|
||||
use rstd::prelude::*;
|
||||
use substrate_primitives::u32_trait::{_2, _4};
|
||||
use primitives::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, SessionKey, Signature,
|
||||
parachain,
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, SessionKey, SessionSignature,
|
||||
Signature, parachain,
|
||||
};
|
||||
use client::{
|
||||
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
|
||||
@@ -87,7 +87,7 @@ use client::{
|
||||
};
|
||||
use sr_primitives::{
|
||||
ApplyResult, generic, transaction_validity::TransactionValidity,
|
||||
traits::{Convert, BlakeTwo256, Block as BlockT, DigestFor, StaticLookup}
|
||||
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup}
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
use grandpa::fg_primitives::{self, ScheduledChange};
|
||||
@@ -98,6 +98,8 @@ use council::seats as council_seats;
|
||||
use version::NativeVersion;
|
||||
use substrate_primitives::OpaqueMetadata;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use staking::StakerStatus;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sr_primitives::BuildStorage;
|
||||
pub use consensus::Call as ConsensusCall;
|
||||
@@ -173,16 +175,8 @@ impl timestamp::Trait for Runtime {
|
||||
type OnTimestampSet = Aura;
|
||||
}
|
||||
|
||||
/// Session key conversion.
|
||||
pub struct SessionKeyConversion;
|
||||
impl Convert<AccountId, SessionKey> for SessionKeyConversion {
|
||||
fn convert(a: AccountId) -> SessionKey {
|
||||
a.to_fixed_bytes().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
type ConvertAccountIdToSessionKey = SessionKeyConversion;
|
||||
type ConvertAccountIdToSessionKey = ();
|
||||
type OnSessionChange = (Staking, grandpa::SyncedAuthorities<Runtime>);
|
||||
type Event = Event;
|
||||
}
|
||||
@@ -244,7 +238,7 @@ impl fees::Trait for Runtime {
|
||||
}
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey>) where
|
||||
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey, SessionSignature>) where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
@@ -343,8 +337,8 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<AccountId> {
|
||||
Session::validators()
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Consensus::authorities() // only possible as long as parachain validator crypto === aura crypto
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster()
|
||||
|
||||
@@ -415,7 +415,7 @@ impl<T: Trait> Module<T> {
|
||||
};
|
||||
|
||||
ensure!(
|
||||
sig.verify(&payload[..], &auth_id.0.into()),
|
||||
sig.verify(&payload[..], &auth_id),
|
||||
"Candidate validity attestation signature is bad."
|
||||
);
|
||||
}
|
||||
@@ -468,7 +468,7 @@ mod tests {
|
||||
use sr_primitives::{generic, BuildStorage};
|
||||
use sr_primitives::traits::{BlakeTwo256, IdentityLookup};
|
||||
use primitives::{parachain::{CandidateReceipt, HeadData, ValidityAttestation}, SessionKey};
|
||||
use keyring::Keyring;
|
||||
use keyring::{AuthorityKeyring, AccountKeyring};
|
||||
use {consensus, timestamp};
|
||||
|
||||
impl_outer_origin! {
|
||||
@@ -496,7 +496,7 @@ mod tests {
|
||||
type Log = ::Log;
|
||||
}
|
||||
impl session::Trait for Test {
|
||||
type ConvertAccountIdToSessionKey = ::SessionKeyConversion;
|
||||
type ConvertAccountIdToSessionKey = ();
|
||||
type OnSessionChange = ();
|
||||
type Event = ();
|
||||
}
|
||||
@@ -511,23 +511,33 @@ mod tests {
|
||||
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities<Blake2Hasher> {
|
||||
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
|
||||
let authority_keys = [
|
||||
Keyring::Alice,
|
||||
Keyring::Bob,
|
||||
Keyring::Charlie,
|
||||
Keyring::Dave,
|
||||
Keyring::Eve,
|
||||
Keyring::Ferdie,
|
||||
Keyring::One,
|
||||
Keyring::Two,
|
||||
AuthorityKeyring::Alice,
|
||||
AuthorityKeyring::Bob,
|
||||
AuthorityKeyring::Charlie,
|
||||
AuthorityKeyring::Dave,
|
||||
AuthorityKeyring::Eve,
|
||||
AuthorityKeyring::Ferdie,
|
||||
AuthorityKeyring::One,
|
||||
AuthorityKeyring::Two,
|
||||
];
|
||||
let validator_keys = [
|
||||
AccountKeyring::Alice,
|
||||
AccountKeyring::Bob,
|
||||
AccountKeyring::Charlie,
|
||||
AccountKeyring::Dave,
|
||||
AccountKeyring::Eve,
|
||||
AccountKeyring::Ferdie,
|
||||
AccountKeyring::One,
|
||||
AccountKeyring::Two,
|
||||
];
|
||||
|
||||
t.extend(consensus::GenesisConfig::<Test>{
|
||||
code: vec![],
|
||||
authorities: authority_keys.iter().map(|k| k.to_raw_public().into()).collect(),
|
||||
authorities: authority_keys.iter().map(|k| SessionKey::from(*k)).collect(),
|
||||
}.build_storage().unwrap().0);
|
||||
t.extend(session::GenesisConfig::<Test>{
|
||||
session_length: 1000,
|
||||
validators: authority_keys.iter().map(|k| k.to_raw_public().into()).collect(),
|
||||
validators: validator_keys.iter().map(|k| ::AccountId::from(*k)).collect(),
|
||||
keys: vec![],
|
||||
}.build_storage().unwrap().0);
|
||||
t.extend(GenesisConfig::<Test>{
|
||||
@@ -545,8 +555,8 @@ mod tests {
|
||||
let candidate_hash = candidate.candidate.hash();
|
||||
|
||||
let authorities = ::Consensus::authorities();
|
||||
let extract_key = |public: SessionKey| {
|
||||
Keyring::from_raw_public(public.0).unwrap()
|
||||
let extract_key = |public: &SessionKey| {
|
||||
AuthorityKeyring::from_public(public).unwrap()
|
||||
};
|
||||
|
||||
let validation_entries = duty_roster.validator_duty.iter()
|
||||
@@ -556,7 +566,7 @@ mod tests {
|
||||
if duty != Chain::Parachain(candidate.parachain_index()) { continue }
|
||||
vote_implicit = !vote_implicit;
|
||||
|
||||
let key = extract_key(authorities[idx]);
|
||||
let key = extract_key(&authorities[idx]);
|
||||
|
||||
let statement = if vote_implicit {
|
||||
Statement::Candidate(candidate.candidate.clone())
|
||||
@@ -567,7 +577,7 @@ mod tests {
|
||||
let payload = localized_payload(statement, parent_hash);
|
||||
let signature = key.sign(&payload[..]).into();
|
||||
|
||||
candidate.validity_votes.push((authorities[idx], if vote_implicit {
|
||||
candidate.validity_votes.push((authorities[idx].clone(), if vote_implicit {
|
||||
ValidityAttestation::Implicit(signature)
|
||||
} else {
|
||||
ValidityAttestation::Explicit(signature)
|
||||
|
||||
Reference in New Issue
Block a user