Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
938 changes: 545 additions & 393 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use sp_consensus::{
};
use sp_inherents::InherentDataProviders;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sc_cli;

use polkadot_collator::{
BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext,
Expand All @@ -43,7 +44,9 @@ use log::{error, trace};

use futures::{task::Spawn, Future, future};

use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
use std::{
fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin, collections::HashMap,
};

use parking_lot::Mutex;

Expand Down Expand Up @@ -207,11 +210,12 @@ where
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: ForkChoiceStrategy::LongestChain,
fork_choice: Some(ForkChoiceStrategy::LongestChain),
allow_missing_state: false,
import_existing: false,
storage_changes: Some(storage_changes),
Expand Down Expand Up @@ -342,20 +346,19 @@ pub trait SetupParachain<Block: BlockT>: Send {
}

/// Run a collator with the given proposer factory.
pub fn run_collator<Block, SP, E>(
pub fn run_collator<Block, SP>(
setup_parachain: SP,
para_id: ParaId,
exit: E,
key: Arc<CollatorPair>,
configuration: polkadot_collator::Configuration,
) -> Result<(), sc_cli::error::Error>
where
Block: BlockT,
SP: SetupParachain<Block> + Send + 'static,
<<SP as SetupParachain<Block>>::ProposerFactory as Environment<Block>>::Proposer: Send,
E: Future<Output = ()> + Unpin + Send + Clone + Sync + 'static,
{
let builder = CollatorBuilder::new(setup_parachain);
let exit = future::pending(); // TODO to delete
polkadot_collator::run_collator(builder, para_id, exit, key, configuration)
}

Expand Down Expand Up @@ -518,7 +521,7 @@ mod tests {
let context = builder
.build::<_, _, polkadot_service::polkadot_runtime::RuntimeApi, _, _>(
Arc::new(
substrate_test_client::TestClientBuilder::<_, _, ()>::default()
substrate_test_client::TestClientBuilder::<_, _, _, ()>::default()
.build_with_native_executor(Some(NativeExecutor::<
polkadot_service::PolkadotExecutor,
>::new(Interpreted, None)))
Expand Down
4 changes: 3 additions & 1 deletion consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// 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 @@ -95,9 +96,10 @@ where
post_digests: Vec::new(),
body,
finalized: false,
intermediates: HashMap::new(),
justification,
auxiliary: Vec::new(),
fork_choice: ForkChoiceStrategy::LongestChain,
fork_choice: Some(ForkChoiceStrategy::LongestChain),
allow_missing_state: false,
import_existing: false,
storage_changes: None,
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
memory-db = { version = "0.18.0", default-features = false }
hash-db = { version = "0.15.2", default-features = false }
trie-db = { version = "0.18.0", default-features = false }
trie-db = { version = "0.19.2", default-features = false }
hashbrown = "0.6.1"

# Substrate dependencies
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 @@ -47,7 +47,6 @@ fn call_validate_block(
.encode();

call_in_wasm::<
_,
(
sp_io::SubstrateHostFunctions,
sc_executor::deprecated_host_interface::SubstrateExternals,
Expand Down
2 changes: 1 addition & 1 deletion test/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulu
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }

sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
15 changes: 10 additions & 5 deletions test/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use runtime::{
genesismap::{additional_storage_with_genesis, GenesisConfig},
Block,
};
use sp_core::{sr25519, storage::Storage};
use sp_core::{sr25519, storage::Storage, ChangesTrieConfiguration};
use sp_keyring::{AccountKeyring, Sr25519Keyring};
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
pub use test_client::*;
Expand All @@ -46,7 +46,7 @@ pub type Executor =
sc_client::LocalCallExecutor<Backend, sc_executor::NativeExecutor<LocalExecutor>>;

/// Test client builder for Cumulus
pub type TestClientBuilder = test_client::TestClientBuilder<Executor, Backend, GenesisParameters>;
pub type TestClientBuilder = test_client::TestClientBuilder<Block, Executor, Backend, GenesisParameters>;

/// LongestChain type for the test runtime/client.
pub type LongestChain = test_client::sc_client::LongestChain<Backend, Block>;
Expand All @@ -64,7 +64,12 @@ impl test_client::GenesisInit for GenesisParameters {
fn genesis_storage(&self) -> Storage {
use codec::Encode;

let mut storage = genesis_config(self.support_changes_trie).genesis_map();
let changes_trie_config: Option<ChangesTrieConfiguration> = if self.support_changes_trie {
Some(sp_test_primitives::changes_trie_config())
} else {
None
};
let mut storage = genesis_config(changes_trie_config).genesis_map();

let child_roots = storage.children.iter().map(|(sk, child_content)| {
let state_root =
Expand Down Expand Up @@ -121,9 +126,9 @@ impl DefaultTestClientBuilderExt for TestClientBuilder {
}
}

fn genesis_config(support_changes_trie: bool) -> GenesisConfig {
fn genesis_config(changes_trie_config: Option<ChangesTrieConfiguration>) -> GenesisConfig {
GenesisConfig::new(
support_changes_trie,
changes_trie_config,
vec![
sr25519::Public::from(Sr25519Keyring::Alice).into(),
sr25519::Public::from(Sr25519Keyring::Bob).into(),
Expand Down
3 changes: 2 additions & 1 deletion test/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-basic-authority = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }

# Cumulus dependencies
Expand All @@ -49,6 +49,7 @@ cumulus-collator = { path = "../../collator" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "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-cli = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" }

[build-dependencies]
vergen = '3.0.4'
Expand Down
6 changes: 6 additions & 0 deletions test/parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ impl_runtime_apis! {
}

impl sp_session::SessionKeys<Block> for Runtime {
fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
}

fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
}
Expand Down
Loading