refactor: remove viper as a direct dependency (#21635)
This commit is contained in:
parent
4fe934e8af
commit
57f35dcdfe
8
core/server/config.go
Normal file
8
core/server/config.go
Normal file
@ -0,0 +1,8 @@
|
||||
package server
|
||||
|
||||
// DynamicConfig defines an interface for configuration that can be dynamically
|
||||
// fetched at runtime by an arbitrary key.
|
||||
type DynamicConfig interface {
|
||||
Get(string) any
|
||||
GetString(string) string
|
||||
}
|
||||
1
go.mod
1
go.mod
@ -185,6 +185,7 @@ require (
|
||||
replace (
|
||||
cosmossdk.io/api => ./api
|
||||
cosmossdk.io/collections => ./collections
|
||||
cosmossdk.io/core => ./core
|
||||
cosmossdk.io/core/testing => ./core/testing
|
||||
cosmossdk.io/store => ./store
|
||||
cosmossdk.io/x/bank => ./x/bank
|
||||
|
||||
2
go.sum
2
go.sum
@ -4,8 +4,6 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
|
||||
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
|
||||
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
|
||||
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
|
||||
@ -7,10 +7,9 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/server/v2/appmanager"
|
||||
@ -25,8 +24,8 @@ import (
|
||||
// the existing app.go initialization conventions.
|
||||
type AppBuilder[T transaction.Tx] struct {
|
||||
app *App[T]
|
||||
storeOptions *rootstore.FactoryOptions
|
||||
viper *viper.Viper
|
||||
config server.DynamicConfig
|
||||
storeOptions rootstore.Options
|
||||
|
||||
// the following fields are used to overwrite the default
|
||||
branch func(state store.ReaderMap) store.WriterMap
|
||||
@ -73,9 +72,6 @@ func (a *AppBuilder[T]) RegisterModules(modules map[string]appmodulev2.AppModule
|
||||
// To be used in combination of RegisterModules.
|
||||
func (a *AppBuilder[T]) RegisterStores(keys ...string) {
|
||||
a.app.storeKeys = append(a.app.storeKeys, keys...)
|
||||
if a.storeOptions != nil {
|
||||
a.storeOptions.StoreKeys = append(a.storeOptions.StoreKeys, keys...)
|
||||
}
|
||||
}
|
||||
|
||||
// Build builds an *App instance.
|
||||
@ -124,29 +120,26 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
|
||||
}
|
||||
a.app.stf = stf
|
||||
|
||||
storeOpts := rootstore.DefaultStoreOptions()
|
||||
if s := a.viper.Sub("store.options"); s != nil {
|
||||
if err := s.Unmarshal(&storeOpts); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal store options: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
home := a.viper.GetString(FlagHome)
|
||||
scRawDb, err := db.NewDB(db.DBType(a.viper.GetString("store.app-db-backend")), "application", filepath.Join(home, "data"), nil)
|
||||
home := a.config.GetString(FlagHome)
|
||||
scRawDb, err := db.NewDB(
|
||||
db.DBType(a.config.GetString("store.app-db-backend")),
|
||||
"application",
|
||||
filepath.Join(home, "data"),
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
storeOptions := &rootstore.FactoryOptions{
|
||||
factoryOptions := &rootstore.FactoryOptions{
|
||||
Logger: a.app.logger,
|
||||
RootDir: home,
|
||||
Options: storeOpts,
|
||||
Options: a.storeOptions,
|
||||
StoreKeys: append(a.app.storeKeys, "stf"),
|
||||
SCRawDB: scRawDb,
|
||||
}
|
||||
a.storeOptions = storeOptions
|
||||
|
||||
rs, err := rootstore.CreateRootStore(a.storeOptions)
|
||||
rs, err := rootstore.CreateRootStore(factoryOptions)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create root store: %w", err)
|
||||
}
|
||||
@ -217,14 +210,14 @@ func AppBuilderWithTxValidator[T transaction.Tx](txValidators func(ctx context.C
|
||||
|
||||
// AppBuilderWithPostTxExec sets logic that will be executed after each transaction.
|
||||
// When not provided, a no-op function will be used.
|
||||
func AppBuilderWithPostTxExec[T transaction.Tx](
|
||||
postTxExec func(
|
||||
ctx context.Context,
|
||||
tx T,
|
||||
success bool,
|
||||
) error,
|
||||
) AppBuilderOption[T] {
|
||||
func AppBuilderWithPostTxExec[T transaction.Tx](postTxExec func(ctx context.Context, tx T, success bool) error) AppBuilderOption[T] {
|
||||
return func(a *AppBuilder[T]) {
|
||||
a.postTxExec = postTxExec
|
||||
}
|
||||
}
|
||||
|
||||
func AppBuilderWithStoreOptions[T transaction.Tx](opts rootstore.Options) AppBuilderOption[T] {
|
||||
return func(a *AppBuilder[T]) {
|
||||
a.storeOptions = opts
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ go 1.23
|
||||
// server v2 integration
|
||||
replace (
|
||||
cosmossdk.io/api => ../../api
|
||||
cosmossdk.io/core => ../../core
|
||||
cosmossdk.io/core/testing => ../../core/testing
|
||||
cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager
|
||||
cosmossdk.io/server/v2/stf => ../../server/v2/stf
|
||||
@ -22,7 +23,6 @@ require (
|
||||
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/tx v0.13.3
|
||||
github.com/cosmos/gogoproto v1.7.0
|
||||
github.com/spf13/viper v1.19.0
|
||||
google.golang.org/grpc v1.66.1
|
||||
google.golang.org/protobuf v1.34.2
|
||||
)
|
||||
@ -45,7 +45,6 @@ require (
|
||||
github.com/cosmos/ics23/go v0.11.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/emicklei/dot v1.6.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
@ -54,19 +53,15 @@ require (
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-metrics v0.5.3 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/linxGnu/grocksdb v1.8.14 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/onsi/gomega v1.28.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.20.3 // indirect
|
||||
@ -75,18 +70,11 @@ require (
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.7.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/stretchr/testify v1.9.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tidwall/btree v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.27.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
@ -95,7 +83,6 @@ require (
|
||||
golang.org/x/text v0.18.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
@ -2,8 +2,6 @@ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fed
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
|
||||
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
|
||||
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
|
||||
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
|
||||
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
|
||||
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA=
|
||||
@ -123,8 +121,6 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
|
||||
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
@ -145,8 +141,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ=
|
||||
github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
@ -156,8 +150,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
@ -182,8 +174,6 @@ github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA=
|
||||
github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
|
||||
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
|
||||
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
@ -219,39 +209,19 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
|
||||
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
|
||||
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
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.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
|
||||
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
|
||||
@ -263,8 +233,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -363,8 +331,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@ -373,7 +339,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/reflect/protodesc"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
@ -18,6 +17,7 @@ import (
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/comet"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/depinject"
|
||||
@ -145,7 +145,7 @@ type AppInputs struct {
|
||||
InterfaceRegistrar registry.InterfaceRegistrar
|
||||
LegacyAmino registry.AminoRegistrar
|
||||
Logger log.Logger
|
||||
Viper *viper.Viper `optional:"true"` // can be nil in client wiring
|
||||
DynamicConfig server.DynamicConfig `optional:"true"` // can be nil in client wiring
|
||||
}
|
||||
|
||||
func SetupAppBuilder(inputs AppInputs) {
|
||||
@ -156,8 +156,8 @@ func SetupAppBuilder(inputs AppInputs) {
|
||||
app.moduleManager.RegisterInterfaces(inputs.InterfaceRegistrar)
|
||||
app.moduleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino)
|
||||
|
||||
if inputs.Viper != nil {
|
||||
inputs.AppBuilder.viper = inputs.Viper
|
||||
if inputs.DynamicConfig != nil {
|
||||
inputs.AppBuilder.config = inputs.DynamicConfig
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -241,6 +241,7 @@ replace (
|
||||
cosmossdk.io/api => ../api
|
||||
cosmossdk.io/client/v2 => ../client/v2
|
||||
cosmossdk.io/collections => ../collections
|
||||
cosmossdk.io/core => ../core
|
||||
cosmossdk.io/core/testing => ../core/testing
|
||||
cosmossdk.io/store => ../store
|
||||
cosmossdk.io/tools/confix => ../tools/confix
|
||||
|
||||
@ -192,8 +192,6 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
|
||||
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
|
||||
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
|
||||
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
|
||||
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
|
||||
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
|
||||
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
|
||||
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
|
||||
@ -18,10 +18,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/configurator"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/testutil/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
@ -72,7 +72,9 @@ func Test_TestnetCmd(t *testing.T) {
|
||||
ctx = context.WithValue(ctx, corectx.LoggerContextKey, logger)
|
||||
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
||||
cmd := testnetInitFilesCmd(moduleManager)
|
||||
cmd.SetArgs([]string{fmt.Sprintf("--%s=test", flags.FlagKeyringBackend), fmt.Sprintf("--output-dir=%s", home)})
|
||||
cmd.SetArgs(
|
||||
[]string{fmt.Sprintf("--%s=test", flags.FlagKeyringBackend), fmt.Sprintf("--output-dir=%s", home)},
|
||||
)
|
||||
err = cmd.ExecuteContext(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/runtime/v2"
|
||||
"cosmossdk.io/store/v2/root"
|
||||
"cosmossdk.io/x/accounts"
|
||||
authzkeeper "cosmossdk.io/x/authz/keeper"
|
||||
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||
@ -96,8 +97,10 @@ func NewSimApp[T transaction.Tx](
|
||||
viper *viper.Viper,
|
||||
) *SimApp[T] {
|
||||
var (
|
||||
app = &SimApp[T]{}
|
||||
appBuilder *runtime.AppBuilder[T]
|
||||
app = &SimApp[T]{}
|
||||
appBuilder *runtime.AppBuilder[T]
|
||||
err error
|
||||
storeOptions = root.DefaultStoreOptions()
|
||||
|
||||
// merge the AppConfig and other configuration in one config
|
||||
appConfig = depinject.Configs(
|
||||
@ -187,8 +190,13 @@ func NewSimApp[T transaction.Tx](
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var err error
|
||||
app.App, err = appBuilder.Build()
|
||||
if sub := viper.Sub("store.options"); sub != nil {
|
||||
err = sub.Unmarshal(&storeOptions)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
app.App, err = appBuilder.Build(runtime.AppBuilderWithStoreOptions[T](storeOptions))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -287,6 +287,7 @@ replace (
|
||||
// server v2 integration
|
||||
replace (
|
||||
cosmossdk.io/api => ../../api
|
||||
cosmossdk.io/core => ../../core
|
||||
cosmossdk.io/core/testing => ../../core/testing
|
||||
cosmossdk.io/runtime/v2 => ../../runtime/v2
|
||||
cosmossdk.io/server/v2 => ../../server/v2
|
||||
|
||||
@ -192,8 +192,6 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
|
||||
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
|
||||
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
|
||||
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
|
||||
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
|
||||
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
|
||||
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
|
||||
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@ -8,6 +9,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"cosmossdk.io/client/v2/offchain"
|
||||
corectx "cosmossdk.io/core/context"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/log"
|
||||
runtimev2 "cosmossdk.io/runtime/v2"
|
||||
@ -63,7 +65,7 @@ func initRootCmd[T transaction.Tx](
|
||||
|
||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
genesisCommand(moduleManager, appExport[T]),
|
||||
genesisCommand(moduleManager),
|
||||
queryCommand(),
|
||||
txCommand(),
|
||||
keys.Commands(),
|
||||
@ -84,13 +86,16 @@ func initRootCmd[T transaction.Tx](
|
||||
}
|
||||
}
|
||||
|
||||
// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter
|
||||
// genesisCommand builds genesis-related `simd genesis` command.
|
||||
func genesisCommand[T transaction.Tx](
|
||||
moduleManager *runtimev2.MM[T],
|
||||
appExport genutilv2.AppExporter,
|
||||
cmds ...*cobra.Command,
|
||||
) *cobra.Command {
|
||||
cmd := v2.Commands(moduleManager.Modules()[genutiltypes.ModuleName].(genutil.AppModule), moduleManager, appExport)
|
||||
cmd := v2.Commands(
|
||||
moduleManager.Modules()[genutiltypes.ModuleName].(genutil.AppModule),
|
||||
moduleManager,
|
||||
appExport[T],
|
||||
)
|
||||
|
||||
for _, subCmd := range cmds {
|
||||
cmd.AddCommand(subCmd)
|
||||
@ -143,11 +148,23 @@ func txCommand() *cobra.Command {
|
||||
|
||||
// appExport creates a new simapp (optionally at a given height) and exports state.
|
||||
func appExport[T transaction.Tx](
|
||||
logger log.Logger,
|
||||
ctx context.Context,
|
||||
height int64,
|
||||
jailAllowedAddrs []string,
|
||||
viper *viper.Viper,
|
||||
) (genutilv2.ExportedApp, error) {
|
||||
value := ctx.Value(corectx.ViperContextKey)
|
||||
viper, ok := value.(*viper.Viper)
|
||||
if !ok {
|
||||
return genutilv2.ExportedApp{},
|
||||
fmt.Errorf("incorrect viper type %T: expected *viper.Viper in context", value)
|
||||
}
|
||||
value = ctx.Value(corectx.LoggerContextKey)
|
||||
logger, ok := value.(log.Logger)
|
||||
if !ok {
|
||||
return genutilv2.ExportedApp{},
|
||||
fmt.Errorf("incorrect logger type %T: expected log.Logger in context", value)
|
||||
}
|
||||
|
||||
// overwrite the FlagInvCheckPeriod
|
||||
viper.Set(server.FlagInvCheckPeriod, 1)
|
||||
viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome)
|
||||
|
||||
@ -82,7 +82,7 @@ func NewRootCmd[T transaction.Tx]() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
initRootCmd[T](rootCmd, clientCtx.TxConfig, moduleManager)
|
||||
initRootCmd(rootCmd, clientCtx.TxConfig, moduleManager)
|
||||
|
||||
nodeCmds := nodeservice.NewNodeCommands()
|
||||
autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions)
|
||||
|
||||
@ -30,9 +30,9 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
gentestutil "github.com/cosmos/cosmos-sdk/testutil/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
gentestutil "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ require (
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/google/gofuzz v1.2.0
|
||||
github.com/jhump/protoreflect v1.17.0
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/spf13/viper v1.19.0
|
||||
)
|
||||
|
||||
@ -180,7 +181,6 @@ require (
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
github.com/rs/cors v1.11.0 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.3.5 // indirect
|
||||
@ -237,6 +237,7 @@ replace (
|
||||
cosmossdk.io/api => ../api
|
||||
cosmossdk.io/client/v2 => ../client/v2
|
||||
cosmossdk.io/collections => ../collections
|
||||
cosmossdk.io/core => ../core
|
||||
cosmossdk.io/core/testing => ../core/testing
|
||||
cosmossdk.io/store => ../store
|
||||
cosmossdk.io/x/accounts => ../x/accounts
|
||||
|
||||
@ -192,8 +192,6 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
|
||||
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
|
||||
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
|
||||
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
|
||||
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
|
||||
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
|
||||
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
|
||||
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cli_test
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,4 +1,4 @@
|
||||
package cli_test
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -19,12 +19,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
genutilhelpers "github.com/cosmos/cosmos-sdk/testutil/x/genutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
@ -78,10 +78,13 @@ func TestAddGenesisAccountCmd(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
v := viper.New()
|
||||
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(
|
||||
codectestutil.CodecOptions{},
|
||||
auth.AppModule{},
|
||||
)
|
||||
appCodec := encodingConfig.Codec
|
||||
txConfig := encodingConfig.TxConfig
|
||||
err = genutiltest.ExecInitCmd(testMbm, home, appCodec)
|
||||
err = genutilhelpers.ExecInitCmd(testMbm, home, appCodec)
|
||||
require.NoError(t, err)
|
||||
|
||||
err := writeAndTrackDefaultConfig(v, home)
|
||||
@ -93,7 +96,13 @@ func TestAddGenesisAccountCmd(t *testing.T) {
|
||||
path := hd.CreateHDPath(118, 0, 0).String()
|
||||
kr, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendMemory, home, nil, appCodec)
|
||||
require.NoError(t, err)
|
||||
_, _, err = kr.NewMnemonic(tc.addr, keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
|
||||
_, _, err = kr.NewMnemonic(
|
||||
tc.addr,
|
||||
keyring.English,
|
||||
path,
|
||||
keyring.DefaultBIP39Passphrase,
|
||||
hd.Secp256k1,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
clientCtx = clientCtx.WithKeyring(kr)
|
||||
}
|
||||
@ -214,10 +223,13 @@ func TestBulkAddGenesisAccountCmd(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
v := viper.New()
|
||||
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{})
|
||||
encodingConfig := moduletestutil.MakeTestEncodingConfig(
|
||||
codectestutil.CodecOptions{},
|
||||
auth.AppModule{},
|
||||
)
|
||||
appCodec := encodingConfig.Codec
|
||||
txConfig := encodingConfig.TxConfig
|
||||
err = genutiltest.ExecInitCmd(testMbm, home, appCodec)
|
||||
err = genutilhelpers.ExecInitCmd(testMbm, home, appCodec)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = writeAndTrackDefaultConfig(v, home)
|
||||
@ -269,7 +281,13 @@ func TestBulkAddGenesisAccountCmd(t *testing.T) {
|
||||
|
||||
require.EqualValues(t, len(tc.expected), len(bankState.Balances))
|
||||
for _, acc := range bankState.Balances {
|
||||
require.True(t, tc.expected[acc.Address].Equal(acc.Coins), "expected: %v, got: %v", tc.expected[acc.Address], acc.Coins)
|
||||
require.True(
|
||||
t,
|
||||
tc.expected[acc.Address].Equal(acc.Coins),
|
||||
"expected: %v, got: %v",
|
||||
tc.expected[acc.Address],
|
||||
acc.Coins,
|
||||
)
|
||||
}
|
||||
|
||||
expectedSupply := sdk.NewCoins()
|
||||
@ -1,4 +1,4 @@
|
||||
package cli_test
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -28,11 +28,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/mock"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
genutilhelpers "github.com/cosmos/cosmos-sdk/testutil/x/genutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
@ -125,7 +125,9 @@ func TestInitRecover(t *testing.T) {
|
||||
})
|
||||
|
||||
// use valid mnemonic and complete recovery key generation successfully
|
||||
mockIn.Reset("decide praise business actor peasant farm drastic weather extend front hurt later song give verb rhythm worry fun pond reform school tumble august one\n")
|
||||
mockIn.Reset(
|
||||
"decide praise business actor peasant farm drastic weather extend front hurt later song give verb rhythm worry fun pond reform school tumble august one\n",
|
||||
)
|
||||
require.NoError(t, cmd.ExecuteContext(ctx))
|
||||
}
|
||||
|
||||
@ -213,7 +215,7 @@ func TestStartStandAlone(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
||||
err := genutiltest.ExecInitCmd(testMbm, home, marshaler)
|
||||
err := genutilhelpers.ExecInitCmd(testMbm, home, marshaler)
|
||||
require.NoError(t, err)
|
||||
|
||||
app, err := mock.NewApp(home, logger)
|
||||
@ -241,7 +243,7 @@ func TestStartStandAlone(t *testing.T) {
|
||||
|
||||
func TestInitNodeValidatorFiles(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
cfg, err := genutiltest.CreateDefaultCometConfig(home)
|
||||
cfg, err := genutilhelpers.CreateDefaultCometConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
||||
nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(cfg, ed25519.KeyType)
|
||||
@ -303,7 +305,7 @@ func TestInitWithHeight(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
logger := log.NewNopLogger()
|
||||
viper := viper.New()
|
||||
cfg, err := genutiltest.CreateDefaultCometConfig(home)
|
||||
cfg, err := genutilhelpers.CreateDefaultCometConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = writeAndTrackDefaultConfig(viper, home)
|
||||
@ -340,7 +342,7 @@ func TestInitWithNegativeHeight(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
logger := log.NewNopLogger()
|
||||
viper := viper.New()
|
||||
cfg, err := genutiltest.CreateDefaultCometConfig(home)
|
||||
cfg, err := genutilhelpers.CreateDefaultCometConfig(home)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = writeAndTrackDefaultConfig(viper, home)
|
||||
@ -385,9 +387,9 @@ func makeCodec() codec.Codec {
|
||||
}
|
||||
|
||||
func writeAndTrackDefaultConfig(v *viper.Viper, home string) error {
|
||||
cfg, err := genutiltest.CreateDefaultCometConfig(home)
|
||||
cfg, err := genutilhelpers.CreateDefaultCometConfig(home)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return genutiltest.WriteAndTrackCometConfig(v, home, cfg)
|
||||
return genutilhelpers.WriteAndTrackCometConfig(v, home, cfg)
|
||||
}
|
||||
@ -23,6 +23,7 @@ import (
|
||||
banktypes "cosmossdk.io/x/bank/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/server/api"
|
||||
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
|
||||
@ -30,7 +31,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
@ -180,7 +180,11 @@ func collectGenFiles(cfg Config, vals []*Validator, cmtConfigs []*cmtcfg.Config,
|
||||
}
|
||||
|
||||
v := vals[i].GetViper()
|
||||
err = genutiltest.TrackCometConfig(v, nodeDir)
|
||||
v.Set(flags.FlagHome, nodeDir)
|
||||
v.SetConfigType("toml")
|
||||
v.SetConfigName("config")
|
||||
v.AddConfigPath(filepath.Join(nodeDir, "config"))
|
||||
err = v.ReadInConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package testutil
|
||||
package genutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
grpcstatus "google.golang.org/grpc/status"
|
||||
@ -16,6 +15,7 @@ import (
|
||||
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
|
||||
"cosmossdk.io/core/address"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/depinject/appconfig"
|
||||
@ -66,7 +66,7 @@ type ModuleInputs struct {
|
||||
ExtraTxValidators []appmodulev2.TxValidator[transaction.Tx] `optional:"true"`
|
||||
UnorderedTxManager *unorderedtx.Manager `optional:"true"`
|
||||
TxFeeChecker ante.TxFeeChecker `optional:"true"`
|
||||
Viper *viper.Viper `optional:"true"` // server v2
|
||||
DynamicConfig server.DynamicConfig `optional:"true"`
|
||||
}
|
||||
|
||||
type ModuleOutputs struct {
|
||||
@ -126,8 +126,8 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
feeTxValidator *ante.DeductFeeDecorator
|
||||
unorderedTxValidator *ante.UnorderedTxDecorator
|
||||
)
|
||||
if in.AccountKeeper != nil && in.BankKeeper != nil && in.Viper != nil {
|
||||
minGasPricesStr := in.Viper.GetString(flagMinGasPricesV2)
|
||||
if in.AccountKeeper != nil && in.BankKeeper != nil && in.DynamicConfig != nil {
|
||||
minGasPricesStr := in.DynamicConfig.GetString(flagMinGasPricesV2)
|
||||
minGasPrices, err = sdk.ParseDecCoins(minGasPricesStr)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("invalid minimum gas prices: %v", err))
|
||||
|
||||
@ -26,7 +26,12 @@ func Commands(genutilModule genutil.AppModule, genMM genesisMM, appExport v2.App
|
||||
|
||||
// CommandsWithCustomMigrationMap adds core sdk's sub-commands into genesis command with custom migration map.
|
||||
// This custom migration map can be used by the application to add its own migration map.
|
||||
func CommandsWithCustomMigrationMap(genutilModule genutil.AppModule, genMM genesisMM, appExport v2.AppExporter, migrationMap genutiltypes.MigrationMap) *cobra.Command {
|
||||
func CommandsWithCustomMigrationMap(
|
||||
genutilModule genutil.AppModule,
|
||||
genMM genesisMM,
|
||||
appExport v2.AppExporter,
|
||||
migrationMap genutiltypes.MigrationMap,
|
||||
) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "genesis",
|
||||
Short: "Application's genesis-related subcommands",
|
||||
|
||||
@ -29,8 +29,6 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
config := client.GetConfigFromCmd(cmd)
|
||||
viper := client.GetViperFromCmd(cmd)
|
||||
logger := client.GetLoggerFromCmd(cmd)
|
||||
|
||||
if _, err := os.Stat(config.GenesisFile()); os.IsNotExist(err) {
|
||||
return err
|
||||
@ -62,7 +60,7 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
|
||||
jailAllowedAddrs, _ := cmd.Flags().GetStringSlice(flagJailAllowedAddrs)
|
||||
outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
|
||||
|
||||
exported, err := appExporter(logger, height, jailAllowedAddrs, viper)
|
||||
exported, err := appExporter(cmd.Context(), height, jailAllowedAddrs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error exporting state: %w", err)
|
||||
}
|
||||
@ -99,8 +97,10 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.Flags().Int64(flagHeight, -1, "Export state from a particular height (-1 means latest height)")
|
||||
cmd.Flags().StringSlice(flagJailAllowedAddrs, []string{}, "Comma-separated list of operator addresses of jailed validators to unjail")
|
||||
cmd.Flags().String(flags.FlagOutputDocument, "", "Exported state is written to the given file instead of STDOUT")
|
||||
cmd.Flags().
|
||||
StringSlice(flagJailAllowedAddrs, []string{}, "Comma-separated list of operator addresses of jailed validators to unjail")
|
||||
cmd.Flags().
|
||||
String(flags.FlagOutputDocument, "", "Exported state is written to the given file instead of STDOUT")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -1,20 +1,16 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
)
|
||||
|
||||
// AppExporter is a function that dumps all app state to
|
||||
// JSON-serializable structure and returns the current validator set.
|
||||
type AppExporter func(
|
||||
logger log.Logger,
|
||||
ctx context.Context,
|
||||
height int64,
|
||||
jailAllowedAddrs []string,
|
||||
viper *viper.Viper,
|
||||
) (ExportedApp, error)
|
||||
|
||||
// ExportedApp represents an exported app state, along with
|
||||
|
||||
@ -2,7 +2,6 @@ package upgrade
|
||||
|
||||
import (
|
||||
"github.com/spf13/cast"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
modulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1"
|
||||
"cosmossdk.io/core/address"
|
||||
@ -16,7 +15,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
@ -43,8 +41,7 @@ type ModuleInputs struct {
|
||||
AppVersionModifier coreserver.VersionModifier
|
||||
ConsensusKeeper types.ConsensusKeeper
|
||||
|
||||
AppOpts servertypes.AppOptions `optional:"true"` // server v0
|
||||
Viper *viper.Viper `optional:"true"` // server v2
|
||||
DynamicConfig coreserver.DynamicConfig `optional:"true"`
|
||||
}
|
||||
|
||||
type ModuleOutputs struct {
|
||||
@ -60,18 +57,13 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
skipUpgradeHeights = make(map[int64]bool)
|
||||
)
|
||||
|
||||
if in.Viper != nil { // viper takes precedence over app options
|
||||
for _, h := range in.Viper.GetIntSlice(server.FlagUnsafeSkipUpgrades) {
|
||||
if in.DynamicConfig != nil {
|
||||
skipUpgrades := cast.ToIntSlice(in.DynamicConfig.Get(server.FlagUnsafeSkipUpgrades))
|
||||
for _, h := range skipUpgrades {
|
||||
skipUpgradeHeights[int64(h)] = true
|
||||
}
|
||||
|
||||
homePath = in.Viper.GetString(flags.FlagHome)
|
||||
} else if in.AppOpts != nil {
|
||||
for _, h := range cast.ToIntSlice(in.AppOpts.Get(server.FlagUnsafeSkipUpgrades)) {
|
||||
skipUpgradeHeights[int64(h)] = true
|
||||
}
|
||||
|
||||
homePath = cast.ToString(in.AppOpts.Get(flags.FlagHome))
|
||||
homePath = in.DynamicConfig.GetString(flags.FlagHome)
|
||||
}
|
||||
|
||||
// default to governance authority if not provided
|
||||
|
||||
@ -26,7 +26,6 @@ require (
|
||||
github.com/spf13/cast v1.7.0
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
|
||||
google.golang.org/grpc v1.66.1
|
||||
@ -160,6 +159,7 @@ require (
|
||||
github.com/sasha-s/go-deadlock v0.3.5 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/viper v1.19.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/supranational/blst v0.3.13 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
@ -203,6 +203,7 @@ replace github.com/cosmos/cosmos-sdk => ../../.
|
||||
|
||||
replace (
|
||||
cosmossdk.io/api => ../../api
|
||||
cosmossdk.io/core => ../../core
|
||||
cosmossdk.io/core/testing => ../../core/testing
|
||||
cosmossdk.io/store => ../../store
|
||||
cosmossdk.io/x/bank => ../bank
|
||||
|
||||
@ -194,8 +194,6 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V
|
||||
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
|
||||
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
|
||||
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
|
||||
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
|
||||
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
|
||||
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
|
||||
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
|
||||
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user