Skip to content

Commit f26dd45

Browse files
authored
Collate only if --validator is given (#161)
1 parent d664a7c commit f26dd45

File tree

16 files changed

+1412
-1350
lines changed

16 files changed

+1412
-1350
lines changed

Cargo.lock

+1,208-1,198
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collator/src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ use sp_runtime::{
4747
use polkadot_collator::{
4848
BuildParachainContext, Network as CollatorNetwork, ParachainContext, RuntimeApiCollection,
4949
};
50-
use polkadot_primitives::{
51-
parachain::{self, BlockData, GlobalValidationSchedule, Id as ParaId, LocalValidationData},
50+
use polkadot_primitives::v0::{
51+
self as parachain, BlockData, GlobalValidationData, Id as ParaId, LocalValidationData,
5252
Block as PBlock, DownwardMessage, Hash as PHash,
5353
};
5454

@@ -105,7 +105,7 @@ impl<Block: BlockT, PF, BI, BS> Collator<Block, PF, BI, BS> {
105105
/// Get the inherent data with validation function parameters injected
106106
fn inherent_data(
107107
inherent_providers: InherentDataProviders,
108-
global_validation: GlobalValidationSchedule,
108+
global_validation: GlobalValidationData,
109109
local_validation: LocalValidationData,
110110
downward_messages: DownwardMessagesType,
111111
) -> Option<InherentData> {
@@ -239,7 +239,7 @@ where
239239
fn produce_candidate(
240240
&mut self,
241241
relay_chain_parent: PHash,
242-
global_validation: GlobalValidationSchedule,
242+
global_validation: GlobalValidationData,
243243
local_validation: LocalValidationData,
244244
downward_messages: Vec<DownwardMessage>,
245245
) -> Self::ProduceCandidate {
@@ -493,10 +493,10 @@ mod tests {
493493
use std::time::Duration;
494494

495495
use polkadot_collator::{collate, SignedStatement};
496-
use polkadot_primitives::parachain::Id as ParaId;
496+
use polkadot_primitives::v0::Id as ParaId;
497497

498498
use sp_blockchain::Result as ClientResult;
499-
use sp_core::testing::SpawnBlockingExecutor;
499+
use sp_core::testing::TaskExecutor;
500500
use sp_inherents::InherentData;
501501
use sp_keyring::Sr25519Keyring;
502502
use sp_runtime::traits::{DigestFor, Header as HeaderT};
@@ -601,7 +601,7 @@ mod tests {
601601
fn collates_produces_a_block() {
602602
let id = ParaId::from(100);
603603
let _ = env_logger::try_init();
604-
let spawner = SpawnBlockingExecutor::new();
604+
let spawner = TaskExecutor::new();
605605
let announce_block = |_, _| ();
606606
let block_announce_validator = DelayedBlockAnnounceValidator::new();
607607
let client = Arc::new(TestClientBuilder::new().build());
@@ -639,7 +639,7 @@ mod tests {
639639
let collation = collate(
640640
Default::default(),
641641
id,
642-
GlobalValidationSchedule {
642+
GlobalValidationData {
643643
block_number: 0,
644644
max_code_size: 0,
645645
max_head_data_size: 0,

consensus/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ use sp_runtime::{
2626
traits::{Block as BlockT, Header as HeaderT},
2727
};
2828

29-
use polkadot_primitives::{
30-
parachain::{Id as ParaId, ParachainHost},
31-
Block as PBlock, Hash as PHash,
29+
use polkadot_primitives::v0::{
30+
Id as ParaId, ParachainHost, Block as PBlock, Hash as PHash,
3231
};
3332

3433
use codec::Decode;

network/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ use sp_runtime::{
3232

3333
use polkadot_collator::Network as CollatorNetwork;
3434
use polkadot_network::legacy::gossip::{GossipMessage, GossipStatement};
35-
use polkadot_primitives::{
36-
parachain::{Id as ParaId, ParachainHost},
37-
Block as PBlock, Hash as PHash,
35+
use polkadot_primitives::v0::{
36+
Id as ParaId, ParachainHost, Block as PBlock, Hash as PHash,
3837
};
39-
use polkadot_statement_table::{SignedStatement, Statement};
38+
use polkadot_statement_table::v0::{SignedStatement, Statement};
4039
use polkadot_validation::check_statement;
4140

4241
use cumulus_primitives::HeadData;

network/src/tests.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616

1717
use super::*;
1818
use cumulus_test_runtime::{Block, Header};
19-
use polkadot_primitives::{
20-
parachain::{
21-
AbridgedCandidateReceipt, Chain, CollatorId, DutyRoster, GlobalValidationSchedule,
22-
Id as ParaId, LocalValidationData, ParachainHost, Retriable, SigningContext,
23-
ValidationCode, ValidatorId,
24-
},
25-
Block as PBlock, Hash as PHash, Header as PHeader,
19+
use polkadot_primitives::v0::{
20+
AbridgedCandidateReceipt, Chain, CollatorId, DutyRoster, GlobalValidationData,
21+
Id as ParaId, LocalValidationData, ParachainHost, Retriable, SigningContext,
22+
ValidationCode, ValidatorId, Block as PBlock, Hash as PHash, Header as PHeader,
2623
};
2724
use polkadot_test_runtime_client::{
2825
DefaultTestClientBuilderExt, TestClient, TestClientBuilder, TestClientBuilderExt,
@@ -418,7 +415,7 @@ sp_api::mock_impl_runtime_apis! {
418415
Some(ValidationCode(Vec::new()))
419416
}
420417

421-
fn global_validation_schedule() -> GlobalValidationSchedule {
418+
fn global_validation_data() -> GlobalValidationData {
422419
Default::default()
423420
}
424421

@@ -440,7 +437,7 @@ sp_api::mock_impl_runtime_apis! {
440437
}
441438
}
442439

443-
fn downward_messages(_: ParaId) -> Vec<polkadot_primitives::DownwardMessage> {
440+
fn downward_messages(_: ParaId) -> Vec<polkadot_primitives::v0::DownwardMessage> {
444441
Vec::new()
445442
}
446443
}

parachain-upgrade/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ parachain = { package = "polkadot-parachain", git = "https://github.com/parityte
1616
# Substrate dependencies
1717
frame-support = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
1818
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
19-
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "2.0.0-dev", default-features = false }
19+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "2.0.0-rc5", default-features = false }
2020
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
2121
sp-io = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
2222
sp-std = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }

primitives/src/validation_function_params.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
use codec::{Decode, Encode};
2020
use polkadot_parachain::primitives::{RelayChainBlockNumber, ValidationParams};
21-
use polkadot_primitives::parachain::{GlobalValidationSchedule, LocalValidationData};
21+
use polkadot_primitives::v0::{GlobalValidationData, LocalValidationData};
2222

2323
/// Validation Function Parameters
2424
///
@@ -48,8 +48,8 @@ impl From<&ValidationParams> for ValidationFunctionParams {
4848
}
4949
}
5050

51-
impl From<(GlobalValidationSchedule, LocalValidationData)> for ValidationFunctionParams {
52-
fn from(t: (GlobalValidationSchedule, LocalValidationData)) -> Self {
51+
impl From<(GlobalValidationData, LocalValidationData)> for ValidationFunctionParams {
52+
fn from(t: (GlobalValidationData, LocalValidationData)) -> Self {
5353
let (global_validation, local_validation) = t;
5454
ValidationFunctionParams {
5555
max_code_size: global_validation.max_code_size,

primitives/src/xcmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
//! XMCP related primitives
1818
19-
use polkadot_primitives::parachain::Id as ParaId;
19+
use polkadot_primitives::v0::Id as ParaId;
2020
use sp_std::vec::Vec;
2121

2222
/// A raw XCMP message that is being send between two Parachain's.

test/parachain/Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumu
3131
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3232
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3333
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
34+
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3435
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3536
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3637
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3738
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
3839
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
39-
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-alpha.5" }
40+
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-rc5" }
4041
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
42+
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
4143
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
4244
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
45+
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
4346

4447
# Cumulus dependencies
4548
cumulus-consensus = { path = "../../consensus" }
@@ -72,6 +75,5 @@ polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch
7275

7376
# Substrate dependencies
7477
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
75-
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
7678
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
7779
substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }

test/parachain/src/command.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ pub fn run() -> Result<()> {
152152
Some(Subcommand::Base(subcommand)) => {
153153
let runner = cli.create_runner(subcommand)?;
154154

155-
runner.run_subcommand(subcommand, |config| {
156-
Ok(new_full_start!(config).0.to_chain_ops_parts())
155+
runner.run_subcommand(subcommand, |mut config| {
156+
let params = crate::service::new_partial(&mut config)?;
157+
158+
Ok((params.client, params.backend, params.import_queue, params.task_manager))
157159
})
158160
}
159161
Some(Subcommand::ExportGenesisState(params)) => {
@@ -185,7 +187,7 @@ pub fn run() -> Result<()> {
185187
let id = ParaId::from(cli.run.parachain_id);
186188

187189
let parachain_account =
188-
AccountIdConversion::<polkadot_primitives::AccountId>::into_account(&id);
190+
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
189191

190192
let block = generate_genesis_state(id)?;
191193
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
@@ -207,8 +209,8 @@ pub fn run() -> Result<()> {
207209
info!("Parachain Account: {}", parachain_account);
208210
info!("Parachain genesis state: {}", genesis_state);
209211

210-
crate::service::run_collator(config, key, polkadot_config, id)
211-
.map(|x| x.task_manager)
212+
crate::service::run_collator(config, key, polkadot_config, id, cli.run.base.validator)
213+
.map(|(x, _)| x)
212214
})
213215
}
214216
}

test/parachain/src/integration_test.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use futures::{
1919
future::{self, FutureExt},
2020
pin_mut, select,
2121
};
22-
use polkadot_primitives::parachain::{Id as ParaId, Info, Scheduling};
22+
use polkadot_primitives::v0::{Id as ParaId, Info, Scheduling};
2323
use polkadot_runtime_common::registrar;
2424
use polkadot_test_runtime_client::Sr25519Keyring;
2525
use sc_client_api::execution_extensions::ExecutionStrategies;
@@ -43,9 +43,8 @@ static INTEGRATION_TEST_ALLOWED_TIME: Option<&str> = option_env!("INTEGRATION_TE
4343
#[ignore]
4444
async fn integration_test() {
4545
let task_executor: TaskExecutor = (|fut, _| {
46-
spawn(fut);
47-
})
48-
.into();
46+
spawn(fut).map(|_| ())
47+
}).into();
4948

5049
// start alice
5150
let mut alice =
@@ -104,10 +103,10 @@ async fn integration_test() {
104103
polkadot_config.rpc_methods = sc_service::config::RpcMethods::Unsafe;
105104
let parachain_config =
106105
parachain_config(task_executor.clone(), Charlie, vec![], para_id).unwrap();
107-
let service =
108-
crate::service::run_collator(parachain_config, key, polkadot_config, para_id).unwrap();
106+
let (_service, charlie_client) =
107+
crate::service::run_collator(parachain_config, key, polkadot_config, para_id, true).unwrap();
109108
sleep(Duration::from_secs(3)).await;
110-
service.client.wait_for_blocks(4).await;
109+
charlie_client.wait_for_blocks(4).await;
111110

112111
alice.task_manager.terminate();
113112
bob.task_manager.terminate();

0 commit comments

Comments
 (0)