Skip to content

Commit 5c08787

Browse files
committed
Update VARIANT_COUNT for HoldIdentifier
The value is used as the max number of hold an account can create, it is set to 100 for now to workaround some issues with this limit, should revist the value later. Signed-off-by: linning <[email protected]>
1 parent 71db792 commit 5c08787

File tree

6 files changed

+16
-34
lines changed

6 files changed

+16
-34
lines changed

crates/pallet-domains/src/tests.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::{
88
Operators, ReceiptHashFor,
99
};
1010
use codec::{Decode, Encode, MaxEncodedLen};
11-
use core::mem;
1211
use domain_runtime_primitives::opaque::Header as DomainHeader;
1312
use domain_runtime_primitives::BlockNumber as DomainBlockNumber;
1413
use frame_support::dispatch::{DispatchInfo, RawOrigin};
@@ -133,11 +132,10 @@ impl pallet_domains::HoldIdentifier<Test> for HoldIdentifier {
133132
}
134133

135134
impl VariantCount for HoldIdentifier {
136-
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() as u32;
135+
const VARIANT_COUNT: u32 = 10;
137136
}
138137

139138
parameter_types! {
140-
pub const MaxHolds: u32 = 10;
141139
pub const ExistentialDeposit: Balance = 1;
142140
}
143141

crates/subspace-runtime/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use crate::fees::{OnChargeTransaction, TransactionByteFee};
3232
use crate::object_mapping::extract_block_object_mapping;
3333
pub use crate::signed_extensions::{CheckStorageAccess, DisablePallets};
3434
use codec::{Decode, Encode, MaxEncodedLen};
35-
use core::mem;
3635
use core::num::NonZeroU64;
3736
use domain_runtime_primitives::opaque::Header as DomainHeader;
3837
use domain_runtime_primitives::{
@@ -408,12 +407,11 @@ impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {
408407
}
409408

410409
impl VariantCount for HoldIdentifier {
411-
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() as u32;
412-
}
413-
414-
parameter_types! {
415-
// TODO: revisit this
416-
pub const MaxHolds: u32 = 100;
410+
// TODO: revist this value, it is used as the max number of hold an account can
411+
// create. Currently, nomination an operator will create 2 holds and opening an
412+
// XDM channel will create 1 hold, so this value also used as the limit of how
413+
// many operator/channel an account can nominate/open.
414+
const VARIANT_COUNT: u32 = 100;
417415
}
418416

419417
impl pallet_balances::Config for Runtime {

domains/runtime/auto-id/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ extern crate alloc;
1313
#[cfg(not(feature = "std"))]
1414
use alloc::format;
1515
use codec::{Decode, Encode, MaxEncodedLen};
16-
use core::mem;
1716
use domain_runtime_primitives::opaque::Header;
1817
pub use domain_runtime_primitives::{
1918
block_weights, maximum_block_length, opaque, Balance, BlockNumber, Hash, Nonce,
@@ -201,10 +200,6 @@ impl OnUnbalanced<Credit<AccountId, Balances>> for DustRemovalHandler {
201200
}
202201
}
203202

204-
parameter_types! {
205-
pub const MaxHolds: u32 = 100;
206-
}
207-
208203
impl pallet_balances::Config for Runtime {
209204
type RuntimeFreezeReason = RuntimeFreezeReason;
210205
type MaxLocks = MaxLocks;
@@ -354,7 +349,10 @@ pub enum HoldIdentifier {
354349
}
355350

356351
impl VariantCount for HoldIdentifier {
357-
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() as u32;
352+
// TODO: revist this value, it is used as the max number of hold an account can
353+
// create. Currently, opening an XDM channel will create 1 hold, so this value
354+
// also used as the limit of how many channel an account can open.
355+
const VARIANT_COUNT: u32 = 100;
358356
}
359357

360358
impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {

domains/runtime/evm/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ extern crate alloc;
1515
#[cfg(not(feature = "std"))]
1616
use alloc::format;
1717
use codec::{Decode, Encode, MaxEncodedLen};
18-
use core::mem;
1918
use domain_runtime_primitives::opaque::Header;
2019
pub use domain_runtime_primitives::{
2120
block_weights, maximum_block_length, opaque, Balance, BlockNumber, Hash, Nonce,
@@ -318,10 +317,6 @@ impl OnUnbalanced<Credit<AccountId, Balances>> for DustRemovalHandler {
318317
}
319318
}
320319

321-
parameter_types! {
322-
pub const MaxHolds: u32 = 100;
323-
}
324-
325320
impl pallet_balances::Config for Runtime {
326321
type RuntimeFreezeReason = RuntimeFreezeReason;
327322
type MaxLocks = MaxLocks;
@@ -468,7 +463,10 @@ pub enum HoldIdentifier {
468463
}
469464

470465
impl VariantCount for HoldIdentifier {
471-
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() as u32;
466+
// TODO: revist this value, it is used as the max number of hold an account can
467+
// create. Currently, opening an XDM channel will create 1 hold, so this value
468+
// also used as the limit of how many channel an account can open.
469+
const VARIANT_COUNT: u32 = 100;
472470
}
473471

474472
impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {

domains/test/runtime/evm/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ extern crate alloc;
1515
#[cfg(not(feature = "std"))]
1616
use alloc::format;
1717
use codec::{Decode, Encode, MaxEncodedLen};
18-
use core::mem;
1918
pub use domain_runtime_primitives::opaque::Header;
2019
use domain_runtime_primitives::{
2120
block_weights, maximum_block_length, EXISTENTIAL_DEPOSIT, MAXIMUM_BLOCK_WEIGHT, SLOT_DURATION,
@@ -306,10 +305,6 @@ parameter_types! {
306305
pub const MaxReserves: u32 = 50;
307306
}
308307

309-
parameter_types! {
310-
pub const MaxHolds: u32 = 100;
311-
}
312-
313308
impl pallet_balances::Config for Runtime {
314309
type RuntimeFreezeReason = RuntimeFreezeReason;
315310
type MaxLocks = MaxLocks;
@@ -432,7 +427,7 @@ pub enum HoldIdentifier {
432427
}
433428

434429
impl VariantCount for HoldIdentifier {
435-
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() as u32;
430+
const VARIANT_COUNT: u32 = 10;
436431
}
437432

438433
impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {

test/subspace-test-runtime/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
2525

2626
use codec::{Compact, CompactLen, Decode, Encode, MaxEncodedLen};
27-
use core::mem;
2827
use core::num::NonZeroU64;
2928
use domain_runtime_primitives::opaque::Header as DomainHeader;
3029
use domain_runtime_primitives::{
@@ -344,11 +343,7 @@ impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {
344343
}
345344

346345
impl VariantCount for HoldIdentifier {
347-
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() as u32;
348-
}
349-
350-
parameter_types! {
351-
pub const MaxHolds: u32 = 10;
346+
const VARIANT_COUNT: u32 = 10;
352347
}
353348

354349
impl pallet_balances::Config for Runtime {

0 commit comments

Comments
 (0)