Commit 468585c2 authored by Bastian Köcher's avatar Bastian Köcher Committed by Gavin Wood
Browse files

Some fixes required for Cumulus (#766)

* Add some more bounds

* More bounds

* More fixes

* More fixes
parent 41e07ffe
Pipeline #74674 passed with stages
in 27 minutes and 52 seconds
......@@ -72,6 +72,7 @@ pub use polkadot_network::validation::Incoming;
pub use polkadot_validation::SignedStatement;
pub use polkadot_primitives::parachain::CollatorId;
pub use sc_network::PeerId;
pub use service::RuntimeApiCollection;
const COLLATION_TIMEOUT: Duration = Duration::from_secs(30);
......@@ -144,13 +145,17 @@ pub trait BuildParachainContext {
) -> Result<Self::ParachainContext, ()>
where
PolkadotClient<B, E, R>: ProvideRuntimeApi<Block>,
<PolkadotClient<B, E, R> as ProvideRuntimeApi<Block>>::Api: service::RuntimeApiCollection<Extrinsic>,
<PolkadotClient<B, E, R> as ProvideRuntimeApi<Block>>::Api: RuntimeApiCollection<Extrinsic>,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
<<PolkadotClient<B, E, R> as ProvideRuntimeApi<Block>>::Api as sp_api::ApiExt<Block>>::StateBackend:
sp_api::StateBackend<Blake2Hasher>,
Extrinsic: codec::Codec + Send + Sync + 'static,
E: sc_client::CallExecutor<Block> + Clone + Send + Sync + 'static,
SP: Spawn + Clone + Send + Sync + 'static;
SP: Spawn + Clone + Send + Sync + 'static,
R: Send + Sync + 'static,
B: sc_client_api::Backend<Block> + 'static,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
B::State: sp_api::StateBackend<Blake2Hasher>;
}
/// Parachain context needed for collation.
......@@ -282,7 +287,7 @@ fn run_collator_node<S, E, P, Extrinsic>(
S: AbstractService<Block = service::Block, NetworkSpecialization = service::PolkadotProtocol>,
sc_client::Client<S::Backend, S::CallExecutor, service::Block, S::RuntimeApi>: ProvideRuntimeApi<Block>,
<sc_client::Client<S::Backend, S::CallExecutor, service::Block, S::RuntimeApi> as ProvideRuntimeApi<Block>>::Api:
service::RuntimeApiCollection<
RuntimeApiCollection<
Extrinsic,
Error = sp_blockchain::Error,
StateBackend = sc_client_api::StateBackendFor<S::Backend, Block>
......@@ -428,7 +433,7 @@ fn run_collator_node<S, E, P, Extrinsic>(
});
let deadlined = future::select(
work,
work.then(|f| f).boxed(),
futures_timer::Delay::new(COLLATION_TIMEOUT)
);
......
......@@ -140,7 +140,11 @@ pub fn validate_candidate<E: Externalities + 'static>(
}
/// The host functions provided by the wasm executor to the parachain wasm blob.
type HostFunctions = (sp_io::SubstrateHostFunctions, crate::wasm_api::parachain::HostFunctions);
type HostFunctions = (
sp_io::SubstrateHostFunctions,
sc_executor::deprecated_host_interface::SubstrateExternals,
crate::wasm_api::parachain::HostFunctions,
);
/// Validate a candidate under the given validation code.
///
......
......@@ -461,7 +461,7 @@ fn do_validation<P>(
&validation_code,
params,
ext.clone(),
ExecutionMode::Remote,
ExecutionMode::Local,
) {
Ok(result) => {
if result.head_data == head_data.0 {
......
......@@ -275,7 +275,7 @@ struct ParachainValidation<C, N, P> {
}
impl<C, N, P> ParachainValidation<C, N, P> where
C: Collators + Send + Unpin + 'static,
C: Collators + Send + Unpin + 'static + Sync,
N: Network,
P: ProvideRuntimeApi<Block> + HeaderBackend<Block> + BlockBody<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + BlockBuilderApi<Block> + ApiExt<Block, Error = sp_blockchain::Error>,
......@@ -436,18 +436,17 @@ impl<C, N, P> ParachainValidation<C, N, P> where
ready(())
});
Some(res)
Ok(Some(res))
}
Err(e) => {
warn!(target: "validation", "Failed to produce a receipt: {:?}", e);
None
Ok(None)
}
}
}
Err(e) => {
warn!(target: "validation", "Failed to collate candidate: {:?}", e);
None
Ok(None)
}
})
};
......@@ -456,7 +455,12 @@ impl<C, N, P> ParachainValidation<C, N, P> where
.map_ok(with_router)
.map_err(|e| {
warn!(target: "validation" , "Failed to build table router: {:?}", e);
});
})
.and_then(|f| f)
.and_then(|f| match f {
Some(f) => f.map(Ok).boxed(),
None => ready(Ok(())).boxed(),
}).boxed();
let cancellable_work = select(exit, router).map(drop);
......@@ -549,7 +553,7 @@ impl<C, N, P, SC, TxPool, B> ProposerFactory<C, N, P, SC, TxPool, B> where
}
impl<C, N, P, SC, TxPool, B> consensus::Environment<Block> for ProposerFactory<C, N, P, SC, TxPool, B> where
C: Collators + Send + Unpin + 'static,
C: Collators + Send + Unpin + 'static + Sync,
N: Network,
TxPool: TransactionPool<Block=Block> + 'static,
P: ProvideRuntimeApi<Block> + HeaderBackend<Block> + BlockBody<Block> + Send + Sync + 'static,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment