Skip to content
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

Merged
merged 20 commits into from
Nov 13, 2024

Conversation

Zebedeusz
Copy link
Contributor

@Zebedeusz Zebedeusz commented Oct 23, 2024

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

  1. Traits added to the derive attribute are used in tests (either directly or indirectly).
  2. The getters had to be placed in a separate impl block since the other one is annotated with #[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.

@Zebedeusz Zebedeusz added the T2-pallets This PR/Issue is related to a particular pallet. label Oct 23, 2024
@Zebedeusz Zebedeusz marked this pull request as ready for review October 23, 2024 08:44
@Zebedeusz Zebedeusz requested a review from a team October 23, 2024 09:34
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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.

@paritytech-review-bot paritytech-review-bot bot requested a review from a team October 25, 2024 13:48
@paritytech-review-bot paritytech-review-bot bot requested a review from a team November 8, 2024 13:57
substrate/frame/staking/src/pallet/mod.rs Outdated Show resolved Hide resolved
substrate/frame/staking/src/pallet/mod.rs Outdated Show resolved Hide resolved
@paritytech-review-bot paritytech-review-bot bot requested a review from a team November 8, 2024 17:16
Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One change but then looks good.

substrate/frame/staking/src/pallet/impls.rs Outdated Show resolved Hide resolved
@Zebedeusz Zebedeusz added this pull request to the merge queue Nov 13, 2024
Merged via the queue into master with commit 95d98e6 Nov 13, 2024
194 of 199 checks passed
@Zebedeusz Zebedeusz deleted the zebedeusz/remove_getter_pallet_staking branch November 13, 2024 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants