Update for Substrate master (#600)

* update substrate for change to palette

* change paint to palette

* update lock

* Fix missing import

* change to polkadot-master

* Use same commit hash of parity-common

* Resolve linking errors

* Rename to frame

* bump spec

* Subsume #602 and #596

* Fix DispatchInfo

* Merge `futures03` and `joe-update-to-palette` (#606)

* Change repo and branch

* Made changes

* Bumped async-std version

* Fix line width

* Bump spec_version

* Fix `run_to_block` for Crowdfund module (#603)

Probably a copy paste error.

* Bump dependencies

* Update trie-db to be inline with substrate

* Fix documentation warning

* Fix test compilation
This commit is contained in:
joe petrowski
2019-11-23 00:16:04 +01:00
committed by Gavin Wood
parent e229074f79
commit c9b1e3d959
27 changed files with 1310 additions and 925 deletions
+1043 -708
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
cli = { package = "polkadot-cli", path = "cli" }
futures = "0.1.29"
futures = "0.3.1"
ctrlc = { version = "3.1.3", features = ["termination"] }
service = { package = "polkadot-service", path = "service" }
@@ -47,3 +47,6 @@ maintenance = { status = "actively-developed" }
[profile.release]
# Polkadot runtime requires unwinding.
panic = "unwind"
[patch.crates-io]
zstd-sys = { git = "https://github.com/bkchr/zstd-rs.git", branch = "bkchr-export-include-paths2" }
+3 -3
View File
@@ -11,6 +11,6 @@ parking_lot = "0.9.0"
log = "0.4.8"
codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = ["derive"] }
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" }
kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" }
kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" }
+2 -2
View File
@@ -8,8 +8,8 @@ edition = "2018"
[dependencies]
log = "0.4.8"
tokio = "0.1.22"
futures = "0.1.29"
exit-future = "0.1.4"
futures = { version = "0.3.1", features = ["compat"] }
futures01 = { package = "futures", version = "0.1.29" }
structopt = "0.3.4"
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
service = { package = "polkadot-service", path = "../service" }
+20 -8
View File
@@ -22,7 +22,7 @@
mod chain_spec;
use chain_spec::ChainSpec;
use futures::Future;
use futures::{Future, FutureExt, TryFutureExt, future::select, channel::oneshot, compat::Future01CompatExt};
use tokio::runtime::Runtime;
use std::sync::Arc;
use log::{info, error};
@@ -36,8 +36,9 @@ pub use service::{
pub use cli::{VersionInfo, IntoExit, NoCustom};
pub use cli::{display_role, error};
type BoxedFuture = Box<dyn futures01::Future<Item = (), Error = ()> + Send>;
/// Abstraction over an executor that lets you spawn tasks in the background.
pub type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
pub type TaskExecutor = Arc<dyn futures01::future::Executor<BoxedFuture> + Send + Sync>;
fn load_spec(id: &str) -> Result<Option<service::ChainSpec>, String> {
Ok(match ChainSpec::from(id) {
@@ -53,7 +54,7 @@ fn load_spec(id: &str) -> Result<Option<service::ChainSpec>, String> {
pub trait Worker: IntoExit {
/// A future that resolves when the work is done or the node should exit.
/// This will be run on a tokio runtime.
type Work: Future<Item=(),Error=()> + Send + 'static;
type Work: Future<Output=()> + Unpin + Send + 'static;
/// Return configuration for the polkadot node.
// TODO: make this the full configuration, so embedded nodes don't need
@@ -143,20 +144,31 @@ fn run_until_exit<T, SC, B, CE, W>(
CE: service::CallExecutor<service::Block, service::Blake2Hasher> + Clone + Send + Sync + 'static,
W: Worker,
{
let (exit_send, exit) = exit_future::signal();
let (exit_send, exit) = oneshot::channel();
let executor = runtime.executor();
let informant = cli::informant::build(&service);
executor.spawn(exit.until(informant).map(|_| ()));
let future = select(exit, informant)
.map(|_| Ok(()))
.compat();
executor.spawn(future);
// we eagerly drop the service so that the internal exit future is fired,
// but we need to keep holding a reference to the global telemetry guard
let _telemetry = service.telemetry();
let work = worker.work(&service, Arc::new(executor));
let service = service.map_err(|err| error!("Error while running Service: {}", err));
let _ = runtime.block_on(service.select(work));
exit_send.fire();
let service = service
.map_err(|err| error!("Error while running Service: {}", err))
.compat();
let future = select(service, work)
.map(|_| Ok::<_, ()>(()))
.compat();
let _ = runtime.block_on(future);
let _ = exit_send.send(());
use futures01::Future;
// TODO [andre]: timeout this future substrate/#1318
let _ = runtime.shutdown_on_idle().wait();
+3 -2
View File
@@ -6,8 +6,8 @@ description = "Collator node implementation"
edition = "2018"
[dependencies]
futures = "0.1.29"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
futures01 = { package = "futures", version = "0.1.17" }
futures = { version = "0.3.1", features = ["compat"] }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client-api = { package = "substrate-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
@@ -21,6 +21,7 @@ polkadot-validation = { path = "../validation" }
polkadot-service = { path = "../service" }
log = "0.4.8"
tokio = "0.1.22"
futures-timer = "1.0"
[dev-dependencies]
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
+111 -96
View File
@@ -49,8 +49,10 @@ use std::fmt;
use std::sync::Arc;
use std::time::Duration;
use futures::{future, Stream, Future, IntoFuture};
use futures03::{TryStreamExt as _, StreamExt as _};
use futures::{
future, Future, Stream, FutureExt, TryFutureExt, StreamExt,
compat::{Compat01As03, Future01CompatExt, Stream01CompatExt}
};
use log::{warn, error};
use client::BlockchainEvents;
use primitives::{Pair, Blake2Hasher};
@@ -67,7 +69,6 @@ use polkadot_cli::{
use polkadot_network::validation::{LeafWorkParams, ValidationNetwork};
use polkadot_network::{PolkadotNetworkService, PolkadotProtocol};
use polkadot_runtime::RuntimeApi;
use tokio::timer::Timeout;
pub use polkadot_cli::{VersionInfo, TaskExecutor};
pub use polkadot_network::validation::Incoming;
@@ -81,14 +82,14 @@ const COLLATION_TIMEOUT: Duration = Duration::from_secs(30);
pub trait Network: Send + Sync {
/// Convert the given `CollatorId` to a `PeerId`.
fn collator_id_to_peer_id(&self, collator_id: CollatorId) ->
Box<dyn Future<Item=Option<PeerId>, Error=()> + Send>;
Box<dyn Future<Output=Option<PeerId>> + Unpin + Send>;
/// Create a `Stream` of checked statements for the given `relay_parent`.
///
/// The returned stream will not terminate, so it is required to make sure that the stream is
/// dropped when it is not required anymore. Otherwise, it will stick around in memory
/// infinitely.
fn checked_statements(&self, relay_parent: Hash) -> Box<dyn Stream<Item=SignedStatement, Error=()>>;
fn checked_statements(&self, relay_parent: Hash) -> Box<dyn Stream<Item=SignedStatement>>;
}
impl<P, E> Network for ValidationNetwork<P, E, PolkadotNetworkService, TaskExecutor> where
@@ -96,13 +97,21 @@ impl<P, E> Network for ValidationNetwork<P, E, PolkadotNetworkService, TaskExecu
E: 'static + Send + Sync,
{
fn collator_id_to_peer_id(&self, collator_id: CollatorId) ->
Box<dyn Future<Item=Option<PeerId>, Error=()> + Send>
Box<dyn Future<Output=Option<PeerId>> + Unpin + Send>
{
Box::new(Self::collator_id_to_peer_id(self, collator_id))
Box::new(
Self::collator_id_to_peer_id(self, collator_id)
.compat()
.map(|res| res.ok().and_then(|id| id))
)
}
fn checked_statements(&self, relay_parent: Hash) -> Box<dyn Stream<Item=SignedStatement, Error=()>> {
Box::new(Self::checked_statements(self, relay_parent))
fn checked_statements(&self, relay_parent: Hash) -> Box<dyn Stream<Item=SignedStatement>> {
Box::new(
Self::checked_statements(self, relay_parent)
.compat()
.filter_map(|item| future::ready(item.ok()))
)
}
}
@@ -153,7 +162,7 @@ pub trait BuildParachainContext {
/// This can be implemented through an externally attached service or a stub.
/// This is expected to be a lightweight, shared type like an Arc.
pub trait ParachainContext: Clone {
type ProduceCandidate: IntoFuture<Item=(BlockData, HeadData, OutgoingMessages), Error=InvalidHead>;
type ProduceCandidate: Future<Output = Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>>;
/// Produce a candidate, given the relay parent hash, the latest ingress queue information
/// and the last parachain head.
@@ -173,14 +182,14 @@ pub trait RelayChainContext {
/// Future that resolves to the un-routed egress queues of a parachain.
/// The first item is the oldest.
type FutureEgress: IntoFuture<Item=ConsolidatedIngress, Error=Self::Error>;
type FutureEgress: Future<Output = Result<ConsolidatedIngress, Self::Error>>;
/// Get un-routed egress queues from a parachain to the local parachain.
fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress;
}
/// Produce a candidate for the parachain, with given contexts, parent head, and signing key.
pub fn collate<'a, R, P>(
pub async fn collate<R, P>(
relay_parent: Hash,
local_id: ParaId,
parachain_status: ParachainStatus,
@@ -188,53 +197,45 @@ pub fn collate<'a, R, P>(
mut para_context: P,
key: Arc<CollatorPair>,
)
-> impl Future<Item=(parachain::Collation, OutgoingMessages), Error=Error<R::Error>> + 'a
-> Result<(parachain::Collation, OutgoingMessages), Error<R::Error>>
where
R: RelayChainContext,
R::Error: 'a,
R::FutureEgress: 'a,
P: ParachainContext + 'a,
<P::ProduceCandidate as IntoFuture>::Future: Send,
P: ParachainContext,
P::ProduceCandidate: Send,
{
let ingress = relay_context.unrouted_egress(local_id).into_future().map_err(Error::Polkadot);
ingress
.and_then(move |ingress| {
para_context.produce_candidate(
relay_parent,
parachain_status,
ingress.0.iter().flat_map(|&(id, ref msgs)| msgs.iter().cloned().map(move |msg| (id, msg)))
)
.into_future()
.map(move |x| (ingress, x))
.map_err(Error::Collator)
})
.and_then(move |(ingress, (block_data, head_data, mut outgoing))| {
let block_data_hash = block_data.hash();
let signature = key.sign(block_data_hash.as_ref()).into();
let egress_queue_roots =
polkadot_validation::egress_roots(&mut outgoing.outgoing_messages);
let ingress = relay_context.unrouted_egress(local_id).await.map_err(Error::Polkadot)?;
let receipt = parachain::CandidateReceipt {
parachain_index: local_id,
collator: key.public(),
signature,
head_data,
egress_queue_roots,
fees: 0,
block_data_hash,
upward_messages: Vec::new(),
};
let (block_data, head_data, mut outgoing) = para_context.produce_candidate(
relay_parent,
parachain_status,
ingress.0.iter().flat_map(|&(id, ref msgs)| msgs.iter().cloned().map(move |msg| (id, msg)))
).map_err(Error::Collator).await?;
let collation = parachain::Collation {
receipt,
pov: PoVBlock {
block_data,
ingress,
},
};
let block_data_hash = block_data.hash();
let signature = key.sign(block_data_hash.as_ref());
let egress_queue_roots =
polkadot_validation::egress_roots(&mut outgoing.outgoing_messages);
Ok((collation, outgoing))
})
let receipt = parachain::CandidateReceipt {
parachain_index: local_id,
collator: key.public(),
signature,
head_data,
egress_queue_roots,
fees: 0,
block_data_hash,
upward_messages: Vec::new(),
};
let collation = parachain::Collation {
receipt,
pov: PoVBlock {
block_data,
ingress,
},
};
Ok((collation, outgoing))
}
/// Polkadot-api context.
@@ -247,10 +248,10 @@ struct ApiContext<P, E> {
impl<P: 'static, E: 'static> RelayChainContext for ApiContext<P, E> where
P: ProvideRuntimeApi + Send + Sync,
P::Api: ParachainHost<Block>,
E: Future<Item=(),Error=()> + Clone + Send + Sync + 'static,
E: futures01::Future<Item=(),Error=()> + Clone + Send + Sync + 'static,
{
type Error = String;
type FutureEgress = Box<dyn Future<Item=ConsolidatedIngress, Error=String> + Send>;
type FutureEgress = Box<dyn Future<Output=Result<ConsolidatedIngress, String>> + Unpin + Send>;
fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress {
// TODO: https://github.com/paritytech/polkadot/issues/253
@@ -260,7 +261,9 @@ impl<P: 'static, E: 'static> RelayChainContext for ApiContext<P, E> where
local_session_key: None,
parent_hash: self.parent_hash,
authorities: self.validators.clone(),
}).map_err(|e| format!("unable to instantiate validation session: {:?}", e));
})
.compat()
.map_err(|e| format!("unable to instantiate validation session: {:?}", e));
Box::new(future::ok(ConsolidatedIngress(Vec::new())))
}
@@ -274,27 +277,27 @@ struct CollationNode<P, E> {
}
impl<P, E> IntoExit for CollationNode<P, E> where
E: Future<Item=(),Error=()> + Send + 'static
E: futures01::Future<Item=(),Error=()> + Unpin + Send + 'static
{
type Exit = E;
type Exit = future::Map<Compat01As03<E>, fn (Result<(), ()>) -> ()>;
fn into_exit(self) -> Self::Exit {
self.exit
self.exit.compat().map(drop)
}
}
impl<P, E> Worker for CollationNode<P, E> where
P: BuildParachainContext + Send + 'static,
P::ParachainContext: Send + 'static,
<<P::ParachainContext as ParachainContext>::ProduceCandidate as IntoFuture>::Future: Send + 'static,
E: Future<Item=(), Error=()> + Clone + Send + Sync + 'static,
<P::ParachainContext as ParachainContext>::ProduceCandidate: Send + 'static,
E: futures01::Future<Item=(),Error=()> + Clone + Unpin + Send + Sync + 'static,
{
type Work = Box<dyn Future<Item=(), Error=()> + Send>;
type Work = Box<dyn Future<Output=()> + Unpin + Send>;
fn configuration(&self) -> CustomConfiguration {
let mut config = CustomConfiguration::default();
config.collating_for = Some((
self.key.public(),
self.para_id.clone(),
self.para_id,
));
config
}
@@ -321,7 +324,7 @@ impl<P, E> Worker for CollationNode<P, E> where
select_chain
} else {
error!("The node cannot work because it can't select chain.");
return Box::new(future::err(()));
return Box::new(future::ready(()));
};
let is_known = move |block_hash: &Hash| {
@@ -364,20 +367,18 @@ impl<P, E> Worker for CollationNode<P, E> where
Ok(ctx) => ctx,
Err(()) => {
error!("Could not build the parachain context!");
return Box::new(future::err(()))
return Box::new(future::ready(()))
}
};
let inner_exit = exit.clone();
let work = client.import_notification_stream()
.map(|v| Ok::<_, ()>(v))
.compat()
.for_each(move |notification| {
macro_rules! try_fr {
($e:expr) => {
match $e {
Ok(x) => x,
Err(e) => return future::Either::A(future::err(Error::Polkadot(
Err(e) => return future::Either::Left(future::err(Error::Polkadot(
format!("{:?}", e)
))),
}
@@ -393,11 +394,11 @@ impl<P, E> Worker for CollationNode<P, E> where
let parachain_context = parachain_context.clone();
let validation_network = validation_network.clone();
let work = future::lazy(move || {
let work = future::lazy(move |_| {
let api = client.runtime_api();
let status = match try_fr!(api.parachain_status(&id, para_id)) {
Some(status) => status,
None => return future::Either::A(future::ok(())),
None => return future::Either::Left(future::ok(())),
};
let validators = try_fr!(api.validators(&id));
@@ -421,7 +422,7 @@ impl<P, E> Worker for CollationNode<P, E> where
context,
parachain_context,
key,
).map(move |(collation, outgoing)| {
).map_ok(move |(collation, outgoing)| {
network.with_spec(move |spec, ctx| {
let res = spec.add_local_collation(
ctx,
@@ -437,23 +438,36 @@ impl<P, E> Worker for CollationNode<P, E> where
})
});
future::Either::B(collation_work)
});
let deadlined = Timeout::new(work, COLLATION_TIMEOUT);
let silenced = deadlined.then(|res| match res {
Ok(()) => Ok(()),
Err(_) => {
warn!("Collation failure: timeout");
Ok(())
}
});
future::Either::Right(collation_work)
}).map(|_| Ok::<_, ()>(()));
tokio::spawn(silenced.select(inner_exit.clone()).then(|_| Ok(())));
Ok(())
let deadlined = future::select(
work,
futures_timer::Delay::new(COLLATION_TIMEOUT)
);
let silenced = deadlined
.map(|either| {
if let future::Either::Right(_) = either {
warn!("Collation failure: timeout");
}
});
let future = future::select(
silenced,
inner_exit.clone().map(|_| Ok::<_, ()>(())).compat()
).map(|_| Ok::<_, ()>(())).compat();
tokio::spawn(future);
future::ready(())
});
let work_and_exit = work.select(exit).then(|_| Ok(()));
Box::new(work_and_exit) as Box<_>
let work_and_exit = future::select(
work,
exit.map(|_| Ok::<_, ()>(())).compat()
).map(|_| ());
Box::new(work_and_exit)
}
}
@@ -481,11 +495,10 @@ pub fn run_collator<P, E>(
) -> polkadot_cli::error::Result<()> where
P: BuildParachainContext + Send + 'static,
P::ParachainContext: Send + 'static,
<<P::ParachainContext as ParachainContext>::ProduceCandidate as IntoFuture>::Future: Send + 'static,
E: IntoFuture<Item=(), Error=()>,
E::Future: Send + Clone + Sync + 'static,
<P::ParachainContext as ParachainContext>::ProduceCandidate: Send + 'static,
E: futures01::Future<Item = (),Error=()> + Unpin + Send + Clone + Sync + 'static,
{
let node_logic = CollationNode { build_parachain_context, exit: exit.into_future(), para_id, key };
let node_logic = CollationNode { build_parachain_context, exit, para_id, key };
polkadot_cli::run(node_logic, version)
}
@@ -503,12 +516,12 @@ mod tests {
impl RelayChainContext for DummyRelayChainContext {
type Error = ();
type FutureEgress = Box<dyn Future<Item=ConsolidatedIngress,Error=()>>;
type FutureEgress = Box<dyn Future<Output=Result<ConsolidatedIngress,()>> + Unpin>;
fn unrouted_egress(&self, para_id: ParaId) -> Self::FutureEgress {
match self.ingress.get(&para_id) {
Some(ingress) => Box::new(future::ok(ingress.clone())),
None => Box::new(future::empty()),
None => Box::new(future::pending()),
}
}
}
@@ -517,16 +530,16 @@ mod tests {
struct DummyParachainContext;
impl ParachainContext for DummyParachainContext {
type ProduceCandidate = Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>;
type ProduceCandidate = future::Ready<Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>>;
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
&mut self,
_relay_parent: Hash,
_status: ParachainStatus,
ingress: I,
) -> Result<(BlockData, HeadData, OutgoingMessages), InvalidHead> {
) -> Self::ProduceCandidate {
// send messages right back.
Ok((
future::ok((
BlockData(vec![1, 2, 3, 4, 5,]),
HeadData(vec![9, 9, 9]),
OutgoingMessages {
@@ -570,7 +583,7 @@ mod tests {
(a, messages_from_a),
]));
let collation = collate(
let future = collate(
Default::default(),
id,
ParachainStatus {
@@ -584,7 +597,9 @@ mod tests {
context.clone(),
DummyParachainContext,
Arc::new(Sr25519Keyring::Alice.pair().into()),
).wait().unwrap().0;
);
let collation = futures::executor::block_on(future).unwrap().0;
// ascending order by root.
assert_eq!(collation.receipt.egress_queue_roots, vec![(a, root_a), (b, root_b)]);
+2 -2
View File
@@ -15,8 +15,8 @@ codec = { package = "parity-scale-codec", version = "1.1.0", default-features =
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.29"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
futures = "0.1"
futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
log = "0.4.8"
exit-future = "0.1.4"
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
+1 -1
View File
@@ -15,7 +15,7 @@ rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", de
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
polkadot-parachain = { path = "../parachain", default-features = false }
bitvec = { version = "0.15.2", default-features = false, features = ["alloc"] }
babe = { package = "paint-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
[dev-dependencies]
substrate-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
+2 -2
View File
@@ -11,7 +11,7 @@ polkadot-primitives = { path = "../primitives" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
paint-system-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
paint-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
frame-system-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
polkadot-runtime = { path = "../runtime" }
+4 -4
View File
@@ -33,12 +33,12 @@ pub fn create<C, P>(client: Arc<C>, pool: Arc<Pool<P>>) -> RpcExtension where
C: ProvideRuntimeApi,
C: client::blockchain::HeaderBackend<Block>,
C: Send + Sync + 'static,
C::Api: paint_system_rpc::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: paint_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
C::Api: frame_system_rpc::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
P: ChainApi + Sync + Send + 'static,
{
use paint_system_rpc::{System, SystemApi};
use paint_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use frame_system_rpc::{System, SystemApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(
+30 -30
View File
@@ -30,33 +30,33 @@ version = { package = "sr-version", git = "https://github.com/paritytech/substra
tx-pool-api = { package = "substrate-transaction-pool-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
block-builder-api = { package = "substrate-block-builder-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authority-discovery = { package = "paint-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authorship = { package = "paint-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "paint-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
balances = { package = "paint-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
transaction-payment = { package = "paint-transaction-payment", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
paint-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
collective = { package = "paint-collective", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
democracy = { package = "paint-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
elections-phragmen = { package = "paint-elections-phragmen", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
executive = { package = "paint-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
finality-tracker = { package = "paint-finality-tracker", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
grandpa = { package = "paint-grandpa", git = "https://github.com/paritytech/substrate", default-features = false, features = ["migrate-authorities"], branch = "polkadot-master" }
im-online = { package = "paint-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
indices = { package = "paint-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
membership = { package = "paint-membership", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
nicks = { package = "paint-nicks", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offences = { package = "paint-offences", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
randomness-collective-flip = { package = "paint-randomness-collective-flip", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
session = { package = "paint-session", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
paint-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
staking = { package = "paint-staking", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
paint-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sudo = { package = "paint-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system = { package = "paint-system", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system_rpc_runtime_api = { package = "paint-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
timestamp = { package = "paint-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
treasury = { package = "paint-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authority-discovery = { package = "pallet-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
transaction-payment = { package = "pallet-transaction-payment", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
collective = { package = "pallet-collective", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
democracy = { package = "pallet-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
elections-phragmen = { package = "pallet-elections-phragmen", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
executive = { package = "frame-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
finality-tracker = { package = "pallet-finality-tracker", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
grandpa = { package = "pallet-grandpa", git = "https://github.com/paritytech/substrate", default-features = false, features = ["migrate-authorities"], branch = "polkadot-master" }
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
indices = { package = "pallet-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
membership = { package = "pallet-membership", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
nicks = { package = "pallet-nicks", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
staking = { package = "pallet-staking", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system_rpc_runtime_api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
primitives = { package = "polkadot-primitives", path = "../primitives", default-features = false }
polkadot-parachain = { path = "../parachain", default-features = false }
@@ -67,7 +67,7 @@ libsecp256k1 = "0.3.2"
tiny-keccak = "1.5.0"
keyring = { package = "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.15.2"
trie-db = "0.16.0"
serde_json = "1.0.41"
[build-dependencies]
@@ -93,11 +93,11 @@ std = [
"offchain-primitives/std",
"rstd/std",
"sr-io/std",
"paint-support/std",
"frame-support/std",
"authorship/std",
"balances/std",
"transaction-payment/std",
"paint-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"collective/std",
"elections-phragmen/std",
"democracy/std",
+1 -1
View File
@@ -21,7 +21,7 @@
use rstd::prelude::*;
use codec::{Encode, Decode};
use paint_support::{decl_storage, decl_module, ensure, dispatch::Result, traits::Get};
use frame_support::{decl_storage, decl_module, ensure, dispatch::Result, traits::Get};
use primitives::{Hash, parachain::{AttestedCandidate, CandidateReceipt, Id as ParaId}};
use sr_primitives::RuntimeDebug;
+5 -4
View File
@@ -18,8 +18,9 @@
use rstd::prelude::*;
use sr_io::{hashing::keccak_256, crypto::secp256k1_ecdsa_recover};
use paint_support::{decl_event, decl_storage, decl_module};
use paint_support::traits::{Currency, Get};
use frame_support::{decl_event, decl_storage, decl_module};
use frame_support::weights::SimpleDispatchInfo;
use frame_support::traits::{Currency, Get};
use system::{ensure_root, ensure_none};
use codec::{Encode, Decode};
#[cfg(feature = "std")]
@@ -27,7 +28,7 @@ use serde::{self, Serialize, Deserialize, Serializer, Deserializer};
#[cfg(feature = "std")]
use sr_primitives::traits::Zero;
use sr_primitives::{
RuntimeDebug, weights::SimpleDispatchInfo, transaction_validity::{
RuntimeDebug, transaction_validity::{
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction
},
};
@@ -249,7 +250,7 @@ mod tests {
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
use balances;
use paint_support::{impl_outer_origin, assert_ok, assert_err, assert_noop, parameter_types};
use frame_support::{impl_outer_origin, assert_ok, assert_err, assert_noop, parameter_types};
impl_outer_origin! {
pub enum Origin for Test {}
+4 -3
View File
@@ -66,15 +66,16 @@
//! order to win a later auction, then it is the parachain's duty to ensure that the right amount of
//! funds ultimately end up in module's fund sub-account.
use paint_support::{
use frame_support::{
decl_module, decl_storage, decl_event, storage::child, ensure, traits::{
Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement::AllowDeath
}
};
use system::ensure_signed;
use sr_primitives::{ModuleId, weights::SimpleDispatchInfo,
use sr_primitives::{ModuleId,
traits::{AccountIdConversion, Hash, Saturating, Zero, CheckedAdd}
};
use frame_support::weights::SimpleDispatchInfo;
use crate::slots;
use codec::{Encode, Decode};
use rstd::vec::Vec;
@@ -489,7 +490,7 @@ mod tests {
use super::*;
use std::{collections::HashMap, cell::RefCell};
use paint_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types};
use frame_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types};
use substrate_primitives::H256;
use primitives::parachain::{Info as ParaInfo, Id as ParaId};
// The testing primitives are very useful for avoiding having to work with signatures
+2 -2
View File
@@ -17,10 +17,10 @@
//! Auxillary struct/enums for polkadot runtime.
use primitives::Balance;
use sr_primitives::weights::Weight;
use sr_primitives::traits::{Convert, Saturating};
use sr_primitives::{Fixed64, Perbill};
use paint_support::traits::{OnUnbalanced, Currency, Get};
use frame_support::weights::Weight;
use frame_support::traits::{OnUnbalanced, Currency, Get};
use crate::{Balances, System, Authorship, MaximumBlockWeight, NegativeImbalance};
/// Logic for the author to get a portion of fees.
+14 -10
View File
@@ -37,9 +37,9 @@ use primitives::{
};
use sr_primitives::{
create_runtime_str, generic, impl_opaque_keys,
ApplyResult, Permill, Perbill, RuntimeDebug,
ApplyExtrinsicResult, Permill, Perbill, RuntimeDebug,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys},
};
use version::RuntimeVersion;
@@ -48,12 +48,13 @@ use grandpa::{AuthorityId as GrandpaId, fg_primitives};
use version::NativeVersion;
use substrate_primitives::OpaqueMetadata;
use sr_staking_primitives::SessionIndex;
use paint_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency, Randomness}
use frame_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency, Randomness},
weights::{Weight, DispatchInfo},
};
use im_online::sr25519::AuthorityId as ImOnlineId;
use system::offchain::TransactionSubmitter;
use paint_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
#[cfg(feature = "std")]
pub use staking::StakerStatus;
@@ -94,8 +95,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 1,
spec_version: 1018,
authoring_version: 2,
spec_version: 1019,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};
@@ -120,7 +121,10 @@ impl SignedExtension for OnlyStakingAndClaims {
type Call = Call;
type AdditionalSigned = ();
type Pre = ();
type DispatchInfo = DispatchInfo;
fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
-> TransactionValidity
{
@@ -278,7 +282,7 @@ impl session::historical::Trait for Runtime {
type FullIdentificationOf = staking::ExposureOf<Runtime>;
}
paint_staking_reward_curve::build! {
pallet_staking_reward_curve::build! {
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
max_inflation: 0_100_000,
@@ -643,7 +647,7 @@ sr_api::impl_runtime_apis! {
}
impl block_builder_api::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Executive::apply_extrinsic(extrinsic)
}
@@ -738,7 +742,7 @@ sr_api::impl_runtime_apis! {
}
}
impl paint_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
Block,
Balance,
UncheckedExtrinsic,
+5 -5
View File
@@ -25,7 +25,7 @@ use sr_primitives::traits::{
Hash as HashT, BlakeTwo256, Saturating, One, Zero, Dispatchable,
AccountIdConversion,
};
use sr_primitives::weights::SimpleDispatchInfo;
use frame_support::weights::SimpleDispatchInfo;
use primitives::{
Hash, Balance,
parachain::{
@@ -33,7 +33,7 @@ use primitives::{
UpwardMessage, BlockIngressRoots, ValidatorId, ActiveParas, CollatorId, Retriable
},
};
use paint_support::{
use frame_support::{
Parameter, dispatch::Result, decl_storage, decl_module, ensure,
traits::{Currency, Get, WithdrawReason, ExistenceRequirement, Randomness},
};
@@ -917,7 +917,7 @@ mod tests {
};
use crate::constants::time::*;
use keyring::Sr25519Keyring;
use paint_support::{
use frame_support::{
impl_outer_origin, impl_outer_dispatch, assert_ok, assert_err, parameter_types,
};
use crate::parachains;
@@ -1026,7 +1026,7 @@ mod tests {
type CreationFee = CreationFee;
}
paint_staking_reward_curve::build! {
pallet_staking_reward_curve::build! {
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
max_inflation: 0_100_000,
@@ -2035,7 +2035,7 @@ mod tests {
#[test]
fn empty_trie_root_const_is_blake2_hashed_null_node() {
let hashed_null_node = <NodeCodec<Blake2Hasher> as trie_db::NodeCodec<Blake2Hasher>>::hashed_null_node();
let hashed_null_node = <NodeCodec<Blake2Hasher> as trie_db::NodeCodec>::hashed_null_node();
assert_eq!(hashed_null_node, EMPTY_TRIE_ROOT.into())
}
}
+5 -4
View File
@@ -24,14 +24,14 @@ use rstd::marker::PhantomData;
use codec::{Encode, Decode};
use sr_primitives::{
weights::{SimpleDispatchInfo, DispatchInfo},
transaction_validity::{TransactionValidityError, ValidTransaction, TransactionValidity},
traits::{Hash as HashT, SignedExtension}
};
use paint_support::{
use frame_support::{
decl_storage, decl_module, decl_event, ensure,
dispatch::{Result, IsSubType}, traits::{Get, Currency, ReservableCurrency}
dispatch::{Result, IsSubType}, traits::{Get, Currency, ReservableCurrency},
weights::{SimpleDispatchInfo, DispatchInfo},
};
use system::{self, ensure_root, ensure_signed};
use primitives::parachain::{
@@ -508,6 +508,7 @@ impl<T: Trait + Send + Sync> SignedExtension for LimitParathreadCommits<T> where
type Call = <T as system::Trait>::Call;
type AdditionalSigned = ();
type Pre = ();
type DispatchInfo = DispatchInfo;
fn additional_signed(&self)
-> rstd::result::Result<Self::AdditionalSigned, TransactionValidityError>
@@ -588,7 +589,7 @@ mod tests {
},
Balance, BlockNumber,
};
use paint_support::{
use frame_support::{
impl_outer_origin, impl_outer_dispatch, assert_ok, parameter_types, assert_noop,
};
use keyring::Sr25519Keyring;
+3 -3
View File
@@ -22,9 +22,9 @@ use rstd::{prelude::*, mem::swap, convert::TryInto};
use sr_primitives::traits::{
CheckedSub, StaticLookup, Zero, One, CheckedConversion, Hash, AccountIdConversion,
};
use sr_primitives::weights::SimpleDispatchInfo;
use frame_support::weights::SimpleDispatchInfo;
use codec::{Encode, Decode, Codec};
use paint_support::{
use frame_support::{
decl_module, decl_storage, decl_event, ensure,
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
};
@@ -825,7 +825,7 @@ mod tests {
Perbill, testing::Header,
traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
};
use paint_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
use frame_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
use balances;
use primitives::parachain::{Id as ParaId, Info as ParaInfo};
+3 -3
View File
@@ -36,9 +36,9 @@ service = { package = "substrate-service", git = "https://github.com/paritytech/
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
paint-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
paint-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
im-online = { package = "paint-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authority-discovery = { package = "substrate-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
+1 -1
View File
@@ -30,7 +30,7 @@ use hex_literal::hex;
use babe_primitives::AuthorityId as BabeId;
use grandpa::AuthorityId as GrandpaId;
use im_online::sr25519::{AuthorityId as ImOnlineId};
use paint_staking::Forcing;
use pallet_staking::Forcing;
const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
const DEFAULT_PROTOCOL_ID: &str = "dot";
+4 -4
View File
@@ -19,15 +19,15 @@
#![warn(missing_docs)]
use cli::{AbstractService, VersionInfo, TaskExecutor};
use futures::sync::oneshot;
use futures::{future, Future};
use futures::channel::oneshot;
use futures::{future, FutureExt};
use std::cell::RefCell;
// the regular polkadot worker simply does nothing until ctrl-c
struct Worker;
impl cli::IntoExit for Worker {
type Exit = future::MapErr<oneshot::Receiver<()>, fn(oneshot::Canceled) -> ()>;
type Exit = future::Map<oneshot::Receiver<()>, fn(Result<(), oneshot::Canceled>) -> ()>;
fn into_exit(self) -> Self::Exit {
// can't use signal directly here because CtrlC takes only `Fn`.
let (exit_send, exit) = oneshot::channel();
@@ -39,7 +39,7 @@ impl cli::IntoExit for Worker {
}
}).expect("Error setting Ctrl-C handler");
exit.map_err(drop)
exit.map(drop)
}
}
@@ -14,5 +14,5 @@ client = { package = "substrate-client", git = "https://github.com/paritytech/su
client-api = { package = "substrate-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
parking_lot = "0.9.0"
ctrlc = { version = "3.1.3", features = ["termination"] }
futures = "0.1.29"
futures = "0.3.1"
exit-future = "0.1.4"
@@ -33,6 +33,7 @@ use collator::{
InvalidHead, ParachainContext, VersionInfo, Network, BuildParachainContext, TaskExecutor,
};
use parking_lot::Mutex;
use futures::future::{Ready, ok, err};
const GENESIS: AdderHead = AdderHead {
number: 0,
@@ -57,17 +58,19 @@ struct AdderContext {
/// The parachain context.
impl ParachainContext for AdderContext {
type ProduceCandidate = Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>;
type ProduceCandidate = Ready<Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>>;
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
&mut self,
_relay_parent: Hash,
status: ParachainStatus,
ingress: I,
) -> Result<(BlockData, HeadData, OutgoingMessages), InvalidHead>
) -> Self::ProduceCandidate
{
let adder_head = AdderHead::decode(&mut &status.head_data.0[..])
.map_err(|_| InvalidHead)?;
let adder_head = match AdderHead::decode(&mut &status.head_data.0[..]) {
Ok(adder_head) => adder_head,
Err(_) => return err(InvalidHead)
};
let mut db = self.db.lock();
@@ -98,7 +101,7 @@ impl ParachainContext for AdderContext {
next_head.number, next_body.state.overflowing_add(next_body.add).0);
db.insert(next_head.clone(), next_body);
Ok((encoded_body, encoded_head, OutgoingMessages { outgoing_messages: Vec::new() }))
ok((encoded_body, encoded_head, OutgoingMessages { outgoing_messages: Vec::new() }))
}
}
+6 -4
View File
@@ -5,9 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
futures = "0.1.29"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
futures-timer = "0.4.0"
futures = "0.1.17"
futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
futures-timer = "2.0"
async-std = { version = "1.0.1", features = ["unstable"] }
parking_lot = "0.9.0"
tokio = "0.1.22"
derive_more = "0.14.1"
@@ -26,11 +27,12 @@ primitives = { package = "substrate-primitives", git = "https://github.com/parit
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
block-builder = { package = "substrate-block-builder", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
bitvec = { version = "0.15.2", default-features = false, features = ["alloc"] }
runtime_babe = { package = "paint-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
runtime_babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
keystore = { package = "substrate-keystore", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
+23 -16
View File
@@ -29,7 +29,13 @@
//!
//! Groups themselves may be compromised by malicious authorities.
use std::{collections::{HashMap, HashSet}, pin::Pin, sync::Arc, time::{self, Duration, Instant}};
use std::{
collections::{HashMap, HashSet},
pin::Pin,
sync::Arc,
time::{self, Duration, Instant},
task::{Poll, Context}
};
use babe_primitives::BabeApi;
use client::{BlockchainEvents, BlockBody};
@@ -48,16 +54,17 @@ use polkadot_primitives::parachain::{
};
use primitives::Pair;
use runtime_primitives::traits::{ProvideRuntimeApi, DigestFor};
use futures_timer::{Delay, Interval};
use futures_timer::Delay;
use async_std::stream::{interval, Interval};
use transaction_pool::txpool::{Pool, ChainApi as PoolChainApi};
use attestation_service::ServiceHandle;
use futures::prelude::*;
use futures03::{future::{self, Either, FutureExt}, task::Context, stream::StreamExt};
use futures03::{future::{self, Either}, FutureExt, StreamExt};
use collation::CollationFetch;
use dynamic_inclusion::DynamicInclusion;
use inherents::InherentData;
use runtime_babe::timestamp::TimestampInherentData;
use sp_timestamp::TimestampInherentData;
use log::{info, debug, warn, trace, error};
use keystore::KeyStorePtr;
use sr_api::ApiExt;
@@ -594,7 +601,7 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
let timing = ProposalTiming {
minimum: delay_future,
attempt_propose: Interval::new(ATTEMPT_PROPOSE_EVERY),
attempt_propose: interval(ATTEMPT_PROPOSE_EVERY),
enough_candidates: Delay::new(enough_candidates),
dynamic_inclusion,
last_included: initial_included,
@@ -642,26 +649,26 @@ struct ProposalTiming {
impl ProposalTiming {
// whether it's time to attempt a proposal.
// shouldn't be called outside of the context of a task.
fn poll(&mut self, cx: &mut Context, included: usize) -> futures03::Poll<Result<(), Error>> {
fn poll(&mut self, cx: &mut Context, included: usize) -> Poll<()> {
// first drain from the interval so when the minimum delay is up
// we don't have any notifications built up.
//
// this interval is just meant to produce periodic task wakeups
// that lead to the `dynamic_inclusion` getting updated as necessary.
while let futures03::Poll::Ready(x) = self.attempt_propose.poll_next_unpin(cx) {
while let Poll::Ready(x) = self.attempt_propose.poll_next_unpin(cx) {
x.expect("timer still alive; intervals never end; qed");
}
// wait until the minimum time has passed.
if let Some(mut minimum) = self.minimum.take() {
if let futures03::Poll::Pending = minimum.poll_unpin(cx) {
if let Poll::Pending = minimum.poll_unpin(cx) {
self.minimum = Some(minimum);
return futures03::Poll::Pending;
return Poll::Pending;
}
}
if included == self.last_included {
return self.enough_candidates.poll_unpin(cx).map_err(Error::Timer);
return self.enough_candidates.poll_unpin(cx);
}
// the amount of includable candidates has changed. schedule a wakeup
@@ -669,10 +676,10 @@ impl ProposalTiming {
match self.dynamic_inclusion.acceptable_in(Instant::now(), included) {
Some(instant) => {
self.last_included = included;
self.enough_candidates.reset(instant);
self.enough_candidates.poll_unpin(cx).map_err(Error::Timer)
self.enough_candidates.reset(Instant::now() + instant);
self.enough_candidates.poll_unpin(cx)
}
None => futures03::Poll::Ready(Ok(())),
None => Poll::Ready(()),
}
}
}
@@ -791,16 +798,16 @@ impl<C, TxApi> futures03::Future for CreateProposal<C, TxApi> where
{
type Output = Result<Block, Error>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> futures03::Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
// 1. try to propose if we have enough includable candidates and other
// delays have concluded.
let included = self.table.includable_count();
futures03::ready!(self.timing.poll(cx, included))?;
futures03::ready!(self.timing.poll(cx, included));
// 2. propose
let proposed_candidates = self.table.proposed_set();
futures03::Poll::Ready(self.propose_with(proposed_candidates))
Poll::Ready(self.propose_with(proposed_candidates))
}
}