Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stf): fixes to make init genesis pass #21088

Merged
merged 3 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions runtime/v2/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
home := v.GetString(FlagHome)

storeOpts := rootstore.DefaultStoreOptions()
if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil {
return nil, fmt.Errorf("failed to store options: %w", err)
if s := v.Sub("store.options"); s != nil {
if err := s.Unmarshal(&storeOpts); err != nil {
return nil, fmt.Errorf("failed to store options: %w", err)
}
}

scRawDb, err := db.NewDB(db.DBType(v.GetString("store.app-db-backend")), "application", filepath.Join(home, "data"), nil)
Expand Down
2 changes: 1 addition & 1 deletion runtime/v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (m *MM[T]) InitGenesisJSON(
case appmodulev2.HasGenesis:
m.logger.Debug("running initialization for module", "module", moduleName)
if err := module.InitGenesis(ctx, genesisData[moduleName]); err != nil {
return err
return fmt.Errorf("init module %s: %w", moduleName, err)
}
case appmodulev2.HasABCIGenesis:
m.logger.Debug("running initialization for module", "module", moduleName)
Expand Down
3 changes: 2 additions & 1 deletion server/v2/stf/core_event_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"slices"

"github.com/cosmos/cosmos-sdk/codec"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't bring in a cosmos-sdk dependency, can we use directly gogoproto jsonpb?

gogoproto "github.com/cosmos/gogoproto/proto"
"golang.org/x/exp/maps"

Expand Down Expand Up @@ -55,7 +56,7 @@ func (em *eventManager) EmitNonConsensus(event gogoproto.Message) error {
// TypedEventToEvent takes typed event and converts to Event object
func TypedEventToEvent(tev gogoproto.Message) (event.Event, error) {
evtType := gogoproto.MessageName(tev)
evtJSON, err := gogoproto.Marshal(tev)
evtJSON, err := codec.ProtoMarshalJSON(tev, nil)
if err != nil {
return event.Event{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion server/v2/store/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger
}

storeOpts := root.DefaultStoreOptions()
if v != nil {
if v != nil && v.Sub("store.options") != nil {
if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil {
return nil, 0, fmt.Errorf("failed to store options: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions simapp/v2/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package simapp
import (
_ "embed"

"github.com/spf13/viper"

clienthelpers "cosmossdk.io/client/v2/helpers"
coreapp "cosmossdk.io/core/app"
"cosmossdk.io/core/legacy"
Expand All @@ -31,6 +29,8 @@ import (
slashingkeeper "cosmossdk.io/x/slashing/keeper"
stakingkeeper "cosmossdk.io/x/staking/keeper"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/spf13/viper"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter won't be happy of this


"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down
Loading