diff --git a/core/state/validators/validators.go b/core/state/validators/validators.go index 1452cd61a..111fd201f 100644 --- a/core/state/validators/validators.go +++ b/core/state/validators/validators.go @@ -10,6 +10,7 @@ import ( "github.com/MinterTeam/minter-go-node/core/types" "github.com/MinterTeam/minter-go-node/rlp" "github.com/MinterTeam/minter-go-node/tree" + "github.com/MinterTeam/minter-go-node/upgrades" "math/big" ) @@ -101,7 +102,10 @@ func (v *Validators) SetValidatorAbsent(height uint64, address types.TmAddress) validator.SetAbsent(height) if validator.CountAbsentTimes() > ValidatorMaxAbsentTimes { - v.punishValidator(height, address) + if !upgrades.IsGraceBlock(height) { + v.punishValidator(height, address) + } + v.turnValidatorOff(address) } } diff --git a/upgrades/grace.go b/upgrades/grace.go new file mode 100644 index 000000000..d41a6eef2 --- /dev/null +++ b/upgrades/grace.go @@ -0,0 +1,28 @@ +package upgrades + +var gracePeriods = []*gracePeriod{ + newGracePeriod(1, 120), +} + +func IsGraceBlock(block uint64) bool { + for _, gp := range gracePeriods { + if gp.isApplicable(block) { + return true + } + } + + return false +} + +type gracePeriod struct { + from uint64 + to uint64 +} + +func (gp *gracePeriod) isApplicable(block uint64) bool { + return block >= gp.from && block <= gp.to +} + +func newGracePeriod(from uint64, to uint64) *gracePeriod { + return &gracePeriod{from: from, to: to} +}