Skip to content

Commit

Permalink
staking: improve formatting and delay varname
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed Mar 11, 2024
1 parent 1032224 commit ec85a43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ impl ActionHandler for Delegate {

let d = self;

// We check if the rate data is for the current epoch.
// We check if the rate data is for the current epoch to provide a helpful
// error message if there is a mismatch.
let current_epoch = state.get_current_epoch().await?;
ensure!(
d.epoch_index == current_epoch.index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use anyhow::Result;
use async_trait::async_trait;
use futures::StreamExt as _;
use penumbra_num::Amount;
use penumbra_sct::{
component::clock::{EpochManager, EpochRead},
};
use penumbra_sct::component::clock::{EpochManager, EpochRead};
use penumbra_shielded_pool::component::{SupplyRead as _, SupplyWrite};
use sha2::{Digest as _, Sha256};
use tendermint::abci::types::{CommitInfo, Misbehavior};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub trait ValidatorDataRead: StateRead {
async fn compute_unbonding_height(
&self,
id: &IdentityKey,
unbonding_height_start: u64,
unbonding_start_height: u64,
) -> Result<u64> {
let Some(val_bonding_state) = self.get_validator_bonding_state(id).await else {
anyhow::bail!(
Expand All @@ -161,14 +161,14 @@ pub trait ValidatorDataRead: StateRead {

let min_block_delay = self.get_stake_params().await?.unbonding_delay;

let upper_bound_height = unbonding_height_start.saturating_add(min_block_delay);
let upper_bound_height = unbonding_start_height.saturating_add(min_block_delay);

let unbonding_height = match val_bonding_state {
Bonded => upper_bound_height,
// When the minimum delay parameter changes, an unbonding validator may
// have a delay that is larger than the new minimum delay. In this case,
Unbonding { unbonds_at_height } => unbonds_at_height.min(upper_bound_height),
Unbonded => unbonding_height_start,
Unbonded => unbonding_start_height,
};

Ok(unbonding_height)
Expand Down

0 comments on commit ec85a43

Please sign in to comment.