Skip to content

Commit

Permalink
Don't log so many stkaing events on genesis block (paritytech#8339)
Browse files Browse the repository at this point in the history
* Don't log so many stkaing events on genesis block

* Clean a few more warn and info logs

* Update frame/staking/src/lib.rs

* Update frame/staking/src/lib.rs
  • Loading branch information
kianenigma authored Mar 15, 2021
1 parent fdac8be commit 3541769
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
8 changes: 6 additions & 2 deletions frame/election-provider-multi-phase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,12 +1019,16 @@ impl<T: Config> Pallet<T> {
)
.map(|(supports, compute)| {
Self::deposit_event(Event::ElectionFinalized(Some(compute)));
log!(info, "Finalized election round with compute {:?}.", compute);
if Self::round() != 1 {
log!(info, "Finalized election round with compute {:?}.", compute);
}
supports
})
.map_err(|err| {
Self::deposit_event(Event::ElectionFinalized(None));
log!(warn, "Failed to finalize election round. reason {:?}", err);
if Self::round() != 1 {
log!(warn, "Failed to finalize election round. reason {:?}", err);
}
err
})
}
Expand Down
28 changes: 16 additions & 12 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2938,13 +2938,15 @@ impl<T: Config> Module<T> {
// emit event
Self::deposit_event(RawEvent::StakingElection(compute));

log!(
info,
"new validator set of size {:?} has been elected via {:?} for staring era {:?}",
elected_stashes.len(),
compute,
current_era,
);
if current_era > 0 {
log!(
info,
"new validator set of size {:?} has been elected via {:?} for staring era {:?}",
elected_stashes.len(),
compute,
current_era,
);
}

Some(elected_stashes)
} else {
Expand Down Expand Up @@ -3132,11 +3134,13 @@ impl<T: Config> Module<T> {
let elected_stashes = exposures.iter().cloned().map(|(x, _)| x).collect::<Vec<_>>();

if (elected_stashes.len() as u32) <= Self::minimum_validator_count() {
log!(
warn,
"chain does not have enough staking candidates to operate for era {:?}",
current_era,
);
if current_era > 0 {
log!(
warn,
"chain does not have enough staking candidates to operate for era {:?}",
current_era,
);
}
return Err(());
}

Expand Down

0 comments on commit 3541769

Please sign in to comment.