From 9a67a80298eb7a50e5e4e2ec50e2e987b7127489 Mon Sep 17 00:00:00 2001 From: Cezary Olborski Date: Wed, 18 Feb 2026 14:54:21 +0800 Subject: [PATCH 1/3] fix: Post Merge Clippy check --- Cargo.lock | 2 - pallets/mining-rewards/src/mock.rs | 1 - pallets/multisig/Cargo.toml | 8 -- pallets/multisig/src/benchmarking.rs | 1 + pallets/multisig/src/mock.rs | 96 +------------------ pallets/treasury/src/tests.rs | 101 ++++++++++---------- pallets/wormhole/Cargo.toml | 1 - pallets/wormhole/src/benchmarking.rs | 4 +- runtime/Cargo.toml | 1 - runtime/tests/governance/tech_collective.rs | 7 +- 10 files changed, 55 insertions(+), 167 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89351fa9..48f2b1b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7130,8 +7130,6 @@ dependencies = [ "frame-support", "frame-system", "log", - "pallet-assets", - "pallet-assets-holder", "pallet-balances", "pallet-preimage", "pallet-recovery", diff --git a/pallets/mining-rewards/src/mock.rs b/pallets/mining-rewards/src/mock.rs index 88ad0b03..e8106731 100644 --- a/pallets/mining-rewards/src/mock.rs +++ b/pallets/mining-rewards/src/mock.rs @@ -4,7 +4,6 @@ use frame_support::{ parameter_types, traits::{ConstU32, Everything, Hooks}, }; -use pallet_treasury; use qp_poseidon::PoseidonHasher; use sp_consensus_pow::POW_ENGINE_ID; use sp_runtime::{ diff --git a/pallets/multisig/Cargo.toml b/pallets/multisig/Cargo.toml index 0fd05da0..b06d0dc2 100644 --- a/pallets/multisig/Cargo.toml +++ b/pallets/multisig/Cargo.toml @@ -30,12 +30,9 @@ sp-runtime.workspace = true [dev-dependencies] frame-support = { workspace = true, features = ["experimental"], default-features = true } frame-system = { workspace = true, default-features = true } -pallet-assets = { workspace = true, default-features = true } -pallet-assets-holder = { workspace = true, default-features = true } pallet-balances = { workspace = true, features = ["std"] } pallet-preimage = { workspace = true, default-features = true } pallet-recovery = { workspace = true, default-features = true } -pallet-reversible-transfers = { path = "../reversible-transfers", default-features = true } pallet-scheduler = { workspace = true, default-features = true } pallet-timestamp.workspace = true pallet-utility = { workspace = true, default-features = true } @@ -74,8 +71,3 @@ std = [ "sp-io/std", "sp-runtime/std", ] -try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "sp-runtime/try-runtime", -] diff --git a/pallets/multisig/src/benchmarking.rs b/pallets/multisig/src/benchmarking.rs index 59f45386..7089fe10 100644 --- a/pallets/multisig/src/benchmarking.rs +++ b/pallets/multisig/src/benchmarking.rs @@ -113,6 +113,7 @@ mod benchmarks { } /// Insert a single proposal into storage. `approvals` = list of account ids that have approved. + #[allow(clippy::too_many_arguments)] fn insert_proposal( multisig_address: &T::AccountId, proposal_id: u32, diff --git a/pallets/multisig/src/mock.rs b/pallets/multisig/src/mock.rs index 82f5cbbd..65164ae9 100644 --- a/pallets/multisig/src/mock.rs +++ b/pallets/multisig/src/mock.rs @@ -1,6 +1,5 @@ -//! Mock runtime for testing pallet-multisig. -//! Single mock used for both unit tests and benchmark tests; implements -//! `pallet_reversible_transfers::Config` so that benchmark test suite compiles and runs. +//! Mock runtime for testing pallet-multisig (unit tests). +//! Does not include pallet-reversible-transfers to avoid pulling pallet-assets/pallet-revive. use core::{cell::RefCell, marker::PhantomData}; @@ -11,7 +10,6 @@ use frame_support::{ PalletId, }; use frame_system::{limits::BlockWeights, EnsureRoot, EnsureSignedBy}; -use qp_scheduler::BlockNumberOrTimestamp; use sp_core::ConstU128; use sp_runtime::{BuildStorage, Perbill, Permill, Weight}; @@ -64,15 +62,6 @@ mod runtime { #[runtime::pallet_index(6)] pub type Utility = pallet_utility::Pallet; - - #[runtime::pallet_index(7)] - pub type Assets = pallet_assets::Pallet; - - #[runtime::pallet_index(8)] - pub type AssetsHolder = pallet_assets_holder::Pallet; - - #[runtime::pallet_index(9)] - pub type ReversibleTransfers = pallet_reversible_transfers::Pallet; } impl TryFrom for pallet_balances::Call { @@ -85,16 +74,6 @@ impl TryFrom for pallet_balances::Call { } } -impl TryFrom for pallet_assets::Call { - type Error = (); - fn try_from(call: RuntimeCall) -> Result { - match call { - RuntimeCall::Assets(c) => Ok(c), - _ => Err(()), - } - } -} - #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { type Block = Block; @@ -171,73 +150,6 @@ impl Time for MockTimestamp { } } -parameter_types! { - pub const ReversibleTransfersPalletIdValue: PalletId = PalletId(*b"rtpallet"); - pub const DefaultDelay: BlockNumberOrTimestamp = - BlockNumberOrTimestamp::BlockNumber(10); - pub const MinDelayPeriodBlocks: u64 = 2; - pub const MinDelayPeriodMoment: u64 = 2000; - pub const MaxReversibleTransfers: u32 = 100; - pub const MaxInterceptorAccounts: u32 = 10; - pub const HighSecurityVolumeFee: Permill = Permill::from_percent(1); -} - -impl pallet_reversible_transfers::Config for Test { - type SchedulerOrigin = OriginCaller; - type RuntimeHoldReason = RuntimeHoldReason; - type Scheduler = Scheduler; - type BlockNumberProvider = System; - type MaxPendingPerAccount = MaxReversibleTransfers; - type DefaultDelay = DefaultDelay; - type MinDelayPeriodBlocks = MinDelayPeriodBlocks; - type MinDelayPeriodMoment = MinDelayPeriodMoment; - type PalletId = ReversibleTransfersPalletIdValue; - type Preimages = Preimage; - type WeightInfo = (); - type Moment = Moment; - type TimeProvider = MockTimestamp; - type MaxInterceptorAccounts = MaxInterceptorAccounts; - type VolumeFee = HighSecurityVolumeFee; -} - -parameter_types! { - pub const AssetDeposit: Balance = 0; - pub const AssetAccountDeposit: Balance = 0; - pub const AssetsStringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = 0; - pub const MetadataDepositPerByte: Balance = 0; -} - -impl pallet_assets::Config for Test { - type Balance = Balance; - type RuntimeEvent = RuntimeEvent; - type AssetId = u32; - type AssetIdParameter = codec::Compact; - type Currency = Balances; - type CreateOrigin = - frame_support::traits::AsEnsureOriginWithArg>; - type ForceOrigin = frame_system::EnsureRoot; - type AssetDeposit = AssetDeposit; - type MetadataDepositBase = MetadataDepositBase; - type MetadataDepositPerByte = MetadataDepositPerByte; - type ApprovalDeposit = sp_core::ConstU128<0>; - type StringLimit = AssetsStringLimit; - type Freezer = (); - type Extra = (); - type WeightInfo = (); - type CallbackHandle = pallet_assets::AutoIncAssetId; - type AssetAccountDeposit = AssetAccountDeposit; - type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; - type Holder = pallet_assets_holder::Pallet; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); -} - -impl pallet_assets_holder::Config for Test { - type RuntimeEvent = RuntimeEvent; - type RuntimeHoldReason = RuntimeHoldReason; -} - parameter_types! { pub const ConfigDepositBase: Balance = 1; pub const FriendDepositFactor: Balance = 1; @@ -313,9 +225,5 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - pallet_reversible_transfers::GenesisConfig:: { initial_high_security_accounts: vec![] } - .assimilate_storage(&mut t) - .unwrap(); - t.into() } diff --git a/pallets/treasury/src/tests.rs b/pallets/treasury/src/tests.rs index 14bf2f12..3b9821cc 100644 --- a/pallets/treasury/src/tests.rs +++ b/pallets/treasury/src/tests.rs @@ -1,58 +1,55 @@ -#[cfg(test)] -mod tests { - use crate::{ - mock::{account_id, new_test_ext, Test, Treasury}, - Error, - }; - use frame_support::{assert_err, assert_ok}; +use crate::{ + mock::{account_id, new_test_ext, Test, Treasury}, + Error, +}; +use frame_support::{assert_err, assert_ok}; - #[test] - fn genesis_sets_treasury_config() { - new_test_ext().execute_with(|| { - assert_eq!(Treasury::account_id(), account_id(1)); - assert_eq!(Treasury::portion(), 50); - }); - } +#[test] +fn genesis_sets_treasury_config() { + new_test_ext().execute_with(|| { + assert_eq!(Treasury::account_id(), account_id(1)); + assert_eq!(Treasury::portion(), 50); + }); +} - #[test] - fn set_treasury_account_works() { - new_test_ext().execute_with(|| { - assert_ok!(Treasury::set_treasury_account( - frame_system::RawOrigin::Root.into(), - account_id(99) - )); - assert_eq!(Treasury::account_id(), account_id(99)); - }); - } +#[test] +fn set_treasury_account_works() { + new_test_ext().execute_with(|| { + assert_ok!(Treasury::set_treasury_account( + frame_system::RawOrigin::Root.into(), + account_id(99) + )); + assert_eq!(Treasury::account_id(), account_id(99)); + }); +} - #[test] - fn set_treasury_account_requires_root() { - new_test_ext().execute_with(|| { - assert_err!( - Treasury::set_treasury_account( - frame_system::RawOrigin::Signed(account_id(1)).into(), - account_id(99) - ), - sp_runtime::DispatchError::BadOrigin - ); - }); - } +#[test] +fn set_treasury_account_requires_root() { + new_test_ext().execute_with(|| { + assert_err!( + Treasury::set_treasury_account( + frame_system::RawOrigin::Signed(account_id(1)).into(), + account_id(99) + ), + sp_runtime::DispatchError::BadOrigin + ); + }); +} - #[test] - fn set_treasury_portion_works() { - new_test_ext().execute_with(|| { - assert_ok!(Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 30)); - assert_eq!(Treasury::portion(), 30); - }); - } +#[test] +fn set_treasury_portion_works() { + new_test_ext().execute_with(|| { + assert_ok!(Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 30)); + assert_eq!(Treasury::portion(), 30); + }); +} - #[test] - fn set_treasury_portion_rejects_invalid() { - new_test_ext().execute_with(|| { - assert_err!( - Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 101), - Error::::InvalidPortion - ); - }); - } +#[test] +fn set_treasury_portion_rejects_invalid() { + new_test_ext().execute_with(|| { + assert_err!( + Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 101), + Error::::InvalidPortion + ); + }); } diff --git a/pallets/wormhole/Cargo.toml b/pallets/wormhole/Cargo.toml index baeaada7..ffa42da9 100644 --- a/pallets/wormhole/Cargo.toml +++ b/pallets/wormhole/Cargo.toml @@ -69,4 +69,3 @@ std = [ "sp-io/std", "sp-runtime/std", ] -try-runtime = ["frame-support/try-runtime", "frame-system/try-runtime"] diff --git a/pallets/wormhole/src/benchmarking.rs b/pallets/wormhole/src/benchmarking.rs index 27ea4823..47d00851 100644 --- a/pallets/wormhole/src/benchmarking.rs +++ b/pallets/wormhole/src/benchmarking.rs @@ -39,9 +39,7 @@ mod benchmarks { // Extract values from aggregated public inputs let block_number_u32 = aggregated_inputs.block_data.block_number; - let block_hash_bytes: [u8; 32] = (*aggregated_inputs.block_data.block_hash) - .try_into() - .map_err(|_| BenchmarkError::Stop("Invalid block hash length"))?; + let block_hash_bytes = *aggregated_inputs.block_data.block_hash; // Ensure nullifiers haven't been used for nullifier in &aggregated_inputs.nullifiers { diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index aa9007f1..0ac0f17e 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -180,7 +180,6 @@ try-runtime = [ "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", - "pallet-wormhole/try-runtime", "sp-runtime/try-runtime", ] diff --git a/runtime/tests/governance/tech_collective.rs b/runtime/tests/governance/tech_collective.rs index 608fe9b3..466be8c2 100644 --- a/runtime/tests/governance/tech_collective.rs +++ b/runtime/tests/governance/tech_collective.rs @@ -8,14 +8,11 @@ mod tests { use quantus_runtime::configs::TechReferendaInstance; use quantus_runtime::{ - Balances, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeOrigin, System, + Balances, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeOrigin, TechCollective, TechReferenda, UNIT, }; - use sp_runtime::{ - traits::{AccountIdConversion, Hash, StaticLookup}, - MultiAddress, - }; + use sp_runtime::{traits::Hash, MultiAddress}; const TRACK_ID: u16 = 0; From 3e5c14f250d9923ce8fc7fa9f2243d509eeac980 Mon Sep 17 00:00:00 2001 From: Cezary Olborski Date: Wed, 18 Feb 2026 17:19:00 +0800 Subject: [PATCH 2/3] fix: Multisig benchmarks --- Cargo.lock | 2 + pallets/multisig/Cargo.toml | 3 + pallets/multisig/src/migration.rs | 0 pallets/multisig/src/mock.rs | 96 ++++++++++++++++++++- runtime/tests/governance/tech_collective.rs | 4 +- 5 files changed, 101 insertions(+), 4 deletions(-) delete mode 100644 pallets/multisig/src/migration.rs diff --git a/Cargo.lock b/Cargo.lock index 48f2b1b4..89351fa9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7130,6 +7130,8 @@ dependencies = [ "frame-support", "frame-system", "log", + "pallet-assets", + "pallet-assets-holder", "pallet-balances", "pallet-preimage", "pallet-recovery", diff --git a/pallets/multisig/Cargo.toml b/pallets/multisig/Cargo.toml index b06d0dc2..295d45df 100644 --- a/pallets/multisig/Cargo.toml +++ b/pallets/multisig/Cargo.toml @@ -30,9 +30,12 @@ sp-runtime.workspace = true [dev-dependencies] frame-support = { workspace = true, features = ["experimental"], default-features = true } frame-system = { workspace = true, default-features = true } +pallet-assets = { workspace = true, default-features = true } +pallet-assets-holder = { workspace = true, default-features = true } pallet-balances = { workspace = true, features = ["std"] } pallet-preimage = { workspace = true, default-features = true } pallet-recovery = { workspace = true, default-features = true } +pallet-reversible-transfers = { path = "../reversible-transfers", default-features = true } pallet-scheduler = { workspace = true, default-features = true } pallet-timestamp.workspace = true pallet-utility = { workspace = true, default-features = true } diff --git a/pallets/multisig/src/migration.rs b/pallets/multisig/src/migration.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/pallets/multisig/src/mock.rs b/pallets/multisig/src/mock.rs index 65164ae9..82f5cbbd 100644 --- a/pallets/multisig/src/mock.rs +++ b/pallets/multisig/src/mock.rs @@ -1,5 +1,6 @@ -//! Mock runtime for testing pallet-multisig (unit tests). -//! Does not include pallet-reversible-transfers to avoid pulling pallet-assets/pallet-revive. +//! Mock runtime for testing pallet-multisig. +//! Single mock used for both unit tests and benchmark tests; implements +//! `pallet_reversible_transfers::Config` so that benchmark test suite compiles and runs. use core::{cell::RefCell, marker::PhantomData}; @@ -10,6 +11,7 @@ use frame_support::{ PalletId, }; use frame_system::{limits::BlockWeights, EnsureRoot, EnsureSignedBy}; +use qp_scheduler::BlockNumberOrTimestamp; use sp_core::ConstU128; use sp_runtime::{BuildStorage, Perbill, Permill, Weight}; @@ -62,6 +64,15 @@ mod runtime { #[runtime::pallet_index(6)] pub type Utility = pallet_utility::Pallet; + + #[runtime::pallet_index(7)] + pub type Assets = pallet_assets::Pallet; + + #[runtime::pallet_index(8)] + pub type AssetsHolder = pallet_assets_holder::Pallet; + + #[runtime::pallet_index(9)] + pub type ReversibleTransfers = pallet_reversible_transfers::Pallet; } impl TryFrom for pallet_balances::Call { @@ -74,6 +85,16 @@ impl TryFrom for pallet_balances::Call { } } +impl TryFrom for pallet_assets::Call { + type Error = (); + fn try_from(call: RuntimeCall) -> Result { + match call { + RuntimeCall::Assets(c) => Ok(c), + _ => Err(()), + } + } +} + #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { type Block = Block; @@ -150,6 +171,73 @@ impl Time for MockTimestamp { } } +parameter_types! { + pub const ReversibleTransfersPalletIdValue: PalletId = PalletId(*b"rtpallet"); + pub const DefaultDelay: BlockNumberOrTimestamp = + BlockNumberOrTimestamp::BlockNumber(10); + pub const MinDelayPeriodBlocks: u64 = 2; + pub const MinDelayPeriodMoment: u64 = 2000; + pub const MaxReversibleTransfers: u32 = 100; + pub const MaxInterceptorAccounts: u32 = 10; + pub const HighSecurityVolumeFee: Permill = Permill::from_percent(1); +} + +impl pallet_reversible_transfers::Config for Test { + type SchedulerOrigin = OriginCaller; + type RuntimeHoldReason = RuntimeHoldReason; + type Scheduler = Scheduler; + type BlockNumberProvider = System; + type MaxPendingPerAccount = MaxReversibleTransfers; + type DefaultDelay = DefaultDelay; + type MinDelayPeriodBlocks = MinDelayPeriodBlocks; + type MinDelayPeriodMoment = MinDelayPeriodMoment; + type PalletId = ReversibleTransfersPalletIdValue; + type Preimages = Preimage; + type WeightInfo = (); + type Moment = Moment; + type TimeProvider = MockTimestamp; + type MaxInterceptorAccounts = MaxInterceptorAccounts; + type VolumeFee = HighSecurityVolumeFee; +} + +parameter_types! { + pub const AssetDeposit: Balance = 0; + pub const AssetAccountDeposit: Balance = 0; + pub const AssetsStringLimit: u32 = 50; + pub const MetadataDepositBase: Balance = 0; + pub const MetadataDepositPerByte: Balance = 0; +} + +impl pallet_assets::Config for Test { + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type AssetId = u32; + type AssetIdParameter = codec::Compact; + type Currency = Balances; + type CreateOrigin = + frame_support::traits::AsEnsureOriginWithArg>; + type ForceOrigin = frame_system::EnsureRoot; + type AssetDeposit = AssetDeposit; + type MetadataDepositBase = MetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type ApprovalDeposit = sp_core::ConstU128<0>; + type StringLimit = AssetsStringLimit; + type Freezer = (); + type Extra = (); + type WeightInfo = (); + type CallbackHandle = pallet_assets::AutoIncAssetId; + type AssetAccountDeposit = AssetAccountDeposit; + type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type Holder = pallet_assets_holder::Pallet; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + +impl pallet_assets_holder::Config for Test { + type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; +} + parameter_types! { pub const ConfigDepositBase: Balance = 1; pub const FriendDepositFactor: Balance = 1; @@ -225,5 +313,9 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); + pallet_reversible_transfers::GenesisConfig:: { initial_high_security_accounts: vec![] } + .assimilate_storage(&mut t) + .unwrap(); + t.into() } diff --git a/runtime/tests/governance/tech_collective.rs b/runtime/tests/governance/tech_collective.rs index 466be8c2..cc232eb0 100644 --- a/runtime/tests/governance/tech_collective.rs +++ b/runtime/tests/governance/tech_collective.rs @@ -8,8 +8,8 @@ mod tests { use quantus_runtime::configs::TechReferendaInstance; use quantus_runtime::{ - Balances, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeOrigin, - TechCollective, TechReferenda, UNIT, + Balances, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeOrigin, TechCollective, + TechReferenda, UNIT, }; use sp_runtime::{traits::Hash, MultiAddress}; From 7b5aec53548dd0841b3236a1fef161d37fe545dc Mon Sep 17 00:00:00 2001 From: Cezary Olborski Date: Thu, 19 Feb 2026 09:12:49 +0800 Subject: [PATCH 3/3] fix: Multisig - benchmark test --- Cargo.lock | 30 ++++++++++++++-------------- pallets/multisig/src/benchmarking.rs | 24 ++++++++++++++++++++-- pallets/multisig/src/tests.rs | 10 +++++++++- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89351fa9..f12b7b84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3040,7 +3040,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.0", + "windows-sys 0.52.0", ] [[package]] @@ -3656,9 +3656,9 @@ dependencies = [ [[package]] name = "frame-system" -version = "41.0.0" +version = "41.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce7df989cefbaab681101774748a1bbbcd23d0cc66e392f8f22d3d3159914db" +checksum = "4189198074d7964bd6cb9d1cf69d77d5d224026bce95bb0ca7efc7768bb8e29c" dependencies = [ "cfg-if", "docify", @@ -4512,7 +4512,7 @@ dependencies = [ "hyper 1.7.0", "libc", "pin-project-lite 0.2.16", - "socket2 0.6.0", + "socket2 0.5.10", "tokio 1.47.1", "tower-service", "tracing", @@ -4894,7 +4894,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi 0.5.2", "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -7265,9 +7265,9 @@ dependencies = [ [[package]] name = "pallet-revive" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "474840408264f98eea7f187839ff2157f83a92bec6f3f3503dbf855c38f4de6b" +checksum = "1459d118aeccd7fef1dfb7e3ea002a376c8f07c61053eb2875acc38b1ceee4d9" dependencies = [ "alloy-core", "derive_more 0.99.20", @@ -8758,7 +8758,7 @@ version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" dependencies = [ - "heck 0.5.0", + "heck 0.4.1", "itertools 0.14.0", "log", "multimap", @@ -9362,7 +9362,7 @@ dependencies = [ "quinn-udp 0.5.14", "rustc-hash 2.1.1", "rustls 0.23.32", - "socket2 0.6.0", + "socket2 0.5.10", "thiserror 2.0.18", "tokio 1.47.1", "tracing", @@ -9430,9 +9430,9 @@ dependencies = [ "cfg_aliases 0.2.1", "libc", "once_cell", - "socket2 0.6.0", + "socket2 0.5.10", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] @@ -9947,7 +9947,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.11.0", - "windows-sys 0.61.0", + "windows-sys 0.52.0", ] [[package]] @@ -10037,7 +10037,7 @@ dependencies = [ "security-framework 3.5.0", "security-framework-sys", "webpki-root-certs 0.26.11", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -13421,7 +13421,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix 1.1.2", - "windows-sys 0.61.0", + "windows-sys 0.52.0", ] [[package]] @@ -14858,7 +14858,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.0", + "windows-sys 0.52.0", ] [[package]] diff --git a/pallets/multisig/src/benchmarking.rs b/pallets/multisig/src/benchmarking.rs index 7089fe10..70facc39 100644 --- a/pallets/multisig/src/benchmarking.rs +++ b/pallets/multisig/src/benchmarking.rs @@ -11,6 +11,24 @@ use frame_support::{traits::fungible::Mutate, BoundedBTreeMap}; const SEED: u32 = 0; +/// Multisig address used by the `propose_high_security` benchmark (signer1+signer2+caller). +/// Exposed so the mock `HighSecurity` can treat it as HS in unit tests. +#[cfg(any(test, feature = "runtime-benchmarks"))] +#[allow(dead_code)] +pub fn propose_high_security_benchmark_multisig_address() -> T::AccountId +where + T: Config + pallet_balances::Config, + BalanceOf2: From, +{ + use frame_benchmarking::v2::{account, whitelisted_caller}; + let caller: T::AccountId = whitelisted_caller(); + let signer1: T::AccountId = account("signer1", 0, SEED); + let signer2: T::AccountId = account("signer2", 1, SEED); + let mut signers = vec![caller, signer1, signer2]; + signers.sort(); + Multisig::::derive_multisig_address(&signers, 2, 0) +} + // Helper to fund an account type BalanceOf2 = ::Balance; @@ -203,11 +221,13 @@ mod benchmarks { /// Benchmark `propose` for high-security multisigs. /// Uses signer1/signer2 so multisig address matches genesis (ReversibleTransfers:: - /// initial_high_security_accounts). HighSecurityAccounts::contains_key reads from trie. + /// initial_high_security_accounts) or mock's HighSecurity (unit tests). + /// Uses whitelisted call (remark "safe") so HS path accepts it. #[benchmark] fn propose_high_security( c: Linear<0, { T::MaxCallSize::get().saturating_sub(100) }>, ) -> Result<(), BenchmarkError> { + let _ = c; let (caller, signers) = setup_funded_signer_set_hs::(); let threshold = 2u32; let multisig_address = insert_multisig::(&caller, &signers, threshold, 0, 0, 0); @@ -217,7 +237,7 @@ mod benchmarks { ); set_block::(100); - let new_call = frame_system::Call::::remark { remark: vec![99u8; c as usize] }; + let new_call = frame_system::Call::::remark { remark: b"safe".to_vec() }; let encoded_call = ::RuntimeCall::from(new_call).encode(); let expiry = frame_system::Pallet::::block_number() + 1000u32.into(); diff --git a/pallets/multisig/src/tests.rs b/pallets/multisig/src/tests.rs index 444661eb..443e9d48 100644 --- a/pallets/multisig/src/tests.rs +++ b/pallets/multisig/src/tests.rs @@ -12,7 +12,15 @@ pub struct MockHighSecurity; impl HighSecurityInspector for MockHighSecurity { fn is_high_security(who: &AccountId32) -> bool { // For testing, account 100 is high security - who == &account_id(100) + if who == &account_id(100) { + return true; + } + // So that bench_propose_high_security passes (mock has no ReversibleTransfers genesis) + #[cfg(feature = "runtime-benchmarks")] + if who == &crate::benchmarking::propose_high_security_benchmark_multisig_address::() { + return true; + } + false } fn is_whitelisted(call: &RuntimeCall) -> bool { // For testing, only remarks with "safe" are whitelisted