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:
@@ -21,7 +21,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use polkadot_primitives::{Block, Hash, AccountId, BlockId};
|
||||
use polkadot_primitives::{Block, Hash, BlockId, parachain::CollatorId};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, Collation, Extrinsic, OutgoingMessage};
|
||||
use polkadot_primitives::parachain::{CandidateReceipt, ParachainHost};
|
||||
use runtime_primitives::traits::ProvideRuntimeApi;
|
||||
@@ -49,7 +49,7 @@ pub trait Collators: Clone {
|
||||
fn collate(&self, parachain: ParaId, relay_parent: Hash) -> Self::Collation;
|
||||
|
||||
/// Note a bad collator. TODO: take proof
|
||||
fn note_bad_collator(&self, collator: AccountId);
|
||||
fn note_bad_collator(&self, collator: CollatorId);
|
||||
}
|
||||
|
||||
/// A future which resolves when a collation is available.
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
//! Errors that can occur during the validation process.
|
||||
|
||||
use primitives::Ed25519AuthorityId as AuthorityId;
|
||||
use runtime_primitives::RuntimeString;
|
||||
|
||||
use primitives::ed25519::Public as AuthorityId;
|
||||
|
||||
error_chain! {
|
||||
links {
|
||||
Client(::client::error::Error, ::client::error::ErrorKind);
|
||||
|
||||
@@ -77,10 +77,9 @@ use parking_lot::Mutex;
|
||||
use polkadot_primitives::{Hash, Block, BlockId, BlockNumber, Header, SessionKey};
|
||||
use polkadot_primitives::parachain::{
|
||||
Id as ParaId, Chain, DutyRoster, BlockData, Extrinsic as ParachainExtrinsic, CandidateReceipt,
|
||||
CandidateSignature, ParachainHost, AttestedCandidate, Statement as PrimitiveStatement, Message,
|
||||
OutgoingMessage,
|
||||
ParachainHost, AttestedCandidate, Statement as PrimitiveStatement, Message, OutgoingMessage, CollatorSignature
|
||||
};
|
||||
use primitives::{Ed25519AuthorityId as AuthorityId, ed25519};
|
||||
use primitives::{Pair, ed25519};
|
||||
use runtime_primitives::{traits::{ProvideRuntimeApi, Header as HeaderT}, ApplyError};
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use tokio::timer::{Delay, Interval};
|
||||
@@ -95,6 +94,8 @@ use inherents::InherentData;
|
||||
use runtime_aura::timestamp::TimestampInherentData;
|
||||
use aura::SlotDuration;
|
||||
|
||||
use ed25519::Public as AuthorityId;
|
||||
|
||||
pub use self::collation::{validate_collation, message_queue_root, egress_roots, Collators};
|
||||
pub use self::error::{ErrorKind, Error};
|
||||
pub use self::shared_table::{
|
||||
@@ -192,7 +193,7 @@ pub struct GroupInfo {
|
||||
/// Sign a table statement against a parent hash.
|
||||
/// The actual message signed is the encoded statement concatenated with the
|
||||
/// parent hash.
|
||||
pub fn sign_table_statement(statement: &Statement, key: &ed25519::Pair, parent_hash: &Hash) -> CandidateSignature {
|
||||
pub fn sign_table_statement(statement: &Statement, key: &ed25519::Pair, parent_hash: &Hash) -> CollatorSignature {
|
||||
// we sign using the primitive statement type because that's what the runtime
|
||||
// expects. These types probably encode the same way so this clone could be optimized
|
||||
// out in the future.
|
||||
@@ -203,7 +204,7 @@ pub fn sign_table_statement(statement: &Statement, key: &ed25519::Pair, parent_h
|
||||
}
|
||||
|
||||
/// Check signature on table statement.
|
||||
pub fn check_statement(statement: &Statement, signature: &CandidateSignature, signer: SessionKey, parent_hash: &Hash) -> bool {
|
||||
pub fn check_statement(statement: &Statement, signature: &CollatorSignature, signer: SessionKey, parent_hash: &Hash) -> bool {
|
||||
use runtime_primitives::traits::Verify;
|
||||
|
||||
let mut encoded = PrimitiveStatement::from(statement.clone()).encode();
|
||||
@@ -799,17 +800,17 @@ impl<C, TxApi> Future for CreateProposal<C, TxApi> where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use substrate_keyring::Keyring;
|
||||
use substrate_keyring::AuthorityKeyring;
|
||||
|
||||
#[test]
|
||||
fn sign_and_check_statement() {
|
||||
let statement: Statement = GenericStatement::Valid([1; 32].into());
|
||||
let parent_hash = [2; 32].into();
|
||||
|
||||
let sig = sign_table_statement(&statement, &Keyring::Alice.pair(), &parent_hash);
|
||||
let sig = sign_table_statement(&statement, &AuthorityKeyring::Alice.pair(), &parent_hash);
|
||||
|
||||
assert!(check_statement(&statement, &sig, Keyring::Alice.to_raw_public().into(), &parent_hash));
|
||||
assert!(!check_statement(&statement, &sig, Keyring::Alice.to_raw_public().into(), &[0xff; 32].into()));
|
||||
assert!(!check_statement(&statement, &sig, Keyring::Bob.to_raw_public().into(), &parent_hash));
|
||||
assert!(check_statement(&statement, &sig, AuthorityKeyring::Alice.into(), &parent_hash));
|
||||
assert!(!check_statement(&statement, &sig, AuthorityKeyring::Alice.into(), &[0xff; 32].into()));
|
||||
assert!(!check_statement(&statement, &sig, AuthorityKeyring::Bob.into(), &parent_hash));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use futures::{future, prelude::*};
|
||||
|
||||
use super::{GroupInfo, Incoming, TableRouter};
|
||||
use self::includable::IncludabilitySender;
|
||||
use primitives::ed25519;
|
||||
use primitives::{Pair, ed25519};
|
||||
use runtime_primitives::{traits::ProvideRuntimeApi};
|
||||
|
||||
mod includable;
|
||||
@@ -544,7 +544,8 @@ impl SharedTable {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use substrate_keyring::Keyring;
|
||||
use substrate_keyring::AuthorityKeyring;
|
||||
use primitives::crypto::UncheckedInto;
|
||||
use futures::future;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -572,15 +573,16 @@ mod tests {
|
||||
let mut groups = HashMap::new();
|
||||
|
||||
let para_id = ParaId::from(1);
|
||||
let local_id = Keyring::Alice.to_raw_public().into();
|
||||
let local_key = Arc::new(Keyring::Alice.pair());
|
||||
|
||||
let validity_other = Keyring::Bob.to_raw_public().into();
|
||||
let validity_other_key = Keyring::Bob.pair();
|
||||
let parent_hash = Default::default();
|
||||
|
||||
let local_key = Arc::new(AuthorityKeyring::Alice.pair());
|
||||
let local_id = local_key.public();
|
||||
|
||||
let validity_other_key = AuthorityKeyring::Bob.pair();
|
||||
let validity_other = validity_other_key.public();
|
||||
|
||||
groups.insert(para_id, GroupInfo {
|
||||
validity_guarantors: [local_id, validity_other].iter().cloned().collect(),
|
||||
validity_guarantors: [local_id, validity_other.clone()].iter().cloned().collect(),
|
||||
needed_validity: 2,
|
||||
});
|
||||
|
||||
@@ -593,7 +595,7 @@ mod tests {
|
||||
|
||||
let candidate = CandidateReceipt {
|
||||
parachain_index: para_id,
|
||||
collator: [1; 32].into(),
|
||||
collator: [1; 32].unchecked_into(),
|
||||
signature: Default::default(),
|
||||
head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
|
||||
balance_uploads: Vec::new(),
|
||||
@@ -622,15 +624,16 @@ mod tests {
|
||||
let mut groups = HashMap::new();
|
||||
|
||||
let para_id = ParaId::from(1);
|
||||
let local_id = Keyring::Alice.to_raw_public().into();
|
||||
let local_key = Arc::new(Keyring::Alice.pair());
|
||||
|
||||
let validity_other = Keyring::Bob.to_raw_public().into();
|
||||
let validity_other_key = Keyring::Bob.pair();
|
||||
let parent_hash = Default::default();
|
||||
|
||||
let local_key = Arc::new(AuthorityKeyring::Alice.pair());
|
||||
let local_id = local_key.public();
|
||||
|
||||
let validity_other_key = AuthorityKeyring::Bob.pair();
|
||||
let validity_other = validity_other_key.public();
|
||||
|
||||
groups.insert(para_id, GroupInfo {
|
||||
validity_guarantors: [local_id, validity_other].iter().cloned().collect(),
|
||||
validity_guarantors: [local_id, validity_other.clone()].iter().cloned().collect(),
|
||||
needed_validity: 1,
|
||||
});
|
||||
|
||||
@@ -643,7 +646,7 @@ mod tests {
|
||||
|
||||
let candidate = CandidateReceipt {
|
||||
parachain_index: para_id,
|
||||
collator: [1; 32].into(),
|
||||
collator: [1; 32].unchecked_into(),
|
||||
signature: Default::default(),
|
||||
head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
|
||||
balance_uploads: Vec::new(),
|
||||
@@ -676,7 +679,7 @@ mod tests {
|
||||
|
||||
let candidate = CandidateReceipt {
|
||||
parachain_index: para_id,
|
||||
collator: [1; 32].into(),
|
||||
collator: [1; 32].unchecked_into(),
|
||||
signature: Default::default(),
|
||||
head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
|
||||
balance_uploads: Vec::new(),
|
||||
@@ -716,7 +719,7 @@ mod tests {
|
||||
|
||||
let candidate = CandidateReceipt {
|
||||
parachain_index: para_id,
|
||||
collator: [1; 32].into(),
|
||||
collator: [1; 32].unchecked_into(),
|
||||
signature: Default::default(),
|
||||
head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
|
||||
balance_uploads: Vec::new(),
|
||||
@@ -751,15 +754,16 @@ mod tests {
|
||||
let mut groups = HashMap::new();
|
||||
|
||||
let para_id = ParaId::from(1);
|
||||
let local_id = Keyring::Alice.to_raw_public().into();
|
||||
let local_key = Arc::new(Keyring::Alice.pair());
|
||||
|
||||
let validity_other = Keyring::Bob.to_raw_public().into();
|
||||
let validity_other_key = Keyring::Bob.pair();
|
||||
let parent_hash = Default::default();
|
||||
|
||||
let local_key = Arc::new(AuthorityKeyring::Alice.pair());
|
||||
let local_id = local_key.public();
|
||||
|
||||
let validity_other_key = AuthorityKeyring::Bob.pair();
|
||||
let validity_other = validity_other_key.public();
|
||||
|
||||
groups.insert(para_id, GroupInfo {
|
||||
validity_guarantors: [local_id, validity_other].iter().cloned().collect(),
|
||||
validity_guarantors: [local_id, validity_other.clone()].iter().cloned().collect(),
|
||||
needed_validity: 1,
|
||||
});
|
||||
|
||||
@@ -772,7 +776,7 @@ mod tests {
|
||||
|
||||
let candidate = CandidateReceipt {
|
||||
parachain_index: para_id,
|
||||
collator: [1; 32].into(),
|
||||
collator: [1; 32].unchecked_into(),
|
||||
signature: Default::default(),
|
||||
head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
|
||||
balance_uploads: Vec::new(),
|
||||
@@ -811,14 +815,16 @@ mod tests {
|
||||
let mut groups = HashMap::new();
|
||||
|
||||
let para_id = ParaId::from(1);
|
||||
let local_id = Keyring::Alice.to_raw_public().into();
|
||||
let local_key = Arc::new(Keyring::Alice.pair());
|
||||
let block_data = BlockData(vec![1, 2, 3]);
|
||||
let extrinsic = Extrinsic { outgoing_messages: Vec::new() };
|
||||
|
||||
let validity_other = Keyring::Bob.to_raw_public().into();
|
||||
let parent_hash = Default::default();
|
||||
|
||||
let local_key = Arc::new(AuthorityKeyring::Alice.pair());
|
||||
let local_id = local_key.public();
|
||||
|
||||
let validity_other_key = AuthorityKeyring::Bob.pair();
|
||||
let validity_other = validity_other_key.public();
|
||||
|
||||
groups.insert(para_id, GroupInfo {
|
||||
validity_guarantors: [local_id, validity_other].iter().cloned().collect(),
|
||||
needed_validity: 1,
|
||||
@@ -833,7 +839,7 @@ mod tests {
|
||||
|
||||
let candidate = CandidateReceipt {
|
||||
parachain_index: para_id,
|
||||
collator: [1; 32].into(),
|
||||
collator: [1; 32].unchecked_into(),
|
||||
signature: Default::default(),
|
||||
head_data: ::polkadot_primitives::parachain::HeadData(vec![1, 2, 3, 4]),
|
||||
balance_uploads: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user