mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-14 15:09:23 +00:00
Compare commits
2 Commits
1b587548d1
...
1ea3ee05c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ea3ee05c6 | ||
|
|
43cdbb1bff |
@@ -18,5 +18,5 @@ pub enum Call {
|
|||||||
pub enum Event {
|
pub enum Event {
|
||||||
Batch { network: ExternalNetworkId, id: u32, block: BlockHash, instructions_hash: [u8; 32] },
|
Batch { network: ExternalNetworkId, id: u32, block: BlockHash, instructions_hash: [u8; 32] },
|
||||||
InstructionFailure { network: ExternalNetworkId, id: u32, index: u32 },
|
InstructionFailure { network: ExternalNetworkId, id: u32, index: u32 },
|
||||||
Halt { network: NetworkId },
|
Halt { network: ExternalNetworkId },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pub mod pallet {
|
|||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
Batch { network: ExternalNetworkId, id: u32, block: BlockHash, instructions_hash: [u8; 32] },
|
Batch { network: ExternalNetworkId, id: u32, block: BlockHash, instructions_hash: [u8; 32] },
|
||||||
InstructionFailure { network: ExternalNetworkId, id: u32, index: u32 },
|
InstructionFailure { network: ExternalNetworkId, id: u32, index: u32 },
|
||||||
Halt { network: NetworkId },
|
Halt { network: ExternalNetworkId },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -86,7 +86,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
// Halted networks.
|
// Halted networks.
|
||||||
#[pallet::storage]
|
#[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
|
// The latest block a network has acknowledged as finalized
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
@@ -231,8 +231,7 @@ pub mod pallet {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn halt(network: NetworkId) -> Result<(), DispatchError> {
|
pub fn halt(network: ExternalNetworkId) -> Result<(), DispatchError> {
|
||||||
// TODO: is it possible to halt serai network?
|
|
||||||
Halted::<T>::set(network, Some(()));
|
Halted::<T>::set(network, Some(()));
|
||||||
Self::deposit_event(Event::Halt { network });
|
Self::deposit_event(Event::Halt { network });
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -325,7 +324,7 @@ pub mod pallet {
|
|||||||
Err(InvalidTransaction::BadProof)?;
|
Err(InvalidTransaction::BadProof)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if Halted::<T>::contains_key(NetworkId::from(network)) {
|
if Halted::<T>::contains_key(network) {
|
||||||
Err(InvalidTransaction::Custom(1))?;
|
Err(InvalidTransaction::Custom(1))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ impl Decode for NetworkId {
|
|||||||
let kind = input.read_byte()?;
|
let kind = input.read_byte()?;
|
||||||
match kind {
|
match kind {
|
||||||
0 => Ok(Self::Serai),
|
0 => Ok(Self::Serai),
|
||||||
_ => Ok(ExternalNetworkId::decode(input)?.into()),
|
_ => Ok(ExternalNetworkId::decode(&mut [kind].as_slice())?.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ impl Decode for Coin {
|
|||||||
let kind = input.read_byte()?;
|
let kind = input.read_byte()?;
|
||||||
match kind {
|
match kind {
|
||||||
0 => Ok(Self::Serai),
|
0 => Ok(Self::Serai),
|
||||||
_ => Ok(ExternalCoin::decode(input)?.into()),
|
_ => Ok(ExternalCoin::decode(&mut [kind].as_slice())?.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
use scale::{Encode, Decode, MaxEncodedLen};
|
use scale::{Encode, Decode, MaxEncodedLen};
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
|
|
||||||
use serai_primitives::NetworkId;
|
use serai_primitives::ExternalNetworkId;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
||||||
#[cfg_attr(feature = "std", derive(zeroize::Zeroize))]
|
#[cfg_attr(feature = "std", derive(zeroize::Zeroize))]
|
||||||
@@ -13,5 +13,5 @@ use serai_primitives::NetworkId;
|
|||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum SignalId {
|
pub enum SignalId {
|
||||||
Retirement([u8; 32]),
|
Retirement([u8; 32]),
|
||||||
Halt(NetworkId),
|
Halt(ExternalNetworkId),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use serai_client::{
|
|||||||
},
|
},
|
||||||
primitives::{
|
primitives::{
|
||||||
crypto::RuntimePublic, Amount, BlockHash, ExternalBalance, ExternalNetworkId, PublicKey,
|
crypto::RuntimePublic, Amount, BlockHash, ExternalBalance, ExternalNetworkId, PublicKey,
|
||||||
SeraiAddress,
|
SeraiAddress, EXTERNAL_NETWORKS,
|
||||||
},
|
},
|
||||||
validator_sets::primitives::Session,
|
validator_sets::primitives::Session,
|
||||||
};
|
};
|
||||||
@@ -190,9 +190,7 @@ pub(crate) async fn substrate_block(
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn batch_test() {
|
fn batch_test() {
|
||||||
for network in
|
for network in EXTERNAL_NETWORKS {
|
||||||
[ExternalNetworkId::Bitcoin, ExternalNetworkId::Ethereum, ExternalNetworkId::Monero]
|
|
||||||
{
|
|
||||||
let (coordinators, test) = new_test(network);
|
let (coordinators, test) = new_test(network);
|
||||||
|
|
||||||
test.run(|ops| async move {
|
test.run(|ops| async move {
|
||||||
|
|||||||
Reference in New Issue
Block a user