Skip to content

Commit

Permalink
Merge branch 'brent/update-pos-params' (#708)
Browse files Browse the repository at this point in the history
* brent/update-pos-params:
  rename slash rate params with `min`, update default `PosParam` values
  • Loading branch information
tzemanovic committed Nov 24, 2022
2 parents 8929369 + 14639ad commit 9418cad
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,12 +1344,12 @@ pub async fn query_protocol_parameters(
"", pos_params.block_vote_reward
);
println!(
"{:4}Duplicate vote slash rate: {}",
"", pos_params.duplicate_vote_slash_rate
"{:4}Duplicate vote minimum slash rate: {}",
"", pos_params.duplicate_vote_min_slash_rate
);
println!(
"{:4}Light client attack slash rate: {}",
"", pos_params.light_client_attack_slash_rate
"{:4}Light client attack minimum slash rate: {}",
"", pos_params.light_client_attack_min_slash_rate
);
println!(
"{:4}Max. validator slots: {}",
Expand Down
12 changes: 6 additions & 6 deletions apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ pub mod genesis_config {
// Portion of a validator's stake that should be slashed on a
// duplicate vote.
// XXX: u64 doesn't work with toml-rs!
pub duplicate_vote_slash_rate: Decimal,
pub duplicate_vote_min_slash_rate: Decimal,
// Portion of a validator's stake that should be slashed on a
// light client attack.
// XXX: u64 doesn't work with toml-rs!
pub light_client_attack_slash_rate: Decimal,
pub light_client_attack_min_slash_rate: Decimal,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -611,8 +611,8 @@ pub mod genesis_config {
block_vote_reward,
max_inflation_rate,
target_staked_ratio,
duplicate_vote_slash_rate,
light_client_attack_slash_rate,
duplicate_vote_min_slash_rate,
light_client_attack_min_slash_rate,
} = pos_params;
let pos_params = PosParams {
max_validator_slots,
Expand All @@ -623,8 +623,8 @@ pub mod genesis_config {
block_vote_reward,
max_inflation_rate,
target_staked_ratio,
duplicate_vote_slash_rate,
light_client_attack_slash_rate,
duplicate_vote_min_slash_rate,
light_client_attack_min_slash_rate,
};

let mut genesis = Genesis {
Expand Down
4 changes: 2 additions & 2 deletions genesis/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ max_inflation_rate = 0.1
target_staked_ratio = 0.6667
# Portion of a validator's stake that should be slashed on a duplicate
# vote.
duplicate_vote_slash_rate = 0.001
duplicate_vote_min_slash_rate = 0.001
# Portion of a validator's stake that should be slashed on a light
# client attack.
light_client_attack_slash_rate = 0.001
light_client_attack_min_slash_rate = 0.001

# Governance parameters.
[gov_params]
Expand Down
4 changes: 2 additions & 2 deletions genesis/e2e-tests-single-node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ max_inflation_rate = 0.1
target_staked_ratio = 0.6667
# Portion of a validator's stake that should be slashed on a duplicate
# vote.
duplicate_vote_slash_rate = 0.001
duplicate_vote_min_slash_rate = 0.001
# Portion of a validator's stake that should be slashed on a light
# client attack.
light_client_attack_slash_rate = 0.001
light_client_attack_min_slash_rate = 0.001

# Governance parameters.
[gov_params]
Expand Down
16 changes: 8 additions & 8 deletions proof_of_stake/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ pub struct PosParams {
pub target_staked_ratio: Decimal,
/// Portion of validator's stake that should be slashed on a duplicate
/// vote.
pub duplicate_vote_slash_rate: Decimal,
pub duplicate_vote_min_slash_rate: Decimal,
/// Portion of validator's stake that should be slashed on a light client
/// attack.
pub light_client_attack_slash_rate: Decimal,
pub light_client_attack_min_slash_rate: Decimal,
}

impl Default for PosParams {
fn default() -> Self {
Self {
max_validator_slots: 128,
max_validator_slots: 100,
pipeline_len: 2,
unbonding_len: 6,
unbonding_len: 21,
// 1 voting power per 1 fundamental token (10^6 per NAM or 1 per
// namnam)
tm_votes_per_token: dec!(1.0),
Expand All @@ -56,10 +56,10 @@ impl Default for PosParams {
max_inflation_rate: dec!(0.1),
// target staked ratio of 2/3
target_staked_ratio: dec!(0.6667),
// slash 5%
duplicate_vote_slash_rate: dec!(0.05),
// slash 5%
light_client_attack_slash_rate: dec!(0.05),
// slash 0.1%
duplicate_vote_min_slash_rate: dec!(0.001),
// slash 0.1%
light_client_attack_min_slash_rate: dec!(0.001),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions proof_of_stake/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@ impl SlashType {
/// parameters.
pub fn get_slash_rate(&self, params: &PosParams) -> Decimal {
match self {
SlashType::DuplicateVote => params.duplicate_vote_slash_rate,
SlashType::DuplicateVote => params.duplicate_vote_min_slash_rate,
SlashType::LightClientAttack => {
params.light_client_attack_slash_rate
params.light_client_attack_min_slash_rate
}
}
}
Expand Down

0 comments on commit 9418cad

Please sign in to comment.