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

chore!: add signing-info migration #2886

Merged
merged 43 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e085b40
chore: merge main into feat/sdk-47-ibc-7 branch (#2625)
sainoe Jun 23, 2023
a8f0e87
resolve merge conflicts
mpoke Jun 29, 2023
ec7c870
feat!: SDK v0.47 & IBC v7 Base (#2541)
glnro Jul 4, 2023
f5fc4ba
feat: refactor base E2E tests (#2587)
sainoe Jul 12, 2023
0510ee7
feat: refactor global fee module for SDK v47 (#2660)
sainoe Jul 24, 2023
861ba39
deps: bump ics to v3.1; chore: update e2e (#2663)
MSalopek Jul 24, 2023
2e4d98d
chore: refactor remaining E2E tests for SDK v47 (#2744)
sainoe Sep 26, 2023
ff8acab
deps: bump go version to 1.21
MSalopek Dec 8, 2023
d0a672a
tests: update hermes images and setup (#2841)
MSalopek Dec 8, 2023
21a192a
deps: use lsm cosmos-sdk fork and ics 3.3.0-rc0-lsm (#2842)
MSalopek Dec 8, 2023
b4730f5
chore!: merge main into feat/sdk-47-ibc7 (#2851)
MSalopek Dec 12, 2023
925bfee
chore: merge main into feat/sdk-47-ibc-7; update broken tests (#2853)
MSalopek Dec 12, 2023
df6cb1a
Merge branch 'main' into feat/sdk-47-ibc-7
MSalopek Dec 12, 2023
a91f8cf
chore: post-merge cleanup
MSalopek Dec 12, 2023
fd63f6e
chore: post-merge cleanup
MSalopek Dec 12, 2023
ce86f31
chore: post-merge cleanup
MSalopek Dec 12, 2023
1b54845
deps: update migration to use latest cosmos-sdk/lsm
MSalopek Dec 13, 2023
c9b7817
chore: appease linter
MSalopek Dec 13, 2023
16a9c97
chore!: add min commission rates migration (prop 826)
MSalopek Dec 13, 2023
ed041ce
chore: add migration tests for v15
MSalopek Dec 14, 2023
ed08c80
chore: rm 3rd party
MSalopek Dec 15, 2023
304e982
migration: change MaxRate to match 0.05 if not provided
MSalopek Dec 18, 2023
89c5afe
nit: add back removed lines from historic v7 migration
MSalopek Dec 18, 2023
b5f8207
Merge branch 'feat/sdk-47-ibc-7' into masa/migrate-v15-validator-comm…
mpoke Jan 4, 2024
f9e494f
save
sainoe Jan 5, 2024
e75e9b6
lint
sainoe Jan 9, 2024
4a30eee
nit
sainoe Jan 10, 2024
1516387
refactoring
sainoe Jan 17, 2024
8a5d155
add CHANGELOG entry
sainoe Jan 18, 2024
8a0b312
nits
sainoe Jan 18, 2024
6b0f529
lint
sainoe Jan 18, 2024
18db793
nit
sainoe Jan 18, 2024
8a85583
refactor
sainoe Jan 18, 2024
9bb3ce7
add .changelog entry
sainoe Jan 18, 2024
2e9e16a
nits
sainoe Jan 18, 2024
726f35c
Merge branch 'masa/migrate-v15-validator-commission-rates' into saino…
sainoe Jan 18, 2024
0aebe9b
doc
sainoe Jan 18, 2024
5967097
remove MinCommissionRate migration rebase
sainoe Jan 18, 2024
7e58f6b
simplify test
sainoe Jan 18, 2024
2516a55
Update .changelog/unreleased/state-breaking/2866-migrate-signing-info…
sainoe Jan 19, 2024
a00cd0b
add logs
sainoe Jan 19, 2024
c57984f
remove panics
sainoe Jan 19, 2024
238bd8d
Merge branch 'main' into sainoe/v15-si-upgrade
sainoe Jan 19, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Migrate the signing infos of validators for which the consensus address
is missing, see https://github.com/cosmos/gaia/issues/1734
([\#2866](https://github.com/cosmos/gaia/pull/2866))
sainoe marked this conversation as resolved.
Show resolved Hide resolved



35 changes: 34 additions & 1 deletion app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ package v15
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/cosmos/gaia/v15/app/keepers"
)

// CreateUpgradeHandler returns a upgrade handler for Gaia v15
// which executes the following migrations:
// - update the slashing module SigningInfos for which the consensus address is empty,
// see https://github.com/cosmos/gaia/issues/1734.
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand All @@ -21,7 +27,34 @@ func CreateUpgradeHandler(
return vm, err
}

ctx.Logger().Info("Upgrade complete")
UpgradeSigningInfos(ctx, keepers.SlashingKeeper)

ctx.Logger().Info("Upgrade v15 complete")
return vm, err
}
}

// UpgradeSigningInfos updates the signing infos of validators for which
// the consensus address is missing
func UpgradeSigningInfos(ctx sdk.Context, sk slashingkeeper.Keeper) {
signingInfos := []slashingtypes.ValidatorSigningInfo{}
mpoke marked this conversation as resolved.
Show resolved Hide resolved

// update consensus address in signing info
// using the store key of validators
sk.IterateValidatorSigningInfos(ctx, func(address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
if info.Address == "" {
info.Address = address.String()
signingInfos = append(signingInfos, info)
}

return false
})

for _, si := range signingInfos {
addr, err := sdk.ConsAddressFromBech32(si.Address)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be safe, avoid the panic, log an error message and move to the next signing info.

}
sk.SetValidatorSigningInfo(ctx, addr, si)
}
}
71 changes: 71 additions & 0 deletions app/upgrades/v15/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package v15_test

import (
"testing"
"time"

"github.com/stretchr/testify/require"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/testutil/mock"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"

"github.com/cosmos/gaia/v15/app/helpers"
v15 "github.com/cosmos/gaia/v15/app/upgrades/v15"
)

func TestUpgradeSigningInfos(t *testing.T) {
gaiaApp := helpers.Setup(t)
ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{})
slashingKeeper := gaiaApp.SlashingKeeper

signingInfosNum := 8
emptyAddrCtr := 0

// create some dummy signing infos, half of which with an empty address field
for i := 0; i < signingInfosNum; i++ {
pubKey, err := mock.NewPV().GetPubKey()
require.NoError(t, err)

consAddr := sdk.ConsAddress(pubKey.Address())
info := slashingtypes.NewValidatorSigningInfo(
consAddr,
0,
0,
time.Unix(0, 0),
false,
0,
)

if i <= signingInfosNum/2 {
info.Address = ""
emptyAddrCtr++
}

slashingKeeper.SetValidatorSigningInfo(ctx, consAddr, info)
require.NoError(t, err)
}

// check signing info were correctly created
slashingKeeper.IterateValidatorSigningInfos(ctx, func(address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
MSalopek marked this conversation as resolved.
Show resolved Hide resolved
if info.Address == "" {
emptyAddrCtr--
}

return false
})
require.Zero(t, emptyAddrCtr)

// upgrade signing infos
v15.UpgradeSigningInfos(ctx, slashingKeeper)

// check that all signing info have the address field correctly updated
slashingKeeper.IterateValidatorSigningInfos(ctx, func(address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
require.NotEmpty(t, info.Address)
require.Equal(t, address.String(), info.Address)

return false
})
}
Loading