Skip to content

Commit

Permalink
Changes WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed Aug 14, 2018
1 parent a2463d0 commit 21be609
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 17 additions & 3 deletions docs/spec/slashing/state-machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ onValidatorUnbonded(address sdk.ValAddress)
return
```

#### Validator Power Changed

When a validator's power changes, we update the in-progress `SlashingPeriod` with the validator's current power:

```golang
onValidatorPowerChanged(address sdk.ValAddress, stakeBonded sdk.Rat)

slashingPeriod = getSlashingPeriod(address, CurrentHeight)
slashingPeriod.MaxStakeBonded = max(slashingPeriod.MaxStakeBonded, stakeBonded)
setSlashingPeriod(slashingPeriod)

return
```

#### Validator Slashed

When a validator is slashed, we look up the appropriate `SlashingPeriod` based on the validator
Expand All @@ -90,11 +104,11 @@ address and the time of infraction, cap the fraction slashed as `max(SlashFracti
beforeValidatorSlashed(address sdk.ValAddress, fraction sdk.Rat, infractionHeight int64)

slashingPeriod = getSlashingPeriod(address, infractionHeight)
totalToSlash = max(slashingPeriod.SlashedSoFar, fraction)
slashingPeriod.SlashedSoFar = totalToSlash
totalFractionToSlash = max(slashingPeriod.SlashedSoFar, fraction)
slashingPeriod.FractionSlashedSoFar = totalToSlash
setSlashingPeriod(slashingPeriod)

remainderToSlash = slashingPeriod.SlashedSoFar - totalToSlash
remainderToSlash = slashingPeriod.FractionSlashedSoFar - totalToSlash
fraction = remainderToSlash

continue with slashing
Expand Down
4 changes: 3 additions & 1 deletion docs/spec/slashing/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type SlashingPeriod struct {
ValidatorAddr sdk.ValAddress // Tendermint address of the validator
StartHeight int64 // Block height at which slashing period begin
EndHeight int64 // Block height at which slashing period ended
SlashedSoFar sdk.Rat // Fraction slashed so far, cumulative
MaxBondedStake sdk.Rat // Maximum bonded stake during period
StakeSlashedSoFar sdk.Rat // Amount of stake slashed so far
FractionSlashedSoFar sdk.Rat // Fraction slashed so far, cumulative
}
```

0 comments on commit 21be609

Please sign in to comment.