Skip to content

Commit

Permalink
Remove Penalty::default method
Browse files Browse the repository at this point in the history
This was a source of confusion about the representation.
  • Loading branch information
cronokirby committed Dec 6, 2023
1 parent a696c62 commit 5ffc155
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions crates/core/component/stake/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ pub(crate) trait StakingImpl: StateWriteExt {
let penalty = self
.penalty_in_epoch(&validator.identity_key, epoch_to_end.index)
.await?
.unwrap_or_default();
.unwrap_or(Penalty::from_percent(0));
let prev_validator_rate_with_penalty = prev_validator_rate.slash(penalty);

// Then compute the next validator rate, accounting for funding streams and validator state.
Expand Down Expand Up @@ -1099,7 +1099,7 @@ pub trait StateReadExt: StateRead {
let start_key = state_key::penalty_in_epoch(id, start);
let end_key = state_key::penalty_in_epoch(id, end);

let mut compounded = Penalty::default();
let mut compounded = Penalty::from_percent(0);
for (_key, penalty) in all_penalties.range(start_key..end_key) {
compounded = compounded.compound(*penalty);
}
Expand Down Expand Up @@ -1413,7 +1413,7 @@ pub trait StateWriteExt: StateWrite {
let current_penalty = self
.penalty_in_epoch(identity_key, current_epoch_index)
.await?
.unwrap_or_default();
.unwrap_or(Penalty::from_percent(0));

let new_penalty = current_penalty.compound(slashing_penalty);

Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/stake/src/penalty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use penumbra_num::{
/// Tracks slashing penalties applied to a validator in some epoch.
///
/// The penalty is represented as a fixed-point integer in bps^2 (denominator 10^8).
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(try_from = "pbs::Penalty", into = "pbs::Penalty")]
pub struct Penalty(U128x128);

Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/stake/src/undelegate_claim/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl ConstraintSynthesizer<Fq> for UndelegateClaimCircuit {

impl DummyWitness for UndelegateClaimCircuit {
fn with_dummy_witness() -> Self {
let penalty = Penalty::default();
let penalty = Penalty::from_percent(0);
let balance_blinding = Fr::from(1);
let unbonding_amount = Amount::from(1u64);
let unbonding_id = *STAKING_TOKEN_ASSET_ID;
Expand Down

0 comments on commit 5ffc155

Please sign in to comment.