Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,167 changes: 683 additions & 484 deletions Cargo.lock

Large diffs are not rendered by default.

60 changes: 12 additions & 48 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
21 changes: 6 additions & 15 deletions consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion runtime/src/validate_block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
36 changes: 19 additions & 17 deletions test/parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand All @@ -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 {
Expand All @@ -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! {
Expand All @@ -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},
}
}
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion test/parachain/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down