Skip to content

Commit

Permalink
staking: fix misc typos
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed Jan 29, 2024
1 parent cfbef11 commit eeafb77
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 360 deletions.
5 changes: 3 additions & 2 deletions crates/core/component/stake/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ pub(crate) trait StakingImpl: StateWriteExt {
Ok(())
}

/// Process all validator unbondings queued for release in the current epoch.
/// Process all `Unbonding` validators, transitioning them to `Unbonded` if their
/// unbonding target has been reached.
#[instrument(skip(self))]
async fn process_validator_unbondings(&mut self) -> Result<()> {
let current_epoch = self.get_current_epoch().await?;
Expand Down Expand Up @@ -1481,7 +1482,7 @@ pub trait StateReadExt: StateRead {
}

/// Compute the number of epochs that will elapse before the validator is unbonded.
/// TODO(erwan): move this to the `ValidatorManager`
// TODO(erwan): move this to the `ValidatorManager`
async fn compute_unbonding_delay_for_validator(
&self,
current_epoch: Epoch,
Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/stake/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(try_from = "pb::StakeParameters", into = "pb::StakeParameters")]
pub struct StakeParameters {
/// The number of epochs that must pass before a validator can be undonded.
/// The number of epochs that must pass before a validator can be unbonded.
pub unbonding_epochs: u64,
/// The number of validators allowed in the consensus set (Active state).
pub active_validator_limit: u64,
Expand Down
14 changes: 4 additions & 10 deletions crates/core/component/stake/src/validator/bonding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum State {
Unbonded,
/// The validator has been removed from the active set.
///
/// All delegations to the validator will be unbonded at `unbonding_epoch`.
/// All delegations to the validator will be unbonded at `unbonds_at_epoch`.
Unbonding { unbonds_at_epoch: u64 },
}

Expand Down Expand Up @@ -46,14 +46,10 @@ impl From<State> for pb::BondingState {
state: match v {
State::Bonded => pb::bonding_state::BondingStateEnum::Bonded as i32,
State::Unbonded => pb::bonding_state::BondingStateEnum::Unbonded as i32,
State::Unbonding {
unbonds_at_epoch: _,
} => pb::bonding_state::BondingStateEnum::Unbonding as i32,
State::Unbonding { .. } => pb::bonding_state::BondingStateEnum::Unbonding as i32,
},
unbonding_epoch: match v {
State::Unbonding {
unbonds_at_epoch: unbonding_epoch,
} => unbonding_epoch,
State::Unbonding { unbonds_at_epoch } => unbonds_at_epoch,
_ => 0,
},
}
Expand All @@ -75,9 +71,7 @@ impl TryFrom<pb::BondingState> for State {
} else {
anyhow::bail!("unbonding epoch should be set for unbonding state")
};
Ok(State::Unbonding {
unbonds_at_epoch: unbonding_epoch,
})
Ok(State::Unbonding { unbonds_at_epoch })
}
pb::bonding_state::BondingStateEnum::Unspecified => {
Err(anyhow::anyhow!("unspecified bonding state!"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub struct BondingState {
#[prost(enumeration = "bonding_state::BondingStateEnum", tag = "1")]
pub state: i32,
#[prost(uint64, tag = "2")]
pub unbonding_epoch: u64,
pub unbonds_at_epoch: u64,
}
/// Nested message and enum types in `BondingState`.
pub mod bonding_state {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl serde::Serialize for BondingState {
if self.state != 0 {
len += 1;
}
if self.unbonding_epoch != 0 {
if self.unbonds_at_epoch != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.component.stake.v1alpha1.BondingState", len)?;
Expand All @@ -149,9 +149,9 @@ impl serde::Serialize for BondingState {
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.state)))?;
struct_ser.serialize_field("state", &v)?;
}
if self.unbonding_epoch != 0 {
if self.unbonds_at_epoch != 0 {
#[allow(clippy::needless_borrow)]
struct_ser.serialize_field("unbondingEpoch", ToString::to_string(&self.unbonding_epoch).as_str())?;
struct_ser.serialize_field("unbondsAtEpoch", ToString::to_string(&self.unbonds_at_epoch).as_str())?;
}
struct_ser.end()
}
Expand All @@ -164,14 +164,14 @@ impl<'de> serde::Deserialize<'de> for BondingState {
{
const FIELDS: &[&str] = &[
"state",
"unbonding_epoch",
"unbondingEpoch",
"unbonds_at_epoch",
"unbondsAtEpoch",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
State,
UnbondingEpoch,
UnbondsAtEpoch,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
Expand All @@ -194,7 +194,7 @@ impl<'de> serde::Deserialize<'de> for BondingState {
{
match value {
"state" => Ok(GeneratedField::State),
"unbondingEpoch" | "unbonding_epoch" => Ok(GeneratedField::UnbondingEpoch),
"unbondsAtEpoch" | "unbonds_at_epoch" => Ok(GeneratedField::UnbondsAtEpoch),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
Expand All @@ -215,7 +215,7 @@ impl<'de> serde::Deserialize<'de> for BondingState {
V: serde::de::MapAccess<'de>,
{
let mut state__ = None;
let mut unbonding_epoch__ = None;
let mut unbonds_at_epoch__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::State => {
Expand All @@ -224,19 +224,19 @@ impl<'de> serde::Deserialize<'de> for BondingState {
}
state__ = Some(map_.next_value::<bonding_state::BondingStateEnum>()? as i32);
}
GeneratedField::UnbondingEpoch => {
if unbonding_epoch__.is_some() {
return Err(serde::de::Error::duplicate_field("unbondingEpoch"));
GeneratedField::UnbondsAtEpoch => {
if unbonds_at_epoch__.is_some() {
return Err(serde::de::Error::duplicate_field("unbondsAtEpoch"));
}
unbonding_epoch__ =
unbonds_at_epoch__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(BondingState {
state: state__.unwrap_or_default(),
unbonding_epoch: unbonding_epoch__.unwrap_or_default(),
unbonds_at_epoch: unbonds_at_epoch__.unwrap_or_default(),
})
}
}
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
Loading

0 comments on commit eeafb77

Please sign in to comment.