Skip to content

Commit

Permalink
[POC] Spawn embeded Container chain node on data preservers assignment (
Browse files Browse the repository at this point in the history
#666)

* wip

* setup new moonwall profile (not working yet)

* get non-modified test suite working

* wip spawner

* fix runtime api call

* hack to ignore absence of metrics in rpc mode

* watcher properly reacts to assignment

* working RPC endpoint spawning with test

* rename interface fn

* update lock + data preservers flag in spawner

* get rid of script

* cleanup

* cleanup

* Improve docs

Co-authored-by: tmpolaczyk <[email protected]>

* add suite to CI

* cleanup and comments

* zepter

* api augment

* add back log

* spawner mock

* test + PR feedback

* lints

* improve test

---------

Co-authored-by: tmpolaczyk <[email protected]>
  • Loading branch information
nanocryk and tmpolaczyk authored Sep 6, 2024
1 parent 1e69d2a commit a896b54
Show file tree
Hide file tree
Showing 24 changed files with 1,213 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ jobs:
strategy:
fail-fast: false
matrix:
test_name: [zombie_tanssi, zombie_tanssi_parathreads, zombie_tanssi_rotation, zombie_tanssi_warp_sync, zombie_tanssi_relay]
test_name: [zombie_tanssi, zombie_tanssi_parathreads, zombie_tanssi_rotation, zombie_tanssi_warp_sync, zombie_tanssi_relay, zombie_data_preservers]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
44 changes: 31 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pallet-collator-assignment = { path = "pallets/collator-assignment", default-fea
pallet-collator-assignment-runtime-api = { path = "pallets/collator-assignment/runtime-api", default-features = false }
pallet-configuration = { path = "pallets/configuration", default-features = false }
pallet-data-preservers = { path = "pallets/data-preservers", default-features = false }
pallet-data-preservers-runtime-api = { path = "pallets/data-preservers/runtime-api", default-features = false }
pallet-inflation-rewards = { path = "pallets/inflation-rewards", default-features = false }
pallet-initializer = { path = "pallets/initializer", default-features = false }
pallet-invulnerables = { path = "pallets/invulnerables", default-features = false }
Expand Down
11 changes: 6 additions & 5 deletions client/consensus/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>.

use polkadot_node_subsystem::messages::{RuntimeApiMessage, RuntimeApiRequest};
use {
crate::{
collators::lookahead::Params as LookAheadParams, OrchestratorAuraWorkerAuxData,
Expand All @@ -29,14 +28,14 @@ use {
CommittedCandidateReceipt, OverseerHandle, RelayChainInterface, RelayChainResult,
StorageValue,
},
futures::channel::oneshot,
futures::prelude::*,
futures::{channel::oneshot, prelude::*},
nimbus_primitives::{
CompatibleDigestItem, NimbusId, NimbusPair, NIMBUS_ENGINE_ID, NIMBUS_KEY_ID,
},
pallet_xcm_core_buyer_runtime_api::BuyingError,
parity_scale_codec::Encode,
polkadot_core_primitives::{Header as PHeader, InboundDownwardMessage, InboundHrmpMessage},
polkadot_node_subsystem::messages::{RuntimeApiMessage, RuntimeApiRequest},
polkadot_overseer::dummy::dummy_overseer_builder,
polkadot_parachain_primitives::primitives::HeadData,
polkadot_primitives::{
Expand Down Expand Up @@ -513,8 +512,10 @@ impl<B: BlockT> sc_consensus::Verifier<B> for SealExtractorVerfier {
}
}

use cumulus_primitives_core::relay_chain::ValidationCodeHash;
use polkadot_node_subsystem::{overseer, OverseerSignal};
use {
cumulus_primitives_core::relay_chain::ValidationCodeHash,
polkadot_node_subsystem::{overseer, OverseerSignal},
};

pub struct DummyCodeHashProvider;
impl ValidationCodeHashProvider<PHash> for DummyCodeHashProvider {
Expand Down
44 changes: 35 additions & 9 deletions client/orchestrator-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ use {
async_trait::async_trait,
core::pin::Pin,
dc_orchestrator_chain_interface::{
BlockNumber, ContainerChainGenesisData, OrchestratorChainError, OrchestratorChainInterface,
OrchestratorChainResult, PHash, PHeader,
BlockNumber, ContainerChainGenesisData, DataPreserverAssignment, DataPreserverProfileId,
OrchestratorChainError, OrchestratorChainInterface, OrchestratorChainResult, PHash,
PHeader,
},
dp_core::ParaId,
futures::{Stream, StreamExt},
Expand Down Expand Up @@ -114,7 +115,7 @@ impl OrchestratorChainRpcClient {
};
let res = self
.request_tracing::<sp_core::Bytes, _>("state_call", params, |err| {
tracing::trace!(
tracing::debug!(
target: LOG_TARGET,
%method_name,
%hash,
Expand Down Expand Up @@ -289,26 +290,38 @@ impl OrchestratorChainInterface for OrchestratorChainRpcClient {
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<ContainerChainGenesisData>> {
self.call_remote_runtime_function("genesis_data", orchestrator_parent, Some(para_id))
.await
self.call_remote_runtime_function(
"RegistrarApi_genesis_data",
orchestrator_parent,
Some(para_id),
)
.await
}

async fn boot_nodes(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Vec<Vec<u8>>> {
self.call_remote_runtime_function("boot_nodes", orchestrator_parent, Some(para_id))
.await
self.call_remote_runtime_function(
"RegistrarApi_boot_nodes",
orchestrator_parent,
Some(para_id),
)
.await
}

async fn latest_block_number(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<BlockNumber>> {
self.call_remote_runtime_function("latest_block_number", orchestrator_parent, Some(para_id))
.await
self.call_remote_runtime_function(
"AuthorNotingApi_latest_block_number",
orchestrator_parent,
Some(para_id),
)
.await
}

async fn best_block_hash(&self) -> OrchestratorChainResult<PHash> {
Expand All @@ -318,4 +331,17 @@ impl OrchestratorChainInterface for OrchestratorChainRpcClient {
async fn finalized_block_hash(&self) -> OrchestratorChainResult<PHash> {
self.request("chain_getFinalizedHead", rpc_params![]).await
}

async fn data_preserver_active_assignment(
&self,
orchestrator_parent: PHash,
profile_id: DataPreserverProfileId,
) -> OrchestratorChainResult<DataPreserverAssignment<ParaId>> {
self.call_remote_runtime_function(
"DataPreserversApi_get_active_assignment",
orchestrator_parent,
Some(profile_id),
)
.await
}
}
9 changes: 8 additions & 1 deletion client/service-container-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ tokio = { workspace = true }
tokio-util = { workspace = true }

# Local
ccp-authorities-noting-inherent = { workspace = true }
ccp-authorities-noting-inherent = { workspace = true, features = [ "std" ] }
dancebox-runtime = { workspace = true, features = [ "std" ] }
manual-xcm-rpc = { workspace = true }
node-common = { workspace = true }
pallet-author-noting-runtime-api = { workspace = true, features = [ "std" ] }
pallet-data-preservers = { workspace = true, features = [ "std" ] }
services-payment-rpc = { workspace = true }
stream-payment-rpc = { workspace = true }
tc-consensus = { workspace = true }
Expand Down Expand Up @@ -81,6 +82,10 @@ cumulus-relay-chain-interface = { workspace = true }
nimbus-consensus = { workspace = true }
nimbus-primitives = { workspace = true }

[dev-dependencies]
polkadot-overseer = { workspace = true }
tokio-stream = { workspace = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true }

Expand All @@ -90,13 +95,15 @@ runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"dancebox-runtime/runtime-benchmarks",
"nimbus-primitives/runtime-benchmarks",
"pallet-data-preservers/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"dancebox-runtime/try-runtime",
"nimbus-primitives/try-runtime",
"pallet-data-preservers/try-runtime",
"sp-runtime/try-runtime",
]

Expand Down
Loading

0 comments on commit a896b54

Please sign in to comment.