Skip to content

Commit

Permalink
Make halting for external networks
Browse files Browse the repository at this point in the history
  • Loading branch information
akildemir committed Oct 4, 2024
1 parent 1b58754 commit 43cdbb1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion substrate/abi/src/in_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ pub enum Call {
pub enum Event {
Batch { network: ExternalNetworkId, id: u32, block: BlockHash, instructions_hash: [u8; 32] },
InstructionFailure { network: ExternalNetworkId, id: u32, index: u32 },
Halt { network: NetworkId },
Halt { network: ExternalNetworkId },
}
9 changes: 4 additions & 5 deletions substrate/in-instructions/pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub mod pallet {
pub enum Event<T: Config> {
Batch { network: ExternalNetworkId, id: u32, block: BlockHash, instructions_hash: [u8; 32] },
InstructionFailure { network: ExternalNetworkId, id: u32, index: u32 },
Halt { network: NetworkId },
Halt { network: ExternalNetworkId },
}

#[pallet::error]
Expand All @@ -86,7 +86,7 @@ pub mod pallet {

// Halted networks.
#[pallet::storage]
pub(crate) type Halted<T: Config> = StorageMap<_, Identity, NetworkId, (), OptionQuery>;
pub(crate) type Halted<T: Config> = StorageMap<_, Identity, ExternalNetworkId, (), OptionQuery>;

// The latest block a network has acknowledged as finalized
#[pallet::storage]
Expand Down Expand Up @@ -231,8 +231,7 @@ pub mod pallet {
Ok(())
}

pub fn halt(network: NetworkId) -> Result<(), DispatchError> {
// TODO: is it possible to halt serai network?
pub fn halt(network: ExternalNetworkId) -> Result<(), DispatchError> {
Halted::<T>::set(network, Some(()));
Self::deposit_event(Event::Halt { network });
Ok(())
Expand Down Expand Up @@ -325,7 +324,7 @@ pub mod pallet {
Err(InvalidTransaction::BadProof)?;
}

if Halted::<T>::contains_key(NetworkId::from(network)) {
if Halted::<T>::contains_key(network) {
Err(InvalidTransaction::Custom(1))?;
}

Expand Down
4 changes: 2 additions & 2 deletions substrate/signals/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use scale::{Encode, Decode, MaxEncodedLen};
use scale_info::TypeInfo;

use serai_primitives::NetworkId;
use serai_primitives::ExternalNetworkId;

#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(zeroize::Zeroize))]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SignalId {
Retirement([u8; 32]),
Halt(NetworkId),
Halt(ExternalNetworkId),
}

0 comments on commit 43cdbb1

Please sign in to comment.