From b9be8d71066c5985cba955eda839f38b8b33e94c Mon Sep 17 00:00:00 2001 From: vedhavyas Date: Thu, 17 Oct 2024 13:55:04 +0530 Subject: [PATCH] update treasury parameters and mark deprecated to specific test instead --- pallets/xc-asset-config/src/tests.rs | 8 ++++---- primitives/src/governance.rs | 5 ++++- runtime/local/src/lib.rs | 16 +++++++--------- runtime/shibuya/src/lib.rs | 15 ++++++--------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/pallets/xc-asset-config/src/tests.rs b/pallets/xc-asset-config/src/tests.rs index 80841ab4dd..c834a4f2b2 100644 --- a/pallets/xc-asset-config/src/tests.rs +++ b/pallets/xc-asset-config/src/tests.rs @@ -16,7 +16,6 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -#![allow(deprecated)] use super::{pallet::Error, pallet::Event, *}; use frame_support::{assert_noop, assert_ok, WeakBoundedVec}; use mock::*; @@ -183,7 +182,7 @@ fn change_asset_location_is_ok() { System::assert_last_event(mock::RuntimeEvent::XcAssetConfig( Event::AssetLocationChanged { previous_asset_location: asset_location.clone().into_versioned(), - asset_id: asset_id, + asset_id, new_asset_location: new_asset_location.clone().into_versioned(), }, )); @@ -276,7 +275,7 @@ fn remove_asset_is_ok() { assert_ok!(XcAssetConfig::remove_asset(RuntimeOrigin::root(), asset_id,)); System::assert_last_event(mock::RuntimeEvent::XcAssetConfig(Event::AssetRemoved { asset_location: asset_location.clone().into_versioned(), - asset_id: asset_id, + asset_id, })); // Assert that storage is empty after successful removal @@ -352,7 +351,7 @@ fn public_interfaces_are_ok() { ); assert!(XcAssetConfig::get_units_per_second(asset_location.clone()).is_none()); - // Register ups and expect value value to be returned + // Register ups and expect value to be returned assert_ok!(XcAssetConfig::set_asset_units_per_second( RuntimeOrigin::root(), Box::new(asset_location.clone().into_versioned()), @@ -389,6 +388,7 @@ fn different_xcm_versions_are_ok() { } #[test] +#[allow(deprecated)] fn incompatible_versioned_multilocations_are_not_ok() { ExternalityBuilder::build().execute_with(|| { // Location that cannot be converted from v2 to v4 diff --git a/primitives/src/governance.rs b/primitives/src/governance.rs index a7a1b9094a..124d06fbf5 100644 --- a/primitives/src/governance.rs +++ b/primitives/src/governance.rs @@ -18,7 +18,7 @@ use crate::AccountId; use frame_support::traits::EitherOfDiverse; -use frame_system::EnsureRoot; +use frame_system::{EnsureRoot, EnsureWithSuccess}; pub type OracleMembershipInst = pallet_membership::Instance1; pub type MainCouncilMembershipInst = pallet_membership::Instance2; @@ -44,6 +44,9 @@ pub type EnsureRootOrTwoThirdsMainCouncil = EitherOfDiverse< pallet_collective::EnsureProportionAtLeast, >; +pub type TreasurySpender = + EnsureWithSuccess; + pub type EnsureRootOrHalfMainCouncil = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionAtLeast, diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index e443912c5f..4ff80193b9 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -75,7 +75,7 @@ use astar_primitives::{ EnsureRootOrTwoThirdsCommunityCouncil, EnsureRootOrTwoThirdsMainCouncil, EnsureRootOrTwoThirdsTechnicalCommittee, MainCouncilCollectiveInst, MainCouncilMembershipInst, MainTreasuryInst, TechnicalCommitteeCollectiveInst, - TechnicalCommitteeMembershipInst, + TechnicalCommitteeMembershipInst, TreasurySpender, }, Address, AssetId, Balance, BlockNumber, Hash, Header, Nonce, }; @@ -96,6 +96,7 @@ pub use pallet_timestamp::Call as TimestampCall; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; + #[cfg(feature = "std")] /// Wasm binary unwrapped. If built with `BUILD_DUMMY_WASM_BINARY`, the function panics. pub fn wasm_binary_unwrap() -> &'static [u8] { @@ -1019,8 +1020,8 @@ impl pallet_democracy::Config for Runtime { } parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(5); pub MainTreasuryAccount: AccountId = Treasury::account_id(); + pub const MaxBalance: Balance = Balance::MAX; } impl pallet_treasury::Config for Runtime { @@ -1045,10 +1046,8 @@ impl pallet_treasury::Config for Runtime { type Paymaster = PayFromAccount; type BalanceConverter = UnityAssetBalanceConversion; - // New approach to using treasury, useful for OpenGov but not necessarily for us. - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - // Only used by 'spend' approach which is disabled - type PayoutPeriod = ConstU32<0>; + type SpendOrigin = TreasurySpender; + type PayoutPeriod = ConstU32<{ 30 * MINUTES }>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); type WeightInfo = pallet_treasury::weights::SubstrateWeight; @@ -1081,9 +1080,8 @@ impl pallet_treasury::Config for Runtime { type BalanceConverter = UnityAssetBalanceConversion; // New approach to using treasury, useful for OpenGov but not necessarily for us. - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - // Only used by 'spend' approach which is disabled - type PayoutPeriod = ConstU32<0>; + type SpendOrigin = TreasurySpender; + type PayoutPeriod = ConstU32<{ 30 * MINUTES }>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); type WeightInfo = pallet_treasury::weights::SubstrateWeight; diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 3881b9bec5..bfa98788ff 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -90,7 +90,7 @@ use astar_primitives::{ EnsureRootOrFourFifthsCommunityCouncil, EnsureRootOrHalfCommunityCouncil, EnsureRootOrHalfMainCouncil, EnsureRootOrHalfTechnicalCommittee, MainCouncilCollectiveInst, MainCouncilMembershipInst, MainTreasuryInst, OracleMembershipInst, - TechnicalCommitteeCollectiveInst, TechnicalCommitteeMembershipInst, + TechnicalCommitteeCollectiveInst, TechnicalCommitteeMembershipInst, TreasurySpender, }, oracle::{CurrencyAmount, CurrencyId, DummyCombineData, Price}, xcm::AssetLocationIdConverter, @@ -1409,8 +1409,8 @@ impl pallet_democracy::Config for Runtime { } parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(5); pub MainTreasuryAccount: AccountId = Treasury::account_id(); + pub const MaxBalance: Balance = Balance::MAX; } impl pallet_treasury::Config for Runtime { @@ -1436,9 +1436,8 @@ impl pallet_treasury::Config for Runtime { type BalanceConverter = UnityAssetBalanceConversion; // New approach to using treasury, useful for OpenGov but not necessarily for us. - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - // Only used by 'spend' approach which is disabled - type PayoutPeriod = ConstU32<0>; + type SpendOrigin = TreasurySpender; + type PayoutPeriod = ConstU32<{ 3 * DAYS }>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); type WeightInfo = pallet_treasury::weights::SubstrateWeight; @@ -1470,10 +1469,8 @@ impl pallet_treasury::Config for Runtime { type Paymaster = PayFromAccount; type BalanceConverter = UnityAssetBalanceConversion; - // New approach to using treasury, useful for OpenGov but not necessarily for us. - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - // Only used by 'spend' approach which is disabled - type PayoutPeriod = ConstU32<0>; + type SpendOrigin = TreasurySpender; + type PayoutPeriod = ConstU32<{ 3 * DAYS }>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); type WeightInfo = pallet_treasury::weights::SubstrateWeight;