-
Notifications
You must be signed in to change notification settings - Fork 684
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
remove pallet::getter from pallet-staking #6184
base: master
Are you sure you want to change the base?
Conversation
@@ -575,7 +575,7 @@ impl<T: Config> Pallet<T> { | |||
|
|||
let era_duration = (now_as_millis_u64.defensive_saturating_sub(active_era_start)) | |||
.saturated_into::<u64>(); | |||
let staked = Self::eras_total_stake(&active_era.index); | |||
let staked = Self::eras_total_stake(active_era.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.
let staked = Self::eras_total_stake(active_era.index); | |
let staked = ErasTotalStake::<T>::get(&active_era.index); |
Part of the aim here is to replace any usage of Self::storage()
with Storage::<T>::get()
in the sdk codebase
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.
Now it's done. I replaced these usages everywhere I was able to spot them.
} | ||
|
||
/// Get the preferences of a given validator. | ||
pub fn validators<EncodedAccountId>(account_id: EncodedAccountId) -> ValidatorPrefs |
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.
@kianenigma cargo expand shows that FRAME macros actually expand to these (seemingly over-) generic function signatures, is this just to allow args to be passed as a ref or value, or is there another reason? I guess we also need them here to not be a breaking change, or can we make assumptions about usage 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.
Yes it was the goal, it is mostly useful for types like tuples where you can pass a tuple of reference.
Here we can probably take a reference but it would be a breaking change indeed. Some people might be giving a reference some other might be giving the type itself.
The generic should be name EncodeLikeAccountId
, because it is not yet encoded.
Description
Part of #3326
Removes all pallet::getter occurrences from pallet-staking and replaces them with explicit implementations.
Adds tests to verify that retrieval of affected entities works as expected so via storage::getter.
Review Notes
derive
attribute are used in tests (either directly or indirectly).#[pallet::call]
and that requires#[pallet::call_index(0)]
annotation on each function in that block. So I thought it's better to separate them.