From 7a5bdff42dbc9b01b727271f37bf27aa01874299 Mon Sep 17 00:00:00 2001 From: linning Date: Wed, 11 Sep 2024 20:48:30 +0800 Subject: [PATCH] Update the VariantCount for the consensus runtime HoldIdentifier Signed-off-by: linning --- crates/subspace-runtime/src/lib.rs | 13 ++++--------- test/subspace-test-runtime/src/lib.rs | 8 ++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 1b4b8e7cbd7..1ff353c0b78 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -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::{ @@ -354,15 +355,9 @@ impl pallet_messenger::HoldIdentifier 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::() as u32 + + mem::variant_count::() as u32; } impl pallet_balances::Config for Runtime { diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index ebfa428c22e..35b1d29df6f 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -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::{ @@ -355,10 +356,9 @@ impl pallet_messenger::HoldIdentifier 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::() as u32 + + mem::variant_count::() as u32; } impl pallet_balances::Config for Runtime {