diff --git a/Cargo.lock b/Cargo.lock index 61928c7..d760e80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1684,6 +1684,7 @@ dependencies = [ "parity-scale-codec", "polkadot-overseer", "sc-client-api", + "serde", "sp-api", "sp-blockchain", "sp-state-machine", diff --git a/client/orchestrator-chain-interface/Cargo.toml b/client/orchestrator-chain-interface/Cargo.toml index b0293b0..ceb5f9c 100644 --- a/client/orchestrator-chain-interface/Cargo.toml +++ b/client/orchestrator-chain-interface/Cargo.toml @@ -13,6 +13,7 @@ async-trait = { workspace = true } futures = { workspace = true } jsonrpsee = { workspace = true } parity-scale-codec = { workspace = true } +serde = { workspace = true } thiserror = { workspace = true } # Dancekit diff --git a/client/orchestrator-chain-interface/src/lib.rs b/client/orchestrator-chain-interface/src/lib.rs index 7b40211..11db791 100644 --- a/client/orchestrator-chain-interface/src/lib.rs +++ b/client/orchestrator-chain-interface/src/lib.rs @@ -25,8 +25,15 @@ //! prove_read: generates a storage proof of a given set of keys at a given Orchestrator parent use { - core::pin::Pin, dp_core::ParaId, futures::Stream, polkadot_overseer::Handle, - sc_client_api::StorageProof, sp_api::ApiError, sp_state_machine::StorageValue, std::sync::Arc, + core::pin::Pin, + dp_core::ParaId, + futures::Stream, + parity_scale_codec::{Decode, Encode}, + polkadot_overseer::Handle, + sc_client_api::StorageProof, + sp_api::ApiError, + sp_state_machine::StorageValue, + std::sync::Arc, }; pub use { cumulus_primitives_core::relay_chain::Slot, @@ -91,6 +98,23 @@ impl From> for OrchestratorChainError { // TODO: proper errors pub type OrchestratorChainResult = Result; +pub type DataPreserverProfileId = u64; + +// Copy of Tanssi's pallet_data_preservers_runtime_api::Assignment +#[derive( + Debug, Copy, Clone, PartialEq, Eq, Encode, Decode, serde::Serialize, serde::Deserialize, +)] +pub enum DataPreserverAssignment { + /// Profile is not currently assigned. + NotAssigned, + /// Profile is activly assigned to this ParaId. + Active(ParaId), + /// Profile is assigned to this ParaId but is inactive for some reason. + /// It may be causes by conditions defined in the assignement configuration, + /// such as lacking payment. + Inactive(ParaId), +} + /// Trait that provides all necessary methods for interaction between collator and orchestrator chain. #[async_trait::async_trait] pub trait OrchestratorChainInterface: Send + Sync { @@ -147,6 +171,12 @@ pub trait OrchestratorChainInterface: Send + Sync { async fn best_block_hash(&self) -> OrchestratorChainResult; async fn finalized_block_hash(&self) -> OrchestratorChainResult; + + async fn data_preserver_active_assignment( + &self, + orchestrator_parent: PHash, + profile_id: DataPreserverProfileId, + ) -> OrchestratorChainResult>; } #[async_trait::async_trait] @@ -227,4 +257,14 @@ where async fn finalized_block_hash(&self) -> OrchestratorChainResult { (**self).finalized_block_hash().await } + + async fn data_preserver_active_assignment( + &self, + orchestrator_parent: PHash, + profile_id: DataPreserverProfileId, + ) -> OrchestratorChainResult> { + (**self) + .data_preserver_active_assignment(orchestrator_parent, profile_id) + .await + } } diff --git a/container-chain-primitives/authorities-noting-inherent/src/tests.rs b/container-chain-primitives/authorities-noting-inherent/src/tests.rs index eafcc19..133d595 100644 --- a/container-chain-primitives/authorities-noting-inherent/src/tests.rs +++ b/container-chain-primitives/authorities-noting-inherent/src/tests.rs @@ -27,7 +27,8 @@ use { }, cumulus_relay_chain_interface::{PHash, PHeader, RelayChainInterface, RelayChainResult}, dc_orchestrator_chain_interface::{ - BlockNumber, ContainerChainGenesisData, OrchestratorChainInterface, OrchestratorChainResult, + BlockNumber, ContainerChainGenesisData, DataPreserverAssignment, DataPreserverProfileId, + OrchestratorChainInterface, OrchestratorChainResult, }, dp_core::{well_known_keys, Header as OrchestratorHeader}, futures::Stream, @@ -163,6 +164,14 @@ impl OrchestratorChainInterface for DummyOrchestratorChainInterface { async fn finalized_block_hash(&self) -> OrchestratorChainResult { unimplemented!("Not needed for test") } + + async fn data_preserver_active_assignment( + &self, + _orchestrator_parent: PHash, + _profile_id: DataPreserverProfileId, + ) -> OrchestratorChainResult> { + unimplemented!("Not needed for test") + } } #[async_trait]