Skip to content

Commit

Permalink
Merge pull request #39 from rarimo/feature/handler-v1.1.1-rc6
Browse files Browse the repository at this point in the history
Feature/handler v1.1.4-rc6
  • Loading branch information
olegfomenko authored Sep 4, 2024
2 parents 00c7ca8 + 4fc0481 commit f9b0dd1
Show file tree
Hide file tree
Showing 7 changed files with 684 additions and 20 deletions.
29 changes: 18 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,14 +1109,14 @@ func New(
app.UpgradeKeeper.SetUpgradeHandler(
"v1.1.4-rc1",
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.RootupdaterKeeper.SetParams(ctx, rootupdatermoduletypes.Params{
ContractAddress: "0xBF926a23B4A0bcA301F97Ccd27358b55Dc4C7D3C",
Root: "0x00",
LastSignedRoot: "0x00",
LastSignedRootIndex: "0x00",
EventName: "RootUpdated",
RootTimestamp: 1724316208,
})
//app.RootupdaterKeeper.SetParams(ctx, rootupdatermoduletypes.Params{
// ContractAddress: "0xBF926a23B4A0bcA301F97Ccd27358b55Dc4C7D3C",
// Root: "0x00",
// LastSignedRoot: "0x00",
// LastSignedRootIndex: "0x00",
// EventName: "RootUpdated",
// RootTimestamp: 1724316208,
//})
fromVM[rootupdatermoduletypes.ModuleName] = rootupdatermodule.AppModule{}.ConsensusVersion()

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
Expand All @@ -1126,9 +1126,9 @@ func New(
app.UpgradeKeeper.SetUpgradeHandler(
"v1.1.4-rc2",
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
params := app.RootupdaterKeeper.GetParams(ctx)
params.ContractAddress = "0xc1534912902BBe8C54626e2D69288C76a843bc0E"
app.RootupdaterKeeper.SetParams(ctx, params)
//params := app.RootupdaterKeeper.GetParams(ctx)
//params.ContractAddress = "0xc1534912902BBe8C54626e2D69288C76a843bc0E"
//app.RootupdaterKeeper.SetParams(ctx, params)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)
Expand Down Expand Up @@ -1161,6 +1161,13 @@ func New(
},
)

app.UpgradeKeeper.SetUpgradeHandler(
"v1.1.4-rc6",
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ require (
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-gonic/gin v1.8.1 // indirect
github.com/github/smimesign v0.2.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,6 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqG
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
Expand Down Expand Up @@ -1154,7 +1153,6 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o=
Expand Down Expand Up @@ -1279,7 +1277,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs=
Expand Down Expand Up @@ -1533,7 +1530,6 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s=
github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI=
Expand Down
24 changes: 24 additions & 0 deletions x/rootupdater/keeper/migrations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v2 "github.com/rarimo/rarimo-core/x/rootupdater/migrations/v2"
)

type Migrator struct {
keeper Keeper
}

func NewMigrator(keeper Keeper) Migrator {
return Migrator{
keeper: keeper,
}
}

func (m Migrator) Migrate1to2(ctx sdk.Context) error {
if err := v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc); err != nil {
return err
}

return nil
}
35 changes: 35 additions & 0 deletions x/rootupdater/migrations/v2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v2

import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/rarimo/rarimo-core/x/rootupdater/types"
)

func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
ctx.Logger().Info(fmt.Sprintf("Performing v1.1.4-rc6 %s module migrations", types.ModuleName))

store := ctx.KVStore(storeKey)

oldParamsBytes := store.Get(types.KeyPrefix(types.ParamsKey))
store.Delete(types.KeyPrefix(types.ParamsKey))

oldParams := OldParamas{}
cdc.MustUnmarshal(oldParamsBytes, &oldParams)
params := types.Params{
DestinationContractAddress: "0x2af05993a27df83094a963af64b5d25296230544",
SourceContractAddress: oldParams.ContractAddress,
Root: oldParams.Root,
RootTimestamp: oldParams.RootTimestamp,
LastSignedRootIndex: oldParams.LastSignedRootIndex,
LastSignedRoot: oldParams.LastSignedRoot,
BlockHeight: oldParams.BlockHeight,
EventName: oldParams.EventName,
}

store.Set(types.KeyPrefix(types.ParamsKey), cdc.MustMarshal(&params))

return nil
}
Loading

0 comments on commit f9b0dd1

Please sign in to comment.