diff --git a/crates/pallet-domains/src/tests.rs b/crates/pallet-domains/src/tests.rs index f85b6fb281..583dbc8dac 100644 --- a/crates/pallet-domains/src/tests.rs +++ b/crates/pallet-domains/src/tests.rs @@ -8,7 +8,6 @@ use crate::{ Operators, ReceiptHashFor, }; use codec::{Decode, Encode, MaxEncodedLen}; -use core::mem; use domain_runtime_primitives::opaque::Header as DomainHeader; use domain_runtime_primitives::BlockNumber as DomainBlockNumber; use frame_support::dispatch::{DispatchInfo, RawOrigin}; @@ -133,11 +132,13 @@ impl pallet_domains::HoldIdentifier for HoldIdentifier { } impl VariantCount for HoldIdentifier { - const VARIANT_COUNT: u32 = mem::variant_count::() as u32; + // TODO: HACK this is not the actual variant count but it is required see + // https://github.com/subspace/subspace/issues/2674 for more details. It + // will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033. + const VARIANT_COUNT: u32 = 10; } parameter_types! { - pub const MaxHolds: u32 = 10; pub const ExistentialDeposit: Balance = 1; } diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index a6df0c47b2..fd76cdecf5 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -32,7 +32,6 @@ use crate::fees::{OnChargeTransaction, TransactionByteFee}; use crate::object_mapping::extract_block_object_mapping; pub use crate::signed_extensions::{CheckStorageAccess, DisablePallets}; use codec::{Decode, Encode, MaxEncodedLen}; -use core::mem; use core::num::NonZeroU64; use domain_runtime_primitives::opaque::Header as DomainHeader; use domain_runtime_primitives::{ @@ -408,12 +407,15 @@ impl pallet_messenger::HoldIdentifier for HoldIdentifier { } impl VariantCount for HoldIdentifier { - const VARIANT_COUNT: u32 = mem::variant_count::() as u32; -} - -parameter_types! { - // TODO: revisit this - pub const MaxHolds: u32 = 100; + // TODO: revist this value, it is used as the max number of hold an account can + // create. Currently, nomination an operator will create 2 holds and opening an + // XDM channel will create 1 hold, so this value also used as the limit of how + // many operator/channel an account can nominate/open. + // + // TODO: HACK this is not the actual variant count but it is required see + // https://github.com/subspace/subspace/issues/2674 for more details. It + // will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033. + const VARIANT_COUNT: u32 = 100; } impl pallet_balances::Config for Runtime { diff --git a/domains/runtime/auto-id/src/lib.rs b/domains/runtime/auto-id/src/lib.rs index 4bec8f66e9..1c70dbad32 100644 --- a/domains/runtime/auto-id/src/lib.rs +++ b/domains/runtime/auto-id/src/lib.rs @@ -13,7 +13,6 @@ extern crate alloc; #[cfg(not(feature = "std"))] use alloc::format; use codec::{Decode, Encode, MaxEncodedLen}; -use core::mem; use domain_runtime_primitives::opaque::Header; pub use domain_runtime_primitives::{ block_weights, maximum_block_length, opaque, Balance, BlockNumber, Hash, Nonce, @@ -201,10 +200,6 @@ impl OnUnbalanced> for DustRemovalHandler { } } -parameter_types! { - pub const MaxHolds: u32 = 100; -} - impl pallet_balances::Config for Runtime { type RuntimeFreezeReason = RuntimeFreezeReason; type MaxLocks = MaxLocks; @@ -354,7 +349,14 @@ pub enum HoldIdentifier { } impl VariantCount for HoldIdentifier { - const VARIANT_COUNT: u32 = mem::variant_count::() as u32; + // TODO: revist this value, it is used as the max number of hold an account can + // create. Currently, opening an XDM channel will create 1 hold, so this value + // also used as the limit of how many channel an account can open. + // + // TODO: HACK this is not the actual variant count but it is required see + // https://github.com/subspace/subspace/issues/2674 for more details. It + // will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033. + const VARIANT_COUNT: u32 = 100; } impl pallet_messenger::HoldIdentifier for HoldIdentifier { diff --git a/domains/runtime/evm/src/lib.rs b/domains/runtime/evm/src/lib.rs index ae6dd411e8..18ca0a5b6c 100644 --- a/domains/runtime/evm/src/lib.rs +++ b/domains/runtime/evm/src/lib.rs @@ -15,7 +15,6 @@ extern crate alloc; #[cfg(not(feature = "std"))] use alloc::format; use codec::{Decode, Encode, MaxEncodedLen}; -use core::mem; use domain_runtime_primitives::opaque::Header; pub use domain_runtime_primitives::{ block_weights, maximum_block_length, opaque, Balance, BlockNumber, Hash, Nonce, @@ -318,10 +317,6 @@ impl OnUnbalanced> for DustRemovalHandler { } } -parameter_types! { - pub const MaxHolds: u32 = 100; -} - impl pallet_balances::Config for Runtime { type RuntimeFreezeReason = RuntimeFreezeReason; type MaxLocks = MaxLocks; @@ -468,7 +463,14 @@ pub enum HoldIdentifier { } impl VariantCount for HoldIdentifier { - const VARIANT_COUNT: u32 = mem::variant_count::() as u32; + // TODO: revist this value, it is used as the max number of hold an account can + // create. Currently, opening an XDM channel will create 1 hold, so this value + // also used as the limit of how many channel an account can open. + // + // TODO: HACK this is not the actual variant count but it is required see + // https://github.com/subspace/subspace/issues/2674 for more details. It + // will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033. + const VARIANT_COUNT: u32 = 100; } impl pallet_messenger::HoldIdentifier for HoldIdentifier { diff --git a/domains/test/runtime/evm/src/lib.rs b/domains/test/runtime/evm/src/lib.rs index b9875f09cb..5564be6f9c 100644 --- a/domains/test/runtime/evm/src/lib.rs +++ b/domains/test/runtime/evm/src/lib.rs @@ -15,7 +15,6 @@ extern crate alloc; #[cfg(not(feature = "std"))] use alloc::format; use codec::{Decode, Encode, MaxEncodedLen}; -use core::mem; pub use domain_runtime_primitives::opaque::Header; use domain_runtime_primitives::{ block_weights, maximum_block_length, EXISTENTIAL_DEPOSIT, MAXIMUM_BLOCK_WEIGHT, SLOT_DURATION, @@ -306,10 +305,6 @@ parameter_types! { pub const MaxReserves: u32 = 50; } -parameter_types! { - pub const MaxHolds: u32 = 100; -} - impl pallet_balances::Config for Runtime { type RuntimeFreezeReason = RuntimeFreezeReason; type MaxLocks = MaxLocks; @@ -432,7 +427,10 @@ pub enum HoldIdentifier { } impl VariantCount for HoldIdentifier { - const VARIANT_COUNT: u32 = mem::variant_count::() as u32; + // TODO: HACK this is not the actual variant count but it is required see + // https://github.com/subspace/subspace/issues/2674 for more details. It + // will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033. + const VARIANT_COUNT: u32 = 10; } impl pallet_messenger::HoldIdentifier for HoldIdentifier { diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index f4a5ac1c48..265246aee1 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -24,7 +24,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Compact, CompactLen, Decode, Encode, MaxEncodedLen}; -use core::mem; use core::num::NonZeroU64; use domain_runtime_primitives::opaque::Header as DomainHeader; use domain_runtime_primitives::{ @@ -344,11 +343,10 @@ impl pallet_messenger::HoldIdentifier for HoldIdentifier { } impl VariantCount for HoldIdentifier { - const VARIANT_COUNT: u32 = mem::variant_count::() as u32; -} - -parameter_types! { - pub const MaxHolds: u32 = 10; + // TODO: HACK this is not the actual variant count but it is required see + // https://github.com/subspace/subspace/issues/2674 for more details. It + // will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033. + const VARIANT_COUNT: u32 = 10; } impl pallet_balances::Config for Runtime {