Skip to content

Commit

Permalink
Update to latest substrate (paritytech#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored and rphmeier committed Feb 4, 2019
1 parent 98203aa commit 69937fd
Show file tree
Hide file tree
Showing 18 changed files with 862 additions and 711 deletions.
1,021 changes: 555 additions & 466 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion availability-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Parity Technologies <[email protected]>"]
polkadot-primitives = { path = "../primitives" }
parking_lot = "0.4"
log = "0.3"
parity-codec = "2.1"
parity-codec = "3.0"
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
kvdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
Expand Down
2 changes: 1 addition & 1 deletion collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "Collator node implementation"
[dependencies]
futures = "0.1.17"
substrate-client = { git = "https://github.com/paritytech/substrate" }
parity-codec = "2.1"
parity-codec = "3.0"
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
polkadot-runtime = { path = "../runtime", version = "0.1" }
polkadot-primitives = { path = "../primitives", version = "0.1" }
Expand Down
2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tokio = "0.1.7"
error-chain = "0.12"
log = "0.3"
exit-future = "0.1"
parity-codec = "2.1"
parity-codec = "3.0"
polkadot-availability-store = { path = "../availability-store" }
polkadot-parachain = { path = "../parachain" }
polkadot-primitives = { path = "../primitives" }
Expand Down
25 changes: 14 additions & 11 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use polkadot_primitives::parachain::{
AttestedCandidate, ParachainHost, Statement as PrimitiveStatement
};
use primitives::{Ed25519AuthorityId as AuthorityId, ed25519};
use runtime_primitives::traits::ProvideRuntimeApi;
use runtime_primitives::{traits::ProvideRuntimeApi, ApplyError};
use tokio::runtime::TaskExecutor;
use tokio::timer::{Delay, Interval};
use transaction_pool::txpool::{Pool, ChainApi as PoolChainApi};
Expand Down Expand Up @@ -507,7 +507,7 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
type Error = Error;
type Create = Either<CreateProposal<C, TxApi>, future::FutureResult<Block, Error>>;

fn propose(&self, inherent_data: InherentData) -> Self::Create {
fn propose(&self, inherent_data: InherentData, max_duration: Duration) -> Self::Create {
const ATTEMPT_PROPOSE_EVERY: Duration = Duration::from_millis(100);
const SLOT_DURATION_DENOMINATOR: u64 = 3; // wait up to 1/3 of the slot for candidates.

Expand Down Expand Up @@ -558,6 +558,8 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
believed_minimum_timestamp: believed_timestamp,
timing,
inherent_data: Some(inherent_data),
// leave some time for the proposal finalisation
deadline: Instant::now() + max_duration - max_duration / 3,
})
}
}
Expand Down Expand Up @@ -626,6 +628,7 @@ pub struct CreateProposal<C: Send + Sync, TxApi: PoolChainApi> {
timing: ProposalTiming,
believed_minimum_timestamp: u64,
inherent_data: Option<InherentData>,
deadline: Instant,
}

impl<C, TxApi> CreateProposal<C, TxApi> where
Expand All @@ -637,8 +640,6 @@ impl<C, TxApi> CreateProposal<C, TxApi> where
use client::block_builder::BlockBuilder;
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256};

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)?;

Expand All @@ -653,18 +654,20 @@ impl<C, TxApi> CreateProposal<C, TxApi> where
}

let mut unqueue_invalid = Vec::new();
let mut pending_size = 0;

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
for ready in self.transaction_pool.ready() {
if Instant::now() > self.deadline {
debug!("Consensus deadline reached when pushing block transactions, proceeding with proposing.");
break;
}

match block_builder.push(ready.data.clone()) {
Ok(()) => {
pending_size += encoded_size;
debug!("[{:?}] Pushed to the block.", ready.hash);
}
Err(client::error::Error(client::error::ErrorKind::ApplyExtrinsicFailed(ApplyError::FullBlock), _)) => {
debug!("Block is full, proceed with proposing.");
break;
}
Err(e) => {
trace!(target: "transaction-pool", "Invalid transaction: {}", e);
Expand Down
2 changes: 1 addition & 1 deletion erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2018"
[dependencies]
polkadot-primitives = { path = "../primitives" }
reed-solomon-erasure = { git = "https://github.com/paritytech/reed-solomon-erasure" }
parity-codec = "2.1"
parity-codec = "3.0"
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-trie = { git = "https://github.com/paritytech/substrate" }
4 changes: 2 additions & 2 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ parking_lot = "0.4"
polkadot-availability-store = { path = "../availability-store" }
polkadot-consensus = { path = "../consensus" }
polkadot-primitives = { path = "../primitives" }
parity-codec = "2.1"
parity-codec-derive = "2.1"
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" }
Expand Down
4 changes: 2 additions & 2 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["Parity Technologies <[email protected]>"]
description = "Types and utilities for creating and working with parachains"

[dependencies]
parity-codec = { version = "2.1", default-features = false }
parity-codec-derive = { version = "2.1", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
wasmi = { version = "0.4.3", optional = true }
error-chain = { version = "0.12", optional = true }

Expand Down
4 changes: 2 additions & 2 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ authors = ["Parity Technologies <[email protected]>"]
[dependencies]
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "2.1", default-features = false }
parity-codec-derive = { version = "2.1", default-features = false }
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 }
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
safe-mix = { version = "1.0", default-features = false}
polkadot-primitives = { path = "../primitives", default-features = false }
parity-codec = { version = "2.2", default-features = false }
parity-codec-derive = { version = "2.2", 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 }
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub use balances::Call as BalancesCall;
pub use parachains::{Call as ParachainsCall, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER};
pub use sr_primitives::{Permill, Perbill};
pub use timestamp::BlockPeriod;
pub use srml_support::{StorageValue, RuntimeMetadata};
pub use srml_support::StorageValue;

/// Runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
Expand Down
Loading

0 comments on commit 69937fd

Please sign in to comment.