From a780cb70e9ec8ba8494aeddf44d57922f9fdfa68 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Wed, 6 May 2020 17:12:37 +0200 Subject: [PATCH 1/2] fix test collator compilation failure Closes #88. --- test/parachain/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parachain/Cargo.toml b/test/parachain/Cargo.toml index 65523231517..07b90e67262 100644 --- a/test/parachain/Cargo.toml +++ b/test/parachain/Cargo.toml @@ -31,7 +31,7 @@ sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumu sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", features = [ "test-helpers" ] } sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } From 398709adb70108b068a062a54f11610be4be8621 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Thu, 7 May 2020 14:50:51 +0200 Subject: [PATCH 2/2] copy method instead of using feature Using a feature gate like "test-features" is problematic because it is leaky: depending on situational considitons such as the current working directory when compilation is attempted, the feature may or may not be applied, which makes success inconsistent. It's simpler in this case to copy a dozen lines of code than to work out all the issues with test features. --- test/parachain/Cargo.toml | 2 +- test/parachain/src/command.rs | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/test/parachain/Cargo.toml b/test/parachain/Cargo.toml index 07b90e67262..65523231517 100644 --- a/test/parachain/Cargo.toml +++ b/test/parachain/Cargo.toml @@ -31,7 +31,7 @@ sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumu sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", features = [ "test-helpers" ] } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } diff --git a/test/parachain/src/command.rs b/test/parachain/src/command.rs index 2ed05226846..59955074a82 100644 --- a/test/parachain/src/command.rs +++ b/test/parachain/src/command.rs @@ -23,12 +23,11 @@ use sc_cli::{ CliConfiguration, Error, ImportParams, KeystoreParams, NetworkParams, Result, SharedParams, SubstrateCli, }; -use sc_service::client::genesis; use sc_network::config::TransportConfig; use sc_service::config::{NetworkConfiguration, NodeKeyConfig, PrometheusConfig}; use sp_core::hexdisplay::HexDisplay; use sp_runtime::{ - traits::{Block as BlockT, Hash as HashT, Header as HeaderT}, + traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero}, BuildStorage, }; use std::net::SocketAddr; @@ -137,7 +136,22 @@ pub fn run() -> Result<()> { let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( storage.top.clone().into_iter().chain(child_roots).collect(), ); - let block: Block = genesis::construct_genesis_block(state_root); + let block = { + let extrinsics_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( + Vec::new(), + ); + + Block::new( + <::Header as HeaderT>::new( + Zero::zero(), + extrinsics_root, + state_root, + Default::default(), + Default::default(), + ), + Default::default(), + ) + }; let header_hex = format!("0x{:?}", HexDisplay::from(&block.header().encode()));