Skip to content

Commit

Permalink
refactor: revert changes in x/slashing proto (#627)
Browse files Browse the repository at this point in the history
* Revert proto modification

* Remove legacy handler

* Remove legacy rest

* Update x/slashing for the reverted protobuf

* Revert "Remove legacy rest"

This reverts commit 37b1903.

* Revert "Remove legacy handler"

This reverts commit 9e003b3.

* Update CHANGELOG.md

* Fix test

* Copy proto from cosmos-sdk as is

* Update comments

* Add start_height validations to tests

* Fix the comment
  • Loading branch information
0Tech authored Aug 10, 2022
1 parent d8cdb8f commit ddc1d4e
Show file tree
Hide file tree
Showing 19 changed files with 371 additions and 230 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (ostracon) [\#610](https://github.com/line/lbm-sdk/pull/610) apply change of prefix of key name in ostracon
* (ostracon) [\#614](https://github.com/line/lbm-sdk/pull/614) apply Ostracon's changes that replace `StakingPower` with `VotingPower` and `StakingPower` with `VotingPower`
* (proto) [\#617](https://github.com/line/lbm-sdk/pull/617) change wasm gRPC path to original `cosmwasm` path.
* (proto) [\#627](https://github.com/line/lbm-sdk/pull/627) revert changes in x/slashing proto

### Build, CI

Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

200 changes: 146 additions & 54 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11370,28 +11370,47 @@ paths:
properties:
address:
type: string
start_height:
type: string
format: int64
title: >-
Height at which validator was first a candidate OR was
unjailed
index_offset:
type: string
format: int64
description: >-
Index which is incremented each time the validator was a
bonded

in a block and may have signed a precommit or not. This
in conjunction with the

`SignedBlocksWindow` param determines the index in the
`MissedBlocksBitArray`.
jailed_until:
type: string
format: date-time
title: timestamp validator cannot be unjailed until
description: >-
Timestamp until which the validator is jailed due to
liveness downtime.
tombstoned:
type: boolean
format: boolean
title: >-
whether or not a validator has been tombstoned (killed
out of validator
description: >-
Whether or not a validator has been tombstoned (killed
out of validator set). It is set

set)
once the validator commits an equivocation or for any
other configured misbehiavor.
missed_blocks_counter:
type: string
format: int64
title: >-
missed blocks counter (to avoid scanning the array every
time)
voter_set_counter:
type: string
format: int64
title: how many times the validator joined to voter set
description: >-
A counter kept to avoid unnecessary array reads.

Note that `Sum(MissedBlocksBitArray)` always equals
`MissedBlocksCounter`.
description: >-
ValidatorSigningInfo defines a validator's signing info for
monitoring their
Expand Down Expand Up @@ -11528,28 +11547,47 @@ paths:
properties:
address:
type: string
start_height:
type: string
format: int64
title: >-
Height at which validator was first a candidate OR was
unjailed
index_offset:
type: string
format: int64
description: >-
Index which is incremented each time the validator was a
bonded

in a block and may have signed a precommit or not. This in
conjunction with the

`SignedBlocksWindow` param determines the index in the
`MissedBlocksBitArray`.
jailed_until:
type: string
format: date-time
title: timestamp validator cannot be unjailed until
description: >-
Timestamp until which the validator is jailed due to
liveness downtime.
tombstoned:
type: boolean
format: boolean
title: >-
whether or not a validator has been tombstoned (killed out
of validator
description: >-
Whether or not a validator has been tombstoned (killed out
of validator set). It is set

set)
once the validator commits an equivocation or for any
other configured misbehiavor.
missed_blocks_counter:
type: string
format: int64
title: >-
missed blocks counter (to avoid scanning the array every
time)
voter_set_counter:
type: string
format: int64
title: how many times the validator joined to voter set
description: >-
A counter kept to avoid unnecessary array reads.

Note that `Sum(MissedBlocksBitArray)` always equals
`MissedBlocksCounter`.
description: >-
ValidatorSigningInfo defines a validator's signing info for
monitoring their
Expand Down Expand Up @@ -53860,26 +53898,44 @@ definitions:
properties:
address:
type: string
start_height:
type: string
format: int64
title: Height at which validator was first a candidate OR was unjailed
index_offset:
type: string
format: int64
description: >-
Index which is incremented each time the validator was a bonded

in a block and may have signed a precommit or not. This in
conjunction with the

`SignedBlocksWindow` param determines the index in the
`MissedBlocksBitArray`.
jailed_until:
type: string
format: date-time
title: timestamp validator cannot be unjailed until
description: >-
Timestamp until which the validator is jailed due to liveness
downtime.
tombstoned:
type: boolean
format: boolean
title: >-
whether or not a validator has been tombstoned (killed out of
validator
description: >-
Whether or not a validator has been tombstoned (killed out of
validator set). It is set

set)
once the validator commits an equivocation or for any other
configured misbehiavor.
missed_blocks_counter:
type: string
format: int64
title: missed blocks counter (to avoid scanning the array every time)
voter_set_counter:
type: string
format: int64
title: how many times the validator joined to voter set
description: >-
A counter kept to avoid unnecessary array reads.

Note that `Sum(MissedBlocksBitArray)` always equals
`MissedBlocksCounter`.
description: >-
ValidatorSigningInfo defines a validator's signing info for monitoring
their
Expand All @@ -53901,26 +53957,44 @@ definitions:
properties:
address:
type: string
start_height:
type: string
format: int64
title: Height at which validator was first a candidate OR was unjailed
index_offset:
type: string
format: int64
description: >-
Index which is incremented each time the validator was a bonded

in a block and may have signed a precommit or not. This in
conjunction with the

`SignedBlocksWindow` param determines the index in the
`MissedBlocksBitArray`.
jailed_until:
type: string
format: date-time
title: timestamp validator cannot be unjailed until
description: >-
Timestamp until which the validator is jailed due to liveness
downtime.
tombstoned:
type: boolean
format: boolean
title: >-
whether or not a validator has been tombstoned (killed out of
validator
description: >-
Whether or not a validator has been tombstoned (killed out of
validator set). It is set

set)
once the validator commits an equivocation or for any other
configured misbehiavor.
missed_blocks_counter:
type: string
format: int64
title: missed blocks counter (to avoid scanning the array every time)
voter_set_counter:
type: string
format: int64
title: how many times the validator joined to voter set
description: >-
A counter kept to avoid unnecessary array reads.

Note that `Sum(MissedBlocksBitArray)` always equals
`MissedBlocksCounter`.
description: >-
ValidatorSigningInfo defines a validator's signing info for
monitoring their
Expand Down Expand Up @@ -53962,26 +54036,44 @@ definitions:
properties:
address:
type: string
start_height:
type: string
format: int64
title: Height at which validator was first a candidate OR was unjailed
index_offset:
type: string
format: int64
description: >-
Index which is incremented each time the validator was a bonded

in a block and may have signed a precommit or not. This in conjunction
with the

`SignedBlocksWindow` param determines the index in the
`MissedBlocksBitArray`.
jailed_until:
type: string
format: date-time
title: timestamp validator cannot be unjailed until
description: >-
Timestamp until which the validator is jailed due to liveness
downtime.
tombstoned:
type: boolean
format: boolean
title: >-
whether or not a validator has been tombstoned (killed out of
validator
description: >-
Whether or not a validator has been tombstoned (killed out of
validator set). It is set

set)
once the validator commits an equivocation or for any other configured
misbehiavor.
missed_blocks_counter:
type: string
format: int64
title: missed blocks counter (to avoid scanning the array every time)
voter_set_counter:
type: string
format: int64
title: how many times the validator joined to voter set
description: >-
A counter kept to avoid unnecessary array reads.

Note that `Sum(MissedBlocksBitArray)` always equals
`MissedBlocksCounter`.
description: >-
ValidatorSigningInfo defines a validator's signing info for monitoring
their
Expand Down
9 changes: 5 additions & 4 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6492,10 +6492,11 @@ liveness activity.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | |
| `jailed_until` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | timestamp validator cannot be unjailed until |
| `tombstoned` | [bool](#bool) | | whether or not a validator has been tombstoned (killed out of validator set) |
| `missed_blocks_counter` | [int64](#int64) | | missed blocks counter (to avoid scanning the array every time) |
| `voter_set_counter` | [int64](#int64) | | how many times the validator joined to voter set |
| `start_height` | [int64](#int64) | | Height at which validator was first a candidate OR was unjailed |
| `index_offset` | [int64](#int64) | | Index which is incremented each time the validator was a bonded in a block and may have signed a precommit or not. This in conjunction with the `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. |
| `jailed_until` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | Timestamp until which the validator is jailed due to liveness downtime. |
| `tombstoned` | [bool](#bool) | | Whether or not a validator has been tombstoned (killed out of validator set). It is set once the validator commits an equivocation or for any other configured misbehiavor. |
| `missed_blocks_counter` | [int64](#int64) | | A counter kept to avoid unnecessary array reads. Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. |



Expand Down
23 changes: 14 additions & 9 deletions proto/cosmos/slashing/v1beta1/slashing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ message ValidatorSigningInfo {
option (gogoproto.goproto_stringer) = false;

string address = 1;
// timestamp validator cannot be unjailed until
google.protobuf.Timestamp jailed_until = 2
// Height at which validator was first a candidate OR was unjailed
int64 start_height = 2 [(gogoproto.moretags) = "yaml:\"start_height\""];
// Index which is incremented each time the validator was a bonded
// in a block and may have signed a precommit or not. This in conjunction with the
// `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`.
int64 index_offset = 3 [(gogoproto.moretags) = "yaml:\"index_offset\""];
// Timestamp until which the validator is jailed due to liveness downtime.
google.protobuf.Timestamp jailed_until = 4
[(gogoproto.moretags) = "yaml:\"jailed_until\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = false];
// whether or not a validator has been tombstoned (killed out of validator
// set)
bool tombstoned = 3;
// missed blocks counter (to avoid scanning the array every time)
int64 missed_blocks_counter = 4 [(gogoproto.moretags) = "yaml:\"missed_blocks_counter\""];
// how many times the validator joined to voter set
int64 voter_set_counter = 5 [(gogoproto.moretags) = "yaml:\"voter_set_counter\""];
// Whether or not a validator has been tombstoned (killed out of validator set). It is set
// once the validator commits an equivocation or for any other configured misbehiavor.
bool tombstoned = 5;
// A counter kept to avoid unnecessary array reads.
// Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`.
int64 missed_blocks_counter = 6 [(gogoproto.moretags) = "yaml:\"missed_blocks_counter\""];
}

// Params represents the parameters used for by the slashing module.
Expand Down
4 changes: 2 additions & 2 deletions simapp/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []

/* Handle slashing state. */

// reset voter set counter on signing infos
// reset start height on signing infos
app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.VoterSetCounter = 0
info.StartHeight = 0
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
return false
},
Expand Down
3 changes: 2 additions & 1 deletion x/slashing/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func TestBeginBlocker(t *testing.T) {

info, found := app.SlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(pk.Address()))
require.True(t, found)
require.Equal(t, int64(1), info.VoterSetCounter)
require.Equal(t, ctx.BlockHeight(), info.StartHeight)
require.Equal(t, int64(1), info.IndexOffset)
require.Equal(t, time.Unix(0, 0).UTC(), info.JailedUntil)
require.Equal(t, int64(0), info.MissedBlocksCounter)

Expand Down
7 changes: 4 additions & 3 deletions x/slashing/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *IntegrationTestSuite) TestGetCmdQuerySigningInfo() {
fmt.Sprintf("--%s=1", flags.FlagHeight),
},
false,
fmt.Sprintf("{\"address\":\"%s\",\"jailed_until\":\"1970-01-01T00:00:00Z\",\"tombstoned\":false,\"missed_blocks_counter\":\"0\",\"voter_set_counter\":\"0\"}", sdk.ConsAddress(val.PubKey.Address())),
fmt.Sprintf("{\"address\":\"%s\",\"start_height\":\"0\",\"index_offset\":\"0\",\"jailed_until\":\"1970-01-01T00:00:00Z\",\"tombstoned\":false,\"missed_blocks_counter\":\"0\"}", sdk.ConsAddress(val.PubKey.Address())),
},
{
"valid address (text output)",
Expand All @@ -76,10 +76,11 @@ func (s *IntegrationTestSuite) TestGetCmdQuerySigningInfo() {
},
false,
fmt.Sprintf(`address: %s
index_offset: "0"
jailed_until: "1970-01-01T00:00:00Z"
missed_blocks_counter: "0"
tombstoned: false
voter_set_counter: "0"`, sdk.ConsAddress(val.PubKey.Address())),
start_height: "0"
tombstoned: false`, sdk.ConsAddress(val.PubKey.Address())),
},
}

Expand Down
Loading

0 comments on commit ddc1d4e

Please sign in to comment.