-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Container chain spawner logic in separate crate (#637)
* refactor into separate crate * cleanup * POC: start embeded CC node in rpc provider * forward features * use same chainspec Extensions type * move orchestrator_para_id in CollationParams
- Loading branch information
Showing
19 changed files
with
1,403 additions
and
900 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
[package] | ||
name = "tc-service-container-chain" | ||
authors = { workspace = true } | ||
build = "build.rs" | ||
edition = "2021" | ||
license = "GPL-3.0-only" | ||
version = "0.1.0" | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
async-trait = { workspace = true } | ||
clap = { workspace = true, features = [ "derive" ] } | ||
flume = { workspace = true } | ||
fs2 = { workspace = true } | ||
futures = { workspace = true } | ||
jsonrpsee = { workspace = true } | ||
log = { workspace = true } | ||
serde = { workspace = true } | ||
tokio = { workspace = true } | ||
tokio-util = { workspace = true } | ||
|
||
# Local | ||
ccp-authorities-noting-inherent = { workspace = true } | ||
dancebox-runtime = { workspace = true, features = [ "std" ] } | ||
manual-xcm-rpc = { workspace = true } | ||
node-common = { workspace = true } | ||
pallet-author-noting-runtime-api = { workspace = true, features = [ "std" ] } | ||
services-payment-rpc = { workspace = true } | ||
stream-payment-rpc = { workspace = true } | ||
tc-consensus = { workspace = true } | ||
|
||
# Dancekit | ||
dc-orchestrator-chain-interface = { workspace = true } | ||
dp-container-chain-genesis-data = { workspace = true, features = [ "json", "std" ] } | ||
dp-slot-duration-runtime-api = { workspace = true } | ||
|
||
# Substrate | ||
sc-basic-authorship = { workspace = true } | ||
sc-chain-spec = { workspace = true } | ||
sc-cli = { workspace = true } | ||
sc-client-api = { workspace = true } | ||
sc-consensus = { workspace = true } | ||
sc-consensus-manual-seal = { workspace = true } | ||
sc-executor = { workspace = true } | ||
sc-network = { workspace = true } | ||
sc-network-sync = { workspace = true } | ||
sc-rpc = { workspace = true } | ||
sc-service = { workspace = true } | ||
sc-telemetry = { workspace = true } | ||
sc-tracing = { workspace = true } | ||
sc-transaction-pool = { workspace = true } | ||
sc-transaction-pool-api = { workspace = true } | ||
sp-blockchain = { workspace = true } | ||
sp-consensus = { workspace = true } | ||
substrate-frame-rpc-system = { workspace = true } | ||
substrate-prometheus-endpoint = { workspace = true } | ||
|
||
sp-api = { workspace = true, features = [ "std" ] } | ||
sp-block-builder = { workspace = true, features = [ "std" ] } | ||
sp-consensus-aura = { workspace = true, features = [ "std" ] } | ||
sp-core = { workspace = true, features = [ "std" ] } | ||
sp-keystore = { workspace = true, features = [ "std" ] } | ||
sp-runtime = { workspace = true, features = [ "std" ] } | ||
sp-timestamp = { workspace = true, features = [ "std" ] } | ||
|
||
# Polkadot | ||
polkadot-primitives = { workspace = true } | ||
|
||
# Cumulus | ||
cumulus-client-collator = { workspace = true } | ||
cumulus-client-consensus-aura = { workspace = true } | ||
cumulus-client-consensus-common = { workspace = true } | ||
cumulus-client-consensus-proposer = { workspace = true } | ||
cumulus-client-service = { workspace = true } | ||
cumulus-primitives-core = { workspace = true } | ||
cumulus-relay-chain-interface = { workspace = true } | ||
|
||
# Nimbus | ||
nimbus-consensus = { workspace = true } | ||
nimbus-primitives = { workspace = true } | ||
|
||
[build-dependencies] | ||
substrate-build-script-utils = { workspace = true } | ||
|
||
[features] | ||
default = [] | ||
runtime-benchmarks = [ | ||
"cumulus-primitives-core/runtime-benchmarks", | ||
"dancebox-runtime/runtime-benchmarks", | ||
"nimbus-primitives/runtime-benchmarks", | ||
"polkadot-primitives/runtime-benchmarks", | ||
"sc-service/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
] | ||
try-runtime = [ | ||
"dancebox-runtime/try-runtime", | ||
"nimbus-primitives/try-runtime", | ||
"sp-runtime/try-runtime", | ||
] | ||
|
||
fast-runtime = [ "dancebox-runtime/fast-runtime" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) Moondance Labs Ltd. | ||
// This file is part of Tanssi. | ||
|
||
// Tanssi is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Tanssi is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Tanssi. If not, see <http://www.gnu.org/licenses/> | ||
|
||
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; | ||
|
||
fn main() { | ||
generate_cargo_keys(); | ||
|
||
rerun_if_git_head_changed(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (C) Moondance Labs Ltd. | ||
// This file is part of Tanssi. | ||
|
||
// Tanssi is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Tanssi is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Tanssi. If not, see <http://www.gnu.org/licenses/> | ||
|
||
use { | ||
sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}, | ||
serde::{Deserialize, Serialize}, | ||
std::collections::BTreeMap, | ||
}; | ||
|
||
/// Specialized `ChainSpec` for container chains that only allows raw genesis format. | ||
pub type RawChainSpec = sc_service::GenericChainSpec<RawGenesisConfig, Extensions>; | ||
|
||
/// Helper type that implements the traits needed to be used as a "GenesisConfig", | ||
/// but whose implementation panics because we only expect it to be used with raw ChainSpecs, | ||
/// so it will never be serialized or deserialized. | ||
/// This is because container chains must use raw chain spec files where the "genesis" | ||
/// field only has one field: "raw". | ||
pub struct RawGenesisConfig { | ||
pub storage_raw: BTreeMap<Vec<u8>, Vec<u8>>, | ||
} | ||
|
||
impl Serialize for RawGenesisConfig { | ||
fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
panic!("RawGenesisConfigDummy should never be serialized") | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for RawGenesisConfig { | ||
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
panic!("Attempted to read a non-raw ContainerChain ChainSpec.\nHelp: add `--raw` flag to `build-spec` command to generate a raw chain spec") | ||
} | ||
} | ||
|
||
impl sp_runtime::BuildStorage for RawGenesisConfig { | ||
fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> { | ||
storage | ||
.top | ||
.extend(self.storage_raw.iter().map(|(k, v)| (k.clone(), v.clone()))); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
/// The extensions for the [`ChainSpec`]. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct Extensions { | ||
/// The relay chain of the Parachain. | ||
pub relay_chain: String, | ||
/// The id of the Parachain. | ||
pub para_id: u32, | ||
} | ||
|
||
impl Extensions { | ||
/// Try to get the extension from the given `ChainSpec`. | ||
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> { | ||
sc_chain_spec::get_extension(chain_spec.extensions()) | ||
} | ||
} |
Oops, something went wrong.