From ca6b929718b5333d5bee95a649168d9291b4f1c2 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 16:30:31 +0530 Subject: [PATCH 01/10] remove getter from lib --- substrate/frame/babe/src/lib.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 686ba6ec2d63..bdceed11f1b2 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -185,12 +185,10 @@ pub mod pallet { /// Current epoch index. #[pallet::storage] - #[pallet::getter(fn epoch_index)] pub type EpochIndex = StorageValue<_, u64, ValueQuery>; /// Current epoch authorities. #[pallet::storage] - #[pallet::getter(fn authorities)] pub type Authorities = StorageValue< _, WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>, @@ -200,12 +198,10 @@ pub mod pallet { /// The slot at which the first epoch actually started. This is 0 /// until the first block of the chain. #[pallet::storage] - #[pallet::getter(fn genesis_slot)] pub type GenesisSlot = StorageValue<_, Slot, ValueQuery>; /// Current slot number. #[pallet::storage] - #[pallet::getter(fn current_slot)] pub type CurrentSlot = StorageValue<_, Slot, ValueQuery>; /// The epoch randomness for the *current* epoch. @@ -222,7 +218,6 @@ pub mod pallet { // array size because the metadata API currently doesn't resolve the // variable to its underlying value. #[pallet::storage] - #[pallet::getter(fn randomness)] pub type Randomness = StorageValue<_, BabeRandomness, ValueQuery>; /// Pending epoch configuration change that will be applied when the next epoch is enacted. @@ -266,7 +261,6 @@ pub mod pallet { /// Temporary value (cleared at block finalization) which is `Some` /// if per-block initialization has already been called for current block. #[pallet::storage] - #[pallet::getter(fn initialized)] pub(super) type Initialized = StorageValue<_, Option>; /// This field should always be populated during block processing unless @@ -274,7 +268,6 @@ pub mod pallet { /// /// It is set in `on_finalize`, before it will contain the value from the last block. #[pallet::storage] - #[pallet::getter(fn author_vrf_randomness)] pub(super) type AuthorVrfRandomness = StorageValue<_, Option, ValueQuery>; /// The block numbers when the last and current epoch have started, respectively `N-1` and @@ -292,13 +285,11 @@ pub mod pallet { /// on block finalization. Querying this storage entry outside of block /// execution context should always yield zero. #[pallet::storage] - #[pallet::getter(fn lateness)] pub(super) type Lateness = StorageValue<_, BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. #[pallet::storage] - #[pallet::getter(fn epoch_config)] pub(super) type EpochConfig = StorageValue<_, BabeEpochConfiguration>; /// The configuration for the next epoch, `None` if the config will not change @@ -315,7 +306,6 @@ pub mod pallet { /// a validator was the owner of a given key on a given session, and what the /// active epoch index was during that session. #[pallet::storage] - #[pallet::getter(fn skipped_epochs)] pub(super) type SkippedEpochs = StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>; From 5c3cd46a6eb4be6e1e9eee78690d2ecfaead62fc Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 16:56:39 +0530 Subject: [PATCH 02/10] remove usage of getter functions in lib --- substrate/frame/babe/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index bdceed11f1b2..85b47277cb5f 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -97,7 +97,7 @@ pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { fn trigger(now: BlockNumberFor) { if >::should_epoch_change(now) { - let authorities = >::authorities(); + let authorities = Authorities::::get(); let next_authorities = authorities.clone(); >::enact_epoch_change(authorities, next_authorities, None); @@ -358,7 +358,7 @@ pub mod pallet { .and_then(|(authority, _)| { let public = authority.as_inner_ref(); let transcript = sp_consensus_babe::make_vrf_transcript( - &Self::randomness(), + &Randomness::::get(), CurrentSlot::::get(), EpochIndex::::get(), ); @@ -500,7 +500,7 @@ impl FindAuthor for Pallet { impl IsMember for Pallet { fn is_member(authority_id: &AuthorityId) -> bool { - >::authorities().iter().any(|id| &id.0 == authority_id) + Authorities::::get().iter().any(|id| &id.0 == authority_id) } } @@ -578,7 +578,7 @@ impl Pallet { ) { // PRECONDITION: caller has done initialization and is guaranteed // by the session module to be called before this. - debug_assert!(Self::initialized().is_some()); + debug_assert!(Initialized::::get().is_some()); if authorities.is_empty() { log::warn!(target: LOG_TARGET, "Ignoring empty epoch change."); @@ -691,8 +691,8 @@ impl Pallet { epoch_index: EpochIndex::::get(), start_slot: Self::current_epoch_start(), duration: T::EpochDuration::get(), - authorities: Self::authorities().into_inner(), - randomness: Self::randomness(), + authorities: Authorities::::get().into_inner(), + randomness: Randomness::::get(), config: EpochConfig::::get() .expect("EpochConfig is initialized in genesis; we never `take` or `kill` it; qed"), } @@ -769,8 +769,8 @@ impl Pallet { // we use the same values as genesis because we haven't collected any // randomness yet. let next = NextEpochDescriptor { - authorities: Self::authorities().into_inner(), - randomness: Self::randomness(), + authorities: Authorities::::get().into_inner(), + randomness: Randomness::::get(), }; Self::deposit_consensus(ConsensusLog::NextEpochData(next)); @@ -779,7 +779,7 @@ impl Pallet { fn initialize(now: BlockNumberFor) { // since `initialize` can be called twice (e.g. if session module is present) // let's ensure that we only do the initialization once per block - let initialized = Self::initialized().is_some(); + let initialized = Initialized::::get().is_some(); if initialized { return } @@ -930,7 +930,7 @@ impl frame_support::traits::EstimateNextSessionRotation frame_support::traits::Lateness> for Pallet { fn lateness(&self) -> BlockNumberFor { - Self::lateness() + Lateness::::get() } } From 33c8ca1ee7cfec1eaeeac457b2f022af11407af5 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 17:38:17 +0530 Subject: [PATCH 03/10] remove getter function usage from test file --- substrate/frame/babe/src/mock.rs | 4 +- substrate/frame/babe/src/tests.rs | 73 ++++++++++++++++--------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index be38e3e7e5db..96f72e78f3dd 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -213,7 +213,7 @@ pub fn go_to_block(n: u64, s: u64) { /// Slots will grow accordingly to blocks pub fn progress_to_block(n: u64) { - let mut slot = u64::from(Babe::current_slot()) + 1; + let mut slot = u64::from(CurrentSlot::::get()) + 1; for i in System::block_number() + 1..=n { go_to_block(i, slot); slot += 1; @@ -272,7 +272,7 @@ pub fn make_vrf_signature_and_randomness( slot: Slot, pair: &sp_consensus_babe::AuthorityPair, ) -> (VrfSignature, Randomness) { - let transcript = sp_consensus_babe::make_vrf_transcript(&Babe::randomness(), slot, 0); + let transcript = sp_consensus_babe::make_vrf_transcript(&pallet_babe::Randomness::::get(), slot, 0); let randomness = pair.as_ref().make_bytes(sp_consensus_babe::RANDOMNESS_VRF_CONTEXT, &transcript); diff --git a/substrate/frame/babe/src/tests.rs b/substrate/frame/babe/src/tests.rs index e65f1844f88f..fcb707307d4b 100644 --- a/substrate/frame/babe/src/tests.rs +++ b/substrate/frame/babe/src/tests.rs @@ -43,7 +43,7 @@ fn empty_randomness_is_correct() { #[test] fn initial_values() { - new_test_ext(4).execute_with(|| assert_eq!(Babe::authorities().len(), 4)) + new_test_ext(4).execute_with(|| assert_eq!(Authorities::::get().len(), 4)) } #[test] @@ -68,25 +68,25 @@ fn first_block_epoch_zero_start() { let pre_digest = make_primary_pre_digest(0, genesis_slot, vrf_signature); - assert_eq!(Babe::genesis_slot(), Slot::from(0)); + assert_eq!(GenesisSlot::::get(), Slot::from(0)); System::reset_events(); System::initialize(&1, &Default::default(), &pre_digest); // see implementation of the function for details why: we issue an // epoch-change digest but don't do it via the normal session mechanism. assert!(!Babe::should_end_session(1)); - assert_eq!(Babe::genesis_slot(), genesis_slot); - assert_eq!(Babe::current_slot(), genesis_slot); - assert_eq!(Babe::epoch_index(), 0); + assert_eq!(GenesisSlot::::get(), genesis_slot); + assert_eq!(CurrentSlot::::get(), genesis_slot); + assert_eq!(EpochIndex::::get(), 0); Babe::on_finalize(1); let header = System::finalize(); - assert_eq!(Babe::author_vrf_randomness(), Some(vrf_randomness)); + assert_eq!(AuthorVrfRandomness::::get(), Some(vrf_randomness)); assert_eq!(SegmentIndex::::get(), 0); assert_eq!(UnderConstruction::::get(0), vec![vrf_randomness]); - assert_eq!(Babe::randomness(), [0; 32]); - assert_eq!(Babe::author_vrf_randomness(), Some(vrf_randomness)); + assert_eq!(Randomness::::get(), [0; 32]); + assert_eq!(AuthorVrfRandomness::::get(), Some(vrf_randomness)); assert_eq!(NextRandomness::::get(), [0; 32]); assert_eq!(header.digest.logs.len(), 2); @@ -95,8 +95,8 @@ fn first_block_epoch_zero_start() { let consensus_log = sp_consensus_babe::ConsensusLog::NextEpochData( sp_consensus_babe::digests::NextEpochDescriptor { - authorities: Babe::authorities().into_inner(), - randomness: Babe::randomness(), + authorities: Authorities::::get().into_inner(), + randomness: Randomness::::get(), }, ); let consensus_digest = DigestItem::Consensus(BABE_ENGINE_ID, consensus_log.encode()); @@ -118,19 +118,19 @@ fn current_slot_is_processed_on_initialization() { System::reset_events(); System::initialize(&1, &Default::default(), &pre_digest); - assert_eq!(Babe::current_slot(), Slot::from(0)); - assert!(Babe::initialized().is_none()); + assert_eq!(CurrentSlot::::get(), Slot::from(0)); + assert!(Initialized::::get().is_none()); // current slot is updated on initialization Babe::initialize(1); - assert_eq!(Babe::current_slot(), genesis_slot); - assert!(Babe::initialized().is_some()); + assert_eq!(CurrentSlot::::get(), genesis_slot); + assert!(Initialized::::get().is_some()); // but author vrf randomness isn't - assert_eq!(Babe::author_vrf_randomness(), None); + assert_eq!(AuthorVrfRandomness::::get(), None); // instead it is updated on block finalization Babe::on_finalize(1); - assert_eq!(Babe::author_vrf_randomness(), Some(vrf_randomness)); + assert_eq!(AuthorVrfRandomness::::get(), Some(vrf_randomness)); }) } @@ -151,16 +151,16 @@ where // author vrf randomness is not updated on initialization Babe::initialize(1); - assert_eq!(Babe::author_vrf_randomness(), None); + assert_eq!(AuthorVrfRandomness::::get(), None); // instead it is updated on block finalization to account for any // epoch changes that might happen during the block Babe::on_finalize(1); - assert_eq!(Babe::author_vrf_randomness(), Some(vrf_randomness)); + assert_eq!(AuthorVrfRandomness::::get(), Some(vrf_randomness)); // and it is kept after finalizing the block System::finalize(); - assert_eq!(Babe::author_vrf_randomness(), Some(vrf_randomness)); + assert_eq!(AuthorVrfRandomness::::get(), Some(vrf_randomness)); }) } @@ -182,14 +182,14 @@ fn no_author_vrf_output_for_secondary_plain() { System::reset_events(); System::initialize(&1, &Default::default(), &secondary_plain_pre_digest); - assert_eq!(Babe::author_vrf_randomness(), None); + assert_eq!(AuthorVrfRandomness::::get(), None); Babe::initialize(1); - assert_eq!(Babe::author_vrf_randomness(), None); + assert_eq!(AuthorVrfRandomness::::get(), None); Babe::on_finalize(1); System::finalize(); - assert_eq!(Babe::author_vrf_randomness(), None); + assert_eq!(AuthorVrfRandomness::::get(), None); }) } @@ -210,14 +210,14 @@ fn can_predict_next_epoch_change() { assert_eq!(::EpochDuration::get(), 3); // this sets the genesis slot to 6; go_to_block(1, 6); - assert_eq!(*Babe::genesis_slot(), 6); - assert_eq!(*Babe::current_slot(), 6); - assert_eq!(Babe::epoch_index(), 0); + assert_eq!(*GenesisSlot::::get(), 6); + assert_eq!(*CurrentSlot::::get(), 6); + assert_eq!(EpochIndex::::get(), 0); progress_to_block(5); - assert_eq!(Babe::epoch_index(), 5 / 3); - assert_eq!(*Babe::current_slot(), 10); + assert_eq!(EpochIndex::::get(), 5 / 3); + assert_eq!(*CurrentSlot::::get(), 10); // next epoch change will be at assert_eq!(*Babe::current_epoch_start(), 9); // next change will be 12, 2 slots from now @@ -266,9 +266,9 @@ fn can_enact_next_config() { assert_eq!(::EpochDuration::get(), 3); // this sets the genesis slot to 6; go_to_block(1, 6); - assert_eq!(*Babe::genesis_slot(), 6); - assert_eq!(*Babe::current_slot(), 6); - assert_eq!(Babe::epoch_index(), 0); + assert_eq!(*GenesisSlot::::get(), 6); + assert_eq!(*CurrentSlot::::get(), 6); + assert_eq!(EpochIndex::::get(), 0); go_to_block(2, 7); let current_config = BabeEpochConfiguration { @@ -431,7 +431,7 @@ fn report_equivocation_current_session_works() { ext.execute_with(|| { start_era(1); - let authorities = Babe::authorities(); + let authorities = Authorities::::get(); let validators = Session::validators(); // make sure that all authorities have the same balance @@ -508,7 +508,7 @@ fn report_equivocation_old_session_works() { ext.execute_with(|| { start_era(1); - let authorities = Babe::authorities(); + let authorities = Authorities::::get(); // we will use the validator at index 0 as the offending authority let offending_validator_index = 1; @@ -566,7 +566,7 @@ fn report_equivocation_invalid_key_owner_proof() { ext.execute_with(|| { start_era(1); - let authorities = Babe::authorities(); + let authorities = Authorities::::get(); // we will use the validator at index 0 as the offending authority let offending_validator_index = 0; @@ -629,7 +629,7 @@ fn report_equivocation_invalid_equivocation_proof() { ext.execute_with(|| { start_era(1); - let authorities = Babe::authorities(); + let authorities = Authorities::::get(); // we will use the validator at index 0 as the offending authority let offending_validator_index = 0; @@ -734,7 +734,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() { ext.execute_with(|| { start_era(1); - let authorities = Babe::authorities(); + let authorities = Authorities::::get(); // generate and report an equivocation for the validator at index 0 let offending_validator_index = 0; @@ -848,7 +848,7 @@ fn report_equivocation_after_skipped_epochs_works() { assert_eq!(SkippedEpochs::::get(), vec![(10, 1)]); // generate an equivocation proof for validator at index 1 - let authorities = Babe::authorities(); + let authorities = Authorities::::get(); let offending_validator_index = 1; let offending_authority_pair = pairs .into_iter() @@ -1044,3 +1044,4 @@ fn skipping_over_epochs_works() { assert_eq!(Babe::session_index_for_epoch(5), 3); }); } + From 09840f3286dd705967d275448c79a24f71cd47f2 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 22:02:45 +0530 Subject: [PATCH 04/10] remove turbofish --- substrate/frame/babe/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 85b47277cb5f..7e483e374b3e 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -96,11 +96,11 @@ pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { fn trigger(now: BlockNumberFor) { - if >::should_epoch_change(now) { + if Pallet::::should_epoch_change(now) { let authorities = Authorities::::get(); let next_authorities = authorities.clone(); - >::enact_epoch_change(authorities, next_authorities, None); + Pallet::::enact_epoch_change(authorities, next_authorities, None); } } } @@ -645,7 +645,7 @@ impl Pallet { NextAuthorities::::put(&next_authorities); // Update the start blocks of the previous and new current epoch. - >::mutate(|(previous_epoch_start_block, current_epoch_start_block)| { + EpochStart::::mutate(|(previous_epoch_start_block, current_epoch_start_block)| { *previous_epoch_start_block = sp_std::mem::take(current_epoch_start_block); *current_epoch_start_block = >::block_number(); }); From 6e409cdc9697178256a40b00855a061dcf0fed92 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 22:28:48 +0530 Subject: [PATCH 05/10] added public function for storage --- substrate/frame/babe/src/lib.rs | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 7e483e374b3e..c33e7ffde8b1 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -516,6 +516,47 @@ impl pallet_session::ShouldEndSession> for Pallet Pallet { + /// Public function to access epoch_index storage. + pub fn epoch_index() -> u64 { + EpochIndex::::get() + } + /// Public function to access authorities storage. + pub fn authorities() -> WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities> { + Authorities::::get() + } + /// Public function to access genesis_slot storage. + pub fn genesis_slot() -> Slot { + GenesisSlot::::get() + } + /// Public function to access current_slot storage. + pub fn current_slot() -> Slot { + CurrentSlot::::get() + } + /// Public function to access randomness storage. + pub fn randomness() -> BabeRandomness { + Randomness::::get() + } + /// Public function to access initialized storage. + pub fn initialized() -> Option> { + Initialized::::get() + } + /// Public function to access author_vrf_randomness storage. + pub fn author_vrf_randomness() -> Option { + AuthorVrfRandomness::::get() + } + /// Public function to access lateness storage. + pub fn lateness() -> BlockNumberFor { + Lateness::::get() + } + /// Public function to access epoch_config storage. + pub fn epoch_config() -> Option { + EpochConfig::::get() + } + /// Public function to access skipped_epochs storage. + pub fn skipped_epochs() -> BoundedVec<(u64, SessionIndex), ConstU32<100>> { + SkippedEpochs::::get() + } + /// Determine the BABE slot duration based on the Timestamp module configuration. pub fn slot_duration() -> T::Moment { // we double the minimum block-period so each author can always propose within From 640268451da2a2b266e650d961cd5d533c0db15e Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 22:29:27 +0530 Subject: [PATCH 06/10] fmt --- substrate/frame/babe/src/lib.rs | 4 ++-- substrate/frame/babe/src/mock.rs | 3 ++- substrate/frame/babe/src/tests.rs | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index c33e7ffde8b1..788066f90e9d 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -521,11 +521,11 @@ impl Pallet { EpochIndex::::get() } /// Public function to access authorities storage. - pub fn authorities() -> WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities> { + pub fn authorities() -> WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities> { Authorities::::get() } /// Public function to access genesis_slot storage. - pub fn genesis_slot() -> Slot { + pub fn genesis_slot() -> Slot { GenesisSlot::::get() } /// Public function to access current_slot storage. diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 96f72e78f3dd..e193a2e3b645 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -272,7 +272,8 @@ pub fn make_vrf_signature_and_randomness( slot: Slot, pair: &sp_consensus_babe::AuthorityPair, ) -> (VrfSignature, Randomness) { - let transcript = sp_consensus_babe::make_vrf_transcript(&pallet_babe::Randomness::::get(), slot, 0); + let transcript = + sp_consensus_babe::make_vrf_transcript(&pallet_babe::Randomness::::get(), slot, 0); let randomness = pair.as_ref().make_bytes(sp_consensus_babe::RANDOMNESS_VRF_CONTEXT, &transcript); diff --git a/substrate/frame/babe/src/tests.rs b/substrate/frame/babe/src/tests.rs index fcb707307d4b..b9a214ca105c 100644 --- a/substrate/frame/babe/src/tests.rs +++ b/substrate/frame/babe/src/tests.rs @@ -1044,4 +1044,3 @@ fn skipping_over_epochs_works() { assert_eq!(Babe::session_index_for_epoch(5), 3); }); } - From 33c0efba18cfda81679c968f22345e7b3bead8ae Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 22:31:41 +0530 Subject: [PATCH 07/10] pr_doc --- prdoc/pr_4908.prdoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 prdoc/pr_4908.prdoc diff --git a/prdoc/pr_4908.prdoc b/prdoc/pr_4908.prdoc new file mode 100644 index 000000000000..4b508a511168 --- /dev/null +++ b/prdoc/pr_4908.prdoc @@ -0,0 +1,14 @@ +# 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` usage from the pallet-babe + +doc: + - audience: Runtime Dev + description: | + This PR removed `pallet::getter`s from `pallet-babe`s storage items. + When accessed inside the pallet, use the syntax `StorageItem::::get()`. + +crates: + - name: pallet-babe + bump: minor From b1a8aec6d62b0d4fc1e45b5c5918435526f0e925 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Fri, 28 Jun 2024 22:34:31 +0530 Subject: [PATCH 08/10] refactor prdoc --- prdoc/{pr_4908.prdoc => pr_4912.prdoc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prdoc/{pr_4908.prdoc => pr_4912.prdoc} (100%) diff --git a/prdoc/pr_4908.prdoc b/prdoc/pr_4912.prdoc similarity index 100% rename from prdoc/pr_4908.prdoc rename to prdoc/pr_4912.prdoc From 88fc283a60fb638db73947db6e59f2c5de4c8cb6 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Sat, 29 Jun 2024 11:45:57 +0530 Subject: [PATCH 09/10] remove super --- substrate/frame/babe/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 788066f90e9d..9e16f1d09515 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -222,15 +222,15 @@ pub mod pallet { /// Pending epoch configuration change that will be applied when the next epoch is enacted. #[pallet::storage] - pub(super) type PendingEpochConfigChange = StorageValue<_, NextConfigDescriptor>; + pub type PendingEpochConfigChange = StorageValue<_, NextConfigDescriptor>; /// Next epoch randomness. #[pallet::storage] - pub(super) type NextRandomness = StorageValue<_, BabeRandomness, ValueQuery>; + pub type NextRandomness = StorageValue<_, BabeRandomness, ValueQuery>; /// Next epoch authorities. #[pallet::storage] - pub(super) type NextAuthorities = StorageValue< + pub type NextAuthorities = StorageValue< _, WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>, ValueQuery, @@ -246,11 +246,11 @@ pub mod pallet { /// We reset all segments and return to `0` at the beginning of every /// epoch. #[pallet::storage] - pub(super) type SegmentIndex = StorageValue<_, u32, ValueQuery>; + pub type SegmentIndex = StorageValue<_, u32, ValueQuery>; /// TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay. #[pallet::storage] - pub(super) type UnderConstruction = StorageMap< + pub type UnderConstruction = StorageMap< _, Twox64Concat, u32, @@ -261,14 +261,14 @@ pub mod pallet { /// Temporary value (cleared at block finalization) which is `Some` /// if per-block initialization has already been called for current block. #[pallet::storage] - pub(super) type Initialized = StorageValue<_, Option>; + pub type Initialized = StorageValue<_, Option>; /// This field should always be populated during block processing unless /// secondary plain slots are enabled (which don't contain a VRF output). /// /// It is set in `on_finalize`, before it will contain the value from the last block. #[pallet::storage] - pub(super) type AuthorVrfRandomness = StorageValue<_, Option, ValueQuery>; + pub type AuthorVrfRandomness = StorageValue<_, Option, ValueQuery>; /// The block numbers when the last and current epoch have started, respectively `N-1` and /// `N`. @@ -285,17 +285,17 @@ pub mod pallet { /// on block finalization. Querying this storage entry outside of block /// execution context should always yield zero. #[pallet::storage] - pub(super) type Lateness = StorageValue<_, BlockNumberFor, ValueQuery>; + pub type Lateness = StorageValue<_, BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. #[pallet::storage] - pub(super) type EpochConfig = StorageValue<_, BabeEpochConfiguration>; + pub type EpochConfig = StorageValue<_, BabeEpochConfiguration>; /// The configuration for the next epoch, `None` if the config will not change /// (you can fallback to `EpochConfig` instead in that case). #[pallet::storage] - pub(super) type NextEpochConfig = StorageValue<_, BabeEpochConfiguration>; + pub type NextEpochConfig = StorageValue<_, BabeEpochConfiguration>; /// A list of the last 100 skipped epochs and the corresponding session index /// when the epoch was skipped. @@ -306,7 +306,7 @@ pub mod pallet { /// a validator was the owner of a given key on a given session, and what the /// active epoch index was during that session. #[pallet::storage] - pub(super) type SkippedEpochs = + pub type SkippedEpochs = StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>; #[derive(frame_support::DefaultNoBound)] From 93227ac9778cda8c5969151402aa929c7f00b9d4 Mon Sep 17 00:00:00 2001 From: Aideepakchaudhary Date: Sat, 6 Jul 2024 19:38:41 +0530 Subject: [PATCH 10/10] refactor pr doc --- prdoc/pr_4912.prdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/prdoc/pr_4912.prdoc b/prdoc/pr_4912.prdoc index 4b508a511168..dd96054b81fa 100644 --- a/prdoc/pr_4912.prdoc +++ b/prdoc/pr_4912.prdoc @@ -8,6 +8,7 @@ doc: description: | This PR removed `pallet::getter`s from `pallet-babe`s storage items. When accessed inside the pallet, use the syntax `StorageItem::::get()`. + When accessed outside the pallet, use the public functions of storage. crates: - name: pallet-babe