mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Update to latest substrate-master and polkadot v0.3 (#195)
* Rebuild runtime * Remove invalid value from chainspec (#68) * service: use grandpa block import for locally sealed aura blocks (#85) * bump version to v0.3.1 * Update lock file. * limit number of transactions when building blocks (#91) * Update to latest Substrate * Bump to 0.3.2 * Actually bump. * v0.3.2 (#98) * bump substrate version * fix polkadot-collator * point to alexander-backports of substrate * bump version * cli: fix node shutdown (#100) * update to latest substrate, change to v0.3.4 * update to latest substrate, bump version to 0.3.5 * v0.3.6 * try to build on every v0.3 commit and update alexander-backports * bump to v0.3.7 * bump to 0.3.8 * Bump to 0.3.9: network and pruning improvements * Bump to 0.3.10: reduce network bandwidth usage * Use libp2p-kad 0.3.2 (#122) * Bump libp2p-identify to 0.3.1 (#123) * Bump to 0.3.12 (#127) * Update Substrate again (#128) * update substrate and bump version to v0.3.13 * bump version to v0.3.14: fix --reserved-nodes * add a manually curated grandpa module (#136) * updating v0.3 to use substrate v0.10 (#146) * updating to latest substrate v0.10 * better handling of outer poll * nit * fix tests * remove comment * reduce indentation * use self.poll * bring oneshot into scope * spaces * wrap * remove match * wrap * Update primitives/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update runtime/wasm/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update runtime/wasm/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update test-parachains/adder/collator/src/main.rs Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * indent * add paranthese * config: fix wrong ip for alexander bootnode (#161) * fix curated-grandpa and rebuild wasm (#162) * [v0.3] Integrates new gossip system into Polkadot (#166) * new gossip validation in network * integrate new gossip into service * network: guard validation network future under exit signal (#168) * bump version to v0.3.15: substrate v0.10 * [v0.3] update to substrate master (#175) * update to substrate master * fix test * service: fix telemetry endpoints on alexander chainspec (#169) (#178) * Update v0.3 to latest Substrate master (#177) * update substrate v0.3 to latest master * bump spec version * update to latest master: remove fees module * update runtime blobs * bump version to 0.3.16 * replace sr25519 accountid with anysigner * bump version to v0.3.17 * Some PoC-3 GRANDPA tweaks (#181) * call on_finalise after triggering curated_grandpa change * make grandpa rounds shorter for faster finalization * use authorities when calculating duty roster (#185) * [v0.3] Update to substrate master (#183) * update to latest substrate master * bump version to 0.3.18 * update to latest substrate master * bump spec version * update runtime wasm blobs * remove current_offline_slash from chain spec * update to substrate master: bump version to v0.3.19 (#188) * update to substrate master: bump version to v0.3.19 libp2p network improvements * network: replace NodeIndex with PeerId * network: fix tests * polkadot v0.3.20 (#190) * update to substrate master: bump version to 0.3.20 * runtime: add offchain worker trait * runtime: rebuild wasm blobs * bump spec version (#191) * Fix compilation * Update version to 0.4.0 * Switch to use `polkadot-master` branch from substrate * Remove unused struct * Remove `grandpa::SyncedAuthorities` from `OnSessionChange`
This commit is contained in:
committed by
Robert Habermeier
parent
5606afd886
commit
7e2714f843
@@ -235,7 +235,7 @@ publish-s3-release:
|
||||
- kubectl get nodes -l node=polkadot
|
||||
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{range @.status.addresses[?(@.type=="ExternalIP")]}{.address}{"\n"}{end}'
|
||||
- echo "# polkadots' nodes"
|
||||
- kubectl -n polkadot get pods
|
||||
- kubectl -n polkadot get pods
|
||||
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'
|
||||
|
||||
|
||||
|
||||
Generated
+1222
-1178
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -4,7 +4,7 @@ path = "src/main.rs"
|
||||
|
||||
[package]
|
||||
name = "polkadot"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ polkadot-primitives = { path = "../primitives" }
|
||||
parking_lot = "0.7.1"
|
||||
log = "0.4.6"
|
||||
parity-codec = "3.0"
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
kvdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
|
||||
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
|
||||
kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "polkadot-cli"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
description = "Polkadot node implementation in Rust."
|
||||
|
||||
@@ -9,5 +9,5 @@ log = "0.4.6"
|
||||
tokio = "0.1.7"
|
||||
futures = "0.1.17"
|
||||
exit-future = "0.1"
|
||||
substrate-cli = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
polkadot-service = { path = "../service" }
|
||||
|
||||
@@ -36,14 +36,13 @@ use chain_spec::ChainSpec;
|
||||
use futures::Future;
|
||||
use tokio::runtime::Runtime;
|
||||
use service::Service as BareService;
|
||||
use cli::NoCustom;
|
||||
|
||||
pub use service::{
|
||||
Components as ServiceComponents, PolkadotService, CustomConfiguration, ServiceFactory, Factory,
|
||||
ProvideRuntimeApi, CoreApi, ParachainHost,
|
||||
};
|
||||
|
||||
pub use cli::{VersionInfo, IntoExit};
|
||||
pub use cli::{VersionInfo, IntoExit, NoCustom};
|
||||
pub use cli::error;
|
||||
pub use tokio::runtime::TaskExecutor;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ description = "Collator node implementation"
|
||||
|
||||
[dependencies]
|
||||
futures = "0.1.17"
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
parity-codec = "3.0"
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
polkadot-runtime = { path = "../runtime", version = "0.1" }
|
||||
polkadot-primitives = { path = "../primitives", version = "0.1" }
|
||||
polkadot-cli = { path = "../cli" }
|
||||
@@ -18,4 +18,4 @@ log = "0.4"
|
||||
tokio = "0.1.7"
|
||||
|
||||
[dev-dependencies]
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -259,14 +259,15 @@ impl<P, E> Worker for CollationNode<P, E> where
|
||||
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::InChain) => match known_oracle.leaves() {
|
||||
Err(_) => None,
|
||||
Ok(leaves) => if leaves.contains(block_hash) {
|
||||
Some(Known::Leaf)
|
||||
} else {
|
||||
Some(Known::Old)
|
||||
},
|
||||
}
|
||||
Ok(BlockStatus::InChainWithState) | Ok(BlockStatus::InChainPruned) =>
|
||||
match known_oracle.leaves() {
|
||||
Err(_) => None,
|
||||
Ok(leaves) => if leaves.contains(block_hash) {
|
||||
Some(Known::Leaf)
|
||||
} else {
|
||||
Some(Known::Old)
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -481,3 +482,4 @@ mod tests {
|
||||
assert_eq!(collation.receipt.egress_queue_roots, vec![(a, root_a), (b, root_b)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ edition = "2018"
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
reed-solomon-erasure = { git = "https://github.com/paritytech/reed-solomon-erasure" }
|
||||
parity-codec = "3.0"
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -5,6 +5,6 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
description = "Polkadot node implementation in Rust."
|
||||
|
||||
[dependencies]
|
||||
substrate-executor = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
polkadot-runtime = { path = "../runtime" }
|
||||
|
||||
@@ -12,9 +12,9 @@ polkadot-validation = { path = "../validation" }
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
parity-codec = "3.0"
|
||||
parity-codec-derive = "3.0"
|
||||
substrate-network = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
futures = "0.1"
|
||||
tokio = "0.1.7"
|
||||
log = "0.4"
|
||||
@@ -22,5 +22,5 @@ slice-group-by = "0.2.2"
|
||||
exit-future = "0.1.4"
|
||||
|
||||
[dev-dependencies]
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Bridge between the network and consensus service for getting collations to it.
|
||||
|
||||
use polkadot_primitives::{parachain::CollatorId, Hash};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, Collation};
|
||||
use polkadot_primitives::Hash;
|
||||
use polkadot_primitives::parachain::{CollatorId, Id as ParaId, Collation};
|
||||
use futures::sync::oneshot;
|
||||
|
||||
use std::collections::hash_map::{HashMap, Entry};
|
||||
|
||||
+28
-28
@@ -55,9 +55,9 @@ pub mod gossip;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use futures::sync::oneshot;
|
||||
use polkadot_primitives::{Block, SessionKey, Hash, Header, parachain::CollatorId};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, BlockData, CandidateReceipt, Collation};
|
||||
use substrate_network::{NodeIndex, RequestId, Context, Severity};
|
||||
use polkadot_primitives::{Block, SessionKey, Hash, Header};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, CollatorId, BlockData, CandidateReceipt, Collation};
|
||||
use substrate_network::{PeerId, RequestId, Context, Severity};
|
||||
use substrate_network::{message, generic_message};
|
||||
use substrate_network::specialization::NetworkSpecialization as Specialization;
|
||||
use substrate_network::StatusMessage as GenericFullStatus;
|
||||
@@ -156,7 +156,7 @@ pub enum Message {
|
||||
Collation(Hash, Collation),
|
||||
}
|
||||
|
||||
fn send_polkadot_message(ctx: &mut Context<Block>, to: NodeIndex, message: Message) {
|
||||
fn send_polkadot_message(ctx: &mut Context<Block>, to: PeerId, message: Message) {
|
||||
trace!(target: "p_net", "Sending polkadot message to {}: {:?}", to, message);
|
||||
let encoded = message.encode();
|
||||
ctx.send_message(to, generic_message::Message::ChainSpecific(encoded))
|
||||
@@ -164,13 +164,13 @@ fn send_polkadot_message(ctx: &mut Context<Block>, to: NodeIndex, message: Messa
|
||||
|
||||
/// Polkadot protocol attachment for substrate.
|
||||
pub struct PolkadotProtocol {
|
||||
peers: HashMap<NodeIndex, PeerInfo>,
|
||||
peers: HashMap<PeerId, PeerInfo>,
|
||||
collating_for: Option<(CollatorId, ParaId)>,
|
||||
collators: CollatorPool,
|
||||
validators: HashMap<SessionKey, NodeIndex>,
|
||||
validators: HashMap<SessionKey, PeerId>,
|
||||
local_collations: LocalCollations<Collation>,
|
||||
live_validation_sessions: LiveValidationSessions,
|
||||
in_flight: HashMap<(RequestId, NodeIndex), BlockDataRequest>,
|
||||
in_flight: HashMap<(RequestId, PeerId), BlockDataRequest>,
|
||||
pending: Vec<BlockDataRequest>,
|
||||
extrinsic_store: Option<::av_store::Store>,
|
||||
next_req_id: u64,
|
||||
@@ -225,7 +225,7 @@ impl PolkadotProtocol {
|
||||
{
|
||||
peer_data.collator_state.send_key(new_local.clone(), |msg| send_polkadot_message(
|
||||
ctx,
|
||||
*id,
|
||||
id.clone(),
|
||||
msg
|
||||
));
|
||||
}
|
||||
@@ -257,7 +257,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
Err(Some(known_keys)) => {
|
||||
let next_peer = known_keys.iter()
|
||||
.filter_map(|x| validator_keys.get(x).map(|id| (x.clone(), *id)))
|
||||
.filter_map(|x| validator_keys.get(x).map(|id| (x.clone(), id.clone())))
|
||||
.find(|&(ref key, _)| pending.attempted_peers.insert(key.clone()))
|
||||
.map(|(_, id)| id);
|
||||
|
||||
@@ -268,7 +268,7 @@ impl PolkadotProtocol {
|
||||
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
Message::RequestBlockData(req_id, parent, c_hash),
|
||||
);
|
||||
|
||||
@@ -290,7 +290,7 @@ impl PolkadotProtocol {
|
||||
self.pending = new_pending;
|
||||
}
|
||||
|
||||
fn on_polkadot_message(&mut self, ctx: &mut Context<Block>, who: NodeIndex, msg: Message) {
|
||||
fn on_polkadot_message(&mut self, ctx: &mut Context<Block>, who: PeerId, msg: Message) {
|
||||
trace!(target: "p_net", "Polkadot message from {}: {:?}", who, msg);
|
||||
match msg {
|
||||
Message::SessionKey(key) => self.on_session_key(ctx, who, key),
|
||||
@@ -313,7 +313,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_session_key(&mut self, ctx: &mut Context<Block>, who: NodeIndex, key: SessionKey) {
|
||||
fn on_session_key(&mut self, ctx: &mut Context<Block>, who: PeerId, key: SessionKey) {
|
||||
{
|
||||
let info = match self.peers.get_mut(&who) {
|
||||
Some(peer) => peer,
|
||||
@@ -343,7 +343,7 @@ impl PolkadotProtocol {
|
||||
for (relay_parent, collation) in new_collations {
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
Message::Collation(relay_parent, collation),
|
||||
)
|
||||
}
|
||||
@@ -354,8 +354,8 @@ impl PolkadotProtocol {
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
|
||||
fn on_block_data(&mut self, ctx: &mut Context<Block>, who: NodeIndex, req_id: RequestId, data: Option<BlockData>) {
|
||||
match self.in_flight.remove(&(req_id, who)) {
|
||||
fn on_block_data(&mut self, ctx: &mut Context<Block>, who: PeerId, req_id: RequestId, data: Option<BlockData>) {
|
||||
match self.in_flight.remove(&(req_id, who.clone())) {
|
||||
Some(req) => {
|
||||
if let Some(data) = data {
|
||||
if data.hash() == req.block_data_hash {
|
||||
@@ -372,7 +372,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
|
||||
// when a validator sends us (a collator) a new role.
|
||||
fn on_new_role(&mut self, ctx: &mut Context<Block>, who: NodeIndex, role: Role) {
|
||||
fn on_new_role(&mut self, ctx: &mut Context<Block>, who: PeerId, role: Role) {
|
||||
let info = match self.peers.get_mut(&who) {
|
||||
Some(peer) => peer,
|
||||
None => {
|
||||
@@ -400,7 +400,7 @@ impl PolkadotProtocol {
|
||||
debug!(target: "p_net", "Broadcasting collation on relay parent {:?}", relay_parent);
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
Message::Collation(relay_parent, collation),
|
||||
)
|
||||
}
|
||||
@@ -413,7 +413,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Status { collating_for: self.collating_for.clone() }.encode()
|
||||
}
|
||||
|
||||
fn on_connect(&mut self, ctx: &mut Context<Block>, who: NodeIndex, status: FullStatus) {
|
||||
fn on_connect(&mut self, ctx: &mut Context<Block>, who: PeerId, status: FullStatus) {
|
||||
let local_status = match Status::decode(&mut &status.chain_status[..]) {
|
||||
Some(status) => status,
|
||||
None => {
|
||||
@@ -440,7 +440,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
peer_info.collator_state.set_role(collator_role, |msg| send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
msg,
|
||||
));
|
||||
}
|
||||
@@ -450,7 +450,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
for local_session_key in self.live_validation_sessions.recent_keys() {
|
||||
peer_info.collator_state.send_key(local_session_key.clone(), |msg| send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
msg,
|
||||
));
|
||||
}
|
||||
@@ -460,7 +460,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
|
||||
fn on_disconnect(&mut self, ctx: &mut Context<Block>, who: NodeIndex) {
|
||||
fn on_disconnect(&mut self, ctx: &mut Context<Block>, who: PeerId) {
|
||||
if let Some(info) = self.peers.remove(&who) {
|
||||
if let Some((acc_id, _)) = info.collating_for {
|
||||
let new_primary = self.collators.on_disconnect(acc_id)
|
||||
@@ -469,7 +469,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
if let Some((new_primary, primary_info)) = new_primary {
|
||||
primary_info.collator_state.set_role(Role::Primary, |msg| send_polkadot_message(
|
||||
ctx,
|
||||
new_primary,
|
||||
new_primary.clone(),
|
||||
msg,
|
||||
));
|
||||
}
|
||||
@@ -502,7 +502,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_message(&mut self, ctx: &mut Context<Block>, who: NodeIndex, message: &mut Option<message::Message<Block>>) {
|
||||
fn on_message(&mut self, ctx: &mut Context<Block>, who: PeerId, message: &mut Option<message::Message<Block>>) {
|
||||
match message.take() {
|
||||
Some(generic_message::Message::ChainSpecific(raw)) => {
|
||||
match Message::decode(&mut raw.as_slice()) {
|
||||
@@ -532,7 +532,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Action::NewRole(account_id, role) => if let Some((collator, info)) = self.collator_peer(account_id) {
|
||||
info.collator_state.set_role(role, |msg| send_polkadot_message(
|
||||
ctx,
|
||||
collator,
|
||||
collator.clone(),
|
||||
msg,
|
||||
))
|
||||
},
|
||||
@@ -548,7 +548,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
impl PolkadotProtocol {
|
||||
// we received a collation from a peer
|
||||
fn on_collation(&mut self, ctx: &mut Context<Block>, from: NodeIndex, relay_parent: Hash, collation: Collation) {
|
||||
fn on_collation(&mut self, ctx: &mut Context<Block>, from: PeerId, relay_parent: Hash, collation: Collation) {
|
||||
let collation_para = collation.receipt.parachain_index;
|
||||
let collated_acc = collation.receipt.collator.clone();
|
||||
|
||||
@@ -577,7 +577,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
|
||||
// get connected peer with given account ID for collation.
|
||||
fn collator_peer(&mut self, collator_id: CollatorId) -> Option<(NodeIndex, &mut PeerInfo)> {
|
||||
fn collator_peer(&mut self, collator_id: CollatorId) -> Option<(PeerId, &mut PeerInfo)> {
|
||||
let check_info = |info: &PeerInfo| info
|
||||
.collating_for
|
||||
.as_ref()
|
||||
@@ -586,7 +586,7 @@ impl PolkadotProtocol {
|
||||
self.peers
|
||||
.iter_mut()
|
||||
.filter(|&(_, ref info)| check_info(&**info))
|
||||
.map(|(who, info)| (*who, info))
|
||||
.map(|(who, info)| (who.clone(), info))
|
||||
.next()
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ impl PolkadotProtocol {
|
||||
debug!(target: "p_net", "Sending local collation to {:?}", primary);
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
*who,
|
||||
who.clone(),
|
||||
Message::Collation(relay_parent, cloned_collation),
|
||||
)
|
||||
},
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
|
||||
use sr_primitives::traits::{ProvideRuntimeApi, BlakeTwo256, Hash as HashT};
|
||||
use polkadot_validation::{
|
||||
SharedTable, TableRouter, SignedStatement, GenericStatement, ParachainWork, Incoming,
|
||||
Validated, Outgoing,
|
||||
SharedTable, TableRouter, SignedStatement, GenericStatement, ParachainWork, Outgoing, Validated
|
||||
};
|
||||
use polkadot_primitives::{Block, Hash, SessionKey};
|
||||
use polkadot_primitives::parachain::{
|
||||
BlockData, Extrinsic, CandidateReceipt, ParachainHost, Id as ParaId, Message
|
||||
};
|
||||
use gossip::RegisteredMessageValidator;
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use futures::prelude::*;
|
||||
@@ -41,7 +41,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
|
||||
use validation::{self, SessionDataFetcher, NetworkService, Executor};
|
||||
use validation::{self, SessionDataFetcher, NetworkService, Executor, Incoming};
|
||||
|
||||
type IngressPairRef<'a> = (ParaId, &'a [Message]);
|
||||
|
||||
@@ -59,19 +59,22 @@ pub struct Router<P, E, N: NetworkService, T> {
|
||||
attestation_topic: Hash,
|
||||
fetcher: SessionDataFetcher<P, E, N, T>,
|
||||
deferred_statements: Arc<Mutex<DeferredStatements>>,
|
||||
message_validator: RegisteredMessageValidator,
|
||||
}
|
||||
|
||||
impl<P, E, N: NetworkService, T> Router<P, E, N, T> {
|
||||
pub(crate) fn new(
|
||||
table: Arc<SharedTable>,
|
||||
fetcher: SessionDataFetcher<P, E, N, T>,
|
||||
message_validator: RegisteredMessageValidator,
|
||||
) -> Self {
|
||||
let parent_hash = fetcher.parent_hash();
|
||||
Router {
|
||||
table,
|
||||
fetcher,
|
||||
attestation_topic: attestation_topic(parent_hash),
|
||||
deferred_statements: Arc::new(Mutex::new(DeferredStatements::new())),
|
||||
fetcher,
|
||||
message_validator,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +108,7 @@ impl<P, E: Clone, N: NetworkService, T: Clone> Clone for Router<P, E, N, T> {
|
||||
fetcher: self.fetcher.clone(),
|
||||
attestation_topic: self.attestation_topic.clone(),
|
||||
deferred_statements: self.deferred_statements.clone(),
|
||||
message_validator: self.message_validator.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,6 +217,7 @@ impl<P: ProvideRuntimeApi + Send + Sync + 'static, E, N, T> Router<P, E, N, T> w
|
||||
validated.extrinsic().cloned(),
|
||||
);
|
||||
|
||||
|
||||
// propagate the statement.
|
||||
// consider something more targeted than gossip in the future.
|
||||
let signed = table.import_validated(validated);
|
||||
@@ -254,7 +259,9 @@ impl<P: ProvideRuntimeApi + Send, E, N, T> TableRouter for Router<P, E, N, T> wh
|
||||
|
||||
impl<P, E, N: NetworkService, T> Drop for Router<P, E, N, T> {
|
||||
fn drop(&mut self) {
|
||||
self.fetcher.network().drop_gossip(self.attestation_topic);
|
||||
let parent_hash = self.parent_hash().clone();
|
||||
self.message_validator.remove_session(&parent_hash);
|
||||
self.network().with_spec(move |spec, _| { spec.remove_validation_session(parent_hash); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use polkadot_primitives::parachain::{CandidateReceipt, HeadData, BlockData, Coll
|
||||
use substrate_primitives::crypto::UncheckedInto;
|
||||
use codec::Encode;
|
||||
use substrate_network::{
|
||||
Severity, NodeIndex, PeerInfo, ClientHandle, Context, config::Roles,
|
||||
Severity, PeerId, PeerInfo, ClientHandle, Context, config::Roles,
|
||||
message::Message as SubstrateMessage, specialization::NetworkSpecialization,
|
||||
generic_message::Message as GenericMessage
|
||||
};
|
||||
@@ -36,9 +36,9 @@ mod validation;
|
||||
|
||||
#[derive(Default)]
|
||||
struct TestContext {
|
||||
disabled: Vec<NodeIndex>,
|
||||
disconnected: Vec<NodeIndex>,
|
||||
messages: Vec<(NodeIndex, SubstrateMessage<Block>)>,
|
||||
disabled: Vec<PeerId>,
|
||||
disconnected: Vec<PeerId>,
|
||||
messages: Vec<(PeerId, SubstrateMessage<Block>)>,
|
||||
}
|
||||
|
||||
impl Context<Block> for TestContext {
|
||||
@@ -46,24 +46,24 @@ impl Context<Block> for TestContext {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn report_peer(&mut self, peer: NodeIndex, reason: Severity) {
|
||||
fn report_peer(&mut self, peer: PeerId, reason: Severity) {
|
||||
match reason {
|
||||
Severity::Bad(_) => self.disabled.push(peer),
|
||||
_ => self.disconnected.push(peer),
|
||||
}
|
||||
}
|
||||
|
||||
fn peer_info(&self, _peer: NodeIndex) -> Option<PeerInfo<Block>> {
|
||||
fn peer_info(&self, _peer: &PeerId) -> Option<PeerInfo<Block>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn send_message(&mut self, who: NodeIndex, data: SubstrateMessage<Block>) {
|
||||
fn send_message(&mut self, who: PeerId, data: SubstrateMessage<Block>) {
|
||||
self.messages.push((who, data))
|
||||
}
|
||||
}
|
||||
|
||||
impl TestContext {
|
||||
fn has_message(&self, to: NodeIndex, message: Message) -> bool {
|
||||
fn has_message(&self, to: PeerId, message: Message) -> bool {
|
||||
use substrate_network::generic_message::Message as GenericMessage;
|
||||
|
||||
let encoded = message.encode();
|
||||
@@ -94,7 +94,7 @@ fn make_validation_session(parent_hash: Hash, local_key: SessionKey) -> SessionP
|
||||
}
|
||||
}
|
||||
|
||||
fn on_message(protocol: &mut PolkadotProtocol, ctx: &mut TestContext, from: NodeIndex, message: Message) {
|
||||
fn on_message(protocol: &mut PolkadotProtocol, ctx: &mut TestContext, from: PeerId, message: Message) {
|
||||
let encoded = message.encode();
|
||||
protocol.on_message(ctx, from, &mut Some(GenericMessage::ChainSpecific(encoded)));
|
||||
}
|
||||
@@ -103,8 +103,8 @@ fn on_message(protocol: &mut PolkadotProtocol, ctx: &mut TestContext, from: Node
|
||||
fn sends_session_key() {
|
||||
let mut protocol = PolkadotProtocol::new(None);
|
||||
|
||||
let peer_a = 1;
|
||||
let peer_b = 2;
|
||||
let peer_a = PeerId::random();
|
||||
let peer_b = PeerId::random();
|
||||
let parent_hash = [0; 32].into();
|
||||
let local_key: ValidatorId = [1; 32].unchecked_into();
|
||||
|
||||
@@ -113,7 +113,7 @@ fn sends_session_key() {
|
||||
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_connect(&mut ctx, peer_a, make_status(&validator_status, Roles::AUTHORITY));
|
||||
protocol.on_connect(&mut ctx, peer_a.clone(), make_status(&validator_status, Roles::AUTHORITY));
|
||||
assert!(ctx.messages.is_empty());
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ fn sends_session_key() {
|
||||
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_connect(&mut ctx, peer_b, make_status(&collator_status, Roles::NONE));
|
||||
assert!(ctx.has_message(peer_b, Message::SessionKey(local_key)));
|
||||
protocol.on_connect(&mut ctx, peer_b.clone(), make_status(&collator_status, Roles::NONE));
|
||||
assert!(ctx.has_message(peer_b.clone(), Message::SessionKey(local_key)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ fn sends_session_key() {
|
||||
fn fetches_from_those_with_knowledge() {
|
||||
let mut protocol = PolkadotProtocol::new(None);
|
||||
|
||||
let peer_a = 1;
|
||||
let peer_b = 2;
|
||||
let peer_a = PeerId::random();
|
||||
let peer_b = PeerId::random();
|
||||
let parent_hash = [0; 32].into();
|
||||
let local_key: ValidatorId = [1; 32].unchecked_into();
|
||||
|
||||
@@ -169,16 +169,16 @@ fn fetches_from_those_with_knowledge() {
|
||||
// connect peer A
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_connect(&mut ctx, peer_a, make_status(&status, Roles::AUTHORITY));
|
||||
assert!(ctx.has_message(peer_a, Message::SessionKey(local_key)));
|
||||
protocol.on_connect(&mut ctx, peer_a.clone(), make_status(&status, Roles::AUTHORITY));
|
||||
assert!(ctx.has_message(peer_a.clone(), Message::SessionKey(local_key)));
|
||||
}
|
||||
|
||||
// peer A gives session key and gets asked for data.
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
on_message(&mut protocol, &mut ctx, peer_a, Message::SessionKey(a_key.clone()));
|
||||
on_message(&mut protocol, &mut ctx, peer_a.clone(), Message::SessionKey(a_key.clone()));
|
||||
assert!(protocol.validators.contains_key(&a_key));
|
||||
assert!(ctx.has_message(peer_a, Message::RequestBlockData(1, parent_hash, candidate_hash)));
|
||||
assert!(ctx.has_message(peer_a.clone(), Message::RequestBlockData(1, parent_hash, candidate_hash)));
|
||||
}
|
||||
|
||||
knowledge.lock().note_statement(b_key.clone(), &GenericStatement::Valid(candidate_hash));
|
||||
@@ -186,18 +186,18 @@ fn fetches_from_those_with_knowledge() {
|
||||
// peer B connects and sends session key. request already assigned to A
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_connect(&mut ctx, peer_b, make_status(&status, Roles::AUTHORITY));
|
||||
on_message(&mut protocol, &mut ctx, peer_b, Message::SessionKey(b_key));
|
||||
assert!(!ctx.has_message(peer_b, Message::RequestBlockData(2, parent_hash, candidate_hash)));
|
||||
protocol.on_connect(&mut ctx, peer_b.clone(), make_status(&status, Roles::AUTHORITY));
|
||||
on_message(&mut protocol, &mut ctx, peer_b.clone(), Message::SessionKey(b_key.clone()));
|
||||
assert!(!ctx.has_message(peer_b.clone(), Message::RequestBlockData(2, parent_hash, candidate_hash)));
|
||||
|
||||
}
|
||||
|
||||
// peer A disconnects, triggering reassignment
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_disconnect(&mut ctx, peer_a);
|
||||
protocol.on_disconnect(&mut ctx, peer_a.clone());
|
||||
assert!(!protocol.validators.contains_key(&a_key));
|
||||
assert!(ctx.has_message(peer_b, Message::RequestBlockData(2, parent_hash, candidate_hash)));
|
||||
assert!(ctx.has_message(peer_b.clone(), Message::RequestBlockData(2, parent_hash, candidate_hash)));
|
||||
}
|
||||
|
||||
// peer B comes back with block data.
|
||||
@@ -213,7 +213,7 @@ fn fetches_from_those_with_knowledge() {
|
||||
fn fetches_available_block_data() {
|
||||
let mut protocol = PolkadotProtocol::new(None);
|
||||
|
||||
let peer_a = 1;
|
||||
let peer_a = PeerId::random();
|
||||
let parent_hash = [0; 32].into();
|
||||
|
||||
let block_data = BlockData(vec![1, 2, 3, 4]);
|
||||
@@ -248,13 +248,13 @@ fn fetches_available_block_data() {
|
||||
// connect peer A
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_connect(&mut ctx, peer_a, make_status(&status, Roles::FULL));
|
||||
protocol.on_connect(&mut ctx, peer_a.clone(), make_status(&status, Roles::FULL));
|
||||
}
|
||||
|
||||
// peer A asks for historic block data and gets response
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
on_message(&mut protocol, &mut ctx, peer_a, Message::RequestBlockData(1, parent_hash, candidate_hash));
|
||||
on_message(&mut protocol, &mut ctx, peer_a.clone(), Message::RequestBlockData(1, parent_hash, candidate_hash));
|
||||
assert!(ctx.has_message(peer_a, Message::BlockData(1, Some(block_data))));
|
||||
}
|
||||
}
|
||||
@@ -263,14 +263,14 @@ fn fetches_available_block_data() {
|
||||
fn remove_bad_collator() {
|
||||
let mut protocol = PolkadotProtocol::new(None);
|
||||
|
||||
let who = 1;
|
||||
let who = PeerId::random();
|
||||
let collator_id: CollatorId = [2; 32].unchecked_into();
|
||||
|
||||
let status = Status { collating_for: Some((collator_id.clone(), 5.into())) };
|
||||
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
protocol.on_connect(&mut ctx, who, make_status(&status, Roles::NONE));
|
||||
protocol.on_connect(&mut ctx, who.clone(), make_status(&status, Roles::NONE));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -298,20 +298,20 @@ fn many_session_keys() {
|
||||
|
||||
assert_eq!(protocol.live_validation_sessions.recent_keys(), &[local_key_a.clone(), local_key_b.clone()]);
|
||||
|
||||
let peer_a = 1;
|
||||
let peer_a = PeerId::random();
|
||||
|
||||
// when connecting a peer, we should get both those keys.
|
||||
{
|
||||
let mut ctx = TestContext::default();
|
||||
|
||||
let status = Status { collating_for: None };
|
||||
protocol.on_connect(&mut ctx, peer_a, make_status(&status, Roles::AUTHORITY));
|
||||
protocol.on_connect(&mut ctx, peer_a.clone(), make_status(&status, Roles::AUTHORITY));
|
||||
|
||||
assert!(ctx.has_message(peer_a, Message::SessionKey(local_key_a.clone())));
|
||||
assert!(ctx.has_message(peer_a.clone(), Message::SessionKey(local_key_a.clone())));
|
||||
assert!(ctx.has_message(peer_a, Message::SessionKey(local_key_b.clone())));
|
||||
}
|
||||
|
||||
let peer_b = 2;
|
||||
let peer_b = PeerId::random();
|
||||
|
||||
assert!(protocol.remove_validation_session(parent_a));
|
||||
|
||||
@@ -319,9 +319,9 @@ fn many_session_keys() {
|
||||
let mut ctx = TestContext::default();
|
||||
|
||||
let status = Status { collating_for: None };
|
||||
protocol.on_connect(&mut ctx, peer_b, make_status(&status, Roles::AUTHORITY));
|
||||
protocol.on_connect(&mut ctx, peer_b.clone(), make_status(&status, Roles::AUTHORITY));
|
||||
|
||||
assert!(!ctx.has_message(peer_b, Message::SessionKey(local_key_a)));
|
||||
assert!(ctx.has_message(peer_b, Message::SessionKey(local_key_b)));
|
||||
assert!(!ctx.has_message(peer_b.clone(), Message::SessionKey(local_key_a.clone())));
|
||||
assert!(ctx.has_message(peer_b, Message::SessionKey(local_key_b.clone())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use validation::NetworkService;
|
||||
use substrate_network::Context as NetContext;
|
||||
use substrate_primitives::NativeOrEncoded;
|
||||
use substrate_primitives::{NativeOrEncoded, ExecutionContext};
|
||||
use substrate_keyring::AuthorityKeyring;
|
||||
use {PolkadotProtocol};
|
||||
|
||||
@@ -29,7 +29,6 @@ use polkadot_primitives::parachain::{Id as ParaId, Chain, DutyRoster, ParachainH
|
||||
use parking_lot::Mutex;
|
||||
use substrate_client::error::Result as ClientResult;
|
||||
use substrate_client::runtime_api::{Core, RuntimeVersion, ApiExt};
|
||||
use sr_primitives::ExecutionContext;
|
||||
use sr_primitives::traits::{ApiRef, ProvideRuntimeApi};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -105,7 +105,7 @@ impl NetworkService for super::NetworkService {
|
||||
}
|
||||
|
||||
fn gossip_message(&self, topic: Hash, message: Vec<u8>) {
|
||||
self.gossip_consensus_message(topic, POLKADOT_ENGINE_ID, message);
|
||||
self.gossip_consensus_message(topic, POLKADOT_ENGINE_ID, message, false);
|
||||
}
|
||||
|
||||
fn drop_gossip(&self, _topic: Hash) { }
|
||||
@@ -241,6 +241,7 @@ impl<P, E, N, T> ParachainNetwork for ValidationNetwork<P, E, N, T> where
|
||||
parent_hash,
|
||||
authorities: authorities.to_vec(),
|
||||
});
|
||||
let message_validator = self.message_validator.clone();
|
||||
|
||||
let executor = self.executor.clone();
|
||||
let work = build_fetcher
|
||||
@@ -249,6 +250,7 @@ impl<P, E, N, T> ParachainNetwork for ValidationNetwork<P, E, N, T> where
|
||||
let table_router = Router::new(
|
||||
table,
|
||||
fetcher,
|
||||
message_validator,
|
||||
);
|
||||
|
||||
table_router.broadcast_egress(outgoing);
|
||||
|
||||
@@ -8,15 +8,15 @@ serde = { version = "1.0", optional = true }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "3.0", default-features = false }
|
||||
parity-codec-derive = { version = "3.0", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
polkadot-parachain = { path = "../parachain", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
pretty_assertions = "0.5.1"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -45,10 +45,10 @@ extern crate serde;
|
||||
extern crate substrate_client;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use runtime_primitives::{generic, traits::Extrinsic};
|
||||
use runtime_primitives::{generic, traits::Extrinsic, AnySignature};
|
||||
|
||||
pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT, Verify};
|
||||
use primitives::{ed25519, sr25519};
|
||||
use primitives::ed25519;
|
||||
|
||||
pub mod parachain;
|
||||
|
||||
@@ -64,21 +64,15 @@ pub type BlockNumber = u64;
|
||||
|
||||
/// Alias to 512-bit hash when used in the context of a signature on the relay chain.
|
||||
/// Equipped with logic for possibly "unsigned" messages.
|
||||
pub type Signature = sr25519::Signature;
|
||||
pub type Signature = AnySignature;
|
||||
|
||||
/// Alias to Ed25519 pubkey that identifies an account on the relay chain.
|
||||
pub type AccountId = sr25519::Public;
|
||||
/// Alias to an sr25519 or ed25519 key.
|
||||
pub type AccountId = <Signature as Verify>::Signer;
|
||||
|
||||
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
|
||||
/// never know...
|
||||
pub type AccountIndex = u32;
|
||||
|
||||
/// Signature with which authorities sign blocks.
|
||||
pub type SessionSignature = ed25519::Signature;
|
||||
|
||||
/// Identity that authorities use.
|
||||
pub type SessionKey = ed25519::Public;
|
||||
|
||||
/// Indentifier for a chain. 32-bit should be plenty.
|
||||
pub type ChainId = u32;
|
||||
|
||||
@@ -88,6 +82,12 @@ pub type Hash = primitives::H256;
|
||||
/// Index of a transaction in the relay chain. 32-bit should be plenty.
|
||||
pub type Nonce = u64;
|
||||
|
||||
/// Signature with which authorities sign blocks.
|
||||
pub type SessionSignature = ed25519::Signature;
|
||||
|
||||
/// Identity that authorities use.
|
||||
pub type SessionKey = ed25519::Public;
|
||||
|
||||
/// The balance of an account.
|
||||
/// 128-bits (or 38 significant decimal figures) will allow for 10m currency (10^7) at a resolution
|
||||
/// to all for one second's worth of an annualised 50% reward be paid to a unit holder (10^11 unit
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
use rstd::prelude::*;
|
||||
use rstd::cmp::Ordering;
|
||||
use super::Hash;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use primitives::bytes;
|
||||
use primitives::ed25519;
|
||||
@@ -28,7 +29,7 @@ pub use polkadot_parachain::Id;
|
||||
/// Identity that collators use.
|
||||
pub type CollatorId = ed25519::Public;
|
||||
|
||||
/// Signature with which collators sign blocks.
|
||||
/// Signature on candidate's block data by a collator.
|
||||
pub type CollatorSignature = ed25519::Signature;
|
||||
|
||||
/// Identity that parachain validators use when signing validation messages.
|
||||
@@ -37,7 +38,7 @@ pub type CollatorSignature = ed25519::Signature;
|
||||
/// so we define it to be the same type as `SessionKey`. In the future it may have different crypto.
|
||||
pub type ValidatorId = super::SessionKey;
|
||||
|
||||
/// Signature with which parachain validators sign blocks.
|
||||
/// Signature with which parachain validators sign blocks.
|
||||
///
|
||||
/// For now we assert that parachain validator set is exactly equivalent to the (Aura) authority set, and
|
||||
/// so we define it to be the same type as `SessionKey`. In the future it may have different crypto.
|
||||
@@ -106,7 +107,7 @@ pub struct Extrinsic {
|
||||
pub struct CandidateReceipt {
|
||||
/// The ID of the parachain this is a candidate for.
|
||||
pub parachain_index: Id,
|
||||
/// The collator's signing ID
|
||||
/// The collator's relay-chain account ID
|
||||
pub collator: CollatorId,
|
||||
/// Signature on blake2-256 of the block data by collator.
|
||||
pub signature: CollatorSignature,
|
||||
|
||||
+29
-30
@@ -13,39 +13,38 @@ safe-mix = { version = "1.0", default-features = false}
|
||||
polkadot-primitives = { path = "../primitives", default-features = false }
|
||||
parity-codec = { version = "3.0", default-features = false }
|
||||
parity-codec-derive = { version = "3.0", default-features = false }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-balances = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-consensus = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-council = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-democracy = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-executive = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-indices = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-session = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-sudo = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-system = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-treasury = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-upgrade-key = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-fees = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-offchain-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-consensus = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-council = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-indices = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
srml-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.1.0"
|
||||
libsecp256k1 = "0.2.1"
|
||||
tiny-keccak = "1.4.2"
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
trie-db = "0.11"
|
||||
|
||||
[features]
|
||||
@@ -56,9 +55,11 @@ std = [
|
||||
"rustc-hex/std",
|
||||
"parity-codec/std",
|
||||
"parity-codec-derive/std",
|
||||
"substrate-inherents/std",
|
||||
"substrate-primitives/std",
|
||||
"substrate-client/std",
|
||||
"substrate-inherents/std",
|
||||
"substrate-offchain-primitives/std",
|
||||
"sr-std/std",
|
||||
"sr-io/std",
|
||||
"srml-support/std",
|
||||
@@ -76,8 +77,6 @@ std = [
|
||||
"srml-system/std",
|
||||
"srml-timestamp/std",
|
||||
"srml-treasury/std",
|
||||
"srml-upgrade-key/std",
|
||||
"srml-fees/std",
|
||||
"sr-version/std",
|
||||
"serde_derive",
|
||||
"serde/std",
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
use rstd::prelude::*;
|
||||
use sr_io::{keccak_256, secp256k1_ecdsa_recover};
|
||||
use srml_support::{StorageValue, StorageMap};
|
||||
use srml_support::traits::{Currency, ArithmeticType};
|
||||
use srml_support::traits::Currency;
|
||||
use system::ensure_signed;
|
||||
use codec::Encode;
|
||||
#[cfg(feature = "std")]
|
||||
use sr_primitives::traits::Zero;
|
||||
use system;
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as ArithmeticType>::Type;
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
|
||||
/// Configuration trait.
|
||||
pub trait Trait: system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Currency: ArithmeticType + Currency<Self::AccountId, Balance=BalanceOf<Self>>;
|
||||
type Currency: Currency<Self::AccountId>;
|
||||
}
|
||||
|
||||
type EthereumAddress = [u8; 20];
|
||||
@@ -59,7 +59,6 @@ impl EcdsaSignature {
|
||||
}
|
||||
}
|
||||
|
||||
/// An event in this module.
|
||||
decl_event!(
|
||||
pub enum Event<T> where
|
||||
B = BalanceOf<T>,
|
||||
@@ -135,7 +134,7 @@ decl_module! {
|
||||
*t -= balance_due
|
||||
});
|
||||
|
||||
T::Currency::increase_free_balance_creating(&sender, balance_due);
|
||||
T::Currency::deposit_creating(&sender, balance_due);
|
||||
|
||||
// Let's deposit an event to let the outside world know this happened.
|
||||
Self::deposit_event(RawEvent::Claimed(sender, signer, balance_due));
|
||||
@@ -186,6 +185,9 @@ mod tests {
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
type Event = ();
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
}
|
||||
impl Trait for Test {
|
||||
type Event = ();
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright 2017 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! A module for manually curated GRANDPA set.
|
||||
|
||||
use {grandpa, system};
|
||||
use codec::Decode;
|
||||
use sr_primitives::traits::{As, Hash as HashT, BlakeTwo256, Zero};
|
||||
use rstd::prelude::*;
|
||||
|
||||
pub trait Trait: grandpa::Trait {}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as CuratedGrandpa {
|
||||
/// How often to shuffle the GRANDPA sets.
|
||||
///
|
||||
/// 0 means never.
|
||||
pub ShufflePeriod get(shuffle_period) config(shuffle_period): T::BlockNumber;
|
||||
}
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
/// curated GRANDPA set.
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// Changes the GRANDPA voter set.
|
||||
fn set_voters(origin, voters: Vec<(T::SessionKey, u64)>) {
|
||||
system::ensure_root(origin)?;
|
||||
grandpa::Module::<T>::schedule_change(voters, T::BlockNumber::zero(), None)?;
|
||||
}
|
||||
|
||||
fn on_finalise(block_number: T::BlockNumber) {
|
||||
// every so often shuffle the voters and issue a change.
|
||||
let shuffle_period: u64 = Self::shuffle_period().as_();
|
||||
if shuffle_period == 0 { return }
|
||||
|
||||
if block_number.as_() % shuffle_period == 0 {
|
||||
let mut seed = system::Module::<T>::random_seed().as_ref().to_vec();
|
||||
seed.extend(b"grandpa_shuffling");
|
||||
let mut seed = BlakeTwo256::hash(&seed);
|
||||
|
||||
let mut voters = grandpa::Module::<T>::grandpa_authorities();
|
||||
let voter_count = voters.len();
|
||||
|
||||
if voter_count == 0 { return }
|
||||
|
||||
for i in 0..(voter_count - 1) {
|
||||
// 4 bytes of entropy used per cycle, 32 bytes entropy per hash
|
||||
let offset = (i * 4 % 32) as usize;
|
||||
|
||||
// number of roles remaining to select from.
|
||||
let remaining = (voter_count - i) as usize;
|
||||
|
||||
// 8 32-bit ints per 256-bit seed.
|
||||
let voter_index = u32::decode(&mut &seed[offset..offset + 4]).expect("using 4 bytes for a 32-bit quantity") as usize % remaining;
|
||||
|
||||
if offset == 28 {
|
||||
// into the last 4 bytes - rehash to gather new entropy
|
||||
seed = BlakeTwo256::hash(seed.as_ref());
|
||||
}
|
||||
|
||||
// exchange last item with randomly chosen first.
|
||||
voters.swap(remaining - 1, voter_index);
|
||||
}
|
||||
|
||||
// finalisation order is undefined, so grandpa's on_finalise might
|
||||
// have already been called. calling it again is OK though.
|
||||
let _ = grandpa::Module::<T>::schedule_change(voters, T::BlockNumber::zero(), None);
|
||||
grandpa::Module::<T>::on_finalise(block_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-22
@@ -37,6 +37,7 @@ extern crate parity_codec as codec;
|
||||
extern crate substrate_consensus_aura_primitives as consensus_aura;
|
||||
extern crate substrate_primitives;
|
||||
extern crate substrate_inherents as inherents;
|
||||
extern crate substrate_offchain_primitives as offchain_primitives;
|
||||
#[macro_use]
|
||||
extern crate substrate_client as client;
|
||||
|
||||
@@ -62,7 +63,6 @@ extern crate srml_sudo as sudo;
|
||||
extern crate srml_system as system;
|
||||
extern crate srml_timestamp as timestamp;
|
||||
extern crate srml_treasury as treasury;
|
||||
extern crate srml_fees as fees;
|
||||
|
||||
extern crate polkadot_primitives as primitives;
|
||||
|
||||
@@ -72,14 +72,15 @@ extern crate substrate_keyring as keyring;
|
||||
#[cfg(test)]
|
||||
extern crate substrate_trie;
|
||||
|
||||
mod curated_grandpa;
|
||||
mod parachains;
|
||||
mod claims;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use substrate_primitives::u32_trait::{_2, _4};
|
||||
use primitives::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, SessionKey, SessionSignature,
|
||||
Signature, parachain,
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, SessionKey, Signature,
|
||||
parachain, SessionSignature,
|
||||
};
|
||||
use client::{
|
||||
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
|
||||
@@ -115,8 +116,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("polkadot"),
|
||||
impl_name: create_runtime_str!("parity-polkadot"),
|
||||
authoring_version: 1,
|
||||
spec_version: 107,
|
||||
impl_version: 1,
|
||||
spec_version: 108,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
@@ -159,6 +160,9 @@ impl balances::Trait for Runtime {
|
||||
type OnFreeBalanceZero = Staking;
|
||||
type OnNewAccount = Indices;
|
||||
type Event = Event;
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
}
|
||||
|
||||
impl consensus::Trait for Runtime {
|
||||
@@ -177,24 +181,28 @@ impl timestamp::Trait for Runtime {
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
type ConvertAccountIdToSessionKey = ();
|
||||
type OnSessionChange = (Staking, grandpa::SyncedAuthorities<Runtime>);
|
||||
type OnSessionChange = Staking;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl staking::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type OnRewardMinted = Treasury;
|
||||
type Event = Event;
|
||||
type Currency = balances::Module<Self>;
|
||||
type Slash = ();
|
||||
type Reward = ();
|
||||
}
|
||||
|
||||
impl democracy::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type Currency = balances::Module<Self>;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl council::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type BadPresentation = ();
|
||||
type BadReaper = ();
|
||||
}
|
||||
|
||||
impl council::voting::Trait for Runtime {
|
||||
@@ -208,10 +216,12 @@ impl council::motions::Trait for Runtime {
|
||||
}
|
||||
|
||||
impl treasury::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type Currency = balances::Module<Self>;
|
||||
type ApproveOrigin = council_motions::EnsureMembers<_4>;
|
||||
type RejectOrigin = council_motions::EnsureMembers<_2>;
|
||||
type Event = Event;
|
||||
type MintedForSpending = ();
|
||||
type ProposalRejection = ();
|
||||
}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
@@ -222,21 +232,13 @@ impl grandpa::Trait for Runtime {
|
||||
|
||||
impl parachains::Trait for Runtime {}
|
||||
|
||||
impl curated_grandpa::Trait for Runtime { }
|
||||
|
||||
impl sudo::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Proposal = Call;
|
||||
}
|
||||
|
||||
impl claims::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
}
|
||||
|
||||
impl fees::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type TransferAsset = Balances;
|
||||
}
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey, SessionSignature>) where
|
||||
Block = Block,
|
||||
@@ -254,6 +256,7 @@ construct_runtime!(
|
||||
Staking: staking,
|
||||
Democracy: democracy,
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config<T>, Log(), Event<T>},
|
||||
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
|
||||
Council: council::{Module, Call, Storage, Event<T>},
|
||||
CouncilVoting: council_voting,
|
||||
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin},
|
||||
@@ -261,8 +264,6 @@ construct_runtime!(
|
||||
Treasury: treasury,
|
||||
Parachains: parachains::{Module, Call, Storage, Config<T>, Inherent},
|
||||
Sudo: sudo,
|
||||
Claims: claims,
|
||||
Fees: fees::{Module, Storage, Config<T>, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -281,7 +282,7 @@ pub type UncheckedExtrinsic = generic::UncheckedMortalCompactExtrinsic<Address,
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Nonce, Call>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Fees, AllModules>;
|
||||
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Balances, AllModules>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl client_api::Core<Block> for Runtime {
|
||||
@@ -336,6 +337,12 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(number: sr_primitives::traits::NumberFor<Block>) {
|
||||
Executive::offchain_worker(number)
|
||||
}
|
||||
}
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Consensus::authorities() // only possible as long as parachain validator crypto === aura crypto
|
||||
|
||||
@@ -478,8 +478,8 @@ mod tests {
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Test;
|
||||
impl consensus::Trait for Test {
|
||||
type SessionKey = SessionKey;
|
||||
type InherentOfflineReport = ();
|
||||
type SessionKey = SessionKey;
|
||||
type Log = ::Log;
|
||||
}
|
||||
impl system::Trait for Test {
|
||||
@@ -555,8 +555,8 @@ mod tests {
|
||||
let candidate_hash = candidate.candidate.hash();
|
||||
|
||||
let authorities = ::Consensus::authorities();
|
||||
let extract_key = |public: &SessionKey| {
|
||||
AuthorityKeyring::from_public(public).unwrap()
|
||||
let extract_key = |public: SessionKey| {
|
||||
AuthorityKeyring::from_raw_public(public.0).unwrap()
|
||||
};
|
||||
|
||||
let validation_entries = duty_roster.validator_duty.iter()
|
||||
@@ -566,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].clone());
|
||||
|
||||
let statement = if vote_implicit {
|
||||
Statement::Candidate(candidate.candidate.clone())
|
||||
@@ -694,7 +694,8 @@ mod tests {
|
||||
egress_queue_roots: vec![],
|
||||
fees: 0,
|
||||
block_data_hash: Default::default(),
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
assert!(Parachains::dispatch(Call::set_heads(vec![candidate]), Origin::INHERENT).is_err());
|
||||
|
||||
Generated
+1164
-330
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
Binary file not shown.
+12
-12
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "polkadot-service"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
@@ -17,14 +17,14 @@ polkadot-primitives = { path = "../primitives" }
|
||||
polkadot-runtime = { path = "../runtime" }
|
||||
polkadot-executor = { path = "../executor" }
|
||||
polkadot-network = { path = "../network" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-consensus-aura = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-finality-grandpa = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-service = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-telemetry = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-transaction-pool = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-keystore = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -21,8 +21,8 @@ use polkadot_primitives::{AccountId, SessionKey};
|
||||
use polkadot_runtime::{
|
||||
GenesisConfig, ConsensusConfig, CouncilSeatsConfig, DemocracyConfig, TreasuryConfig,
|
||||
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill,
|
||||
CouncilVotingConfig, GrandpaConfig, SudoConfig, IndicesConfig,
|
||||
ClaimsConfig, FeesConfig, Permill, StakerStatus
|
||||
CouncilVotingConfig, GrandpaConfig, SudoConfig, IndicesConfig, Permill,
|
||||
CuratedGrandpaConfig, StakerStatus,
|
||||
};
|
||||
use telemetry::TelemetryEndpoints;
|
||||
|
||||
@@ -82,6 +82,8 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
}),
|
||||
system: None,
|
||||
balances: Some(BalancesConfig {
|
||||
transaction_base_fee: 1 * CENTS,
|
||||
transaction_byte_fee: 10 * MILLICENTS,
|
||||
balances: endowed_accounts.iter()
|
||||
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
|
||||
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
|
||||
@@ -105,7 +107,6 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
current_era: 0,
|
||||
offline_slash: Perbill::from_billionths(1_000_000),
|
||||
session_reward: Perbill::from_billionths(2_065),
|
||||
current_offline_slash: 0,
|
||||
current_session_reward: 0,
|
||||
validator_count: 7,
|
||||
sessions_per_era: 12,
|
||||
@@ -154,13 +155,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
grandpa: Some(GrandpaConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
|
||||
}),
|
||||
fees: Some(FeesConfig {
|
||||
transaction_base_fee: 1 * CENTS,
|
||||
transaction_byte_fee: 10 * MILLICENTS,
|
||||
}),
|
||||
parachains: Some(Default::default()),
|
||||
claims: Some(ClaimsConfig {
|
||||
claims: vec![],
|
||||
curated_grandpa: Some(CuratedGrandpaConfig {
|
||||
shuffle_period: 1024,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -199,7 +196,7 @@ pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, Sessio
|
||||
(
|
||||
get_account_id_from_seed(&format!("{}//stash", seed)),
|
||||
get_account_id_from_seed(seed),
|
||||
get_session_key_from_seed(seed)
|
||||
get_session_key_from_seed(seed),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -222,7 +219,6 @@ pub fn testnet_genesis(
|
||||
|
||||
const STASH: u128 = 1 << 20;
|
||||
const ENDOWMENT: u128 = 1 << 20;
|
||||
|
||||
GenesisConfig {
|
||||
consensus: Some(ConsensusConfig {
|
||||
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
|
||||
@@ -233,6 +229,8 @@ pub fn testnet_genesis(
|
||||
ids: endowed_accounts.clone(),
|
||||
}),
|
||||
balances: Some(BalancesConfig {
|
||||
transaction_base_fee: 1,
|
||||
transaction_byte_fee: 0,
|
||||
existential_deposit: 500,
|
||||
transfer_fee: 0,
|
||||
creation_fee: 0,
|
||||
@@ -252,7 +250,6 @@ pub fn testnet_genesis(
|
||||
bonding_duration: 2 * 60 * 12,
|
||||
offline_slash: Perbill::zero(),
|
||||
session_reward: Perbill::zero(),
|
||||
current_offline_slash: 0,
|
||||
current_session_reward: 0,
|
||||
offline_slash_grace: 0,
|
||||
stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
|
||||
@@ -297,15 +294,11 @@ pub fn testnet_genesis(
|
||||
sudo: Some(SudoConfig {
|
||||
key: root_key,
|
||||
}),
|
||||
claims: Some(ClaimsConfig {
|
||||
claims: vec![],
|
||||
}),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
|
||||
}),
|
||||
fees: Some(FeesConfig {
|
||||
transaction_base_fee: 1,
|
||||
transaction_byte_fee: 0,
|
||||
curated_grandpa: Some(CuratedGrandpaConfig {
|
||||
shuffle_period: 1024,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
+19
-14
@@ -43,16 +43,15 @@ pub mod chain_spec;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use polkadot_primitives::{parachain, parachain::CollatorId, Block, Hash, BlockId};
|
||||
use polkadot_primitives::{parachain, Block, Hash, BlockId};
|
||||
use polkadot_runtime::{GenesisConfig, RuntimeApi};
|
||||
use polkadot_network::gossip::{self as network_gossip, Known};
|
||||
use primitives::{Pair, ed25519};
|
||||
use primitives::{ed25519, Pair};
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use service::{FactoryFullConfiguration, FullBackend, LightBackend, FullExecutor, LightExecutor};
|
||||
use transaction_pool::txpool::{Pool as TransactionPool};
|
||||
use aura::{import_queue, start_aura, AuraImportQueue, SlotDuration, NothingExtra};
|
||||
use inherents::InherentDataProviders;
|
||||
|
||||
pub use service::{
|
||||
Roles, PruningMode, TransactionPoolOptions, ComponentClient,
|
||||
ErrorKind, Error, ComponentBlock, LightComponents, FullComponents,
|
||||
@@ -61,7 +60,7 @@ pub use service::{
|
||||
pub use service::config::full_version_from_strs;
|
||||
pub use client::{backend::Backend, runtime_api::Core as CoreApi, ExecutionStrategy};
|
||||
pub use polkadot_network::{PolkadotProtocol, NetworkService};
|
||||
pub use polkadot_primitives::parachain::ParachainHost;
|
||||
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
|
||||
pub use primitives::{Blake2Hasher};
|
||||
pub use sr_primitives::traits::ProvideRuntimeApi;
|
||||
pub use chain_spec::ChainSpec;
|
||||
@@ -71,7 +70,7 @@ pub type Configuration = FactoryFullConfiguration<Factory>;
|
||||
|
||||
/// Polkadot-specific configuration.
|
||||
pub struct CustomConfiguration {
|
||||
/// Set to `Some` with a collator `AccountId` and desired parachain
|
||||
/// Set to `Some` with a collator `CollatorId` and desired parachain
|
||||
/// if the network protocol should be started in collator mode.
|
||||
pub collating_for: Option<(CollatorId, parachain::Id)>,
|
||||
|
||||
@@ -156,7 +155,9 @@ construct_service_factory! {
|
||||
struct Factory {
|
||||
Block = Block,
|
||||
RuntimeApi = RuntimeApi,
|
||||
NetworkProtocol = PolkadotProtocol { |config: &Configuration| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())) },
|
||||
NetworkProtocol = PolkadotProtocol {
|
||||
|config: &Configuration| Ok(PolkadotProtocol::new(config.custom.collating_for.clone()))
|
||||
},
|
||||
RuntimeDispatch = polkadot_executor::Executor,
|
||||
FullTransactionPoolApi = TxChainApi<FullBackend<Self>, FullExecutor<Self>>
|
||||
{ |config, client| Ok(TransactionPool::new(config, TxChainApi::new(client))) },
|
||||
@@ -176,12 +177,18 @@ construct_service_factory! {
|
||||
|
||||
// always run GRANDPA in order to sync.
|
||||
{
|
||||
let local_key = if service.config.disable_grandpa {
|
||||
None
|
||||
} else {
|
||||
key.clone()
|
||||
};
|
||||
|
||||
let voter = grandpa::run_grandpa(
|
||||
grandpa::Config {
|
||||
// TODO: make gossip_duration available through chainspec
|
||||
// https://github.com/paritytech/substrate/issues/1578
|
||||
gossip_duration: Duration::new(4, 0),
|
||||
local_key: key.clone(),
|
||||
local_key,
|
||||
justification_period: 4096,
|
||||
name: Some(service.config.name.clone()),
|
||||
},
|
||||
@@ -230,7 +237,7 @@ construct_service_factory! {
|
||||
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::InChain) => match known_oracle.leaves() {
|
||||
Ok(BlockStatus::InChainWithState) | Ok(BlockStatus::InChainPruned) => match known_oracle.leaves() {
|
||||
Err(_) => None,
|
||||
Ok(leaves) => if leaves.contains(block_hash) {
|
||||
Some(Known::Leaf)
|
||||
@@ -271,6 +278,7 @@ construct_service_factory! {
|
||||
service.network(),
|
||||
service.on_exit(),
|
||||
service.config.custom.inherent_data_providers.clone(),
|
||||
service.config.force_authoring,
|
||||
)?;
|
||||
|
||||
executor.spawn(task);
|
||||
@@ -284,15 +292,12 @@ construct_service_factory! {
|
||||
{ |config: &mut FactoryFullConfiguration<Self>, client: Arc<FullClient<Self>>| {
|
||||
let slot_duration = SlotDuration::get_or_compute(&*client)?;
|
||||
|
||||
let (block_import, link_half) =
|
||||
grandpa::block_import::<_, _, _, RuntimeApi, FullClient<Self>>(
|
||||
client.clone(), client.clone(),
|
||||
)?;
|
||||
let (block_import, link_half) = grandpa::block_import::<_, _, _, RuntimeApi, FullClient<Self>>(client.clone(), client.clone())?;
|
||||
let block_import = Arc::new(block_import);
|
||||
let justification_import = block_import.clone();
|
||||
|
||||
config.custom.grandpa_import_setup = Some((block_import.clone(), link_half));
|
||||
import_queue(
|
||||
import_queue::<_, _, _, ed25519::Pair>(
|
||||
slot_duration,
|
||||
block_import,
|
||||
Some(justification_import),
|
||||
@@ -307,7 +312,7 @@ construct_service_factory! {
|
||||
{ |config: &mut FactoryFullConfiguration<Self>, client: Arc<LightClient<Self>>| {
|
||||
let slot_duration = SlotDuration::get_or_compute(&*client)?;
|
||||
|
||||
import_queue(
|
||||
import_queue::<_, _, _, ed25519::Pair>(
|
||||
slot_duration,
|
||||
client.clone(),
|
||||
None,
|
||||
|
||||
@@ -6,5 +6,5 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
[dependencies]
|
||||
parity-codec = "3.0"
|
||||
parity-codec-derive = "3.0"
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
|
||||
@@ -8,7 +8,7 @@ adder = { path = ".." }
|
||||
polkadot-parachain = { path = "../../../parachain" }
|
||||
polkadot-collator = { path = "../../../collator" }
|
||||
polkadot-primitives = { path = "../../../primitives" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
parking_lot = "0.7.1"
|
||||
ctrlc = { version = "3.0", features = ["termination"] }
|
||||
futures = "0.1"
|
||||
|
||||
@@ -31,7 +31,7 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use adder::{HeadData as AdderHead, BlockData as AdderBody};
|
||||
use substrate_primitives::{Pair as PairT, ed25519::Pair};
|
||||
use substrate_primitives::Pair;
|
||||
use parachain::codec::{Encode, Decode};
|
||||
use primitives::parachain::{HeadData, BlockData, Id as ParaId, Message, Extrinsic};
|
||||
use collator::{InvalidHead, ParachainContext, VersionInfo};
|
||||
|
||||
@@ -10,22 +10,23 @@ tokio = "0.1.7"
|
||||
error-chain = "0.12"
|
||||
log = "0.4.6"
|
||||
exit-future = "0.1"
|
||||
parity-codec = "3.0"
|
||||
parity-codec = "3.1"
|
||||
polkadot-availability-store = { path = "../availability-store" }
|
||||
polkadot-parachain = { path = "../parachain" }
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
polkadot-runtime = { path = "../runtime" }
|
||||
polkadot-statement-table = { path = "../statement-table" }
|
||||
substrate-consensus-aura = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-finality-grandpa = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-consensus-common = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-transaction-pool = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-consensus-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
[dev-dependencies]
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -37,7 +37,9 @@ extern crate polkadot_runtime;
|
||||
extern crate polkadot_primitives;
|
||||
|
||||
extern crate parity_codec as codec;
|
||||
extern crate substrate_inherents as inherents;
|
||||
extern crate substrate_primitives as primitives;
|
||||
extern crate srml_aura as runtime_aura;
|
||||
extern crate sr_primitives as runtime_primitives;
|
||||
extern crate substrate_client as client;
|
||||
extern crate substrate_trie as trie;
|
||||
@@ -46,10 +48,9 @@ extern crate exit_future;
|
||||
extern crate tokio;
|
||||
extern crate substrate_consensus_common as consensus;
|
||||
extern crate substrate_consensus_aura as aura;
|
||||
extern crate substrate_consensus_aura_primitives as aura_primitives;
|
||||
extern crate substrate_finality_grandpa as grandpa;
|
||||
extern crate substrate_transaction_pool as transaction_pool;
|
||||
extern crate substrate_inherents as inherents;
|
||||
extern crate srml_aura as runtime_aura;
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
@@ -67,6 +68,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use std::time::{self, Duration, Instant};
|
||||
|
||||
use aura::SlotDuration;
|
||||
use client::{BlockchainEvents, ChainHead, BlockBody};
|
||||
use client::blockchain::HeaderBackend;
|
||||
use client::block_builder::api::BlockBuilder as BlockBuilderApi;
|
||||
@@ -92,7 +94,6 @@ use collation::CollationFetch;
|
||||
use dynamic_inclusion::DynamicInclusion;
|
||||
use inherents::InherentData;
|
||||
use runtime_aura::timestamp::TimestampInherentData;
|
||||
use aura::SlotDuration;
|
||||
|
||||
use ed25519::Public as AuthorityId;
|
||||
|
||||
@@ -734,7 +735,11 @@ impl<C, TxApi> CreateProposal<C, TxApi> where
|
||||
use client::block_builder::BlockBuilder;
|
||||
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256};
|
||||
|
||||
let mut inherent_data = self.inherent_data.take().expect("CreateProposal is not polled after finishing; qed");
|
||||
const MAX_TRANSACTIONS: usize = 40;
|
||||
|
||||
let mut inherent_data = self.inherent_data
|
||||
.take()
|
||||
.expect("CreateProposal is not polled after finishing; qed");
|
||||
inherent_data.put_data(polkadot_runtime::PARACHAIN_INHERENT_IDENTIFIER, &candidates).map_err(ErrorKind::InherentError)?;
|
||||
|
||||
let runtime_api = self.client.runtime_api();
|
||||
@@ -748,16 +753,23 @@ impl<C, TxApi> CreateProposal<C, TxApi> where
|
||||
}
|
||||
|
||||
let mut unqueue_invalid = Vec::new();
|
||||
let mut pending_size = 0;
|
||||
|
||||
for ready in self.transaction_pool.ready() {
|
||||
let ready_iter = self.transaction_pool.ready();
|
||||
for ready in ready_iter.take(MAX_TRANSACTIONS) {
|
||||
let encoded_size = ready.data.encode().len();
|
||||
if pending_size + encoded_size >= MAX_TRANSACTIONS_SIZE {
|
||||
break
|
||||
}
|
||||
if Instant::now() > self.deadline {
|
||||
debug!("Validation deadline reached when pushing block transactions, proceeding with proposing.");
|
||||
debug!("Consensus deadline reached when pushing block transactions, proceeding with proposing.");
|
||||
break;
|
||||
}
|
||||
|
||||
match block_builder.push(ready.data.clone()) {
|
||||
Ok(()) => {
|
||||
debug!("[{:?}] Pushed to the block.", ready.hash);
|
||||
pending_size += encoded_size;
|
||||
}
|
||||
Err(client::error::Error(client::error::ErrorKind::ApplyExtrinsicFailed(ApplyError::FullBlock), _)) => {
|
||||
debug!("Block is full, proceed with proposing.");
|
||||
|
||||
@@ -33,8 +33,8 @@ use futures::{future, prelude::*};
|
||||
|
||||
use super::{GroupInfo, Incoming, TableRouter};
|
||||
use self::includable::IncludabilitySender;
|
||||
use primitives::{Pair, ed25519};
|
||||
use runtime_primitives::{traits::ProvideRuntimeApi};
|
||||
use primitives::{ed25519, Pair};
|
||||
use runtime_primitives::traits::ProvideRuntimeApi;
|
||||
|
||||
mod includable;
|
||||
|
||||
@@ -546,7 +546,6 @@ mod tests {
|
||||
use super::*;
|
||||
use substrate_keyring::AuthorityKeyring;
|
||||
use primitives::crypto::UncheckedInto;
|
||||
use futures::future;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct DummyRouter;
|
||||
|
||||
Reference in New Issue
Block a user