fix: ConsensusVersion on machine module (#432)

* fix: ConsensusVersion on machine module
* fix: use correct key to store activated ta counter on migration
---------
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2024-07-25 10:31:15 +02:00 committed by GitHub
parent c2ef2b5924
commit 5d84ae6806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 6 deletions

View File

@ -22,5 +22,5 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
}
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.taStoreKey, m.keeper.cdc)
return v3.MigrateStore(ctx, m.keeper.taStoreKey, m.keeper.storeKey)
}

View File

@ -3,18 +3,17 @@ package v3
import (
"encoding/binary"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/machine/types"
)
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, _ codec.BinaryCodec) error {
store := prefix.NewStore(ctx.KVStore(storeKey), types.KeyPrefix(types.TrustAnchorKey))
func MigrateStore(ctx sdk.Context, taStoreKey storetypes.StoreKey, storeKey storetypes.StoreKey) error {
store := ctx.KVStore(taStoreKey)
count := uint64(0)
iterator := store.Iterator(nil, nil)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.TrustAnchorKey))
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
if iterator.Value()[0] == 1 {

View File

@ -149,7 +149,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}
// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return 4 }
// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {