diff --git a/state-chain/pallets/cf-lp/src/benchmarking.rs b/state-chain/pallets/cf-lp/src/benchmarking.rs index 58c2101cdd..d5e005a65b 100644 --- a/state-chain/pallets/cf-lp/src/benchmarking.rs +++ b/state-chain/pallets/cf-lp/src/benchmarking.rs @@ -2,13 +2,15 @@ use super::*; use cf_chains::{address::EncodedAddress, benchmarking_value::BenchmarkValue}; -use cf_primitives::Asset; -use cf_traits::AccountRoleRegistry; +use cf_primitives::{Asset, FLIPPERINOS_PER_FLIP}; +use cf_traits::{AccountRoleRegistry, FeePayment}; use frame_benchmarking::v2::*; use frame_support::{assert_ok, traits::OnNewAccount}; use frame_system::RawOrigin; -#[benchmarks] +#[benchmarks( + where ::Amount: From +)] mod benchmarks { use super::*; @@ -21,6 +23,8 @@ mod benchmarks { RawOrigin::Signed(caller.clone()).into(), EncodedAddress::Eth(Default::default()), )); + // A non-zero balance is required to pay for the channel opening fee. + T::FeePayment::mint_to_account(&caller, (5 * FLIPPERINOS_PER_FLIP).into()); #[extrinsic_call] request_liquidity_deposit_address(RawOrigin::Signed(caller), Asset::Eth, 0); diff --git a/state-chain/pallets/cf-lp/src/lib.rs b/state-chain/pallets/cf-lp/src/lib.rs index 9426927b11..b440a8ea67 100644 --- a/state-chain/pallets/cf-lp/src/lib.rs +++ b/state-chain/pallets/cf-lp/src/lib.rs @@ -65,6 +65,12 @@ pub mod pallet { /// Benchmark weights type WeightInfo: WeightInfo; + + #[cfg(feature = "runtime-benchmarks")] + type FeePayment: cf_traits::FeePayment< + Amount = ::Amount, + AccountId = ::AccountId, + >; } #[pallet::error] diff --git a/state-chain/pallets/cf-lp/src/mock.rs b/state-chain/pallets/cf-lp/src/mock.rs index 9faa0d4591..91bafa9b9e 100644 --- a/state-chain/pallets/cf-lp/src/mock.rs +++ b/state-chain/pallets/cf-lp/src/mock.rs @@ -5,6 +5,8 @@ use cf_chains::{ AnyChain, Chain, Ethereum, }; use cf_primitives::{chains::assets, AccountId, ChannelId}; +#[cfg(feature = "runtime-benchmarks")] +use cf_traits::mocks::fee_payment::MockFeePayment; use cf_traits::{ impl_mock_chainflip, impl_mock_runtime_safe_mode, mocks::{ @@ -102,6 +104,8 @@ impl crate::Config for Test { type SafeMode = MockRuntimeSafeMode; type WeightInfo = (); type PoolApi = Self; + #[cfg(feature = "runtime-benchmarks")] + type FeePayment = MockFeePayment; } pub const LP_ACCOUNT: [u8; 32] = [1u8; 32]; diff --git a/state-chain/pallets/cf-swapping/src/benchmarking.rs b/state-chain/pallets/cf-swapping/src/benchmarking.rs index 4df33f7f8f..5e22749da8 100644 --- a/state-chain/pallets/cf-swapping/src/benchmarking.rs +++ b/state-chain/pallets/cf-swapping/src/benchmarking.rs @@ -3,7 +3,8 @@ use super::*; use cf_chains::{address::EncodedAddress, benchmarking_value::BenchmarkValue}; -use cf_traits::AccountRoleRegistry; +use cf_primitives::FLIPPERINOS_PER_FLIP; +use cf_traits::{AccountRoleRegistry, FeePayment}; use frame_benchmarking::v2::*; use frame_support::{ assert_ok, @@ -11,7 +12,9 @@ use frame_support::{ }; use frame_system::RawOrigin; -#[benchmarks] +#[benchmarks( + where ::Amount: From +)] mod benchmarks { use super::*; @@ -20,6 +23,8 @@ mod benchmarks { let caller: T::AccountId = whitelisted_caller(); ::OnNewAccount::on_new_account(&caller); assert_ok!(T::AccountRoleRegistry::register_as_broker(&caller)); + // A non-zero balance is required to pay for the channel opening fee. + T::FeePayment::mint_to_account(&caller, (5 * FLIPPERINOS_PER_FLIP).into()); let origin = RawOrigin::Signed(caller); let call = Call::::request_swap_deposit_address { diff --git a/state-chain/pallets/cf-swapping/src/lib.rs b/state-chain/pallets/cf-swapping/src/lib.rs index 6585e680b8..a48da63726 100644 --- a/state-chain/pallets/cf-swapping/src/lib.rs +++ b/state-chain/pallets/cf-swapping/src/lib.rs @@ -226,6 +226,12 @@ pub mod pallet { /// The Weight information. type WeightInfo: WeightInfo; + + #[cfg(feature = "runtime-benchmarks")] + type FeePayment: cf_traits::FeePayment< + Amount = ::Amount, + AccountId = ::AccountId, + >; } #[pallet::pallet] diff --git a/state-chain/pallets/cf-swapping/src/mock.rs b/state-chain/pallets/cf-swapping/src/mock.rs index 63f37b4a72..7c095bd1f3 100644 --- a/state-chain/pallets/cf-swapping/src/mock.rs +++ b/state-chain/pallets/cf-swapping/src/mock.rs @@ -3,6 +3,8 @@ use core::cell::Cell; use crate::{self as pallet_cf_swapping, PalletSafeMode, WeightInfo}; use cf_chains::AnyChain; use cf_primitives::{Asset, AssetAmount}; +#[cfg(feature = "runtime-benchmarks")] +use cf_traits::mocks::fee_payment::MockFeePayment; use cf_traits::{ impl_mock_chainflip, impl_mock_runtime_safe_mode, mocks::{ @@ -140,6 +142,8 @@ impl pallet_cf_swapping::Config for Test { type SwappingApi = MockSwappingApi; type SafeMode = MockRuntimeSafeMode; type WeightInfo = MockWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type FeePayment = MockFeePayment; } pub const ALICE: ::AccountId = 123u64; diff --git a/state-chain/runtime/src/lib.rs b/state-chain/runtime/src/lib.rs index 5f277806b2..9e122982e0 100644 --- a/state-chain/runtime/src/lib.rs +++ b/state-chain/runtime/src/lib.rs @@ -235,6 +235,8 @@ impl pallet_cf_swapping::Config for Runtime { type AddressConverter = ChainAddressConverter; type SafeMode = RuntimeSafeMode; type WeightInfo = pallet_cf_swapping::weights::PalletWeight; + #[cfg(feature = "runtime-benchmarks")] + type FeePayment = Flip; } impl pallet_cf_vaults::Config for Runtime { @@ -349,6 +351,8 @@ impl pallet_cf_lp::Config for Runtime { type SafeMode = RuntimeSafeMode; type PoolApi = LiquidityPools; type WeightInfo = pallet_cf_lp::weights::PalletWeight; + #[cfg(feature = "runtime-benchmarks")] + type FeePayment = Flip; } impl pallet_cf_account_roles::Config for Runtime {