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

refactor(core,server): make commands not rely on server context #20422

Merged
merged 39 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7a6f8aa
simplify server ctx
hieuvubk May 7, 2024
620509e
remove toolchain
hieuvubk May 7, 2024
67e13d1
fix build simapp
hieuvubk May 7, 2024
16c293b
fix
hieuvubk May 7, 2024
217c539
Merge branch 'main' into hieu/simplify_server_ctx
hieuvubk May 7, 2024
c46359d
fix init test
hieuvubk May 8, 2024
251fa0c
Merge branch 'hieu/simplify_server_ctx' of https://github.com/decentr…
hieuvubk May 8, 2024
95b2c29
fix export tests
hieuvubk May 8, 2024
467428e
network track config
hieuvubk May 8, 2024
b9a7278
fix gen test
hieuvubk May 8, 2024
4dcf9e6
Merge branch 'main' into hieu/simplify_server_ctx
hieuvubk May 8, 2024
e8d9242
fix gen_acc test
hieuvubk May 8, 2024
5e1df8d
Merge branch 'hieu/simplify_server_ctx' of https://github.com/decentr…
hieuvubk May 8, 2024
77c3bc1
fix e2e err
hieuvubk May 8, 2024
081cc22
Merge branch 'main' into hieu/simplify_server_ctx
hieuvubk May 8, 2024
0b8808e
rename
hieuvubk May 8, 2024
6c9992d
clean up
hieuvubk May 8, 2024
f63a54e
fix test
hieuvubk May 8, 2024
ef68e88
no more server context
hieuvubk May 11, 2024
eafb6bb
Merge branch 'main' into hieu/simplify_server_ctx
tac0turtle May 17, 2024
cc3a5df
fix network tests
hieuvubk May 20, 2024
e7aee2d
Merge branch 'main' into hieu/simplify_server_ctx
tac0turtle May 20, 2024
a360be7
lint + some cleanup
hieuvubk May 20, 2024
1d3c29f
Merge branch 'hieu/simplify_server_ctx' of https://github.com/cosmos/…
hieuvubk May 20, 2024
c27b303
err check
hieuvubk May 20, 2024
0bcea5e
lint
hieuvubk May 20, 2024
6ab5b56
rerun CI
hieuvubk May 20, 2024
b31896d
refactor: keep LegacyServerContext
hieuvubk May 22, 2024
7c4e602
address comment
hieuvubk May 22, 2024
baae5d4
key as type
hieuvubk May 22, 2024
5de4f6c
add deprecated cmt
hieuvubk May 23, 2024
9fbb8e8
revert: server v0 use Context
hieuvubk May 23, 2024
731751b
fix err format
hieuvubk May 23, 2024
d7e7864
lint
hieuvubk May 23, 2024
c90c6ac
add changelog
hieuvubk May 23, 2024
e3c0a03
rename
hieuvubk May 23, 2024
7896c75
unused
hieuvubk May 23, 2024
9fb1cf8
Merge branch 'main' into hieu/simplify_server_ctx
julienrbrt May 27, 2024
8eb2ebf
resolve conflict
hieuvubk May 28, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### API Breaking Changes

