mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
ensure that the bridge GRANDPA pallet is initialized in the finality relay (#1423)
This commit is contained in:
committed by
Bastian Köcher
parent
4001cfb758
commit
78a43c561a
@@ -54,6 +54,9 @@ pub enum Error {
|
|||||||
/// The bridge pallet is halted and all transactions will be rejected.
|
/// The bridge pallet is halted and all transactions will be rejected.
|
||||||
#[error("Bridge pallet is halted.")]
|
#[error("Bridge pallet is halted.")]
|
||||||
BridgePalletIsHalted,
|
BridgePalletIsHalted,
|
||||||
|
/// The bridge pallet is not yet initialized and all transactions will be rejected.
|
||||||
|
#[error("Bridge pallet is not initialized.")]
|
||||||
|
BridgePalletIsNotInitialized,
|
||||||
/// An error has happened when we have tried to parse storage proof.
|
/// An error has happened when we have tried to parse storage proof.
|
||||||
#[error("Error when parsing storage proof: {0:?}.")]
|
#[error("Error when parsing storage proof: {0:?}.")]
|
||||||
StorageProofError(bp_runtime::StorageProofError),
|
StorageProofError(bp_runtime::StorageProofError),
|
||||||
|
|||||||
@@ -110,7 +110,11 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `Ok(true)` if bridge has already been initialized.
|
/// Returns `Ok(true)` if bridge has already been initialized.
|
||||||
async fn is_initialized<E: Engine<SourceChain>, SourceChain: Chain, TargetChain: Chain>(
|
pub(crate) async fn is_initialized<
|
||||||
|
E: Engine<SourceChain>,
|
||||||
|
SourceChain: Chain,
|
||||||
|
TargetChain: Chain,
|
||||||
|
>(
|
||||||
target_client: &Client<TargetChain>,
|
target_client: &Client<TargetChain>,
|
||||||
) -> Result<bool, Error<HashOf<SourceChain>, BlockNumberOf<SourceChain>>> {
|
) -> Result<bool, Error<HashOf<SourceChain>, BlockNumberOf<SourceChain>>> {
|
||||||
Ok(target_client
|
Ok(target_client
|
||||||
|
|||||||
@@ -53,10 +53,20 @@ impl<P: SubstrateFinalitySyncPipeline> SubstrateFinalityTarget<P> {
|
|||||||
pub async fn ensure_pallet_active(&self) -> Result<(), Error> {
|
pub async fn ensure_pallet_active(&self) -> Result<(), Error> {
|
||||||
let is_halted = self.client.storage_value(P::FinalityEngine::is_halted_key(), None).await?;
|
let is_halted = self.client.storage_value(P::FinalityEngine::is_halted_key(), None).await?;
|
||||||
if is_halted.unwrap_or(false) {
|
if is_halted.unwrap_or(false) {
|
||||||
Err(Error::BridgePalletIsHalted)
|
return Err(Error::BridgePalletIsHalted)
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let is_initialized =
|
||||||
|
super::initialize::is_initialized::<P::FinalityEngine, P::SourceChain, P::TargetChain>(
|
||||||
|
&self.client,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| Error::Custom(e.to_string()))?;
|
||||||
|
if !is_initialized {
|
||||||
|
return Err(Error::BridgePalletIsNotInitialized)
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user