Skip to content

Commit

Permalink
WIP slash processing in Abstract state
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Aug 11, 2023
1 parent f9c9da1 commit 090219f
Show file tree
Hide file tree
Showing 3 changed files with 576 additions and 69 deletions.
4 changes: 3 additions & 1 deletion proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5190,7 +5190,7 @@ where
}

fn slash_validator<S>(
storage: &mut S,
storage: &S,
params: &PosParams,
validator: &Address,
slash_rate: Dec,
Expand Down Expand Up @@ -5455,6 +5455,8 @@ where
let redel_unbonds = total_redelegated_unbonded.at(&epoch);
let non_redelegated_amount = if !redel_unbonds
.is_empty(storage)?
// TODO: shouldn't the below just
// use `unbonded` above?
{
total_unbonded
.get(storage, &epoch)?
Expand Down
18 changes: 9 additions & 9 deletions proof_of_stake/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3891,7 +3891,7 @@ fn test_slash_validator() {
// There are no non-genesis bonds or slashes
println!("\nTEST 1:");
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down Expand Up @@ -3921,7 +3921,7 @@ fn test_slash_validator() {
)
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand All @@ -3948,7 +3948,7 @@ fn test_slash_validator() {
)
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand All @@ -3975,7 +3975,7 @@ fn test_slash_validator() {
)
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down Expand Up @@ -4014,7 +4014,7 @@ fn test_slash_validator() {
.insert(&mut storage, Epoch(3), token::Change::from(1))
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down Expand Up @@ -4049,7 +4049,7 @@ fn test_slash_validator() {
)
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down Expand Up @@ -4084,7 +4084,7 @@ fn test_slash_validator() {
.remove(&mut storage, &Epoch(3))
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down Expand Up @@ -4135,7 +4135,7 @@ fn test_slash_validator() {
.insert(&mut storage, current_epoch, token::Change::from(6))
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down Expand Up @@ -4187,7 +4187,7 @@ fn test_slash_validator() {
)
.unwrap();
let res = slash_validator(
&mut storage,
&storage,
&params,
&bob,
slash_rate,
Expand Down
Loading

0 comments on commit 090219f

Please sign in to comment.