mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Have serai-runtime compile again
This commit is contained in:
@@ -22,13 +22,13 @@ workspace = true
|
||||
borsh = { version = "1", default-features = false, features = ["derive", "de_strict_order"] }
|
||||
|
||||
bitvec = { version = "1", default-features = false, features = ["alloc"] }
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "799658329bf66a829e67b34a0e86376b63eb7d23", default-features = false }
|
||||
sp-core = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "2bfdaed4b3614de2fe7d10e4ece3e6a912833e90", default-features = false }
|
||||
|
||||
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
|
||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"], optional = true }
|
||||
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "799658329bf66a829e67b34a0e86376b63eb7d23", default-features = false, features = ["serde"], optional = true }
|
||||
frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "799658329bf66a829e67b34a0e86376b63eb7d23", default-features = false, optional = true }
|
||||
sp-runtime = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "2bfdaed4b3614de2fe7d10e4ece3e6a912833e90", default-features = false, features = ["serde"], optional = true }
|
||||
frame-support = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "2bfdaed4b3614de2fe7d10e4ece3e6a912833e90", default-features = false, optional = true }
|
||||
|
||||
serai-primitives = { path = "../primitives", version = "0.1", default-features = false }
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ pub struct Block {
|
||||
mod substrate {
|
||||
use core::fmt::Debug;
|
||||
|
||||
use scale::{Encode, Decode, DecodeWithMemTracking, IoReader};
|
||||
use scale::{Encode, Decode, DecodeWithMemTracking};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use sp_core::H256;
|
||||
@@ -133,7 +133,7 @@ mod substrate {
|
||||
use sp_core::serde::de::Error;
|
||||
let bytes = <Vec<u8> as sp_core::serde::Deserialize>::deserialize(deserializer)?;
|
||||
let mut reader = bytes.as_slice();
|
||||
let block = Self::decode(&mut IoReader(&mut reader)).map_err(D::Error::custom)?;
|
||||
let block = Self::decode(&mut reader).map_err(D::Error::custom)?;
|
||||
if !reader.is_empty() {
|
||||
Err(D::Error::custom("extraneous bytes at end"))?;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ mod substrate {
|
||||
}
|
||||
|
||||
/// A block, as needed by Substrate.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode, DecodeWithMemTracking, TypeInfo)]
|
||||
pub struct SubstrateBlock {
|
||||
header: SubstrateHeader,
|
||||
transactions: Vec<Transaction>,
|
||||
@@ -306,7 +306,7 @@ mod substrate {
|
||||
use sp_core::serde::de::Error;
|
||||
let bytes = <Vec<u8> as sp_core::serde::Deserialize>::deserialize(deserializer)?;
|
||||
let mut reader = bytes.as_slice();
|
||||
let block = Self::decode(&mut IoReader(&mut reader)).map_err(D::Error::custom)?;
|
||||
let block = Self::decode(&mut reader).map_err(D::Error::custom)?;
|
||||
if !reader.is_empty() {
|
||||
Err(D::Error::custom("extraneous bytes at end"))?;
|
||||
}
|
||||
|
||||
@@ -262,6 +262,12 @@ mod substrate {
|
||||
})?;
|
||||
// If we're still calling `read`, we try to read at least one more byte
|
||||
let to_read = buf.len().min(remaining_len.unwrap_or(1));
|
||||
// This may not be _allocated_ making this over-zealous, but it's the best we can do
|
||||
self.0.on_before_alloc_mem(to_read).map_err(|err| {
|
||||
self.1 = Some(err);
|
||||
#[allow(clippy::io_other_error)]
|
||||
borsh::io::Error::new(borsh::io::ErrorKind::Other, "")
|
||||
})?;
|
||||
self.0.read(&mut buf[.. to_read]).map_err(|err| {
|
||||
self.1 = Some(err);
|
||||
#[allow(clippy::io_other_error)]
|
||||
@@ -278,6 +284,23 @@ mod substrate {
|
||||
}
|
||||
}
|
||||
|
||||
// Clean `Transaction` tracks its memory during decoding, as we do call
|
||||
// `Input::on_before_alloc_mem`
|
||||
impl scale::DecodeWithMemTracking for Transaction {}
|
||||
|
||||
// Shim `TypeInfo` for `Transaction`
|
||||
impl scale_info::TypeInfo for Transaction {
|
||||
type Identity = Self;
|
||||
fn type_info() -> scale_info::Type {
|
||||
scale_info::Type {
|
||||
path: scale_info::Path { segments: vec!["serai_abi", "transaction", "Transaction"] },
|
||||
type_params: vec![],
|
||||
type_def: (scale_info::TypeDefComposite { fields: vec![] }).into(),
|
||||
docs: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The context which transactions are executed in.
|
||||
pub trait TransactionContext: 'static + Send + Sync + Clone + PartialEq + Eq + Debug {
|
||||
/// The base weight for a signed transaction.
|
||||
|
||||
Reference in New Issue
Block a user