mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 11:17:56 +00:00
Unify the operating mode for bridge pallets (#1483)
Unify the operating mode for bridge pallets - define the OperationMode trait and BasicOperatingMode enum - use the OperationMode trait in all the bridge pallets - use BasicOperatingMode instead of IsHalted for the Grandpa pallet - use BasicOperatingMode as part of MessagesOperatingMode Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
ff342fafa9
commit
f8ff3c9142
@@ -19,6 +19,7 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use bp_runtime::BasicOperatingMode;
|
||||
use codec::{Codec, Decode, Encode, EncodeLike};
|
||||
use core::{clone::Clone, cmp::Eq, default::Default, fmt::Debug};
|
||||
use scale_info::TypeInfo;
|
||||
@@ -66,8 +67,8 @@ pub struct InitializationData<H: HeaderT> {
|
||||
pub authority_list: AuthorityList,
|
||||
/// The ID of the initial authority set.
|
||||
pub set_id: SetId,
|
||||
/// Should the pallet block transaction immediately after initialization.
|
||||
pub is_halted: bool,
|
||||
/// Pallet operating mode.
|
||||
pub operating_mode: BasicOperatingMode,
|
||||
}
|
||||
|
||||
/// base trait for verifying transaction inclusion proofs.
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
//! Storage keys of bridge GRANDPA pallet.
|
||||
|
||||
/// Name of the `IsHalted` storage value.
|
||||
pub const IS_HALTED_VALUE_NAME: &str = "IsHalted";
|
||||
pub const PALLET_OPERATING_MODE_VALUE_NAME: &str = "PalletOperatingMode";
|
||||
/// Name of the `BestFinalized` storage value.
|
||||
pub const BEST_FINALIZED_VALUE_NAME: &str = "BestFinalized";
|
||||
|
||||
use sp_core::storage::StorageKey;
|
||||
|
||||
/// Storage key of the `IsHalted` flag in the runtime storage.
|
||||
pub fn is_halted_key(pallet_prefix: &str) -> StorageKey {
|
||||
/// Storage key of the `PalletOperatingMode` variable in the runtime storage.
|
||||
pub fn pallet_operating_mode_key(pallet_prefix: &str) -> StorageKey {
|
||||
StorageKey(
|
||||
bp_runtime::storage_value_final_key(
|
||||
pallet_prefix.as_bytes(),
|
||||
IS_HALTED_VALUE_NAME.as_bytes(),
|
||||
PALLET_OPERATING_MODE_VALUE_NAME.as_bytes(),
|
||||
)
|
||||
.to_vec(),
|
||||
)
|
||||
@@ -51,13 +51,13 @@ mod tests {
|
||||
use hex_literal::hex;
|
||||
|
||||
#[test]
|
||||
fn is_halted_key_computed_properly() {
|
||||
fn pallet_operating_mode_key_computed_properly() {
|
||||
// If this test fails, then something has been changed in module storage that is breaking
|
||||
// compatibility with previous pallet.
|
||||
let storage_key = is_halted_key("BridgeGrandpa").0;
|
||||
let storage_key = pallet_operating_mode_key("BridgeGrandpa").0;
|
||||
assert_eq!(
|
||||
storage_key,
|
||||
hex!("0b06f475eddb98cf933a12262e0388de9611a984bbd04e2fd39f97bbc006115f").to_vec(),
|
||||
hex!("0b06f475eddb98cf933a12262e0388de0f4cf0917788d791142ff6c1f216e7b3").to_vec(),
|
||||
"Unexpected storage key: {}",
|
||||
hex::encode(&storage_key),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user