Skip to content

Commit

Permalink
More changes for Tanssi Data Preservers container chain spawning on a…
Browse files Browse the repository at this point in the history
…ssignment (#26)

* add new interface fn + move rpc interface to tanssi

* remove unused fn in Tanssi

* fmt

* remove generic
  • Loading branch information
nanocryk committed Jul 16, 2024
1 parent 73dc2e3 commit 55566e6
Show file tree
Hide file tree
Showing 11 changed files with 584 additions and 1,050 deletions.
278 changes: 33 additions & 245 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
members = [
"client/orchestrator-chain-interface",
"client/orchestrator-chain-rpc-interface",
"container-chain-pallets/*",
"container-chain-primitives/*",
"pallets/*",
Expand All @@ -21,10 +20,10 @@ ccp-xcm = { path = "container-chain-primitives/xcm", default-features = false }
pallet-cc-authorities-noting = { path = "container-chain-pallets/authorities-noting", default-features = false }

dc-orchestrator-chain-interface = { path = "client/orchestrator-chain-interface" }
dc-orchestrator-chain-rpc-interface = { path = "client/orchestrator-chain-rpc-interface" }
dp-chain-state-snapshot = { path = "primitives/chain-state-snapshot", default-features = false }
dp-collator-assignment = { path = "primitives/collator-assignment", default-features = false }
dp-consensus = { path = "primitives/consensus", default-features = false }
dp-container-chain-genesis-data = { path = "primitives/container-chain-genesis-data", default-features = false }
dp-core = { path = "primitives/core", default-features = false }
dp-impl-tanssi-pallets-config = { path = "primitives/core", default-features = false }
test-relay-sproof-builder = { path = "test-sproof-builder", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions client/orchestrator-chain-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ parity-scale-codec = { workspace = true }
thiserror = { workspace = true }

# Dancekit
dp-container-chain-genesis-data = { workspace = true }
dp-core = { workspace = true }

# Substrate
Expand Down
49 changes: 31 additions & 18 deletions client/orchestrator-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use {
};
pub use {
cumulus_primitives_core::relay_chain::Slot,
dp_core::{Hash as PHash, Header as PHeader},
dp_container_chain_genesis_data::ContainerChainGenesisData,
dp_core::{BlockNumber, Hash as PHash, Header as PHeader},
};

#[derive(thiserror::Error, Debug)]
Expand All @@ -56,6 +57,9 @@ pub enum OrchestratorChainError {
#[error("Scale codec deserialization error: {0}")]
DeserializationError(#[from] parity_scale_codec::Error),

#[error("API error: {0}")]
ApiError(#[from] sp_api::ApiError),

#[error("Unspecified error occured: {0}")]
GenericError(String),
}
Expand Down Expand Up @@ -90,8 +94,6 @@ pub type OrchestratorChainResult<T> = Result<T, OrchestratorChainError>;
/// Trait that provides all necessary methods for interaction between collator and orchestrator chain.
#[async_trait::async_trait]
pub trait OrchestratorChainInterface: Send + Sync {
type AuthorityId;

/// Fetch a storage item by key.
async fn get_storage_by_key(
&self,
Expand Down Expand Up @@ -124,29 +126,30 @@ pub trait OrchestratorChainInterface: Send + Sync {
&self,
) -> OrchestratorChainResult<Pin<Box<dyn Stream<Item = PHeader> + Send>>>;

/// Return the set of authorities assigned to the paraId where
/// the first eligible key from the keystore is collating
async fn authorities(
async fn genesis_data(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<Vec<Self::AuthorityId>>>;
) -> OrchestratorChainResult<Option<ContainerChainGenesisData>>;

/// Returns the minimum slot frequency for this para id.
async fn min_slot_freq(
async fn boot_nodes(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<Slot>>;
) -> OrchestratorChainResult<Vec<Vec<u8>>>;

async fn latest_block_number(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<BlockNumber>>;
}

#[async_trait::async_trait]
impl<T> OrchestratorChainInterface for Arc<T>
where
T: OrchestratorChainInterface + ?Sized,
{
type AuthorityId = T::AuthorityId;

fn overseer_handle(&self) -> OrchestratorChainResult<Handle> {
(**self).overseer_handle()
}
Expand Down Expand Up @@ -187,19 +190,29 @@ where
(**self).finality_notification_stream().await
}

async fn authorities(
async fn genesis_data(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<Vec<Self::AuthorityId>>> {
(**self).authorities(orchestrator_parent, para_id).await
) -> OrchestratorChainResult<Option<ContainerChainGenesisData>> {
(**self).genesis_data(orchestrator_parent, para_id).await
}

async fn min_slot_freq(
async fn boot_nodes(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<Slot>> {
(**self).min_slot_freq(orchestrator_parent, para_id).await
) -> OrchestratorChainResult<Vec<Vec<u8>>> {
(**self).boot_nodes(orchestrator_parent, para_id).await
}

async fn latest_block_number(
&self,
orchestrator_parent: PHash,
para_id: ParaId,
) -> OrchestratorChainResult<Option<BlockNumber>> {
(**self)
.latest_block_number(orchestrator_parent, para_id)
.await
}
}
38 changes: 0 additions & 38 deletions client/orchestrator-chain-rpc-interface/Cargo.toml

This file was deleted.

Loading

0 comments on commit 55566e6

Please sign in to comment.