From 43fa7a64e8b33e49c46aea5bcfdfb940eebfc096 Mon Sep 17 00:00:00 2001 From: Just van Stam Date: Wed, 19 Jun 2024 15:33:02 +0200 Subject: [PATCH] fix wrong fallback weight in on_initialize --- pallets/funding/src/lib.rs | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8b34935fc..1f0841ca4 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1164,14 +1164,14 @@ pub mod pallet { Self::do_evaluation_end(project_id) } - #[pallet::call_index(59)] + #[pallet::call_index(29)] #[pallet::weight(WeightInfoOf::::start_auction_manually(::MaxProjectsToUpdateInsertionAttempts::get() - 1))] pub fn root_do_auction_opening(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { ensure_root(origin)?; Self::do_start_auction_opening(T::PalletId::get().into_account_truncating(), project_id) } - #[pallet::call_index(29)] + #[pallet::call_index(30)] #[pallet::weight(WeightInfoOf::::start_auction_closing_phase( ::MaxProjectsToUpdateInsertionAttempts::get() - 1, ))] @@ -1183,7 +1183,28 @@ pub mod pallet { Self::do_start_auction_closing(project_id) } - #[pallet::call_index(30)] + #[pallet::call_index(31)] + #[pallet::weight(WeightInfoOf::::end_auction_closing( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + ::MaxBidsPerProject::get() / 2, + ::MaxBidsPerProject::get() / 2, + ) + .max(WeightInfoOf::::end_auction_closing( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + ::MaxBidsPerProject::get(), + 0u32, + )) + .max(WeightInfoOf::::end_auction_closing( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + 0u32, + ::MaxBidsPerProject::get(), + )))] + pub fn root_do_end_auction_closing(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + Self::do_end_auction_closing(project_id) + } + + #[pallet::call_index(32)] #[pallet::weight(WeightInfoOf::::start_community_funding( ::MaxProjectsToUpdateInsertionAttempts::get() - 1, ::MaxBidsPerProject::get() / 2, @@ -1204,7 +1225,7 @@ pub mod pallet { Self::do_start_community_funding(project_id) } - #[pallet::call_index(31)] + #[pallet::call_index(33)] #[pallet::weight(WeightInfoOf::::start_remainder_funding( ::MaxProjectsToUpdateInsertionAttempts::get() - 1, ))] @@ -1213,7 +1234,7 @@ pub mod pallet { Self::do_start_remainder_funding(project_id) } - #[pallet::call_index(32)] + #[pallet::call_index(34)] #[pallet::weight(WeightInfoOf::::end_funding_automatically_rejected_evaluators_slashed( ::MaxProjectsToUpdateInsertionAttempts::get() - 1, ) @@ -1232,7 +1253,7 @@ pub mod pallet { Self::do_end_funding(project_id) } - #[pallet::call_index(33)] + #[pallet::call_index(36)] #[pallet::weight(WeightInfoOf::::project_decision())] pub fn root_do_project_decision( origin: OriginFor, @@ -1243,7 +1264,7 @@ pub mod pallet { Self::do_project_decision(project_id, decision) } - #[pallet::call_index(34)] + #[pallet::call_index(37)] #[pallet::weight(WeightInfoOf::::start_settlement_funding_success() .max(WeightInfoOf::::start_settlement_funding_failure()))] pub fn root_do_start_settlement(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { @@ -1306,7 +1327,7 @@ pub mod pallet { UpdateType::AuctionClosingEnd => { let call = Self::do_end_auction_closing(project_id); let fallback_weight = - Call::::root_do_start_auction_closing { project_id }.get_dispatch_info().weight; + Call::::root_do_end_auction_closing { project_id }.get_dispatch_info().weight; update_weight(&mut used_weight, call, fallback_weight); },