mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Update serai-abi, and dependencies, to patch-polkadot-sdk
This commit is contained in:
@@ -21,11 +21,11 @@ borsh = { version = "1", default-features = false, features = ["derive", "de_str
|
||||
|
||||
bitvec = { version = "1", default-features = false, features = ["alloc"] }
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
||||
sp-core = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "serai-next", default-features = false }
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "799658329bf66a829e67b34a0e86376b63eb7d23", default-features = false }
|
||||
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", default-features = false, features = ["alloc"] }
|
||||
dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false }
|
||||
dkg = { path = "../../crypto/dkg", default-features = false }
|
||||
dkg = { package = "dkg-musig", path = "../../crypto/dkg/musig", default-features = false }
|
||||
|
||||
bech32 = { version = "0.11", default-features = false }
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ impl ExternalCoin {
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
#[cfg_attr(feature = "non_canonical_scale_derivations", allow(clippy::cast_possible_truncation))]
|
||||
#[cfg_attr(feature = "serde", derive(sp_core::serde::Serialize, sp_core::serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(crate = "sp_core::serde"))]
|
||||
pub enum Coin {
|
||||
|
||||
@@ -67,6 +67,7 @@ impl BorshDeserialize for Batch {
|
||||
let read = self.reader.read(buf)?;
|
||||
self.read = self.read.saturating_add(read);
|
||||
if self.read > Batch::MAX_SIZE {
|
||||
#[allow(clippy::io_other_error)]
|
||||
Err(io::Error::new(io::ErrorKind::Other, "Batch size exceeded maximum"))?;
|
||||
}
|
||||
Ok(read)
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::{address::ExternalAddress, balance::ExternalBalance};
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
#[cfg_attr(feature = "non_canonical_scale_derivations", allow(clippy::cast_possible_truncation))]
|
||||
pub enum OutInstruction {
|
||||
/// Transfer to the specified address.
|
||||
Transfer(ExternalAddress),
|
||||
|
||||
@@ -69,6 +69,8 @@ impl From<u64> for BlockNumber {
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[rustfmt::skip]
|
||||
#[derive(scale::Encode, scale::Decode)] // This is safe as scale and borsh share an encoding here
|
||||
#[cfg_attr(feature = "serde", derive(sp_core::serde::Serialize, sp_core::serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(crate = "sp_core::serde"))]
|
||||
pub struct BlockHash(pub [u8; 32]);
|
||||
impl From<[u8; 32]> for BlockHash {
|
||||
fn from(hash: [u8; 32]) -> BlockHash {
|
||||
|
||||
@@ -145,19 +145,6 @@ fn unbalanced_merkle_tree() {
|
||||
let with_new = UnbalancedMerkleTree::new(tag, list_of_hashes.clone());
|
||||
// Check `is_empty` works
|
||||
assert_eq!(with_new.is_empty(), i == 0);
|
||||
// The reference method, easy to audit, should have identical behavior to the optimized method
|
||||
assert_eq!(
|
||||
with_new,
|
||||
UnbalancedMerkleTree::from_scale_encoded_list_of_hashes(tag, list_of_hashes.encode())
|
||||
);
|
||||
// The encoding of a slice should work the same as the encoding of a list
|
||||
assert_eq!(
|
||||
with_new,
|
||||
UnbalancedMerkleTree::from_scale_encoded_list_of_hashes(
|
||||
tag,
|
||||
list_of_hashes.as_slice().encode()
|
||||
)
|
||||
);
|
||||
// Check the incremental method produces an identical result
|
||||
assert_eq!(incremental.clone().calculate(tag), with_new, "{i}");
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ impl ExternalNetworkId {
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
#[cfg_attr(feature = "non_canonical_scale_derivations", allow(clippy::cast_possible_truncation))]
|
||||
pub enum NetworkId {
|
||||
/// The Serai network.
|
||||
Serai,
|
||||
|
||||
@@ -45,6 +45,7 @@ pub fn borsh_deserialize_bounded_vec<R: Read, T: BorshDeserialize, const B: u32>
|
||||
reader.read_exact(&mut length[.. bytes_for_length])?;
|
||||
let length = u32::from_le_bytes(length);
|
||||
if length > B {
|
||||
#[allow(clippy::io_other_error)]
|
||||
Err(Error::new(ErrorKind::Other, "bound exceeded"))?;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,24 @@ impl TryFrom<ValidatorSet> for ExternalValidatorSet {
|
||||
|
||||
impl ExternalValidatorSet {
|
||||
/// The MuSig context for this validator set.
|
||||
pub fn musig_context(&self) -> Vec<u8> {
|
||||
borsh::to_vec(&(b"ValidatorSets-musig_key".as_ref(), self)).unwrap()
|
||||
pub fn musig_context(&self) -> [u8; 32] {
|
||||
let mut res = [0; 32];
|
||||
|
||||
const DST: &[u8] = b"ValidatorSets-musig_key";
|
||||
res[0] = u8::try_from(DST.len()).unwrap();
|
||||
#[allow(clippy::range_plus_one)]
|
||||
res[1 .. (1 + DST.len())].copy_from_slice(DST);
|
||||
|
||||
// Check we have room to encode into `res`, using the approximate `size_of` for the max size of
|
||||
// the serialization
|
||||
const BYTES_FOR_SET: usize = 32 - (1 + DST.len());
|
||||
const _ASSERT_MORE_BYTES_THAN_SIZE: [();
|
||||
BYTES_FOR_SET - core::mem::size_of::<ExternalValidatorSet>()] = [(); _];
|
||||
|
||||
let encoded = borsh::to_vec(&self).unwrap();
|
||||
res[(1 + DST.len()) .. (1 + DST.len() + encoded.len())].copy_from_slice(&encoded);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
/// The MuSig public key for a validator set.
|
||||
@@ -80,7 +96,7 @@ impl ExternalValidatorSet {
|
||||
.expect("invalid participant"),
|
||||
);
|
||||
}
|
||||
Public(dkg::musig::musig_key::<Ristretto>(&self.musig_context(), &keys).unwrap().to_bytes())
|
||||
Public(dkg::musig_key::<Ristretto>(self.musig_context(), &keys).unwrap().to_bytes())
|
||||
}
|
||||
|
||||
/// The message for the `set_keys` signature.
|
||||
|
||||
@@ -24,6 +24,7 @@ fn downtime_per_slash_point(validators: NonZero<u16>) -> Duration {
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
#[cfg_attr(feature = "non_canonical_scale_derivations", allow(clippy::cast_possible_truncation))]
|
||||
pub enum Slash {
|
||||
/// The slash points accumulated by this validator.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user