Skip to content

Commit 85b91aa

Browse files
committed
Add DecodeWithMemTracking derive to SCALE types.
1 parent 0292c45 commit 85b91aa

14 files changed

Lines changed: 299 additions & 129 deletions

File tree

Cargo.lock

Lines changed: 65 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ serde_json = { version = "1.0", default-features = false }
6262
serde_arrays = { version = "0.2", default-features = false }
6363

6464
# Substrate/SCALE deps.
65-
bounded-collections = { version = "0.1.4", default-features = false }
65+
bounded-collections = { version = "0.3.2", default-features = false }
6666
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false }
6767
scale-info = { version = "2.0", default-features = false }
6868

@@ -118,7 +118,7 @@ scale-info = { workspace = true, default-features = false, features = [
118118
"derive",
119119
] }
120120
bounded-collections = { workspace = true, default-features = false }
121-
sp-io = { version = "44.0.0", default-features = false, optional = true }
121+
sp-io = { git = "https://github.com/PolymeshAssociation/polkadot-sdk", branch = "polymesh-v8-stable2512", default-features = false, optional = true }
122122

123123
# serde support
124124
serde = { workspace = true, default-features = false, features = [

src/bp/account.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rayon::prelude::*;
33
#[cfg(feature = "serde")]
44
use serde::{Deserialize, Serialize};
55

6-
use codec::{Decode, Encode, MaxEncodedLen};
6+
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
77
use scale_info::TypeInfo;
88

99
use ark_ec::CurveConfig;
@@ -33,7 +33,7 @@ pub trait AccountStateUpdate {
3333
fn root_block(&self) -> BlockNumber;
3434
}
3535

36-
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
36+
#[derive(Clone, Debug, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq)]
3737
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3838
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
3939
pub struct AccountState {
@@ -100,6 +100,7 @@ impl TryFrom<BPAccountState> for AccountState {
100100
MaxEncodedLen,
101101
Encode,
102102
Decode,
103+
DecodeWithMemTracking,
103104
TypeInfo,
104105
Debug,
105106
PartialEq,
@@ -121,7 +122,18 @@ impl AccountStateNullifier {
121122
}
122123
}
123124

124-
#[derive(Copy, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, Debug, PartialEq, Eq)]
125+
#[derive(
126+
Copy,
127+
Clone,
128+
MaxEncodedLen,
129+
Encode,
130+
Decode,
131+
DecodeWithMemTracking,
132+
TypeInfo,
133+
Debug,
134+
PartialEq,
135+
Eq,
136+
)]
125137
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
126138
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
127139
pub struct AccountStateCommitment(CompressedAffine);
@@ -190,7 +202,7 @@ impl AccountAssetStateChange {
190202
}
191203
}
192204

193-
#[derive(Clone, Debug, Encode, Decode)]
205+
#[derive(Clone, Debug, Encode, Decode, DecodeWithMemTracking)]
194206
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
195207
pub struct AccountAssetState {
196208
pub current_state: AccountState,
@@ -337,7 +349,7 @@ impl AccountAssetState {
337349
/// Batched account asset registration proof.
338350
///
339351
/// This is used to register multiple account/asset pairs in a single proof.
340-
#[derive(Clone, Encode, Decode, Debug, TypeInfo, PartialEq, Eq)]
352+
#[derive(Clone, Encode, Decode, DecodeWithMemTracking, Debug, TypeInfo, PartialEq, Eq)]
341353
#[scale_info(skip_type_params(T))]
342354
pub struct BatchedAccountAssetRegistrationProof<T: DartLimits = ()> {
343355
pub proofs: BoundedVec<AccountAssetRegistrationProof, T::MaxAccountAssetRegProofs>,
@@ -513,7 +525,7 @@ impl<T: DartLimits> BatchedAccountAssetRegistrationProof<T> {
513525
}
514526

515527
/// Account asset registration proof. Report section 5.1.3 "Account Registration".
516-
#[derive(Clone, Encode, Decode, Debug, TypeInfo, PartialEq, Eq)]
528+
#[derive(Clone, Encode, Decode, DecodeWithMemTracking, Debug, TypeInfo, PartialEq, Eq)]
517529
pub struct AccountAssetRegistrationProof {
518530
pub account: AccountPublicKey,
519531
pub asset_id: AssetId,

0 commit comments

Comments
 (0)