* (server) [#20422](https://github.com/cosmos/cosmos-sdk/pull/20422) Deprecated `ServerContext`. To get `cmtcfg.Config` from cmd, use `client.GetCometConfigFromCmd(cmd)` instead of `server.GetServerContextFromCmd(cmd).Config`
* (types)[#20369](https://github.com/cosmos/cosmos-sdk/pull/20369) The signature of `HasAminoCodec` has changed to accept a `core/legacy.Amino` interface instead of `codec.LegacyAmino`.
* (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument.
* (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`.
Expand Down
41 changes: 41 additions & 0 deletions client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import (
"slices"
"strings"

cmtcfg "github.com/cometbft/cometbft/config"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"

signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
corectx "cosmossdk.io/core/context"
"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand Down Expand Up @@ -373,3 +377,40 @@ func SetCmdClientContext(cmd *cobra.Command, clientCtx Context) error {

return nil
}

hieuvubk marked this conversation as resolved.
Show resolved Hide resolved
func GetViperFromCmd(cmd *cobra.Command) *viper.Viper {
value := cmd.Context().Value(corectx.ViperContextKey{})
v, ok := value.(*viper.Viper)
if !ok {
return viper.New()
}
return v
}

func GetConfigFromCmd(cmd *cobra.Command) *cmtcfg.Config {
v := cmd.Context().Value(corectx.ViperContextKey{})
viper, ok := v.(*viper.Viper)
if !ok {
return cmtcfg.DefaultConfig()
}
return GetConfigFromViper(viper)
}

func GetLoggerFromCmd(cmd *cobra.Command) log.Logger {
v := cmd.Context().Value(corectx.LoggerContextKey{})
logger, ok := v.(log.Logger)
if !ok {
return log.NewLogger(cmd.OutOrStdout())
}
return logger
}

func GetConfigFromViper(v *viper.Viper) *cmtcfg.Config {
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
hieuvubk marked this conversation as resolved.
Show resolved Hide resolved
conf := cmtcfg.DefaultConfig()
err := v.Unmarshal(conf)
rootDir := v.GetString(flags.FlagHome)
if err != nil {
return cmtcfg.DefaultConfig().SetRoot(rootDir)
}
return conf.SetRoot(rootDir)
Comment on lines +408 to +415
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize error handling in GetConfigFromViper.

The function GetConfigFromViper handles errors by returning a default configuration with the root directory set. However, it might be more appropriate to also log the error or throw it back to the caller to handle it, as swallowing the error might hide underlying issues.

- return cmtcfg.DefaultConfig().SetRoot(rootDir)
+ return nil, fmt.Errorf("failed to unmarshal configuration: %w", err)

}
5 changes: 3 additions & 2 deletions client/snapshot/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
)

Expand All @@ -14,7 +15,7 @@ func DeleteSnapshotCmd() *cobra.Command {
Short: "Delete a local snapshot",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
viper := client.GetViperFromCmd(cmd)

height, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
Expand All @@ -25,7 +26,7 @@ func DeleteSnapshotCmd() *cobra.Command {
return err
}

snapshotStore, err := server.GetSnapshotStore(ctx.Viper)
snapshotStore, err := server.GetSnapshotStore(viper)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions client/snapshot/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
)

Expand All @@ -21,8 +22,8 @@ func DumpArchiveCmd() *cobra.Command {
Short: "Dump the snapshot as portable archive format",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
snapshotStore, err := server.GetSnapshotStore(ctx.Viper)
viper := client.GetViperFromCmd(cmd)
snapshotStore, err := server.GetSnapshotStore(viper)
if err != nil {
return err
}
Expand Down
10 changes: 6 additions & 4 deletions client/snapshot/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
)
Expand All @@ -16,20 +17,21 @@ func ExportSnapshotCmd[T servertypes.Application](appCreator servertypes.AppCrea
Short: "Export app state to snapshot store",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
cfg := client.GetConfigFromCmd(cmd)
viper := client.GetViperFromCmd(cmd)

height, err := cmd.Flags().GetInt64("height")
if err != nil {
return err
}

home := ctx.Config.RootDir
db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
home := cfg.RootDir
db, err := openDB(home, server.GetAppDBBackend(viper))
if err != nil {
return err
}
logger := log.NewLogger(cmd.OutOrStdout())
app := appCreator(logger, db, nil, ctx.Viper)
app := appCreator(logger, db, nil, viper)

if height == 0 {
height = app.CommitMultiStore().LastCommitID().Version
Expand Down
5 changes: 3 additions & 2 deletions client/snapshot/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
)

Expand All @@ -13,8 +14,8 @@ var ListSnapshotsCmd = &cobra.Command{
Use: "list",
Short: "List local snapshots",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
snapshotStore, err := server.GetSnapshotStore(ctx.Viper)
viper := client.GetViperFromCmd(cmd)
snapshotStore, err := server.GetSnapshotStore(viper)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions client/snapshot/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

snapshottypes "cosmossdk.io/store/snapshots/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
)

Expand All @@ -27,8 +28,8 @@ func LoadArchiveCmd() *cobra.Command {
Short: "Load a snapshot archive file (.tar.gz) into snapshot store",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
snapshotStore, err := server.GetSnapshotStore(ctx.Viper)
viper := client.GetViperFromCmd(cmd)
snapshotStore, err := server.GetSnapshotStore(viper)
if err != nil {
return err
}
Expand Down
10 changes: 6 additions & 4 deletions client/snapshot/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
)
Expand All @@ -21,7 +22,8 @@ func RestoreSnapshotCmd[T servertypes.Application](appCreator servertypes.AppCre
Long: "Restore app state from local snapshot",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
cfg := client.GetConfigFromCmd(cmd)
viper := client.GetViperFromCmd(cmd)

height, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
Expand All @@ -32,13 +34,13 @@ func RestoreSnapshotCmd[T servertypes.Application](appCreator servertypes.AppCre
return err
}

home := ctx.Config.RootDir
db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
home := cfg.RootDir
db, err := openDB(home, server.GetAppDBBackend(viper))
if err != nil {
return err
}
logger := log.NewLogger(cmd.OutOrStdout())
app := appCreator(logger, db, nil, ctx.Viper)
app := appCreator(logger, db, nil, viper)

sm := app.SnapshotManager()
return sm.RestoreLocalSnapshot(height, uint32(format))
Expand Down
6 changes: 6 additions & 0 deletions core/context/server_context.go
hieuvubk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package context

type (
LoggerContextKey struct{}
ViperContextKey struct{}
)
4 changes: 2 additions & 2 deletions core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ require (
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
Expand Down
8 changes: 4 additions & 4 deletions core/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE=
github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand All @@ -25,8 +25,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
Expand Down
8 changes: 7 additions & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/spf13/viper"
"golang.org/x/sync/errgroup"

corectx "cosmossdk.io/core/context"
"cosmossdk.io/log"
"cosmossdk.io/store"
"cosmossdk.io/store/snapshots"
Expand All @@ -45,6 +46,7 @@ import (
const ServerContextKey = sdk.ContextKey("server.context")

// Context server context
// Deprecated: Do not use since we use viper to track all config
type Context struct {
Viper *viper.Viper
Config *cmtcfg.Config
Expand Down Expand Up @@ -223,7 +225,11 @@ func SetCmdServerContext(cmd *cobra.Command, serverCtx *Context) error {
cmdCtx = cmd.Context()
}

cmd.SetContext(context.WithValue(cmdCtx, ServerContextKey, serverCtx))
cmdCtx = context.WithValue(cmdCtx, ServerContextKey, serverCtx)
cmdCtx = context.WithValue(cmdCtx, corectx.ViperContextKey{}, serverCtx.Viper)
hieuvubk marked this conversation as resolved.
Show resolved Hide resolved
cmdCtx = context.WithValue(cmdCtx, corectx.LoggerContextKey{}, serverCtx.Logger)

cmd.SetContext(cmdCtx)

return nil
}
Expand Down
6 changes: 4 additions & 2 deletions simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ Example:
return err
}

serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config
config := client.GetConfigFromCmd(cmd)

args := initArgs{}
args.outputDir, _ = cmd.Flags().GetString(flagOutputDir)
Expand Down Expand Up @@ -407,6 +406,9 @@ func initTestnetFiles(
return err
}

// Update viper root since root dir become rootdir/node/simd
client.GetViperFromCmd(cmd).Set(flags.FlagHome, nodeConfig.RootDir)

cmd.PrintErrf("Successfully initialized %d node directories\n", args.numValidators)
return nil
}
Expand Down
11 changes: 7 additions & 4 deletions simapp/simd/cmd/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/viper"
"github.com/stretchr/testify/require"

corectx "cosmossdk.io/core/context"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"cosmossdk.io/x/auth"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
"github.com/cosmos/cosmos-sdk/types/module"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
Expand Down Expand Up @@ -51,13 +51,15 @@ func Test_TestnetCmd(t *testing.T) {
cdcOpts := codectestutil.CodecOptions{}
encodingConfig := moduletestutil.MakeTestEncodingConfig(cdcOpts, auth.AppModule{}, staking.AppModule{})
logger := log.NewNopLogger()
viper := viper.New()
cfg, err := genutiltest.CreateDefaultCometConfig(home)
require.NoError(t, err)

err = genutiltest.ExecInitCmd(moduleManager, home, encodingConfig.Codec)
require.NoError(t, err)

serverCtx := server.NewContext(viper.New(), cfg, logger)
err = genutiltest.WriteAndTrackCometConfig(viper, home, cfg)
require.NoError(t, err)
clientCtx := client.Context{}.
WithCodec(encodingConfig.Codec).
WithHomeDir(home).
Expand All @@ -66,14 +68,15 @@ func Test_TestnetCmd(t *testing.T) {
WithValidatorAddressCodec(cdcOpts.GetValidatorCodec())

ctx := context.Background()
ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx)
ctx = context.WithValue(ctx, corectx.ViperContextKey{}, viper)
ctx = context.WithValue(ctx, corectx.LoggerContextKey{}, logger)
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
cmd := testnetInitFilesCmd(moduleManager, banktypes.GenesisBalancesIterator{})
cmd.SetArgs([]string{fmt.Sprintf("--%s=test", flags.FlagKeyringBackend), fmt.Sprintf("--output-dir=%s", home)})
err = cmd.ExecuteContext(ctx)
require.NoError(t, err)

genFile := cfg.GenesisFile()
genFile := client.GetConfigFromCmd(cmd).GenesisFile()
appState, _, err := genutiltypes.GenesisStateFromGenFile(genFile)
require.NoError(t, err)

Expand Down
7 changes: 4 additions & 3 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
minttypes "cosmossdk.io/x/mint/types"

bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/server"
Expand Down Expand Up @@ -228,11 +229,11 @@ func NewTestNetworkFixture() network.TestFixture {

appCtr := func(val network.ValidatorI) servertypes.Application {
return NewSimApp(
val.GetCtx().Logger, dbm.NewMemDB(), nil, true,
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
val.GetLogger(), dbm.NewMemDB(), nil, true,
simtestutil.NewAppOptionsWithFlagHome(client.GetConfigFromViper(val.GetViper()).RootDir),
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
bam.SetChainID(val.GetCtx().Viper.GetString(flags.FlagChainID)),
bam.SetChainID(val.GetViper().GetString(flags.FlagChainID)),
Comment on lines +232 to +236
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper handling of configuration retrieval and error checking.

- val.GetLogger(), dbm.NewMemDB(), nil, true,
- simtestutil.NewAppOptionsWithFlagHome(client.GetConfigFromViper(val.GetViper()).RootDir),
- bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
- bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
- bam.SetChainID(val.GetViper().GetString(flags.FlagChainID)),
+ logger, db, nil, true,
+ appOpts,
+ bam.SetPruning(pruningOpts),
+ bam.SetMinGasPrices(minGasPrices),
+ bam.SetChainID(chainID),

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
val.GetLogger(), dbm.NewMemDB(), nil, true,
simtestutil.NewAppOptionsWithFlagHome(client.GetConfigFromViper(val.GetViper()).RootDir),
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
bam.SetChainID(val.GetCtx().Viper.GetString(flags.FlagChainID)),
bam.SetChainID(val.GetViper().GetString(flags.FlagChainID)),
logger, db, nil, true,
appOpts,
bam.SetPruning(pruningOpts),
bam.SetMinGasPrices(minGasPrices),
bam.SetChainID(chainID),

)
}

Expand Down
Loading
Loading