Remove uncles related code (#13216)

The code was added without any clear usage. The inherent for example is not benchmarked and not used.
This commit is contained in:
Bastian Köcher
2023-01-29 21:56:10 +01:00
committed by GitHub
parent 700a732170
commit e851b3ae73
22 changed files with 47 additions and 906 deletions
+8 -10
View File
@@ -91,14 +91,14 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Historical: pallet_session::historical::{Pallet, Storage},
VoterBagsList: pallet_bags_list::<Instance1>::{Pallet, Call, Storage, Event<T>},
System: frame_system,
Authorship: pallet_authorship,
Timestamp: pallet_timestamp,
Balances: pallet_balances,
Staking: pallet_staking,
Session: pallet_session,
Historical: pallet_session::historical,
VoterBagsList: pallet_bags_list::<Instance1>,
}
);
@@ -182,8 +182,6 @@ impl pallet_session::historical::Config for Test {
}
impl pallet_authorship::Config for Test {
type FindAuthor = Author11;
type UncleGenerations = ConstU64<0>;
type FilterUncle = ();
type EventHandler = Pallet<Test>;
}
@@ -1217,8 +1217,6 @@ impl<T: Config> historical::SessionManager<T::AccountId, Exposure<T::AccountId,
/// Add reward points to block authors:
/// * 20 points to the block producer for producing a (non-uncle) block in the relay chain,
/// * 2 points to the block producer for each reference to a previously unreferenced uncle, and
/// * 1 point to the producer of each referenced uncle block.
impl<T> pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Pallet<T>
where
T: Config + pallet_authorship::Config + pallet_session::Config,
@@ -1226,14 +1224,6 @@ where
fn note_author(author: T::AccountId) {
Self::reward_by_ids(vec![(author, 20)])
}
fn note_uncle(uncle_author: T::AccountId, _age: T::BlockNumber) {
// defensive-only: block author must exist.
if let Some(block_author) = <pallet_authorship::Pallet<T>>::author() {
Self::reward_by_ids(vec![(block_author, 2), (uncle_author, 1)])
} else {
crate::log!(warn, "block author not set, this should never happen");
}
}
}
/// This is intended to be used with `FilterHistoricalOffences`.
+2 -7
View File
@@ -2237,9 +2237,7 @@ fn reward_from_authorship_event_handler_works() {
assert_eq!(<pallet_authorship::Pallet<Test>>::author(), Some(11));
Pallet::<Test>::note_author(11);
Pallet::<Test>::note_uncle(21, 1);
// Rewarding the same two times works.
Pallet::<Test>::note_uncle(11, 1);
Pallet::<Test>::note_author(11);
// Not mandatory but must be coherent with rewards
assert_eq_uvec!(Session::validators(), vec![11, 21]);
@@ -2248,10 +2246,7 @@ fn reward_from_authorship_event_handler_works() {
// 11 is rewarded as a block producer and uncle referencer and uncle producer
assert_eq!(
ErasRewardPoints::<Test>::get(active_era()),
EraRewardPoints {
individual: vec![(11, 20 + 2 * 2 + 1), (21, 1)].into_iter().collect(),
total: 26,
},
EraRewardPoints { individual: vec![(11, 20 * 2)].into_iter().collect(), total: 40 },
);
})
}