From 8fca6fac1162c0fce408e68c1481ea92b295f05d Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Tue, 29 Aug 2023 17:01:07 +0200 Subject: [PATCH 1/2] Review in progress --- pallets/dao-bounties/src/benchmarking.rs | 22 +++++++++++- pallets/dao-collective/src/benchmarking.rs | 12 +++++++ pallets/dao-collective/src/weights.rs | 6 ++++ pallets/dao-subscription/src/benchmarking.rs | 9 +++++ pallets/dao-subscription/src/lib.rs | 35 +++++++++++++++++--- primitives/dao/src/lib.rs | 26 +++++++++++++-- runtime/src/xcm_config.rs | 11 ++++++ 7 files changed, 114 insertions(+), 7 deletions(-) diff --git a/pallets/dao-bounties/src/benchmarking.rs b/pallets/dao-bounties/src/benchmarking.rs index 0fd6685..9b22463 100644 --- a/pallets/dao-bounties/src/benchmarking.rs +++ b/pallets/dao-bounties/src/benchmarking.rs @@ -17,6 +17,21 @@ const SEED: u32 = 0; // Create the pre-requisite information needed to create a dao. fn setup_dao_payload, I: 'static>() -> Vec { + /// let dao_json = json!({ "name": "name", "purpose": "purpose", @@ -41,7 +56,6 @@ fn setup_dao_payload, I: 'static>() -> Vec { fn create_dao, I: 'static>() -> Result<(), DispatchError> { let caller = account("caller", 0, SEED); let data = setup_dao_payload::(); - T::DaoProvider::create_dao(caller, vec![], vec![], data)?; let dao_account_id = T::DaoProvider::dao_account_id(0); @@ -122,6 +136,12 @@ fn assert_last_event, I: 'static>(generic_event: >:: frame_system::Pallet::::assert_last_event(generic_event.into()); } +/// benchmarks_instance_pallet! { create_bounty { create_dao::()?; diff --git a/pallets/dao-collective/src/benchmarking.rs b/pallets/dao-collective/src/benchmarking.rs index e5f8f2c..2d5d515 100644 --- a/pallets/dao-collective/src/benchmarking.rs +++ b/pallets/dao-collective/src/benchmarking.rs @@ -118,6 +118,13 @@ benchmarks_instance_pallet! { let bounded = T::Preimages::bound(proposal.clone())?.transmute(); let proposal_hash = T::Hashing::hash_of(&bounded); + /// let meta: Option> = Some("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \ incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \ exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \ @@ -416,6 +423,11 @@ benchmarks_instance_pallet! { let m in 4 .. T::MaxMembers::get(); let p in 1 .. T::MaxProposals::get(); + /// let bytes = 100; let bytes_in_storage = bytes + size_of::() as u32; diff --git a/pallets/dao-collective/src/weights.rs b/pallets/dao-collective/src/weights.rs index 54e7893..046c0ff 100644 --- a/pallets/dao-collective/src/weights.rs +++ b/pallets/dao-collective/src/weights.rs @@ -149,6 +149,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 50]`. + /// fn close_early_approved(_b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `871 + b * (1 ±0) + m * (64 ±0) + p * (185 ±0)` diff --git a/pallets/dao-subscription/src/benchmarking.rs b/pallets/dao-subscription/src/benchmarking.rs index ace1cc5..0bf9f59 100644 --- a/pallets/dao-subscription/src/benchmarking.rs +++ b/pallets/dao-subscription/src/benchmarking.rs @@ -20,6 +20,15 @@ benchmarks! { set_subscription_tier { let (tier, details) = Subscription::::get_default_tier_details(); + /// is composed by TokenBalances: + /// pub type TokenBalances = BoundedVec<(AssetId, Balance), TokenBalancesLimit>; + /// + /// the call can be called with a different token_prices len size and make a discrepancy with the the default len comming from get_default_tier_details()? + /// + /// + /// ? }: _(RawOrigin::Root, tier.clone(), details.clone()) verify { let subscription_tier = Subscription::::subscription_tiers(tier).unwrap(); diff --git a/pallets/dao-subscription/src/lib.rs b/pallets/dao-subscription/src/lib.rs index b70e222..15ba0e0 100644 --- a/pallets/dao-subscription/src/lib.rs +++ b/pallets/dao-subscription/src/lib.rs @@ -191,7 +191,10 @@ pub mod pallet { tier: VersionedDaoSubscriptionTier, details: SubscriptionDetailsOf, ) -> DispatchResult { - ensure_root(origin.clone())?; + /// + ensure_root(origin)?; Self::do_set_subscription_tier(tier, details) } @@ -203,6 +206,9 @@ pub mod pallet { dao_id: DaoId, reason: SuspensionReason, ) -> DispatchResult { + /// ensure_root(origin.clone())?; Subscriptions::::try_mutate( @@ -295,9 +301,13 @@ pub mod pallet { extra_check(subscription)?; - subscription.fn_balance = fn_balance - .checked_sub(1) - .ok_or(Error::::FunctionBalanceLow)?; + /// + subscription.fn_balance = fn_balance.checked_sub(1).ok_or(Error::::FunctionBalanceLow)?; let (block_number, fn_calls) = subscription.fn_per_block; @@ -330,6 +340,11 @@ pub mod pallet { T::TreasuryPalletId::get().into_account_truncating() } + /// // TODO: try to use default for subscription details pub fn get_default_tier_details() -> (VersionedDaoSubscriptionTier, SubscriptionDetailsOf) { @@ -467,6 +482,13 @@ impl fn unsubscribe(dao_id: DaoId) -> Result<(), DispatchError> { let subscription = Subscriptions::::get(dao_id); if subscription.is_some() { + ///< SBP MR2 + /// + /// Is this the only required action for subscribing ? + /// What about the opther storage items ? I wonder if it worths to do some cleanup for + /// storage optimization once they unsubscribe happens + /// + /// > Subscriptions::::remove(dao_id); Self::deposit_event(Event::DaoUnsubscribed { dao_id }); @@ -549,6 +571,11 @@ impl Self::pay_for_subscription(account_id, &details, token_id)?; + /// subscription.tier = tier.clone(); subscription.details = details.clone(); diff --git a/primitives/dao/src/lib.rs b/primitives/dao/src/lib.rs index 8a20869..02764ca 100644 --- a/primitives/dao/src/lib.rs +++ b/primitives/dao/src/lib.rs @@ -601,8 +601,19 @@ pub enum SuspensionReason { #[derive(Encode, Decode, Clone, PartialEq, TypeInfo, RuntimeDebug, MaxEncodedLen)] pub enum DaoSubscriptionStatus { - Active { until: BlockNumber }, - Suspended { at: BlockNumber, reason: SuspensionReason }, + /// + Active { + until: BlockNumber, + }, + Suspended { + at: BlockNumber, + reason: SuspensionReason, + }, } pub type DaoFunctionBalance = u32; @@ -630,6 +641,17 @@ pub struct DaoSubscription { pub subscribed_at: BlockNumber, pub last_renewed_at: Option, pub status: DaoSubscriptionStatus, + /// pub fn_balance: DaoFunctionBalance, pub fn_per_block: FunctionPerBlock, } diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs index 82aaa90..18bb43c 100644 --- a/runtime/src/xcm_config.rs +++ b/runtime/src/xcm_config.rs @@ -154,6 +154,12 @@ where } } + + /// < SBP MR2 + /// + /// This struct can be removed since is not being used anywhere. + /// + /// > // See issue #5233 pub struct DenyReserveTransferToRelayChain; impl ShouldExecute for DenyReserveTransferToRelayChain { @@ -200,6 +206,11 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { type Barrier = ( TakeWeightCredit, + /// < SBP MR2 + /// + /// AllowTopLevelPaidExecutionFrom duplicated. + /// + /// > AllowTopLevelPaidExecutionFrom, AllowTopLevelPaidExecutionFrom, AllowKnownQueryResponses, From aace0f72b21bc0b6d34b87adccbd197f0d7ff832 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 30 Aug 2023 17:17:15 +0200 Subject: [PATCH 2/2] Last comment --- runtime/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs index 18bb43c..23574ae 100644 --- a/runtime/src/xcm_config.rs +++ b/runtime/src/xcm_config.rs @@ -208,7 +208,7 @@ type Barrier = ( TakeWeightCredit, /// < SBP MR2 /// - /// AllowTopLevelPaidExecutionFrom duplicated. + /// Remove AllowTopLevelPaidExecutionFrom duplicated. /// /// > AllowTopLevelPaidExecutionFrom,