mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Update substrate async api (#49)
* Update substrate: async API fix * Fix to update polkadot and substrate * Update substrate & polkadot to use cumulus-branch * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
+17
-17
@@ -6,20 +6,20 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
# Substrate dependencies
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-client = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
|
||||
# Polkadot dependencies
|
||||
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
|
||||
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
|
||||
|
||||
# Cumulus dependencies
|
||||
cumulus-consensus = { path = "../consensus" }
|
||||
@@ -37,13 +37,13 @@ test-runtime = { package = "cumulus-test-runtime", path = "../test/runtime" }
|
||||
test-client = { package = "cumulus-test-client", path = "../test/client" }
|
||||
|
||||
# Substrate dependencies
|
||||
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||
|
||||
# Polkadot dependencies
|
||||
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }
|
||||
|
||||
# Other dependencies
|
||||
env_logger = "0.7.1"
|
||||
|
||||
+19
-11
@@ -41,7 +41,7 @@ use codec::{Decode, Encode};
|
||||
|
||||
use log::{error, trace};
|
||||
|
||||
use futures::{task::Spawn, Future};
|
||||
use futures::{task::Spawn, Future, future};
|
||||
|
||||
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
|
||||
|
||||
@@ -120,20 +120,25 @@ where
|
||||
let inherent_providers = self.inherent_data_providers.clone();
|
||||
let block_import = self.block_import.clone();
|
||||
|
||||
Box::pin(async move {
|
||||
trace!(target: "cumulus-collator", "Producing candidate");
|
||||
trace!(target: "cumulus-collator", "Producing candidate");
|
||||
|
||||
let last_head = HeadData::<Block>::decode(&mut &status.head_data.0[..]).map_err(|e| {
|
||||
let last_head = match HeadData::<Block>::decode(&mut &status.head_data.0[..]) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
error!(target: "cumulus-collator", "Could not decode the head data: {:?}", e);
|
||||
InvalidHead
|
||||
})?;
|
||||
return Box::pin(future::ready(Err(InvalidHead)));
|
||||
}
|
||||
};
|
||||
|
||||
let proposer_future = factory
|
||||
.lock()
|
||||
.init(&last_head.header);
|
||||
|
||||
Box::pin(async move {
|
||||
let parent_state_root = *last_head.header.state_root();
|
||||
|
||||
let mut proposer = factory
|
||||
.lock()
|
||||
.init(&last_head.header)
|
||||
let mut proposer = proposer_future
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
target: "cumulus-collator",
|
||||
@@ -393,9 +398,12 @@ mod tests {
|
||||
impl Environment<Block> for DummyFactory {
|
||||
type Proposer = DummyProposer;
|
||||
type Error = Error;
|
||||
type CreateProposer = Pin<Box<
|
||||
dyn Future<Output = Result<Self::Proposer, Self::Error>> + Send + Unpin + 'static
|
||||
>>;
|
||||
|
||||
fn init(&mut self, _: &Header) -> Result<Self::Proposer, Self::Error> {
|
||||
Ok(DummyProposer)
|
||||
fn init(&mut self, _: &Header) -> Self::CreateProposer {
|
||||
Box::pin(future::ready(Ok(DummyProposer)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user