Skip to content

Commit

Permalink
WIP changes from Manu and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Jun 1, 2023
1 parent 7848f9c commit c21b1ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
13 changes: 4 additions & 9 deletions proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1692,14 +1692,9 @@ where
tracing::debug!("bond ∆ at epoch {}: {}", ep, delta);
}
}
let stake_at_pipeline =
read_validator_stake(storage, &params, validator, pipeline_epoch)?
.unwrap_or_default()
.change();
let token_change = cmp::min(amount_after_slashing, stake_at_pipeline);
tracing::debug!(
"Token change including slashes on unbond = {}",
token_change
-amount_after_slashing
);

// Update the validator set at the pipeline offset. Since unbonding from a
Expand All @@ -1716,7 +1711,7 @@ where
storage,
&params,
validator,
-token_change,
-amount_after_slashing,
current_epoch,
)?;
}
Expand All @@ -1726,14 +1721,14 @@ where
storage,
&params,
validator,
-token_change,
-amount_after_slashing,
current_epoch,
params.pipeline_len,
)?;
update_total_deltas(
storage,
&params,
-token_change,
-amount_after_slashing,
current_epoch,
params.pipeline_len,
)?;
Expand Down
24 changes: 13 additions & 11 deletions proof_of_stake/src/tests/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ impl ConcretePosState {
current_epoch,
current_epoch + params.pipeline_len,
) {
// println!("Epoch {epoch}");
tracing::debug!("Epoch {epoch}");
let mut vals = HashSet::<Address>::new();
for WeightedValidator {
bonded_stake,
Expand Down Expand Up @@ -2015,19 +2015,21 @@ impl AbstractPosState {
.unwrap()
.get(&id.validator)
.unwrap();
let pipeline_stake = self
.validator_stakes
.get(&self.pipeline())
.unwrap()
.get(&id.validator)
.unwrap();
println!("pipeline stake = {}", pipeline_stake);
let token_change = cmp::min(*pipeline_stake, amount_after_slashing);
// let pipeline_stake = self
// .validator_stakes
// .get(&self.pipeline())
// .unwrap()
// .get(&id.validator)
// .unwrap();
// let token_change = cmp::min(*pipeline_stake, amount_after_slashing);

if *pipeline_state != ValidatorState::Jailed {
self.update_validator_sets(&id.validator, -token_change);
self.update_validator_sets(&id.validator, -amount_after_slashing);
}
self.update_validator_total_stake(&id.validator, -token_change);
self.update_validator_total_stake(
&id.validator,
-amount_after_slashing,
);
}

/// Update validator's total stake with bonded or unbonded change at the
Expand Down

0 comments on commit c21b1ea

Please sign in to comment.