mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Pallet AURA: remove pallet::getter macro and write the corresponding code (#3350)
Removed the `pallet::getter` macro call from storage type definitions and added the corresponding implementations directly. fixes #3330 polkadot address: 14JzTPPUd8x8phKi8qLxHgNTnTMg6DUukCLXoWprejkaHXPz --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -63,14 +63,14 @@ pub mod pallet {
|
|||||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||||
fn on_finalize(_: BlockNumberFor<T>) {
|
fn on_finalize(_: BlockNumberFor<T>) {
|
||||||
// Update to the latest AuRa authorities.
|
// Update to the latest AuRa authorities.
|
||||||
Authorities::<T>::put(Aura::<T>::authorities());
|
Authorities::<T>::put(pallet_aura::Authorities::<T>::get());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
||||||
// Fetch the authorities once to get them into the storage proof of the PoV.
|
// Fetch the authorities once to get them into the storage proof of the PoV.
|
||||||
Authorities::<T>::get();
|
Authorities::<T>::get();
|
||||||
|
|
||||||
let new_slot = Aura::<T>::current_slot();
|
let new_slot = pallet_aura::CurrentSlot::<T>::get();
|
||||||
|
|
||||||
let (new_slot, authored) = match SlotInfo::<T>::get() {
|
let (new_slot, authored) = match SlotInfo::<T>::get() {
|
||||||
Some((slot, authored)) if slot == new_slot => (slot, authored + 1),
|
Some((slot, authored)) if slot == new_slot => (slot, authored + 1),
|
||||||
@@ -116,7 +116,7 @@ pub mod pallet {
|
|||||||
#[pallet::genesis_build]
|
#[pallet::genesis_build]
|
||||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||||
fn build(&self) {
|
fn build(&self) {
|
||||||
let authorities = Aura::<T>::authorities();
|
let authorities = pallet_aura::Authorities::<T>::get();
|
||||||
Authorities::<T>::put(authorities);
|
Authorities::<T>::put(authorities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1067,7 +1067,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1098,7 +1098,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -790,7 +790,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -777,7 +777,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -758,7 +758,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
|
||||||
|
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
|
||||||
|
|
||||||
|
title: removed `pallet::getter` from Pallet AURA
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Runtime Dev
|
||||||
|
description: |
|
||||||
|
This PR removes all the declarations of macro `pallet::getter` in the Pallet AURA and replaces the use of storage getter functions authorities() & current_slot() with `StorageItem::get()` API across the crates as listed bellow.
|
||||||
|
The purpose is to discourage developers to use this macro, that is currently being removed and soon will be deprecated.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: pallet-aura
|
||||||
|
- name: solochain-template-runtime
|
||||||
|
- name: cumulus-pallet-aura-ext
|
||||||
|
- name: parachain-template-runtime
|
||||||
|
- name: people-westend-runtime
|
||||||
|
- name: people-rococo-runtime
|
||||||
|
- name: bridge-hub-rococo-runtime
|
||||||
|
- name: bridge-hub-westend-runtime
|
||||||
|
- name: rococo-parachain-runtime
|
||||||
|
- name: penpal-runtime
|
||||||
|
- name: glutton-westend-runtime
|
||||||
|
- name: shell-runtime
|
||||||
|
- name: seedling-runtime
|
||||||
|
- name: collectives-westend-runtime
|
||||||
|
- name: asset-hub-rococo-runtime
|
||||||
|
- name: asset-hub-westend-runtime
|
||||||
|
- name: contracts-rococo-runtime
|
||||||
|
- name: coretime-westend-runtime
|
||||||
|
- name: coretime-rococo-runtime
|
||||||
@@ -161,16 +161,14 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// The current authority set.
|
/// The current authority set.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn authorities)]
|
pub type Authorities<T: Config> =
|
||||||
pub(super) type Authorities<T: Config> =
|
|
||||||
StorageValue<_, BoundedVec<T::AuthorityId, T::MaxAuthorities>, ValueQuery>;
|
StorageValue<_, BoundedVec<T::AuthorityId, T::MaxAuthorities>, ValueQuery>;
|
||||||
|
|
||||||
/// The current slot of this block.
|
/// The current slot of this block.
|
||||||
///
|
///
|
||||||
/// This will be set in `on_initialize`.
|
/// This will be set in `on_initialize`.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn current_slot)]
|
pub type CurrentSlot<T: Config> = StorageValue<_, Slot, ValueQuery>;
|
||||||
pub(super) type CurrentSlot<T: Config> = StorageValue<_, Slot, ValueQuery>;
|
|
||||||
|
|
||||||
#[pallet::genesis_config]
|
#[pallet::genesis_config]
|
||||||
#[derive(frame_support::DefaultNoBound)]
|
#[derive(frame_support::DefaultNoBound)]
|
||||||
@@ -318,7 +316,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
|
|||||||
// instant changes
|
// instant changes
|
||||||
if changed {
|
if changed {
|
||||||
let next_authorities = validators.map(|(_, k)| k).collect::<Vec<_>>();
|
let next_authorities = validators.map(|(_, k)| k).collect::<Vec<_>>();
|
||||||
let last_authorities = Self::authorities();
|
let last_authorities = Authorities::<T>::get();
|
||||||
if last_authorities != next_authorities {
|
if last_authorities != next_authorities {
|
||||||
if next_authorities.len() as u32 > T::MaxAuthorities::get() {
|
if next_authorities.len() as u32 > T::MaxAuthorities::get() {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
@@ -374,7 +372,7 @@ impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::AuthorityId>
|
|||||||
{
|
{
|
||||||
let i = Inner::find_author(digests)?;
|
let i = Inner::find_author(digests)?;
|
||||||
|
|
||||||
let validators = <Pallet<T>>::authorities();
|
let validators = Authorities::<T>::get();
|
||||||
validators.get(i as usize).cloned()
|
validators.get(i as usize).cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,7 +382,7 @@ pub type AuraAuthorId<T> = FindAccountFromAuthorIndex<T, Pallet<T>>;
|
|||||||
|
|
||||||
impl<T: Config> IsMember<T::AuthorityId> for Pallet<T> {
|
impl<T: Config> IsMember<T::AuthorityId> for Pallet<T> {
|
||||||
fn is_member(authority_id: &T::AuthorityId) -> bool {
|
fn is_member(authority_id: &T::AuthorityId) -> bool {
|
||||||
Self::authorities().iter().any(|id| id == authority_id)
|
Authorities::<T>::get().iter().any(|id| id == authority_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
|
||||||
use crate::mock::{build_ext_and_execute_test, Aura, MockDisabledValidators, System};
|
use super::pallet;
|
||||||
|
use crate::mock::{build_ext_and_execute_test, Aura, MockDisabledValidators, System, Test};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_support::traits::OnInitialize;
|
use frame_support::traits::OnInitialize;
|
||||||
use sp_consensus_aura::{Slot, AURA_ENGINE_ID};
|
use sp_consensus_aura::{Slot, AURA_ENGINE_ID};
|
||||||
@@ -28,8 +29,8 @@ use sp_runtime::{Digest, DigestItem};
|
|||||||
#[test]
|
#[test]
|
||||||
fn initial_values() {
|
fn initial_values() {
|
||||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||||
assert_eq!(Aura::current_slot(), 0u64);
|
assert_eq!(pallet::CurrentSlot::<Test>::get(), 0u64);
|
||||||
assert_eq!(Aura::authorities().len(), Aura::authorities_len());
|
assert_eq!(pallet::Authorities::<Test>::get().len(), Aura::authorities_len());
|
||||||
assert_eq!(Aura::authorities_len(), 4);
|
assert_eq!(Aura::authorities_len(), 4);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
|||||||
|
|
||||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||||
|
|
||||||
|
use pallet_aura::Authorities;
|
||||||
|
|
||||||
// XCM Imports
|
// XCM Imports
|
||||||
use xcm::latest::prelude::BodyId;
|
use xcm::latest::prelude::BodyId;
|
||||||
|
|
||||||
@@ -547,7 +549,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
Aura::authorities().into_inner()
|
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user