-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task(bump) Pallet Salary #5163
base: master
Are you sure you want to change the base?
Task(bump) Pallet Salary #5163
Conversation
The CI pipeline was cancelled due to failure one of the required jobs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking this up!
@@ -146,6 +165,7 @@ parameter_types! { | |||
} | |||
|
|||
impl Config for Test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use derive_impl
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we need to
|
||
#[pallet::hooks] | ||
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> { | ||
#[cfg(feature = "experimental")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove experimental now and get this audited. Thoughts @kianenigma @ggwpez ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, some comments
cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml
Outdated
Show resolved
Hide resolved
match res { | ||
Ok(_) => log::info!(target: LOG_TARGET, "Submitted the task."), | ||
Err(e) => log::error!(target: LOG_TARGET, "Error submitting task: {:?}", e), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So every block we try to submit the task?
Is submitting a transaction so cheap? Maybe we should at least verify the task condition before trying to submit it.
maybe we can use the task list here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gupnik what is the recommended way to submit tasks? every pallet do its own offchain worker that calls Task::iter()
? or is there some system offchain worker responsible for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know about this. I think system should have an offchain worker that calls Task::iter()
, otherwise what is the point of the iter method.
cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs
Outdated
Show resolved
Hide resolved
cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs
Outdated
Show resolved
Hide resolved
cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs
Outdated
Show resolved
Hide resolved
cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs
Outdated
Show resolved
Hide resolved
- audience: Runtime Dev | ||
description: | | ||
This PR places `pallet_salary::bump` on an offchain task, this acts as an alternative to | ||
munaul execution (i.e tasks are executed in a random order). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
munaul execution (i.e tasks are executed in a random order). | |
manual execution (i.e tasks are executed in a random order). |
@@ -89,13 +95,16 @@ pub struct ClaimantStatus<CycleIndex, Balance, Id> { | |||
pub mod pallet { | |||
use super::*; | |||
use frame_support::{dispatch::Pays, pallet_prelude::*}; | |||
use frame_system::pallet_prelude::*; | |||
use frame_system::pallet_prelude::{BlockNumberFor, *}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use frame_system::pallet_prelude::{BlockNumberFor, *}; | |
use frame_system::pallet_prelude::*; |
let mut status = Status::<T, I>::get().ok_or(Error::<T, I>::NotStarted)?; | ||
status.cycle_index.saturating_inc(); | ||
status.cycle_start = frame_system::Pallet::<T>::block_number(); | ||
status.budget = T::Budget::get(); | ||
status.total_registrations = Zero::zero(); | ||
status.total_unregistered_paid = Zero::zero(); | ||
Status::<T, I>::put(&status); | ||
|
||
Pallet::deposit_event(Event::<T, I>::CycleStarted { index: status.cycle_index }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can factorize with the bump call into one function: do_bump_unchecked
.
Resolves #4545
Blocked on #5194