Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,550 changes: 780 additions & 770 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ path = "src/main.rs"

[package]
name = "polkadot"
version = "0.3.15"
version = "0.3.16"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-cli"
version = "0.3.15"
version = "0.3.16"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot node implementation in Rust."

Expand Down
13 changes: 4 additions & 9 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ use std::time::Duration;

use futures::{future, stream, Stream, Future, IntoFuture};
use client::BlockchainEvents;
use primitives::ed25519;
use polkadot_primitives::{AccountId, BlockId, SessionKey};
use primitives::{ed25519, Pair};
use polkadot_primitives::{BlockId, SessionKey};
use polkadot_primitives::parachain::{self, BlockData, DutyRoster, HeadData, ConsolidatedIngress, Message, Id as ParaId};
use polkadot_cli::{PolkadotService, CustomConfiguration, CoreApi, ParachainHost};
use polkadot_cli::{Worker, IntoExit, ProvideRuntimeApi};
Expand Down Expand Up @@ -127,11 +127,6 @@ pub trait RelayChainContext {
fn unrouted_egress(&self, id: ParaId) -> Self::FutureEgress;
}

fn key_to_account_id(key: &ed25519::Pair) -> AccountId {
let pubkey_bytes: [u8; 32] = key.public().into();
pubkey_bytes.into()
}

/// Collate the necessary ingress queue using the given context.
pub fn collate_ingress<'a, R>(relay_context: R)
-> impl Future<Item=ConsolidatedIngress, Error=R::Error> + 'a
Expand Down Expand Up @@ -195,7 +190,7 @@ pub fn collate<'a, R, P>(

let receipt = parachain::CandidateReceipt {
parachain_index: local_id,
collator: key_to_account_id(&*key),
collator: key.public(),
signature,
head_data,
balance_uploads: Vec::new(),
Expand Down Expand Up @@ -253,7 +248,7 @@ impl<P, E> Worker for CollationNode<P, E> where
fn configuration(&self) -> CustomConfiguration {
let mut config = CustomConfiguration::default();
config.collating_for = Some((
key_to_account_id(&*self.key),
self.key.public(),
self.para_id.clone(),
));
config
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/collation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

use std::sync::Arc;

use polkadot_primitives::{Block, Hash, AccountId, BlockId};
use polkadot_primitives::parachain::{Id as ParaId, Collation, Extrinsic};
use polkadot_primitives::{Block, Hash, BlockId};
use polkadot_primitives::parachain::{Id as ParaId, Collation, Extrinsic, CollatorId};
use polkadot_primitives::parachain::ParachainHost;
use runtime_primitives::traits::ProvideRuntimeApi;

Expand All @@ -47,7 +47,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.
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Errors that can occur during the consensus process.

use primitives::Ed25519AuthorityId as AuthorityId;
use primitives::ed25519::Public as AuthorityId;
use runtime_primitives::RuntimeString;

error_chain! {
Expand Down
18 changes: 9 additions & 9 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,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};
use polkadot_primitives::parachain::{Id as ParaId, Chain, DutyRoster, BlockData, Extrinsic as ParachainExtrinsic, CandidateReceipt, CollatorSignature};
use polkadot_primitives::parachain::{AttestedCandidate, ParachainHost, Statement as PrimitiveStatement};
use primitives::{Ed25519AuthorityId as AuthorityId, ed25519};
use primitives::{Pair, ed25519::{self, Public as AuthorityId}};
use runtime_primitives::traits::ProvideRuntimeApi;
use tokio::runtime::TaskExecutor;
use tokio::timer::{Delay, Interval};
Expand Down Expand Up @@ -163,7 +163,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.
Expand All @@ -174,7 +174,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();
Expand Down Expand Up @@ -756,17 +756,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));
}
}
39 changes: 21 additions & 18 deletions consensus/src/shared_table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use futures::{future, prelude::*};

use super::{GroupInfo, TableRouter};
use self::includable::IncludabilitySender;
use primitives::ed25519;
use primitives::{ed25519, Pair};

mod includable;

Expand Down Expand Up @@ -500,7 +500,8 @@ impl SharedTable {
#[cfg(test)]
mod tests {
use super::*;
use substrate_keyring::Keyring;
use substrate_keyring::AuthorityKeyring;
use primitives::crypto::UncheckedInto;

#[derive(Clone)]
struct DummyRouter;
Expand All @@ -525,15 +526,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(),
availability_guarantors: Default::default(),
needed_validity: 2,
needed_availability: 0,
Expand All @@ -548,7 +550,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(),
Expand Down Expand Up @@ -580,15 +582,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: [validity_other].iter().cloned().collect(),
validity_guarantors: [validity_other.clone()].iter().cloned().collect(),
availability_guarantors: [local_id].iter().cloned().collect(),
needed_validity: 1,
needed_availability: 1,
Expand All @@ -603,7 +606,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(),
Expand Down Expand Up @@ -640,7 +643,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(),
Expand Down Expand Up @@ -684,7 +687,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(),
Expand Down
Loading