mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-08 11:59:55 +00:00
b296be8515
* Add SignalsConfig to chain_spec * Correct multiexp feature flagging for rand_core std * Remove bincode for borsh Replaces a non-canonical encoding with a canonical encoding which additionally should be faster. Also fixes an issue where we used bincode in transcripts where it cannot be trusted. This ended up fixing a myriad of other bugs observed, unfortunately. Accordingly, it either has to be merged or the bug fixes from it must be ported to a new PR. * Make serde optional, minimize usage * Make borsh an optional dependency of substrate/ crates * Remove unused dependencies * Use [u8; 64] where possible in the processor messages * Correct borsh feature flagging
55 lines
1.6 KiB
Rust
55 lines
1.6 KiB
Rust
#[cfg(feature = "std")]
|
|
use zeroize::Zeroize;
|
|
|
|
#[cfg(feature = "borsh")]
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
|
#[cfg(feature = "serde")]
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use scale::{Encode, Decode, MaxEncodedLen};
|
|
use scale_info::TypeInfo;
|
|
|
|
use sp_core::H256;
|
|
|
|
/// The type used to identify block numbers.
|
|
#[derive(
|
|
Clone, Copy, Default, PartialEq, Eq, Hash, Debug, Encode, Decode, MaxEncodedLen, TypeInfo,
|
|
)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub struct BlockNumber(pub u64);
|
|
impl From<u64> for BlockNumber {
|
|
fn from(number: u64) -> BlockNumber {
|
|
BlockNumber(number)
|
|
}
|
|
}
|
|
|
|
/// The type used to identify block hashes.
|
|
// This may not be universally compatible
|
|
// If a block exists with a hash which isn't 32-bytes, it can be hashed into a value with 32-bytes
|
|
// This would require the processor to maintain a mapping of 32-byte IDs to actual hashes, which
|
|
// would be fine
|
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
#[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))]
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
pub struct BlockHash(pub [u8; 32]);
|
|
|
|
impl AsRef<[u8]> for BlockHash {
|
|
fn as_ref(&self) -> &[u8] {
|
|
self.0.as_ref()
|
|
}
|
|
}
|
|
|
|
impl From<[u8; 32]> for BlockHash {
|
|
fn from(hash: [u8; 32]) -> BlockHash {
|
|
BlockHash(hash)
|
|
}
|
|
}
|
|
|
|
impl From<H256> for BlockHash {
|
|
fn from(hash: H256) -> BlockHash {
|
|
BlockHash(hash.into())
|
|
}
|
|
}
|