Skip to content

Commit

Permalink
delete ethermint store content
Browse files Browse the repository at this point in the history
  • Loading branch information
catShaark committed Oct 23, 2024
1 parent 9bef0f2 commit 78d395f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (app *RealioNetwork) setupUpgradeHandlers() {
app.ParamsKeeper,
app.ConsensusParamsKeeper,
*app.IBCKeeper,
app.CommitMultiStore().GetKVStore(app.keys["evm"]),
),
)

Expand Down
23 changes: 23 additions & 0 deletions app/upgrades/v2/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v2
import (
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -33,6 +34,7 @@ func CreateUpgradeHandler(
paramskeeper paramskeeper.Keeper,
consensuskeeper consensusparamkeeper.Keeper,
IBCKeeper ibckeeper.Keeper,
EvmStore storetypes.KVStore,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

Expand Down Expand Up @@ -79,6 +81,27 @@ func CreateUpgradeHandler(
params.AllowedClients = append(params.AllowedClients, exported.Localhost)
IBCKeeper.ClientKeeper.SetParams(sdkCtx, params)

err := deleteKVStore(EvmStore)
if err != nil {
return nil, err
}

return mm.RunMigrations(ctx, configurator, vm)
}
}

func deleteKVStore(kv storetypes.KVStore) error {
// Note that we cannot write while iterating, so load all keys here, delete below
var keys [][]byte
itr := kv.Iterator(nil, nil)
for itr.Valid() {
keys = append(keys, itr.Key())
itr.Next()
}
_ = itr.Close()

for _, k := range keys {
kv.Delete(k)
}
return nil
}

0 comments on commit 78d395f

Please sign in to comment.