Skip to content

Commit b586999

Browse files
authored
feat(evidence): disable double signing slashing during singularity (#18) (#19)
1 parent 1816b52 commit b586999

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

x/evidence/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,5 @@ require (
154154
pgregory.net/rapid v1.1.0 // indirect
155155
sigs.k8s.io/yaml v1.4.0 // indirect
156156
)
157+
158+
replace github.com/cosmos/cosmos-sdk => github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.15

x/evidence/go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK
143143
github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA=
144144
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
145145
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
146-
github.com/cosmos/cosmos-sdk v0.50.6 h1:efR3MsvMHX5sxS3be+hOobGk87IzlZbSpsI2x/Vw3hk=
147-
github.com/cosmos/cosmos-sdk v0.50.6/go.mod h1:lVkRY6cdMJ0fG3gp8y4hFrsKZqF4z7y0M2UXFb9Yt40=
148146
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
149147
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
150148
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
@@ -575,6 +573,9 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0
575573
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
576574
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
577575
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
576+
github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.15/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s=
577+
github.com/piplabs/cosmos-sdk v0.50.8-0.20241021173134-3032e1bdd6bf h1:SRT51TtdhuluqhQANrKP9ySQefV+XOwXzIeu8k3ewlY=
578+
github.com/piplabs/cosmos-sdk v0.50.8-0.20241021173134-3032e1bdd6bf/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s=
578579
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
579580
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
580581
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

x/evidence/keeper/infraction.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ import (
2727
func (k Keeper) handleEquivocationEvidence(ctx context.Context, evidence *types.Equivocation) error {
2828
sdkCtx := sdk.UnwrapSDKContext(ctx)
2929
logger := k.Logger(ctx)
30+
31+
singularityHeight, err := k.slashingKeeper.SingularityHeight(ctx)
32+
if err != nil {
33+
return err
34+
}
35+
36+
if sdkCtx.BlockHeight() < int64(singularityHeight) {
37+
logger.Debug("skip handling evidence before singularity")
38+
return nil
39+
}
40+
3041
consAddr := evidence.GetConsensusAddress(k.stakingKeeper.ConsensusAddressCodec())
3142

3243
validator, err := k.stakingKeeper.ValidatorByConsAddr(ctx, consAddr)

x/evidence/types/expected_keepers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type (
3434
SlashFractionDoubleSign(context.Context) (math.LegacyDec, error)
3535
Jail(context.Context, sdk.ConsAddress) error
3636
JailUntil(context.Context, sdk.ConsAddress, time.Time) error
37+
38+
// For Story
39+
SingularityHeight(ctx context.Context) (uint64, error)
3740
}
3841

3942
// AccountKeeper define the account keeper interface contracted needed by the evidence module

0 commit comments

Comments
 (0)