Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support shared hold id to have constant number of hold id #3013

Merged
merged 8 commits into from
Sep 25, 2024
13 changes: 4 additions & 9 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ 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 @@ -354,15 +355,9 @@ impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
// 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/autonomys/subspace/issues/2674 for more details. It
// will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033.
const VARIANT_COUNT: u32 = 100;
const VARIANT_COUNT: u32 = 1
+ mem::variant_count::<DomainsHoldIdentifier>() as u32
+ mem::variant_count::<MessengerHoldIdentifier>() as u32;
}

impl pallet_balances::Config for Runtime {
Expand Down
8 changes: 4 additions & 4 deletions test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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 @@ -355,10 +356,9 @@ impl pallet_messenger::HoldIdentifier<Runtime> for HoldIdentifier {
}

impl VariantCount for HoldIdentifier {
// TODO: HACK this is not the actual variant count but it is required see
// https://github.com/autonomys/subspace/issues/2674 for more details. It
// will be resolved as https://github.com/paritytech/polkadot-sdk/issues/4033.
const VARIANT_COUNT: u32 = 10;
const VARIANT_COUNT: u32 = 1
+ mem::variant_count::<DomainsHoldIdentifier>() as u32
+ mem::variant_count::<MessengerHoldIdentifier>() as u32;
nazar-pc marked this conversation as resolved.
Show resolved Hide resolved
}

impl pallet_balances::Config for Runtime {
Expand Down
Loading