Skip to content

Commit

Permalink
Update VARIANT_COUNT for HoldIdentifier
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
NingLin-P committed Apr 8, 2024
1 parent 71db792 commit c489074
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
7 changes: 4 additions & 3 deletions crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -133,11 +132,13 @@ impl pallet_domains::HoldIdentifier<Test> for HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() 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;
}

Expand Down
16 changes: 9 additions & 7 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -408,12 +407,15 @@ impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() 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 {
Expand Down
14 changes: 8 additions & 6 deletions domains/runtime/auto-id/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -201,10 +200,6 @@ impl OnUnbalanced<Credit<AccountId, Balances>> for DustRemovalHandler {
}
}

parameter_types! {
pub const MaxHolds: u32 = 100;
}

impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type MaxLocks = MaxLocks;
Expand Down Expand Up @@ -354,7 +349,14 @@ pub enum HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() 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<Runtime> for HoldIdentifier {
Expand Down
14 changes: 8 additions & 6 deletions domains/runtime/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -318,10 +317,6 @@ impl OnUnbalanced<Credit<AccountId, Balances>> for DustRemovalHandler {
}
}

parameter_types! {
pub const MaxHolds: u32 = 100;
}

impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type MaxLocks = MaxLocks;
Expand Down Expand Up @@ -468,7 +463,14 @@ pub enum HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() 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<Runtime> for HoldIdentifier {
Expand Down
10 changes: 4 additions & 6 deletions domains/test/runtime/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -432,7 +427,10 @@ pub enum HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() 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<Runtime> for HoldIdentifier {
Expand Down
10 changes: 4 additions & 6 deletions test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -344,11 +343,10 @@ impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
const VARIANT_COUNT: u32 = mem::variant_count::<Self>() 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 {
Expand Down

0 comments on commit c489074

Please sign in to comment.