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 28ad9997ea
commit 41817628b7
8 changed files with 727 additions and 571 deletions
Generated
+687 -488
View File
File diff suppressed because it is too large Load Diff
+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;
+6 -15
View File
@@ -15,7 +15,6 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use std::sync::Arc;
use std::collections::HashMap;
use sc_client::Client;
use sc_client_api::{Backend, CallExecutor, TransactionFor};
@@ -90,20 +89,12 @@ where
body = Some(inner_body);
}
let block_import_params = BlockImportParams {
origin,
header,
post_digests: Vec::new(),
body,
finalized: false,
intermediates: HashMap::new(),
justification,
auxiliary: Vec::new(),
fork_choice: Some(ForkChoiceStrategy::LongestChain),
allow_missing_state: false,
import_existing: false,
storage_changes: None,
};
let post_hash = Some(header.hash());
let mut block_import_params = BlockImportParams::new(origin, header);
block_import_params.body = body;
block_import_params.justification = justification;
block_import_params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
block_import_params.post_hash = post_hash;
Ok((block_import_params, None))
}
+1 -1
View File
@@ -22,7 +22,7 @@ use sp_blockchain::Error as ClientError;
use sp_consensus::block_validation::{BlockAnnounceValidator, Validation};
use sp_runtime::traits::Block as BlockT;
use polkadot_network::gossip::{GossipMessage, GossipStatement};
use polkadot_network::legacy::gossip::{GossipMessage, GossipStatement};
use polkadot_primitives::parachain::ValidatorId;
use polkadot_statement_table::{SignedStatement, Statement};
use polkadot_validation::check_statement;
-1
View File
@@ -42,7 +42,6 @@ fn call_validate_block(
let params = ValidationParams {
block_data: block_data.encode(),
parent_head: parent_head.encode(),
ingress: Vec::new(),
}
.encode();
+19 -17
View File
@@ -169,18 +169,20 @@ impl frame_system::Trait for Runtime {
type Version = Version;
/// Converts a module to an index of this module in the runtime.
type ModuleToIndex = ModuleToIndex;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = Balances;
}
parameter_types! {
pub const IndexDeposit: Balance = 1;
}
impl pallet_indices::Trait for Runtime {
/// The type for recording indexing into the account enumeration. If this ever overflows, there
/// will be problems!
type AccountIndex = u32;
/// Use the standard means of resolving an index hint from an id.
type ResolveHint = pallet_indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
/// Determine whether an account is dead.
type IsDeadAccount = Balances;
/// The ubiquitous event type.
type Event = Event;
type Currency = Balances;
type Deposit = IndexDeposit;
}
parameter_types! {
@@ -205,15 +207,11 @@ parameter_types! {
impl pallet_balances::Trait for Runtime {
/// The type for recording an account's balance.
type Balance = Balance;
/// What to do if a new account is created.
type OnNewAccount = Indices;
/// The ubiquitous event type.
type Event = Event;
type DustRemoval = ();
type TransferPayment = ();
type ExistentialDeposit = ExistentialDeposit;
type CreationFee = CreationFee;
type OnReapAccount = System;
type AccountStore = System;
}
impl pallet_transaction_payment::Trait for Runtime {
@@ -226,8 +224,8 @@ impl pallet_transaction_payment::Trait for Runtime {
}
impl pallet_sudo::Trait for Runtime {
type Call = Call;
type Event = Event;
type Proposal = Call;
}
construct_runtime! {
@@ -236,11 +234,11 @@ construct_runtime! {
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Storage, Config, Event},
System: frame_system::{Module, Call, Storage, Config, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Indices: pallet_indices,
Balances: pallet_balances,
Sudo: pallet_sudo,
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
}
}
@@ -305,6 +303,10 @@ impl_runtime_apis! {
Executive::apply_extrinsic(extrinsic)
}
fn apply_trusted_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Executive::apply_trusted_extrinsic(extrinsic)
}
fn finalize_block() -> <Block as BlockT>::Header {
Executive::finalize_block()
}
+1 -1
View File
@@ -87,7 +87,7 @@ fn testnet_genesis(
changes_trie_config: Default::default(),
}),
pallet_indices: Some(IndicesConfig {
ids: endowed_accounts.clone(),
indices: vec![],
}),
pallet_balances: Some(BalancesConfig {
balances: endowed_accounts
+1
View File
@@ -122,6 +122,7 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
enable_mdns: false,
allow_private_ipv4,
wasm_external_transport: None,
use_yamux_flow_control: false,
};
match config.roles {