message: Remove unbonding purses while slashing.
  We're removing the entry completely as it's indexed by validator's
  public key. There's no need for distinction and purging entries as
  purging effectively means we're removing all the entries (validators and
  delegators) which can be simplified this way.
diff: @@ -8,10 +8,7 @@ mod seigniorage_recipient;
  mod types;
  mod unbonding_purse;
  -use alloc::{
  - collections::{BTreeMap, BTreeSet},
  - vec::Vec,
  -};
  +use alloc::{collections::BTreeMap, vec::Vec};
  use num_rational::Ratio;
  @@ -275,44 +272,20 @@ pub trait Auction:
  let mut unbonding_purses_modified = false;
  for validator_public_key in validator_public_keys {
  // Remove bid for given validator, saving its delegators
  - let orphaned_delegators = match bids.remove(&validator_public_key) {
  - Some(bid) => {
  + if let Some(bid) = bids.remove(&validator_public_key) {
  burned_amount += *bid.staked_amount();
  bids_modified = true;
  -
  - bid.delegators().keys().copied().collect()
  - }
  - None => BTreeSet::new(),
  };
  // Update unbonding entries for given validator
  - if let Some(unbonding_list) = unbonding_purses.get_mut(&validator_public_key) {
  - let initial_length = unbonding_list.len();
  -
  - unbonding_list.retain(|unbonding_purse| {
  - // Retain all entries where this validator is delegating to another validator.
  - let should_retain = !unbonding_purse.is_validator()
  - && !orphaned_delegators.contains(unbonding_purse.unbonder_public_key());
  -
  - if !should_retain {
  - // Amounts inside removed entries are burned only.
  - burned_amount += *unbonding_purse.amount()
  - }
  -
  - should_retain
  - });
  -
  - if unbonding_list.len() != initial_length {
  - unbonding_purses_modified = true;
  - }
  -
  - if unbonding_list.is_empty() {
  - // Cleans up empty map entries to preserve global state.
  - unbonding_purses.remove(&validator_public_key).unwrap();
  + if let Some(unbonding_list) = unbonding_purses.remove(&validator_public_key) {
  + burned_amount += unbonding_list
  + .into_iter()
  + .map(|unbonding_purse| *unbonding_purse.amount())
  + .sum();
  unbonding_purses_modified = true;
  }
  }
  - }
  if unbonding_purses_modified {
  detail::set_unbonding_purses(self, unbonding_purses)?;
  