Skip to content

Commit

Permalink
feat: extra logging in in-place store migrations (backport cosmos#10768
Browse files Browse the repository at this point in the history
…) (cosmos#11107)

* feat: extra logging in in-place store migrations (cosmos#10768)

## Description

Closes: cosmos#10689

it'd also be good to add more fine-grained tracking of individual migrations,
but there doesn't seem to be a quick way of doing it.
Perhaps the best is to leave it to each migration implementation
to add its own internal logging?

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] ~added `!` to the type prefix if API or client breaking change~
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] ~included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)~
- [x] added a changelog entry to `CHANGELOG.md`
- [ ] ~included comments for [documenting Go code](https://blog.golang.org/godoc)~
- [ ] ~updated the relevant documentation or specification~
- [x] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit 8b74157)

# Conflicts:
#	types/module/module.go

* fix conflict

* remove files

Co-authored-by: Tomas Tauber <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 921e272 commit 3abb791
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [\#10768](https://github.com/cosmos/cosmos-sdk/pull/10768) Added extra logging for tracking in-place store migrations
* [\#10262](https://github.com/cosmos/cosmos-sdk/pull/10262) Remove unnecessary logging in `x/feegrant` simulation.
* [\#10327](https://github.com/cosmos/cosmos-sdk/pull/10327) Add null guard for possible nil `Amount` in tx fee `Coins`
* [\#10339](https://github.com/cosmos/cosmos-sdk/pull/10339) Improve performance of `removeZeroCoins` by only allocating memory when necessary
Expand Down
9 changes: 1 addition & 8 deletions types/module/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ package module
import (
"fmt"

"github.com/cosmos/gogoproto/grpc"
googlegrpc "google.golang.org/grpc"
protobuf "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"

cosmosmsg "cosmossdk.io/api/cosmos/msg/v1"
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
"github.com/gogo/protobuf/grpc"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
16 changes: 6 additions & 10 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,17 +666,13 @@ func (m Manager) RunMigrations(ctx context.Context, cfg Configurator, fromVM app
return nil, err
}
}
if module, ok := m.Modules[moduleName].(HasABCIGenesis); ok {
moduleValUpdates, err := module.InitGenesis(sdkCtx, module.DefaultGenesis())
if err != nil {
return nil, err
}

// The module manager assumes only one module will update the
// validator set, and it can't be a new module.
if len(moduleValUpdates) > 0 {
return nil, errorsmod.Wrapf(sdkerrors.ErrLogic, "validator InitGenesis update is already set by another module")
}
moduleValUpdates := module.InitGenesis(ctx, cfgtor.cdc, module.DefaultGenesis(cfgtor.cdc))
ctx.Logger().Info(fmt.Sprintf("adding a new module: %s", moduleName))
// The module manager assumes only one module will update the
// validator set, and that it will not be by a new module.
if len(moduleValUpdates) > 0 {
return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, "validator InitGenesis updates already set by a previous module")
}
}

Expand Down

0 comments on commit 3abb791

Please sign in to comment.