Update Polkadot/Substrate (#68)

* Update Polkadot/Substrate

* Update branch
This commit is contained in:
Bastian Köcher
2020-02-24 21:52:49 +01:00
committed by GitHub
parent 5678c8a188
commit ad8b70a8e4
8 changed files with 727 additions and 571 deletions
+12 -48
View File
@@ -30,11 +30,7 @@ use polkadot_collator::{
PolkadotClient,
};
use polkadot_primitives::{
parachain::{
self, BlockData, Id as ParaId, Message, OutgoingMessages,
Status as ParachainStatus,
},
Block as PBlock, Hash as PHash,
parachain::{self, BlockData, Status as ParachainStatus}, Block as PBlock, Hash as PHash,
};
use codec::{Decode, Encode};
@@ -43,9 +39,7 @@ use log::{error, trace};
use futures::{task::Spawn, Future, future};
use std::{
fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin, collections::HashMap,
};
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
use parking_lot::Mutex;
@@ -108,15 +102,14 @@ where
+ 'static,
{
type ProduceCandidate = Pin<Box<
dyn Future<Output=Result<(BlockData, parachain::HeadData, OutgoingMessages), InvalidHead>>
dyn Future<Output=Result<(BlockData, parachain::HeadData), InvalidHead>>
+ Send,
>>;
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
fn produce_candidate(
&mut self,
_relay_chain_parent: PHash,
status: ParachainStatus,
_: I,
) -> Self::ProduceCandidate {
let factory = self.proposer_factory.clone();
let inherent_providers = self.inherent_data_providers.clone();
@@ -196,29 +189,16 @@ where
// Create the parachain block data for the validators.
let b = ParachainBlockData::<Block>::new(
header,
header.clone(),
extrinsics,
proof.iter_nodes().collect(),
parent_state_root,
);
let block_import_params = BlockImportParams {
origin: BlockOrigin::Own,
header: b.header().clone(),
justification: None,
post_digests: vec![],
body: Some(b.extrinsics().to_vec()),
finalized: false,
intermediates: HashMap::new(),
auxiliary: vec![], // block-weight is written in block import.
// TODO: block-import handles fork choice and this shouldn't even have the
// option to specify one.
// https://github.com/paritytech/substrate/issues/3623
fork_choice: Some(ForkChoiceStrategy::LongestChain),
allow_missing_state: false,
import_existing: false,
storage_changes: Some(storage_changes),
};
let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header);
block_import_params.body = Some(b.extrinsics().to_vec());
block_import_params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
block_import_params.storage_changes = Some(storage_changes);
if let Err(err) = block_import
.lock()
@@ -237,14 +217,10 @@ where
let head_data = HeadData::<Block> {
header: b.into_header(),
};
let messages = OutgoingMessages {
outgoing_messages: Vec::new(),
};
let candidate = (
block_data,
parachain::HeadData(head_data.encode()),
messages,
);
trace!(target: "cumulus-collator", "Produced candidate: {:?}", candidate);
@@ -349,8 +325,8 @@ mod tests {
use super::*;
use std::time::Duration;
use polkadot_collator::{collate, CollatorId, PeerId, RelayChainContext, SignedStatement};
use polkadot_primitives::parachain::{ConsolidatedIngress, FeeSchedule, HeadData};
use polkadot_collator::{collate, CollatorId, PeerId, SignedStatement};
use polkadot_primitives::parachain::{FeeSchedule, HeadData, Id as ParaId};
use sp_blockchain::Result as ClientResult;
use sp_inherents::InherentData;
@@ -437,17 +413,6 @@ mod tests {
}
}
struct DummyRelayChainContext;
impl RelayChainContext for DummyRelayChainContext {
type Error = Error;
type FutureEgress = future::Ready<Result<ConsolidatedIngress, Error>>;
fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress {
future::ready(Ok(ConsolidatedIngress(Vec::new())))
}
}
#[derive(Clone)]
struct DummyPolkadotClient;
@@ -534,12 +499,11 @@ mod tests {
per_byte: 1,
},
},
DummyRelayChainContext,
context,
Arc::new(Sr25519Keyring::Alice.pair().into()),
);
let collation = futures::executor::block_on(collation).unwrap().0;
let collation = futures::executor::block_on(collation).unwrap();
let block_data = collation.pov.block_data;