-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from Fairblock/add-keyshare-migration
Add keyshare migration
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package keeper | ||
|
||
import ( | ||
v2 "github.com/Fairblock/fairyring/x/keyshare/migrations/v2" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Migrator is a struct for handling in-place store migrations. | ||
type Migrator struct { | ||
keeper Keeper | ||
} | ||
|
||
// NewMigrator returns a new Migrator. | ||
func NewMigrator(keeper Keeper) Migrator { | ||
return Migrator{keeper: keeper} | ||
} | ||
|
||
// Migrate1to2 migrates from version 1 to 2. | ||
func (m Migrator) Migrate1to2(ctx sdk.Context) error { | ||
return v2.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v2 | ||
|
||
import ( | ||
"cosmossdk.io/core/store" | ||
"github.com/Fairblock/fairyring/x/keyshare/types" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// MigrateStore migrates the x/keyshare module state from the consensus version 1 to version 2. | ||
func MigrateStore(ctx sdk.Context, storeService store.KVStoreService, cdc codec.BinaryCodec) error { | ||
currParams := types.NewParams( | ||
463000, | ||
[]string{"fairy1r6q07ne3deq64ezcjwkedcfe6669f0ewpwnxy9"}, | ||
types.DefaultMinimumBonded, | ||
types.DefaultSlashFractionNoKeyShare, | ||
types.DefaultSlashFractionWrongKeyShare, | ||
types.DefaultMaxIdledBlock) | ||
|
||
bz, err := cdc.Marshal(&currParams) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
store := storeService.OpenKVStore(ctx) | ||
return store.Set(types.ParamsKey, bz) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters