Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include rotate keys logic in abci #18236

Merged
merged 115 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
b6b512a
feat: implement rotate cons key method in msg server
atheeshp Oct 20, 2023
7c7322a
fix tests
atheeshp Oct 24, 2023
9aef4f4
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 24, 2023
37675e6
fix tests
atheeshp Oct 24, 2023
a9be784
fix tests
atheeshp Oct 24, 2023
2a713b5
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 24, 2023
43923ce
go mod tidy
atheeshp Oct 24, 2023
d674890
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 24, 2023
c9f32a7
feat: include rotate keys logic in abci
atheeshp Oct 24, 2023
20f27b7
Merge branch 'main' into ap/add-msg-srvr-code
atheeshp Oct 25, 2023
a51cca3
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 25, 2023
cacc0d8
go mod
atheeshp Oct 25, 2023
e9231e4
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Oct 25, 2023
5086c5f
fix lint
atheeshp Oct 26, 2023
202e2ef
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 26, 2023
3b52332
review changes
atheeshp Oct 26, 2023
4843ae1
fix tests
atheeshp Oct 26, 2023
67e15e0
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 27, 2023
8ffaa71
code rabbit review changes
atheeshp Oct 27, 2023
c093905
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Oct 27, 2023
cce3c19
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 30, 2023
4a63bde
conflicts
atheeshp Oct 30, 2023
4350e5b
review changes
atheeshp Oct 30, 2023
bbcb932
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 30, 2023
7b2b9bd
fix tests
atheeshp Oct 31, 2023
6e8eb7f
review changes
atheeshp Oct 31, 2023
04f1cbe
Merge branch 'main' into ap/add-msg-srvr-code
atheeshp Oct 31, 2023
55496f9
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Oct 31, 2023
535d00f
review changes
atheeshp Oct 31, 2023
46ae281
review changes
atheeshp Oct 31, 2023
12274e9
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 31, 2023
b19d163
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Oct 31, 2023
e463855
go mod
atheeshp Oct 31, 2023
552e683
go mod
atheeshp Oct 31, 2023
2ea32bc
fix go mod
atheeshp Oct 31, 2023
fb3363f
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Oct 31, 2023
9976530
go mod
atheeshp Oct 31, 2023
f0113eb
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Nov 1, 2023
d4439ec
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 2, 2023
87aebe8
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Nov 2, 2023
3a0f4da
review changes
atheeshp Nov 2, 2023
89ca04f
proto
atheeshp Nov 2, 2023
6d138b8
proto-gen
atheeshp Nov 2, 2023
49f1745
review changes
atheeshp Nov 2, 2023
4183c78
review changes
atheeshp Nov 2, 2023
327929f
proto-gen
atheeshp Nov 2, 2023
efb8022
review changes
atheeshp Nov 2, 2023
dfbb63a
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 2, 2023
dd8c72c
review changes
atheeshp Nov 2, 2023
0359d96
review changes
atheeshp Nov 2, 2023
441f6ee
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 3, 2023
f41fdf0
go mod tidy
atheeshp Nov 3, 2023
c7563f5
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 6, 2023
44731ce
try fixing go mod
atheeshp Nov 6, 2023
8a00a07
fix go mod changes
atheeshp Nov 6, 2023
7ed213f
review change
atheeshp Nov 6, 2023
78c4eda
review changes
atheeshp Nov 6, 2023
b236334
review changes
atheeshp Nov 7, 2023
a4b06da
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 7, 2023
cae4de4
clean comments
atheeshp Nov 7, 2023
1539aaa
review changes
atheeshp Nov 7, 2023
e30bece
Merge branch 'main' into ap/add-msg-srvr-code
atheeshp Nov 7, 2023
d4bf237
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 7, 2023
20bf052
conflicts
atheeshp Nov 7, 2023
10f6e38
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Nov 7, 2023
d32c833
go mod tidy
atheeshp Nov 7, 2023
05e560a
review changes
atheeshp Nov 8, 2023
e27c72a
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/add-msg-s…
atheeshp Nov 8, 2023
aee5587
Merge branch 'ap/add-msg-srvr-code' of github.com:cosmos/cosmos-sdk i…
atheeshp Nov 8, 2023
06d7170
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Nov 15, 2023
d560884
conflicts
atheeshp Nov 15, 2023
17852c2
go mod
atheeshp Nov 15, 2023
9a7a82b
go mod
atheeshp Nov 15, 2023
f98c94c
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Nov 16, 2023
1a2a897
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Nov 17, 2023
1f04845
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Nov 20, 2023
82bc8f5
review changes
atheeshp Nov 21, 2023
03469a5
review changes
atheeshp Nov 21, 2023
a8544f0
nit
atheeshp Nov 21, 2023
ea22a3d
fix tests
atheeshp Nov 22, 2023
3756d84
fix tests
atheeshp Nov 22, 2023
91fe4f1
review changes
atheeshp Nov 22, 2023
5ed6003
add tests for rotation
atheeshp Nov 29, 2023
1191858
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Nov 29, 2023
75eb409
add extra test
atheeshp Nov 29, 2023
088255b
review changes
atheeshp Dec 1, 2023
c221c55
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 1, 2023
6b55e4b
review changes
atheeshp Dec 1, 2023
0f1011b
review changes
atheeshp Dec 1, 2023
cc2c0a1
review changes
atheeshp Dec 12, 2023
3d5c8b4
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 12, 2023
1ca3562
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 13, 2023
cddbc58
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 14, 2023
f362a93
review changes
atheeshp Dec 17, 2023
42979cb
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 17, 2023
fbd4e41
review changes
atheeshp Dec 17, 2023
9961cc5
fix test
atheeshp Dec 18, 2023
a8bab2f
lint
atheeshp Dec 19, 2023
159375e
test
atheeshp Dec 19, 2023
663c8ef
lint
atheeshp Dec 19, 2023
19bf12b
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 19, 2023
320af37
review changes
atheeshp Dec 20, 2023
fcabe10
lint
atheeshp Dec 20, 2023
5e4736a
review changes
atheeshp Dec 20, 2023
2eedad0
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 20, 2023
97c871d
remove unnecessary code
atheeshp Dec 20, 2023
8f219bd
add test to check validator identifier
atheeshp Dec 21, 2023
1b1f4b7
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 21, 2023
c742783
fix lint
atheeshp Dec 21, 2023
7a4419a
review changes
atheeshp Dec 21, 2023
075865b
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 21, 2023
98862ef
fix `GetValidatorByConsAddr`
atheeshp Dec 21, 2023
bc53191
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 21, 2023
693a7eb
review changes
atheeshp Dec 21, 2023
bd92cec
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/abci-and-…
atheeshp Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/integration/staking/keeper/unbonding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func SetupUnbondingTests(t *testing.T, f *fixture, hookCalled *bool, ubdeID *uin
mockStackingHooks.EXPECT().BeforeDelegationSharesModified(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
mockStackingHooks.EXPECT().BeforeValidatorModified(gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
mockStackingHooks.EXPECT().BeforeValidatorSlashed(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
mockStackingHooks.EXPECT().AfterConsensusPubKeyUpdate(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
f.stakingKeeper.SetHooks(types.NewMultiStakingHooks(mockStackingHooks))

addrDels = simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, f.sdkCtx, 2, math.NewInt(10000))
Expand Down
5 changes: 5 additions & 0 deletions x/distribution/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"cosmossdk.io/x/distribution/types"
stakingtypes "cosmossdk.io/x/staking/types"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -187,3 +188,7 @@ func (h Hooks) BeforeDelegationRemoved(_ context.Context, _ sdk.AccAddress, _ sd
func (h Hooks) AfterUnbondingInitiated(_ context.Context, _ uint64) error {
return nil
}

func (h Hooks) AfterConsensusPubKeyUpdate(_ context.Context, _, _ cryptotypes.PubKey, _ sdk.Coin) error {
return nil
}
9 changes: 9 additions & 0 deletions x/evidence/keeper/infraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ func (k Keeper) handleEquivocationEvidence(ctx context.Context, evidence *types.
}

if len(validator.GetOperator()) != 0 {
// get the consAddr again, this is because validator might've rotated it's key.
// the consAddr submitted by the evidence can be an address which is before the rotation
// (because there is unbonding period window to submit the evidences)
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
valConsAddr, err := validator.GetConsAddr()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this a little bit more? Getting the consAddr this way doesn't get it from the store again if that's what you meant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atheeshp ping on this one, I think you added more comments but I'm still confused 😅

Copy link
Contributor Author

@atheeshp atheeshp Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an evidence for a validator's behaviour can be submitted till the unbonding period window.
When a validator rotates it's key that will update the validator.ConsAddr to the new address in the validator details immediately. But if the evidence submitted (within the unbonding period of the rotation) with old cons address we cannot find the required details of the validator in the slashing state because of the key rotation. To find them we need to get the validator's rotated consAddr which will be present at validator.consAddr

if err != nil {
return err
}
consAddr = valConsAddr

if _, err := k.slashingKeeper.GetPubkey(ctx, consAddr.Bytes()); err != nil {
// Ignore evidence that cannot be handled.
//
Expand Down
14 changes: 14 additions & 0 deletions x/slashing/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdkmath "cosmossdk.io/math"
"cosmossdk.io/x/slashing/types"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -99,3 +100,16 @@ func (h Hooks) BeforeValidatorSlashed(_ context.Context, _ sdk.ValAddress, _ sdk
func (h Hooks) AfterUnbondingInitiated(_ context.Context, _ uint64) error {
return nil
}

// AfterConsensusPubKeyUpdate triggers the functions to rotate the signing-infos also sets address pubkey relation.
func (h Hooks) AfterConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey cryptotypes.PubKey, _ sdk.Coin) error {
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
if err := h.k.performConsensusPubKeyUpdate(ctx, oldPubKey, newPubKey); err != nil {
return err
}

if err := h.k.AddrPubkeyRelation.Remove(ctx, oldPubKey.Address()); err != nil {
return err
}

return nil
}
71 changes: 60 additions & 11 deletions x/slashing/keeper/signing_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/x/slashing/types"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -75,13 +76,35 @@ func (k Keeper) SetMissedBlockBitmapChunk(ctx context.Context, addr sdk.ConsAddr
return k.ValidatorMissedBlockBitmap.Set(ctx, collections.Join(addr.Bytes(), uint64(chunkIndex)), chunk)
}

// getPreviousConsKey checks if the key rotated, returns the old consKey to get the missed blocks
// because missed blocks are still pointing to the old key
func (k Keeper) getPreviousConsKey(ctx context.Context, addr sdk.ConsAddress) (sdk.ConsAddress, error) {
oldPk, err := k.sk.ValidatorIdentifier(ctx, addr)
if err != nil {
return nil, err
}

if oldPk != nil {
return oldPk, nil
}

return addr, nil
}

// GetMissedBlockBitmapValue returns true if a validator missed signing a block
// at the given index and false otherwise. The index provided is assumed to be
// the index in the range [0, SignedBlocksWindow), which represents the bitmap
// where each bit represents a height, and is determined by the validator's
// IndexOffset modulo SignedBlocksWindow. This index is used to fetch the chunk
// in the bitmap and the relative bit in that chunk.
func (k Keeper) GetMissedBlockBitmapValue(ctx context.Context, addr sdk.ConsAddress, index int64) (bool, error) {
// check the key rotated, if rotated use the returned consKey to get the missed blocks
// because missed blocks are still pointing to the old key
addr, err := k.getPreviousConsKey(ctx, addr)
if err != nil {
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
return false, err
}

// get the chunk or "word" in the logical bitmap
chunkIndex := index / types.MissedBlockBitmapChunkSize

Expand Down Expand Up @@ -111,6 +134,13 @@ func (k Keeper) GetMissedBlockBitmapValue(ctx context.Context, addr sdk.ConsAddr
// index is used to fetch the chunk in the bitmap and the relative bit in that
// chunk.
func (k Keeper) SetMissedBlockBitmapValue(ctx context.Context, addr sdk.ConsAddress, index int64, missed bool) error {
// check the key rotated, if rotated use the returned consKey to get the missed blocks
// because missed blocks are still pointing to the old key
addr, err := k.getPreviousConsKey(ctx, addr)
if err != nil {
return err
}

// get the chunk or "word" in the logical bitmap
chunkIndex := index / types.MissedBlockBitmapChunkSize

Expand Down Expand Up @@ -144,19 +174,21 @@ func (k Keeper) SetMissedBlockBitmapValue(ctx context.Context, addr sdk.ConsAddr

// DeleteMissedBlockBitmap removes a validator's missed block bitmap from state.
func (k Keeper) DeleteMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddress) error {
// check the key rotated, if rotated use the returned consKey to delete the missed blocks
// because missed blocks are still pointing to the old key
addr, err := k.getPreviousConsKey(ctx, addr)
if err != nil {
return err
}

rng := collections.NewPrefixedPairRange[[]byte, uint64](addr.Bytes())
err := k.ValidatorMissedBlockBitmap.Walk(ctx, rng, func(key collections.Pair[[]byte, uint64], value []byte) (bool, error) {
return k.ValidatorMissedBlockBitmap.Walk(ctx, rng, func(key collections.Pair[[]byte, uint64], value []byte) (bool, error) {
err := k.ValidatorMissedBlockBitmap.Remove(ctx, key)
if err != nil {
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
return true, err
}
return false, nil
})
if err != nil {
return err
}

return nil
}

// IterateMissedBlockBitmap iterates over a validator's signed blocks window
Expand All @@ -168,7 +200,7 @@ func (k Keeper) DeleteMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddres
func (k Keeper) IterateMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddress, cb func(index int64, missed bool) (stop bool)) error {
var index int64
rng := collections.NewPrefixedPairRange[[]byte, uint64](addr.Bytes())
err := k.ValidatorMissedBlockBitmap.Walk(ctx, rng, func(key collections.Pair[[]byte, uint64], value []byte) (bool, error) {
return k.ValidatorMissedBlockBitmap.Walk(ctx, rng, func(key collections.Pair[[]byte, uint64], value []byte) (bool, error) {
bs := bitset.New(uint(types.MissedBlockBitmapChunkSize))

if err := bs.UnmarshalBinary(value); err != nil {
Expand All @@ -185,10 +217,6 @@ func (k Keeper) IterateMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddre
}
return false, nil
})
if err != nil {
return err
}
return nil
}

// GetValidatorMissedBlocks returns array of missed blocks for given validator.
Expand All @@ -209,3 +237,24 @@ func (k Keeper) GetValidatorMissedBlocks(ctx context.Context, addr sdk.ConsAddre

return missedBlocks, err
}

atheeshp marked this conversation as resolved.
Show resolved Hide resolved
// performConsensusPubKeyUpdate updates cons address to its pub key relation
// Updates signing info, missed blocks (removes old one, and sets new one)
func (k Keeper) performConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey cryptotypes.PubKey) error {
// Connect new consensus address with PubKey
if err := k.AddrPubkeyRelation.Set(ctx, newPubKey.Address(), newPubKey); err != nil {
return err
}

// Migrate ValidatorSigningInfo from oldPubKey to newPubKey
signingInfo, err := k.ValidatorSigningInfo.Get(ctx, sdk.ConsAddress(oldPubKey.Address()))
if err != nil {
return types.ErrInvalidConsPubKey.Wrap("failed to get signing info for old public key")
}

if err := k.ValidatorSigningInfo.Set(ctx, sdk.ConsAddress(newPubKey.Address()), signingInfo); err != nil {
return err
}

return k.ValidatorSigningInfo.Remove(ctx, sdk.ConsAddress(oldPubKey.Address()))
}
12 changes: 12 additions & 0 deletions x/slashing/keeper/signing_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package keeper_test
import (
"time"

"github.com/golang/mock/gomock"

"cosmossdk.io/x/slashing/testutil"
slashingtypes "cosmossdk.io/x/slashing/types"

Expand Down Expand Up @@ -65,6 +67,8 @@ func (s *KeeperTestSuite) TestValidatorMissedBlockBitmap_SmallWindow() {
params.SignedBlocksWindow = window
require.NoError(keeper.Params.Set(ctx, params))

s.stakingKeeper.EXPECT().ValidatorIdentifier(gomock.Any(), consAddr).Return(consAddr, nil).AnyTimes()

// validator misses all blocks in the window
var valIdxOffset int64
for valIdxOffset < params.SignedBlocksWindow {
Expand Down Expand Up @@ -97,5 +101,13 @@ func (s *KeeperTestSuite) TestValidatorMissedBlockBitmap_SmallWindow() {
missedBlocks, err = keeper.GetValidatorMissedBlocks(ctx, consAddr)
require.NoError(err)
require.Len(missedBlocks, int(params.SignedBlocksWindow)-1)

// if the validator rotated it's key there will be different consKeys and a mapping will be added in the state.
consAddr1 := sdk.ConsAddress(sdk.AccAddress([]byte("addr1_______________")))
s.stakingKeeper.EXPECT().ValidatorIdentifier(gomock.Any(), consAddr1).Return(consAddr, nil).AnyTimes()

missedBlocks, err = keeper.GetValidatorMissedBlocks(ctx, consAddr1)
require.NoError(err)
require.Len(missedBlocks, int(params.SignedBlocksWindow)-1)
}
}
15 changes: 15 additions & 0 deletions x/slashing/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions x/slashing/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ var (
ErrNoSigningInfoFound = errors.Register(ModuleName, 8, "no validator signing info found")
ErrValidatorTombstoned = errors.Register(ModuleName, 9, "validator already tombstoned")
ErrInvalidSigner = errors.Register(ModuleName, 10, "expected authority account as only signer for proposal message")
ErrInvalidConsPubKey = errors.Register(ModuleName, 11, "invalid consensus pubkey")
)
4 changes: 4 additions & 0 deletions x/slashing/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ type StakingKeeper interface {

// IsValidatorJailed returns if the validator is jailed.
IsValidatorJailed(ctx context.Context, addr sdk.ConsAddress) (bool, error)

// ValidatorIdentifier maps the new cons key to previous cons key (which is the address before the rotation).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessary love this name, it doesn't accurately describe what it does

// (that is: newConsKey -> oldConsKey)
ValidatorIdentifier(context.Context, sdk.ConsAddress) (sdk.ConsAddress, error)
}

// StakingHooks event hooks for staking validator object (noalias)
Expand Down
Loading