update substrate (#259)

* WIP

* merging select_chain

* WIP

* update to point to gui-polkadot-master

* Fix collator

* update gui-polkadot-master and fix

* fix unwraps

* better returning an error
This commit is contained in:
thiolliere
2019-05-15 20:35:27 +02:00
committed by Robert Habermeier
parent ac2b9168ac
commit 6d778c99d2
25 changed files with 1005 additions and 943 deletions
+5 -4
View File
@@ -6,10 +6,11 @@ description = "Collator node implementation"
[dependencies]
futures = "0.1.17"
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "gui-polkadot-master" }
parity-codec = "3.0"
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-consensus-authorities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "gui-polkadot-master" }
substrate-consensus-authorities = { git = "https://github.com/paritytech/substrate", branch = "gui-polkadot-master" }
substrate-consensus-common= { git = "https://github.com/paritytech/substrate", branch = "gui-polkadot-master" }
polkadot-runtime = { path = "../runtime", version = "0.1" }
polkadot-primitives = { path = "../primitives", version = "0.1" }
polkadot-cli = { path = "../cli" }
@@ -19,4 +20,4 @@ log = "0.4"
tokio = "0.1.7"
[dev-dependencies]
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "gui-polkadot-master" }
+10 -2
View File
@@ -49,6 +49,7 @@ extern crate substrate_client as client;
extern crate parity_codec as codec;
extern crate substrate_primitives as primitives;
extern crate substrate_consensus_authorities as consensus_authorities;
extern crate substrate_consensus_common as consensus_common;
extern crate tokio;
extern crate polkadot_cli;
@@ -82,6 +83,7 @@ use polkadot_network::validation::{ValidationNetwork, SessionParams};
use polkadot_network::NetworkService;
use tokio::timer::Timeout;
use consensus_authorities::AuthoritiesApi;
use consensus_common::SelectChain;
pub use polkadot_cli::VersionInfo;
pub use polkadot_network::validation::Incoming;
@@ -256,18 +258,24 @@ impl<P, E> Worker for CollationNode<P, E> where
let client = service.client();
let network = service.network();
let known_oracle = client.clone();
let select_chain = if let Some(select_chain) = service.select_chain() {
select_chain
} else {
info!("The node cannot work because it can't select chain.");
return Box::new(future::err(()));
};
let message_validator = polkadot_network::gossip::register_validator(
&*network,
move |block_hash: &Hash| {
use client::{BlockStatus, ChainHead};
use client::BlockStatus;
use polkadot_network::gossip::Known;
match known_oracle.block_status(&BlockId::hash(*block_hash)) {
Err(_) | Ok(BlockStatus::Unknown) | Ok(BlockStatus::Queued) => None,
Ok(BlockStatus::KnownBad) => Some(Known::Bad),
Ok(BlockStatus::InChainWithState) | Ok(BlockStatus::InChainPruned) =>
match known_oracle.leaves() {
match select_chain.leaves() {
Err(_) => None,
Ok(leaves) => if leaves.contains(block_hash) {
Some(Known::Leaf)