Changes WIP
This commit is contained in:
parent
a2463d038b
commit
21be609f52
|
@ -80,6 +80,20 @@ onValidatorUnbonded(address sdk.ValAddress)
|
||||||
return
|
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
|
#### Validator Slashed
|
||||||
|
|
||||||
When a validator is slashed, we look up the appropriate `SlashingPeriod` based on the validator
|
When a validator is slashed, we look up the appropriate `SlashingPeriod` based on the validator
|
||||||
|
@ -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)
|
beforeValidatorSlashed(address sdk.ValAddress, fraction sdk.Rat, infractionHeight int64)
|
||||||
|
|
||||||
slashingPeriod = getSlashingPeriod(address, infractionHeight)
|
slashingPeriod = getSlashingPeriod(address, infractionHeight)
|
||||||
totalToSlash = max(slashingPeriod.SlashedSoFar, fraction)
|
totalFractionToSlash = max(slashingPeriod.SlashedSoFar, fraction)
|
||||||
slashingPeriod.SlashedSoFar = totalToSlash
|
slashingPeriod.FractionSlashedSoFar = totalToSlash
|
||||||
setSlashingPeriod(slashingPeriod)
|
setSlashingPeriod(slashingPeriod)
|
||||||
|
|
||||||
remainderToSlash = slashingPeriod.SlashedSoFar - totalToSlash
|
remainderToSlash = slashingPeriod.FractionSlashedSoFar - totalToSlash
|
||||||
fraction = remainderToSlash
|
fraction = remainderToSlash
|
||||||
|
|
||||||
continue with slashing
|
continue with slashing
|
||||||
|
|
|
@ -75,6 +75,8 @@ type SlashingPeriod struct {
|
||||||
ValidatorAddr sdk.ValAddress // Tendermint address of the validator
|
ValidatorAddr sdk.ValAddress // Tendermint address of the validator
|
||||||
StartHeight int64 // Block height at which slashing period begin
|
StartHeight int64 // Block height at which slashing period begin
|
||||||
EndHeight int64 // Block height at which slashing period ended
|
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
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue