Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
623d7227a3
commit
ea770de0fd
46
runtime/config.go
Normal file
46
runtime/config.go
Normal file
@ -0,0 +1,46 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/depinject"
|
||||
)
|
||||
|
||||
// ModuleConfigMaps is a map module scoped ConfigMaps
|
||||
type ModuleConfigMaps map[string]server.ConfigMap
|
||||
|
||||
type ModuleConfigMapsInput struct {
|
||||
depinject.In
|
||||
|
||||
ModuleConfigs []server.ModuleConfigMap
|
||||
DynamicConfig server.DynamicConfig `optional:"true"`
|
||||
}
|
||||
|
||||
// ProvideModuleConfigMaps returns a map of module name to module config map.
|
||||
// The module config map is a map of flag to value.
|
||||
func ProvideModuleConfigMaps(in ModuleConfigMapsInput) ModuleConfigMaps {
|
||||
moduleConfigMaps := make(ModuleConfigMaps)
|
||||
if in.DynamicConfig == nil {
|
||||
return moduleConfigMaps
|
||||
}
|
||||
for _, moduleConfig := range in.ModuleConfigs {
|
||||
cfg := moduleConfig.Config
|
||||
name := moduleConfig.Module
|
||||
moduleConfigMaps[name] = make(server.ConfigMap)
|
||||
for flag, df := range cfg {
|
||||
val := in.DynamicConfig.Get(flag)
|
||||
if val != nil {
|
||||
moduleConfigMaps[name][flag] = val
|
||||
} else {
|
||||
moduleConfigMaps[name][flag] = df
|
||||
}
|
||||
}
|
||||
}
|
||||
return moduleConfigMaps
|
||||
}
|
||||
|
||||
func ProvideModuleScopedConfigMap(
|
||||
key depinject.ModuleKey,
|
||||
moduleConfigs ModuleConfigMaps,
|
||||
) server.ConfigMap {
|
||||
return moduleConfigs[key.Name()]
|
||||
}
|
||||
@ -103,6 +103,8 @@ func init() {
|
||||
ProvideTransientStoreService,
|
||||
ProvideModuleManager,
|
||||
ProvideCometService,
|
||||
ProvideModuleConfigMaps,
|
||||
ProvideModuleScopedConfigMap,
|
||||
),
|
||||
appconfig.Invoke(SetupAppBuilder),
|
||||
)
|
||||
|
||||
@ -19,9 +19,9 @@ require (
|
||||
cosmossdk.io/core v1.0.0-alpha.5
|
||||
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
|
||||
cosmossdk.io/log v1.4.1
|
||||
cosmossdk.io/server/v2 v2.0.0-20241021134528-681366e3469c // main
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241021134528-681366e3469c // main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241021134528-681366e3469c // main
|
||||
cosmossdk.io/server/v2 v2.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/store/v2 v2.0.0-20241017091405-f01baf302e2b // main
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
|
||||
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
|
||||
@ -81,7 +81,7 @@ require (
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||
github.com/emicklei/dot v1.6.2 // indirect
|
||||
github.com/fatih/color v1.17.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.29.0 // indirect
|
||||
@ -107,11 +107,11 @@ require (
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-metrics v0.5.3 // indirect
|
||||
github.com/hashicorp/go-plugin v1.6.1 // indirect
|
||||
github.com/hashicorp/go-plugin v1.6.2 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
|
||||
github.com/huandu/skiplist v1.2.1 // indirect
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
@ -127,7 +127,6 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/minio/highwayhash v1.0.3 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
@ -139,7 +138,7 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.60.0 // indirect
|
||||
github.com/prometheus/common v0.60.1 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
@ -167,7 +166,7 @@ require (
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/term v0.25.0 // indirect
|
||||
@ -175,7 +174,7 @@ require (
|
||||
golang.org/x/tools v0.25.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
|
||||
google.golang.org/grpc v1.67.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@ -24,12 +24,12 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
|
||||
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241021134528-681366e3469c h1:LK1ycnBLeAE/anYr8lGSg36GB5iDaBnmv0qcS/jbsCs=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241021134528-681366e3469c/go.mod h1:FMGQ99V9+I3gpQV7nidWAtxMSRAwRizt2wqbAD7Z81I=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241021134528-681366e3469c h1:yKf19uDz3nJNEcud3G2KAzIf/dxkurGD0gSef5sZVfs=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241021134528-681366e3469c/go.mod h1:o20qgxElItJvBh+k9DJedXE2tp6udkNrWaf5Fn1mSb4=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241021134528-681366e3469c h1:MbjFJxzzr1vuXBI9ih/agdTl9fX4nvzhOBbsi38I7Yk=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241021134528-681366e3469c/go.mod h1:MjuTMonZ319tZQX6CV2O5E/+F85KrkNUj5U5ObrrkWs=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241029092041-78cfc68c83af h1:3r/aOcDmQUn6aaoCl5PugqSOQVbnqKOQuDJncCjXwaQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241029092041-78cfc68c83af/go.mod h1:CwDB1XPrjXyK1nBtmOf5hW/JtNb4nqqhwFQ2bPittfo=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af h1:uDQXvGBH3kZW1UXFccMlNCgHf2L5QCGjNmw51q6atzI=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af/go.mod h1:mONOF8GRbxs5R04zMscuQQI1gx/XHTY7imKjcwLI5uo=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af h1:jefP4LTtln0XsXHeSqRENeAGyPQ9qSbGHMy6811FE/c=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af/go.mod h1:npAiRkgEOigiBlWyLhwTucbzghItNAIPm2eYWSHG/cI=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241009154331-597e0fac1173 h1:MlvTcx2h4zmZZtIDg35B6bovbb5iUAExPmvaPE1Zci4=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20241009154331-597e0fac1173/go.mod h1:lrhcXu/hRXrLJP4L8syVbs68GJU1WSRBFO3mmjn5oGc=
|
||||
cosmossdk.io/store/v2 v2.0.0-20241017091405-f01baf302e2b h1:epPBD1ebUwat6Ruw40rsEU4N9CHJ2ZN0ev8EGoNYBvE=
|
||||
@ -177,8 +177,8 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
|
||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
@ -290,8 +290,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE=
|
||||
github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
|
||||
github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI=
|
||||
github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0=
|
||||
github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog=
|
||||
github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q=
|
||||
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
|
||||
@ -303,8 +303,8 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
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/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
|
||||
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
|
||||
github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU=
|
||||
github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
@ -361,8 +361,6 @@ github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxU
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q=
|
||||
github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
|
||||
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
|
||||
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=
|
||||
@ -433,8 +431,8 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA=
|
||||
github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
@ -563,8 +561,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -655,8 +653,8 @@ google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUE
|
||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:cUMEy+8oS78BWIH9OWazBkzbr090Od9tWBNtZHkOhf0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
|
||||
@ -18,12 +18,17 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/schema/decoding"
|
||||
"cosmossdk.io/schema/indexer"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/server/v2/appmanager"
|
||||
cometlog "cosmossdk.io/server/v2/cometbft/log"
|
||||
"cosmossdk.io/server/v2/cometbft/mempool"
|
||||
"cosmossdk.io/server/v2/cometbft/types"
|
||||
"cosmossdk.io/store/v2/snapshots"
|
||||
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
@ -49,34 +54,39 @@ type CometBFTServer[T transaction.Tx] struct {
|
||||
}
|
||||
|
||||
func New[T transaction.Tx](
|
||||
logger log.Logger,
|
||||
appName string,
|
||||
store types.Store,
|
||||
appManager appmanager.AppManager[T],
|
||||
queryHandlers map[string]appmodulev2.Handler,
|
||||
decoderResolver decoding.DecoderResolver,
|
||||
txCodec transaction.Codec[T],
|
||||
cfg server.ConfigMap,
|
||||
serverOptions ServerOptions[T],
|
||||
cfgOptions ...CfgOption,
|
||||
) *CometBFTServer[T] {
|
||||
return &CometBFTServer[T]{
|
||||
) (*CometBFTServer[T], error) {
|
||||
srv := &CometBFTServer[T]{
|
||||
initTxCodec: txCodec,
|
||||
serverOptions: serverOptions,
|
||||
cfgOptions: cfgOptions,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logger log.Logger) error {
|
||||
home, _ := cfg[serverv2.FlagHome].(string)
|
||||
|
||||
// get configs (app.toml + config.toml) from viper
|
||||
appTomlConfig := s.Config().(*AppTomlConfig)
|
||||
appTomlConfig := srv.Config().(*AppTomlConfig)
|
||||
configTomlConfig := cmtcfg.DefaultConfig().SetRoot(home)
|
||||
if len(cfg) > 0 {
|
||||
if err := serverv2.UnmarshalSubConfig(cfg, s.Name(), &appTomlConfig); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal config: %w", err)
|
||||
if err := serverv2.UnmarshalSubConfig(cfg, srv.Name(), &appTomlConfig); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
|
||||
}
|
||||
|
||||
if err := serverv2.UnmarshalSubConfig(cfg, "", &configTomlConfig); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal config: %w", err)
|
||||
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
s.config = Config{
|
||||
srv.config = Config{
|
||||
ConfigTomlConfig: configTomlConfig,
|
||||
AppTomlConfig: appTomlConfig,
|
||||
}
|
||||
@ -96,59 +106,68 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
|
||||
}
|
||||
}
|
||||
|
||||
indexEvents := make(map[string]struct{}, len(s.config.AppTomlConfig.IndexEvents))
|
||||
for _, e := range s.config.AppTomlConfig.IndexEvents {
|
||||
indexEvents := make(map[string]struct{}, len(srv.config.AppTomlConfig.IndexEvents))
|
||||
for _, e := range srv.config.AppTomlConfig.IndexEvents {
|
||||
indexEvents[e] = struct{}{}
|
||||
}
|
||||
|
||||
s.logger = logger.With(log.ModuleKey, s.Name())
|
||||
rs := appI.Store()
|
||||
srv.logger = logger.With(log.ModuleKey, srv.Name())
|
||||
consensus := NewConsensus(
|
||||
s.logger,
|
||||
appI.Name(),
|
||||
appI,
|
||||
appI.Close,
|
||||
s.serverOptions.Mempool(cfg),
|
||||
logger,
|
||||
appName,
|
||||
appManager,
|
||||
nil,
|
||||
srv.serverOptions.Mempool(cfg),
|
||||
indexEvents,
|
||||
appI.QueryHandlers(),
|
||||
rs,
|
||||
s.config,
|
||||
s.initTxCodec,
|
||||
queryHandlers,
|
||||
store,
|
||||
srv.config,
|
||||
srv.initTxCodec,
|
||||
chainID,
|
||||
)
|
||||
consensus.prepareProposalHandler = s.serverOptions.PrepareProposalHandler
|
||||
consensus.processProposalHandler = s.serverOptions.ProcessProposalHandler
|
||||
consensus.checkTxHandler = s.serverOptions.CheckTxHandler
|
||||
consensus.verifyVoteExt = s.serverOptions.VerifyVoteExtensionHandler
|
||||
consensus.extendVote = s.serverOptions.ExtendVoteHandler
|
||||
consensus.addrPeerFilter = s.serverOptions.AddrPeerFilter
|
||||
consensus.idPeerFilter = s.serverOptions.IdPeerFilter
|
||||
consensus.prepareProposalHandler = srv.serverOptions.PrepareProposalHandler
|
||||
consensus.processProposalHandler = srv.serverOptions.ProcessProposalHandler
|
||||
consensus.checkTxHandler = srv.serverOptions.CheckTxHandler
|
||||
consensus.verifyVoteExt = srv.serverOptions.VerifyVoteExtensionHandler
|
||||
consensus.extendVote = srv.serverOptions.ExtendVoteHandler
|
||||
consensus.addrPeerFilter = srv.serverOptions.AddrPeerFilter
|
||||
consensus.idPeerFilter = srv.serverOptions.IdPeerFilter
|
||||
|
||||
ss := rs.GetStateStorage().(snapshots.StorageSnapshotter)
|
||||
sc := rs.GetStateCommitment().(snapshots.CommitSnapshotter)
|
||||
ss := store.GetStateStorage().(snapshots.StorageSnapshotter)
|
||||
sc := store.GetStateCommitment().(snapshots.CommitSnapshotter)
|
||||
|
||||
snapshotStore, err := GetSnapshotStore(s.config.ConfigTomlConfig.RootDir)
|
||||
snapshotStore, err := GetSnapshotStore(srv.config.ConfigTomlConfig.RootDir)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
consensus.snapshotManager = snapshots.NewManager(snapshotStore, s.serverOptions.SnapshotOptions(cfg), sc, ss, nil, s.logger)
|
||||
consensus.snapshotManager = snapshots.NewManager(
|
||||
snapshotStore, srv.serverOptions.SnapshotOptions(cfg), sc, ss, nil, logger)
|
||||
|
||||
srv.Consensus = consensus
|
||||
|
||||
// initialize the indexer
|
||||
if indexerCfg := s.config.AppTomlConfig.Indexer; len(indexerCfg.Target) > 0 {
|
||||
if indexerCfg := srv.config.AppTomlConfig.Indexer; len(indexerCfg.Target) > 0 {
|
||||
listener, err := indexer.StartIndexing(indexer.IndexingOptions{
|
||||
Config: indexerCfg,
|
||||
Resolver: appI.SchemaDecoderResolver(),
|
||||
Logger: s.logger.With(log.ModuleKey, "indexer"),
|
||||
Resolver: decoderResolver,
|
||||
Logger: logger.With(log.ModuleKey, "indexer"),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start indexing: %w", err)
|
||||
return nil, fmt.Errorf("failed to start indexing: %w", err)
|
||||
}
|
||||
consensus.listener = &listener.Listener
|
||||
}
|
||||
|
||||
s.Consensus = consensus
|
||||
return srv, nil
|
||||
}
|
||||
|
||||
return nil
|
||||
// NewWithConfigOptions creates a new CometBFT server with the provided config options.
|
||||
// It is *not* a fully functional server (since it has been created without dependencies)
|
||||
// The returned server should only be used to get and set configuration.
|
||||
func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *CometBFTServer[T] {
|
||||
return &CometBFTServer[T]{
|
||||
cfgOptions: opts,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CometBFTServer[T]) Name() string {
|
||||
|
||||
@ -93,8 +93,10 @@ func init() {
|
||||
// AppConfig returns the default app config.
|
||||
func AppConfig() depinject.Config {
|
||||
return depinject.Configs(
|
||||
appConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML)
|
||||
depinject.Provide(ProvideExampleMintFn), // optional: override the mint module's mint function with epoched minting
|
||||
appConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML)
|
||||
depinject.Provide(
|
||||
ProvideExampleMintFn, // optional: override the mint module's mint function with epoched minting
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -103,8 +103,8 @@ var (
|
||||
// pooltypes.ModuleName
|
||||
}
|
||||
|
||||
// application configuration (used by depinject)
|
||||
appConfig = appconfig.Compose(&appv1alpha1.Config{
|
||||
// ModuleConfig is the application module configuration used by depinject
|
||||
ModuleConfig = appconfig.Compose(&appv1alpha1.Config{
|
||||
Modules: []*appv1alpha1.ModuleConfig{
|
||||
{
|
||||
Name: runtime.ModuleName,
|
||||
|
||||
@ -2,10 +2,8 @@ package simapp
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
clienthelpers "cosmossdk.io/client/v2/helpers"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/transaction"
|
||||
@ -28,9 +26,6 @@ import (
|
||||
_ "github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
)
|
||||
|
||||
// DefaultNodeHome default home directories for the application daemon
|
||||
var DefaultNodeHome string
|
||||
|
||||
// SimApp extends an ABCI application, but with most of its parameters exported.
|
||||
// They are exported for convenience in creating helper functions, as object
|
||||
// capabilities aren't needed for testing.
|
||||
@ -48,24 +43,24 @@ type SimApp[T transaction.Tx] struct {
|
||||
StakingKeeper *stakingkeeper.Keeper
|
||||
}
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
DefaultNodeHome, err = clienthelpers.GetNodeHomeDirectory(".simappv2")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// AppConfig returns the default app config.
|
||||
func AppConfig() depinject.Config {
|
||||
return depinject.Configs(
|
||||
appConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML)
|
||||
ModuleConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML)
|
||||
runtime.DefaultServiceBindings(),
|
||||
depinject.Provide(
|
||||
codec.ProvideInterfaceRegistry,
|
||||
codec.ProvideAddressCodec,
|
||||
codec.ProvideProtoCodec,
|
||||
codec.ProvideLegacyAmino,
|
||||
ProvideRootStoreConfig,
|
||||
// inject desired account types:
|
||||
multisigdepinject.ProvideAccount,
|
||||
basedepinject.ProvideAccount,
|
||||
lockupdepinject.ProvideAllLockupAccounts,
|
||||
|
||||
// provide base account options
|
||||
basedepinject.ProvideSecp256K1PubKey,
|
||||
),
|
||||
depinject.Invoke(
|
||||
std.RegisterInterfaces,
|
||||
@ -74,89 +69,80 @@ func AppConfig() depinject.Config {
|
||||
)
|
||||
}
|
||||
|
||||
// NewSimApp returns a reference to an initialized SimApp.
|
||||
func NewSimApp[T transaction.Tx](
|
||||
logger log.Logger,
|
||||
viper *viper.Viper,
|
||||
) *SimApp[T] {
|
||||
config depinject.Config,
|
||||
outputs ...any,
|
||||
) (*SimApp[T], error) {
|
||||
var (
|
||||
app = &SimApp[T]{}
|
||||
appBuilder *runtime.AppBuilder[T]
|
||||
err error
|
||||
storeBuilder root.Builder
|
||||
logger log.Logger
|
||||
|
||||
// merge the AppConfig and other configuration in one config
|
||||
appConfig = depinject.Configs(
|
||||
AppConfig(),
|
||||
config,
|
||||
depinject.Supply(
|
||||
logger,
|
||||
viper,
|
||||
// ADVANCED CONFIGURATION
|
||||
|
||||
// ADVANCED CONFIGURATION
|
||||
//
|
||||
// AUTH
|
||||
//
|
||||
// For providing a custom function required in auth to generate custom account types
|
||||
// add it below. By default the auth module uses simulation.RandomGenesisAccounts.
|
||||
//
|
||||
// authtypes.RandomGenesisAccountsFn(simulation.RandomGenesisAccounts),
|
||||
//
|
||||
// For providing a custom a base account type add it below.
|
||||
// By default the auth module uses authtypes.ProtoBaseAccount().
|
||||
//
|
||||
// func() sdk.AccountI { return authtypes.ProtoBaseAccount() },
|
||||
//
|
||||
// For providing a different address codec, add it below.
|
||||
// By default the auth module uses a Bech32 address codec,
|
||||
// with the prefix defined in the auth module configuration.
|
||||
//
|
||||
// func() address.Codec { return <- custom address codec type -> }
|
||||
|
||||
//
|
||||
// AUTH
|
||||
//
|
||||
// For providing a custom function required in auth to generate custom account types
|
||||
// add it below. By default the auth module uses simulation.RandomGenesisAccounts.
|
||||
//
|
||||
// authtypes.RandomGenesisAccountsFn(simulation.RandomGenesisAccounts),
|
||||
//
|
||||
// For providing a custom a base account type add it below.
|
||||
// By default the auth module uses authtypes.ProtoBaseAccount().
|
||||
//
|
||||
// func() sdk.AccountI { return authtypes.ProtoBaseAccount() },
|
||||
//
|
||||
// For providing a different address codec, add it below.
|
||||
// By default the auth module uses a Bech32 address codec,
|
||||
// with the prefix defined in the auth module configuration.
|
||||
//
|
||||
// func() address.Codec { return <- custom address codec type -> }
|
||||
//
|
||||
// STAKING
|
||||
//
|
||||
// For provinding a different validator and consensus address codec, add it below.
|
||||
// By default the staking module uses the bech32 prefix provided in the auth config,
|
||||
// and appends "valoper" and "valcons" for validator and consensus addresses respectively.
|
||||
// When providing a custom address codec in auth, custom address codecs must be provided here as well.
|
||||
//
|
||||
// func() runtime.ValidatorAddressCodec { return <- custom validator address codec type -> }
|
||||
// func() runtime.ConsensusAddressCodec { return <- custom consensus address codec type -> }
|
||||
|
||||
//
|
||||
// STAKING
|
||||
//
|
||||
// For provinding a different validator and consensus address codec, add it below.
|
||||
// By default the staking module uses the bech32 prefix provided in the auth config,
|
||||
// and appends "valoper" and "valcons" for validator and consensus addresses respectively.
|
||||
// When providing a custom address codec in auth, custom address codecs must be provided here as well.
|
||||
//
|
||||
// func() runtime.ValidatorAddressCodec { return <- custom validator address codec type -> }
|
||||
// func() runtime.ConsensusAddressCodec { return <- custom consensus address codec type -> }
|
||||
//
|
||||
// MINT
|
||||
//
|
||||
|
||||
//
|
||||
// MINT
|
||||
//
|
||||
|
||||
// For providing a custom inflation function for x/mint add here your
|
||||
// custom function that implements the minttypes.InflationCalculationFn
|
||||
// interface.
|
||||
// For providing a custom inflation function for x/mint add here your
|
||||
// custom function that implements the minttypes.InflationCalculationFn
|
||||
// interface.
|
||||
),
|
||||
depinject.Provide(
|
||||
// inject desired account types:
|
||||
multisigdepinject.ProvideAccount,
|
||||
basedepinject.ProvideAccount,
|
||||
lockupdepinject.ProvideAllLockupAccounts,
|
||||
|
||||
// provide base account options
|
||||
basedepinject.ProvideSecp256K1PubKey,
|
||||
// if you want to provide a custom public key you
|
||||
// can do it from here.
|
||||
// Example:
|
||||
// basedepinject.ProvideCustomPubkey[Ed25519PublicKey]()
|
||||
//
|
||||
// You can also provide a custom public key with a custom validation function:
|
||||
//
|
||||
// basedepinject.ProvideCustomPubKeyAndValidationFunc(func(pub Ed25519PublicKey) error {
|
||||
// if len(pub.Key) != 64 {
|
||||
// return fmt.Errorf("invalid pub key size")
|
||||
// }
|
||||
// })
|
||||
// if you want to provide a custom public key you
|
||||
// can do it from here.
|
||||
// Example:
|
||||
// basedepinject.ProvideCustomPubkey[Ed25519PublicKey]()
|
||||
//
|
||||
// You can also provide a custom public key with a custom validation function:
|
||||
//
|
||||
// basedepinject.ProvideCustomPubKeyAndValidationFunc(func(pub Ed25519PublicKey) error {
|
||||
// if len(pub.Key) != 64 {
|
||||
// return fmt.Errorf("invalid pub key size")
|
||||
// }
|
||||
// })
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
if err := depinject.Inject(appConfig,
|
||||
outputs = append(outputs,
|
||||
&logger,
|
||||
&storeBuilder,
|
||||
&appBuilder,
|
||||
&app.appCodec,
|
||||
@ -164,25 +150,21 @@ func NewSimApp[T transaction.Tx](
|
||||
&app.txConfig,
|
||||
&app.interfaceRegistry,
|
||||
&app.UpgradeKeeper,
|
||||
&app.StakingKeeper,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// store/v2 follows a slightly more eager config life cycle than server components
|
||||
storeConfig, err := serverstore.UnmarshalConfig(viper.AllSettings())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
app.store, err = storeBuilder.Build(logger, storeConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
&app.StakingKeeper)
|
||||
|
||||
if err := depinject.Inject(appConfig, outputs...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var err error
|
||||
app.App, err = appBuilder.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
app.store = storeBuilder.Get()
|
||||
if app.store == nil {
|
||||
return nil, fmt.Errorf("store builder did not return a db")
|
||||
}
|
||||
|
||||
/**** Module Options ****/
|
||||
@ -190,14 +172,10 @@ func NewSimApp[T transaction.Tx](
|
||||
// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
|
||||
app.RegisterUpgradeHandlers()
|
||||
|
||||
// TODO (here or in runtime/v2)
|
||||
// wire simulation manager
|
||||
// wire unordered tx manager
|
||||
|
||||
if err := app.LoadLatest(); err != nil {
|
||||
panic(err)
|
||||
if err = app.LoadLatest(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return app
|
||||
return app, nil
|
||||
}
|
||||
|
||||
// AppCodec returns SimApp's app codec.
|
||||
@ -231,3 +209,7 @@ func (app *SimApp[T]) Close() error {
|
||||
|
||||
return app.App.Close()
|
||||
}
|
||||
|
||||
func ProvideRootStoreConfig(config runtime.GlobalConfig) (*root.Config, error) {
|
||||
return serverstore.UnmarshalConfig(config)
|
||||
}
|
||||
|
||||
@ -16,9 +16,12 @@ import (
|
||||
"cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"cosmossdk.io/runtime/v2"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
serverv2store "cosmossdk.io/server/v2/store"
|
||||
"cosmossdk.io/store/v2/db"
|
||||
banktypes "cosmossdk.io/x/bank/types"
|
||||
|
||||
@ -35,10 +38,14 @@ func NewTestApp(t *testing.T) (*SimApp[transaction.Tx], context.Context) {
|
||||
logger := log.NewTestLogger(t)
|
||||
|
||||
vp := viper.New()
|
||||
vp.Set("store.app-db-backend", string(db.DBTypeGoLevelDB))
|
||||
vp.Set(serverv2store.FlagAppDBBackend, string(db.DBTypeGoLevelDB))
|
||||
vp.Set(serverv2.FlagHome, t.TempDir())
|
||||
|
||||
app := NewSimApp[transaction.Tx](logger, vp)
|
||||
app, err := NewSimApp[transaction.Tx](depinject.Configs(
|
||||
depinject.Supply(logger, runtime.GlobalConfig(vp.AllSettings()))),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
genesis := app.ModuleManager().DefaultGenesis()
|
||||
|
||||
privVal := mock.NewPV()
|
||||
|
||||
@ -10,8 +10,8 @@ require (
|
||||
cosmossdk.io/depinject v1.0.0
|
||||
cosmossdk.io/log v1.4.1
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241021134528-681366e3469c // main
|
||||
cosmossdk.io/server/v2 v2.0.0-20241021134528-681366e3469c // main
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/server/v2 v2.0.0-20241029092041-78cfc68c83af // main
|
||||
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/store/v2 v2.0.0-20241017091405-f01baf302e2b // main
|
||||
cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000
|
||||
@ -62,8 +62,8 @@ require (
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241021134528-681366e3469c // indirect; main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241021134528-681366e3469c // indirect; main
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af // indirect; main
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af // indirect; main
|
||||
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect; main
|
||||
cosmossdk.io/x/tx v1.0.0-alpha.1 // indirect; main
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
@ -109,7 +109,7 @@ require (
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||
github.com/emicklei/dot v1.6.2 // indirect
|
||||
github.com/fatih/color v1.17.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.29.0 // indirect
|
||||
@ -144,13 +144,13 @@ require (
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-metrics v0.5.3 // indirect
|
||||
github.com/hashicorp/go-plugin v1.6.1 // indirect
|
||||
github.com/hashicorp/go-plugin v1.6.2 // indirect
|
||||
github.com/hashicorp/go-safetemp v1.0.0 // indirect
|
||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
|
||||
github.com/huandu/skiplist v1.2.1 // indirect
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
@ -185,7 +185,7 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.60.0 // indirect
|
||||
github.com/prometheus/common v0.60.1 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
@ -219,7 +219,7 @@ require (
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/oauth2 v0.23.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
@ -230,7 +230,7 @@ require (
|
||||
google.golang.org/api v0.185.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20240617180043-68d350f18fd4 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
|
||||
google.golang.org/grpc v1.67.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@ -210,16 +210,16 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
|
||||
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
|
||||
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
|
||||
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241021134528-681366e3469c h1:f9qU7HpJ1CuUDj4OkHca4BFbSW4X3rAYgwzwFNXiBhg=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241021134528-681366e3469c/go.mod h1:KROAOJt1EDL7nELDT7LPpFqWubhTJFD4Uwa1gy2/yxo=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241029092041-78cfc68c83af h1:kEyFCZi+ZJwDgt9aChlGzRu/1J7cXLl6jn3enOdWWPE=
|
||||
cosmossdk.io/runtime/v2 v2.0.0-20241029092041-78cfc68c83af/go.mod h1:SCdBCUiZGKVFNUvglrCUontMZSoXAES5iMbRvPv8bsI=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
|
||||
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241021134528-681366e3469c h1:LK1ycnBLeAE/anYr8lGSg36GB5iDaBnmv0qcS/jbsCs=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241021134528-681366e3469c/go.mod h1:FMGQ99V9+I3gpQV7nidWAtxMSRAwRizt2wqbAD7Z81I=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241021134528-681366e3469c h1:yKf19uDz3nJNEcud3G2KAzIf/dxkurGD0gSef5sZVfs=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241021134528-681366e3469c/go.mod h1:o20qgxElItJvBh+k9DJedXE2tp6udkNrWaf5Fn1mSb4=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241021134528-681366e3469c h1:MbjFJxzzr1vuXBI9ih/agdTl9fX4nvzhOBbsi38I7Yk=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241021134528-681366e3469c/go.mod h1:MjuTMonZ319tZQX6CV2O5E/+F85KrkNUj5U5ObrrkWs=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241029092041-78cfc68c83af h1:3r/aOcDmQUn6aaoCl5PugqSOQVbnqKOQuDJncCjXwaQ=
|
||||
cosmossdk.io/server/v2 v2.0.0-20241029092041-78cfc68c83af/go.mod h1:CwDB1XPrjXyK1nBtmOf5hW/JtNb4nqqhwFQ2bPittfo=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af h1:uDQXvGBH3kZW1UXFccMlNCgHf2L5QCGjNmw51q6atzI=
|
||||
cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af/go.mod h1:mONOF8GRbxs5R04zMscuQQI1gx/XHTY7imKjcwLI5uo=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af h1:jefP4LTtln0XsXHeSqRENeAGyPQ9qSbGHMy6811FE/c=
|
||||
cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af/go.mod h1:npAiRkgEOigiBlWyLhwTucbzghItNAIPm2eYWSHG/cI=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 h1:UUW0+2UgbDwQ452o2aw4DrVSWmowcad7DB7Vln+N94I=
|
||||
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214/go.mod h1:ct8HATr+s48YYTRXEyP3HF33v9qEVWHMxwOL8P/v4iQ=
|
||||
cosmossdk.io/store/v2 v2.0.0-20241017091405-f01baf302e2b h1:epPBD1ebUwat6Ruw40rsEU4N9CHJ2ZN0ev8EGoNYBvE=
|
||||
@ -401,8 +401,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
@ -586,8 +586,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE=
|
||||
github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
|
||||
github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI=
|
||||
github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0=
|
||||
github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog=
|
||||
github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q=
|
||||
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
|
||||
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
|
||||
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
|
||||
@ -605,8 +605,8 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
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/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
|
||||
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
|
||||
github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU=
|
||||
github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
@ -753,8 +753,8 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA=
|
||||
github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
@ -978,8 +978,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -1362,8 +1362,8 @@ google.golang.org/genproto v0.0.0-20240617180043-68d350f18fd4 h1:CUiCqkPw1nNrNQz
|
||||
google.golang.org/genproto v0.0.0-20240617180043-68d350f18fd4/go.mod h1:EvuUDCulqGgV80RvP1BHuom+smhX4qtlhnNatHuroGQ=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:cUMEy+8oS78BWIH9OWazBkzbr090Od9tWBNtZHkOhf0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
|
||||
@ -1,96 +1,153 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"cosmossdk.io/client/v2/offchain"
|
||||
corectx "cosmossdk.io/core/context"
|
||||
coreserver "cosmossdk.io/core/server"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/log"
|
||||
runtimev2 "cosmossdk.io/runtime/v2"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/server/v2/api/grpc"
|
||||
"cosmossdk.io/server/v2/api/rest"
|
||||
"cosmossdk.io/server/v2/api/telemetry"
|
||||
"cosmossdk.io/server/v2/cometbft"
|
||||
serverstore "cosmossdk.io/server/v2/store"
|
||||
"cosmossdk.io/simapp/v2"
|
||||
confixcmd "cosmossdk.io/tools/confix/cmd"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/config"
|
||||
"github.com/cosmos/cosmos-sdk/client/debug"
|
||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
genutilv2 "github.com/cosmos/cosmos-sdk/x/genutil/v2"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2/cli"
|
||||
)
|
||||
|
||||
func newApp[T transaction.Tx](logger log.Logger, viper *viper.Viper) serverv2.AppI[T] {
|
||||
viper.SetDefault(serverv2.FlagHome, simapp.DefaultNodeHome)
|
||||
return serverv2.AppI[T](simapp.NewSimApp[T](logger, viper))
|
||||
// CommandDependencies is a struct that contains all the dependencies needed to initialize the root command.
|
||||
// an alternative design could fetch these even later from the command context
|
||||
type CommandDependencies[T transaction.Tx] struct {
|
||||
GlobalConfig coreserver.ConfigMap
|
||||
TxConfig client.TxConfig
|
||||
ModuleManager *runtimev2.MM[T]
|
||||
SimApp *simapp.SimApp[T]
|
||||
Consensus serverv2.ServerComponent[T]
|
||||
}
|
||||
|
||||
func initRootCmd[T transaction.Tx](
|
||||
func InitRootCmd[T transaction.Tx](
|
||||
rootCmd *cobra.Command,
|
||||
moduleManager *runtimev2.MM[T],
|
||||
consensusComponent serverv2.ServerComponent[T],
|
||||
) {
|
||||
logger log.Logger,
|
||||
deps CommandDependencies[T],
|
||||
) (serverv2.ConfigWriter, error) {
|
||||
cfg := sdk.GetConfig()
|
||||
cfg.Seal()
|
||||
|
||||
rootCmd.AddCommand(
|
||||
genutilcli.InitCmd(moduleManager),
|
||||
genutilcli.InitCmd(deps.ModuleManager),
|
||||
genesisCommand(deps.ModuleManager, deps.SimApp),
|
||||
NewTestnetCmd(deps.ModuleManager),
|
||||
debug.Cmd(),
|
||||
confixcmd.ConfigCommand(),
|
||||
NewTestnetCmd(moduleManager),
|
||||
)
|
||||
|
||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
genesisCommand(moduleManager),
|
||||
// add keybase, auxiliary RPC, query, genesis, and tx child commands
|
||||
queryCommand(),
|
||||
txCommand(),
|
||||
keys.Commands(),
|
||||
offchain.OffChain(),
|
||||
)
|
||||
|
||||
// wire server commands
|
||||
if err := serverv2.AddCommands(
|
||||
rootCmd,
|
||||
newApp,
|
||||
initServerConfig(),
|
||||
consensusComponent,
|
||||
grpc.New[T](),
|
||||
serverstore.New[T](),
|
||||
telemetry.New[T](),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
// build CLI skeleton for initial config parsing or a client application invocation
|
||||
if deps.SimApp == nil {
|
||||
if deps.Consensus == nil {
|
||||
deps.Consensus = cometbft.NewWithConfigOptions[T](initCometConfig())
|
||||
}
|
||||
return serverv2.AddCommands[T](
|
||||
rootCmd,
|
||||
logger,
|
||||
deps.GlobalConfig,
|
||||
initServerConfig(),
|
||||
deps.Consensus,
|
||||
&grpc.Server[T]{},
|
||||
&serverstore.Server[T]{},
|
||||
&telemetry.Server[T]{},
|
||||
&rest.Server[T]{},
|
||||
)
|
||||
}
|
||||
|
||||
// build full app!
|
||||
simApp := deps.SimApp
|
||||
grpcServer, err := grpc.New[T](logger, simApp.InterfaceRegistry(), simApp.QueryHandlers(), simApp, deps.GlobalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// store component (not a server)
|
||||
storeComponent, err := serverstore.New[T](simApp.Store(), deps.GlobalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
restServer, err := rest.New[T](simApp.App.AppManager, logger, deps.GlobalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// consensus component
|
||||
if deps.Consensus == nil {
|
||||
deps.Consensus, err = cometbft.New(
|
||||
logger,
|
||||
simApp.Name(),
|
||||
simApp.Store(),
|
||||
simApp.App.AppManager,
|
||||
simApp.App.QueryHandlers(),
|
||||
simApp.App.SchemaDecoderResolver(),
|
||||
&genericTxDecoder[T]{deps.TxConfig},
|
||||
deps.GlobalConfig,
|
||||
initCometOptions[T](),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
telemetryServer, err := telemetry.New[T](deps.GlobalConfig, logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// wire server commands
|
||||
return serverv2.AddCommands[T](
|
||||
rootCmd,
|
||||
logger,
|
||||
deps.GlobalConfig,
|
||||
initServerConfig(),
|
||||
deps.Consensus,
|
||||
grpcServer,
|
||||
storeComponent,
|
||||
telemetryServer,
|
||||
restServer,
|
||||
)
|
||||
}
|
||||
|
||||
// genesisCommand builds genesis-related `simd genesis` command.
|
||||
func genesisCommand[T transaction.Tx](
|
||||
moduleManager *runtimev2.MM[T],
|
||||
cmds ...*cobra.Command,
|
||||
app *simapp.SimApp[T],
|
||||
) *cobra.Command {
|
||||
var genTxValidator func([]transaction.Msg) error
|
||||
if moduleManager != nil {
|
||||
genTxValidator = moduleManager.Modules()[genutiltypes.ModuleName].(genutil.AppModule).GenTxValidator()
|
||||
}
|
||||
cmd := v2.Commands(
|
||||
moduleManager.Modules()[genutiltypes.ModuleName].(genutil.AppModule),
|
||||
genTxValidator,
|
||||
moduleManager,
|
||||
appExport[T],
|
||||
app,
|
||||
)
|
||||
|
||||
for _, subCmd := range cmds {
|
||||
cmd.AddCommand(subCmd)
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -137,41 +194,31 @@ func txCommand() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
// appExport creates a new simapp (optionally at a given height) and exports state.
|
||||
func appExport[T transaction.Tx](
|
||||
ctx context.Context,
|
||||
height int64,
|
||||
jailAllowedAddrs []string,
|
||||
) (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)
|
||||
}
|
||||
func RootCommandPersistentPreRun(clientCtx client.Context) func(*cobra.Command, []string) error {
|
||||
return func(cmd *cobra.Command, args []string) error {
|
||||
// set the default command outputs
|
||||
cmd.SetOut(cmd.OutOrStdout())
|
||||
cmd.SetErr(cmd.ErrOrStderr())
|
||||
|
||||
// overwrite the FlagInvCheckPeriod
|
||||
viper.Set(server.FlagInvCheckPeriod, 1)
|
||||
viper.SetDefault(serverv2.FlagHome, simapp.DefaultNodeHome)
|
||||
|
||||
var simApp *simapp.SimApp[T]
|
||||
if height != -1 {
|
||||
simApp = simapp.NewSimApp[T](logger, viper)
|
||||
|
||||
if err := simApp.LoadHeight(uint64(height)); err != nil {
|
||||
return genutilv2.ExportedApp{}, err
|
||||
clientCtx = clientCtx.WithCmdContext(cmd.Context())
|
||||
clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
simApp = simapp.NewSimApp[T](logger, viper)
|
||||
}
|
||||
|
||||
return simApp.ExportAppStateAndValidators(jailAllowedAddrs)
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
clientCtx, err = config.CreateClientConfig(
|
||||
clientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = client.SetCmdClientContextHandler(clientCtx, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var _ transaction.Codec[transaction.Tx] = &genericTxDecoder[transaction.Tx]{}
|
||||
|
||||
69
simapp/v2/simdv2/cmd/depinject.go
Normal file
69
simapp/v2/simdv2/cmd/depinject.go
Normal file
@ -0,0 +1,69 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/runtime/v2"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/config"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
// ProvideClientContext is a depinject Provider function which assembles and returns a client.Context.
|
||||
func ProvideClientContext(
|
||||
configMap runtime.GlobalConfig,
|
||||
appCodec codec.Codec,
|
||||
interfaceRegistry codectypes.InterfaceRegistry,
|
||||
txConfigOpts tx.ConfigOptions,
|
||||
legacyAmino registry.AminoRegistrar,
|
||||
addressCodec address.Codec,
|
||||
validatorAddressCodec address.ValidatorAddressCodec,
|
||||
consensusAddressCodec address.ConsensusAddressCodec,
|
||||
) client.Context {
|
||||
var err error
|
||||
amino, ok := legacyAmino.(*codec.LegacyAmino)
|
||||
if !ok {
|
||||
panic("registry.AminoRegistrar must be an *codec.LegacyAmino instance for legacy ClientContext")
|
||||
}
|
||||
homeDir, ok := configMap[serverv2.FlagHome].(string)
|
||||
if !ok {
|
||||
panic("server.ConfigMap must contain a string value for serverv2.FlagHome")
|
||||
}
|
||||
|
||||
clientCtx := client.Context{}.
|
||||
WithCodec(appCodec).
|
||||
WithInterfaceRegistry(interfaceRegistry).
|
||||
WithLegacyAmino(amino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
WithAddressCodec(addressCodec).
|
||||
WithValidatorAddressCodec(validatorAddressCodec).
|
||||
WithConsensusAddressCodec(consensusAddressCodec).
|
||||
WithHomeDir(homeDir).
|
||||
WithViper("") // uses by default the binary name as prefix
|
||||
|
||||
// Read the config to overwrite the default values with the values from the config file
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
clientCtx, err = config.CreateClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// textual is enabled by default, we need to re-create the tx config grpc instead of bank keeper.
|
||||
txConfigOpts.TextualCoinMetadataQueryFn = authtxconfig.NewGRPCCoinMetadataQueryFn(clientCtx)
|
||||
txConfig, err := tx.NewTxConfigWithOptions(clientCtx.Codec, txConfigOpts)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
clientCtx = clientCtx.WithTxConfig(txConfig)
|
||||
|
||||
return clientCtx
|
||||
}
|
||||
@ -1,161 +1,98 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
"cosmossdk.io/client/v2/autocli"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/runtime/v2"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/server/v2/cometbft"
|
||||
"cosmossdk.io/simapp/v2"
|
||||
basedepinject "cosmossdk.io/x/accounts/defaults/base/depinject"
|
||||
lockupdepinject "cosmossdk.io/x/accounts/defaults/lockup/depinject"
|
||||
multisigdepinject "cosmossdk.io/x/accounts/defaults/multisig/depinject"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/config"
|
||||
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
// NewCometBFTRootCmd creates a new root command for simd,
|
||||
// using the CometBFT server component for consensus.
|
||||
// It is called once in the main function.
|
||||
func NewCometBFTRootCmd[T transaction.Tx]() *cobra.Command {
|
||||
return NewRootCmdWithConsensusComponent(func(cc client.Context) serverv2.ServerComponent[T] {
|
||||
return cometbft.New[T](
|
||||
&genericTxDecoder[T]{cc.TxConfig},
|
||||
initCometOptions[T](),
|
||||
initCometConfig(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// NewRootCmdWithConsensusComponent returns a new root command,
|
||||
// using the provided callback to instantiate the server component for the consensus layer.
|
||||
// Callers who want to use CometBFT should call [NewCometBFTRootCmd] directly.
|
||||
func NewRootCmdWithConsensusComponent[T transaction.Tx](
|
||||
makeConsensusComponent func(cc client.Context) serverv2.ServerComponent[T],
|
||||
) *cobra.Command {
|
||||
var (
|
||||
autoCliOpts autocli.AppOptions
|
||||
moduleManager *runtime.MM[T]
|
||||
clientCtx client.Context
|
||||
)
|
||||
|
||||
if err := depinject.Inject(
|
||||
depinject.Configs(
|
||||
simapp.AppConfig(),
|
||||
depinject.Provide(
|
||||
ProvideClientContext,
|
||||
// inject desired account types:
|
||||
multisigdepinject.ProvideAccount,
|
||||
basedepinject.ProvideAccount,
|
||||
lockupdepinject.ProvideAllLockupAccounts,
|
||||
|
||||
// provide base account options
|
||||
basedepinject.ProvideSecp256K1PubKey),
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&autoCliOpts,
|
||||
&moduleManager,
|
||||
&clientCtx,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "simd",
|
||||
Short: "simulation app",
|
||||
func NewRootCmd[T transaction.Tx](
|
||||
args ...string,
|
||||
) (*cobra.Command, error) {
|
||||
rootCommand := &cobra.Command{
|
||||
Use: "simdv2",
|
||||
SilenceErrors: true,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx = clientCtx.WithCmdContext(cmd.Context())
|
||||
clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
clientCtx, err = config.CreateClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := client.SetCmdClientContextHandler(clientCtx, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
configWriter, err := InitRootCmd(rootCommand, log.NewNopLogger(), CommandDependencies[T]{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
factory, err := serverv2.NewCommandFactory(
|
||||
serverv2.WithConfigWriter(configWriter),
|
||||
serverv2.WithStdDefaultHomeDir(".simappv2"),
|
||||
serverv2.WithLoggerFactory(serverv2.NewLogger),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
consensusComponent := makeConsensusComponent(clientCtx)
|
||||
initRootCmd(rootCmd, moduleManager, consensusComponent)
|
||||
subCommand, configMap, logger, err := factory.ParseCommand(rootCommand, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
autoCliOpts autocli.AppOptions
|
||||
moduleManager *runtime.MM[T]
|
||||
clientCtx client.Context
|
||||
simApp *simapp.SimApp[T]
|
||||
depinjectConfig = depinject.Configs(
|
||||
depinject.Supply(logger, runtime.GlobalConfig(configMap)),
|
||||
depinject.Provide(ProvideClientContext),
|
||||
)
|
||||
)
|
||||
if serverv2.IsAppRequired(subCommand) {
|
||||
// server construction
|
||||
simApp, err = simapp.NewSimApp[T](depinjectConfig, &autoCliOpts, &moduleManager, &clientCtx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// client construction
|
||||
if err = depinject.Inject(
|
||||
depinject.Configs(
|
||||
simapp.AppConfig(),
|
||||
depinjectConfig,
|
||||
),
|
||||
&autoCliOpts, &moduleManager, &clientCtx,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
commandDeps := CommandDependencies[T]{
|
||||
GlobalConfig: configMap,
|
||||
TxConfig: clientCtx.TxConfig,
|
||||
ModuleManager: moduleManager,
|
||||
SimApp: simApp,
|
||||
}
|
||||
rootCommand = &cobra.Command{
|
||||
Use: "simdv2",
|
||||
Short: "simulation app",
|
||||
SilenceErrors: true,
|
||||
PersistentPreRunE: RootCommandPersistentPreRun(clientCtx),
|
||||
}
|
||||
factory.EnhanceRootCommand(rootCommand)
|
||||
_, err = InitRootCmd(rootCommand, logger, commandDeps)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nodeCmds := nodeservice.NewNodeCommands()
|
||||
autoCliOpts.ModuleOptions = make(map[string]*autocliv1.ModuleOptions)
|
||||
autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions()
|
||||
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
|
||||
panic(err)
|
||||
if err := autoCliOpts.EnhanceRootCommand(rootCommand); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
func ProvideClientContext(
|
||||
appCodec codec.Codec,
|
||||
interfaceRegistry codectypes.InterfaceRegistry,
|
||||
txConfigOpts tx.ConfigOptions,
|
||||
legacyAmino registry.AminoRegistrar,
|
||||
addressCodec address.Codec,
|
||||
validatorAddressCodec address.ValidatorAddressCodec,
|
||||
consensusAddressCodec address.ConsensusAddressCodec,
|
||||
) client.Context {
|
||||
var err error
|
||||
|
||||
amino, ok := legacyAmino.(*codec.LegacyAmino)
|
||||
if !ok {
|
||||
panic("registry.AminoRegistrar must be an *codec.LegacyAmino instance for legacy ClientContext")
|
||||
}
|
||||
|
||||
clientCtx := client.Context{}.
|
||||
WithCodec(appCodec).
|
||||
WithInterfaceRegistry(interfaceRegistry).
|
||||
WithLegacyAmino(amino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.AccountRetriever{}).
|
||||
WithAddressCodec(addressCodec).
|
||||
WithValidatorAddressCodec(validatorAddressCodec).
|
||||
WithConsensusAddressCodec(consensusAddressCodec).
|
||||
WithHomeDir(simapp.DefaultNodeHome).
|
||||
WithViper("") // uses by default the binary name as prefix
|
||||
|
||||
// Read the config to overwrite the default values with the values from the config file
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
clientCtx, err = config.CreateClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// textual is enabled by default, we need to re-create the tx config grpc instead of bank keeper.
|
||||
txConfigOpts.TextualCoinMetadataQueryFn = authtxconfig.NewGRPCCoinMetadataQueryFn(clientCtx)
|
||||
txConfig, err := tx.NewTxConfigWithOptions(clientCtx.Codec, txConfigOpts)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
clientCtx = clientCtx.WithTxConfig(txConfig)
|
||||
|
||||
return clientCtx
|
||||
return rootCommand, nil
|
||||
}
|
||||
|
||||
@ -7,8 +7,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/core/transaction"
|
||||
svrcmd "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/simapp/v2"
|
||||
"cosmossdk.io/simapp/v2/simdv2/cmd"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
@ -16,27 +14,29 @@ import (
|
||||
)
|
||||
|
||||
func TestInitCmd(t *testing.T) {
|
||||
rootCmd := cmd.NewCometBFTRootCmd[transaction.Tx]()
|
||||
rootCmd.SetArgs([]string{
|
||||
args := []string{
|
||||
"init", // Test the init cmd
|
||||
"simapp-test", // Moniker
|
||||
fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists
|
||||
})
|
||||
|
||||
require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome))
|
||||
}
|
||||
rootCmd, err := cmd.NewRootCmd[transaction.Tx](args...)
|
||||
require.NoError(t, err)
|
||||
rootCmd.SetArgs(args)
|
||||
require.NoError(t, rootCmd.Execute())
|
||||
}
|
||||
|
||||
func TestHomeFlagRegistration(t *testing.T) {
|
||||
homeDir := "/tmp/foo"
|
||||
|
||||
rootCmd := cmd.NewCometBFTRootCmd[transaction.Tx]()
|
||||
rootCmd.SetArgs([]string{
|
||||
args := []string{
|
||||
"query",
|
||||
fmt.Sprintf("--%s", flags.FlagHome),
|
||||
homeDir,
|
||||
})
|
||||
}
|
||||
|
||||
require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome))
|
||||
rootCmd, err := cmd.NewRootCmd[transaction.Tx](args...)
|
||||
require.NoError(t, err)
|
||||
rootCmd.SetArgs(args)
|
||||
require.NoError(t, rootCmd.Execute())
|
||||
|
||||
result, err := rootCmd.Flags().GetString(flags.FlagHome)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -334,15 +334,10 @@ func initTestnetFiles[T transaction.Tx](
|
||||
serverCfg := serverv2.DefaultServerConfig()
|
||||
serverCfg.MinGasPrices = args.minGasPrices
|
||||
|
||||
// Write server config
|
||||
cometServer := cometbft.New[T](
|
||||
&genericTxDecoder[T]{clientCtx.TxConfig},
|
||||
cometbft.ServerOptions[T]{},
|
||||
cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig),
|
||||
)
|
||||
storeServer := store.New[T]()
|
||||
grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig))
|
||||
server := serverv2.NewServer[T](serverCfg, cometServer, grpcServer, storeServer)
|
||||
cometServer := cometbft.NewWithConfigOptions[T](cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig))
|
||||
storeServer := &store.Server[T]{}
|
||||
grpcServer := grpc.NewWithConfigOptions[T](grpc.OverwriteDefaultConfig(grpcConfig))
|
||||
server := serverv2.NewServer[T](serverCfg, cometServer, storeServer, grpcServer)
|
||||
err = server.WriteConfig(filepath.Join(nodeDir, "config"))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -362,7 +357,6 @@ func initTestnetFiles[T transaction.Tx](
|
||||
return err
|
||||
}
|
||||
|
||||
// Update viper root since root dir become rootdir/node/simd
|
||||
serverv2.GetViperFromCmd(cmd).Set(flags.FlagHome, nodeConfig.RootDir)
|
||||
|
||||
cmd.PrintErrf("Successfully initialized %d node directories\n", args.numValidators)
|
||||
|
||||
@ -7,8 +7,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/core/transaction"
|
||||
svrcmd "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/simapp/v2"
|
||||
"cosmossdk.io/simapp/v2/simdv2/cmd"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
@ -16,12 +14,13 @@ import (
|
||||
)
|
||||
|
||||
func TestInitTestFilesCmd(t *testing.T) {
|
||||
rootCmd := cmd.NewCometBFTRootCmd[transaction.Tx]()
|
||||
rootCmd.SetArgs([]string{
|
||||
args := []string{
|
||||
"testnet", // Test the testnet init-files command
|
||||
"init-files",
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), // Set keyring-backend to test
|
||||
})
|
||||
|
||||
require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome))
|
||||
}
|
||||
rootCmd, err := cmd.NewRootCmd[transaction.Tx](args...)
|
||||
require.NoError(t, err)
|
||||
rootCmd.SetArgs(args)
|
||||
require.NoError(t, rootCmd.Execute())
|
||||
}
|
||||
|
||||
@ -1,20 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
clientv2helpers "cosmossdk.io/client/v2/helpers"
|
||||
"cosmossdk.io/core/transaction"
|
||||
serverv2 "cosmossdk.io/server/v2"
|
||||
"cosmossdk.io/simapp/v2"
|
||||
"cosmossdk.io/simapp/v2/simdv2/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootCmd := cmd.NewCometBFTRootCmd[transaction.Tx]()
|
||||
if err := serverv2.Execute(rootCmd, clientv2helpers.EnvPrefix, simapp.DefaultNodeHome); err != nil {
|
||||
fmt.Fprintln(rootCmd.OutOrStderr(), err)
|
||||
// reproduce default cobra behavior so that eager parsing of flags is possible.
|
||||
// see: https://github.com/spf13/cobra/blob/e94f6d0dd9a5e5738dca6bce03c4b1207ffbc0ec/command.go#L1082
|
||||
args := os.Args[1:]
|
||||
rootCmd, err := cmd.NewRootCmd[transaction.Tx](args...)
|
||||
if err != nil {
|
||||
if _, pErr := fmt.Fprintln(os.Stderr, err); pErr != nil {
|
||||
panic(errors.Join(err, pErr))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = rootCmd.Execute(); err != nil {
|
||||
if _, pErr := fmt.Fprintln(rootCmd.OutOrStderr(), err); pErr != nil {
|
||||
panic(errors.Join(err, pErr))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/runtime/v2"
|
||||
"cosmossdk.io/x/accounts"
|
||||
epochstypes "cosmossdk.io/x/epochs/types"
|
||||
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
|
||||
upgradetypes "cosmossdk.io/x/upgrade/types"
|
||||
)
|
||||
@ -36,6 +37,7 @@ func (app *SimApp[T]) RegisterUpgradeHandlers() {
|
||||
storeUpgrades := store.StoreUpgrades{
|
||||
Added: []string{
|
||||
accounts.ModuleName,
|
||||
epochstypes.StoreKey,
|
||||
protocolpooltypes.ModuleName,
|
||||
},
|
||||
Deleted: []string{"crisis"}, // The SDK discontinued the crisis module in v0.52.0
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/errors"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -16,7 +17,7 @@ import (
|
||||
const flagGenTxDir = "gentx-dir"
|
||||
|
||||
// CollectGenTxsCmd - return the cobra command to collect genesis transactions
|
||||
func CollectGenTxsCmd(validator types.MessageValidator) *cobra.Command {
|
||||
func CollectGenTxsCmd(validator func([]transaction.Msg) error) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "collect-gentxs",
|
||||
Short: "Collect genesis txs and output a genesis.json file",
|
||||
@ -50,7 +51,9 @@ func CollectGenTxsCmd(validator types.MessageValidator) *cobra.Command {
|
||||
toPrint := newPrintInfo(config.Moniker, appGenesis.ChainID, nodeID, genTxsDir, json.RawMessage(""))
|
||||
initCfg := types.NewInitConfig(appGenesis.ChainID, genTxsDir, nodeID, valPubKey)
|
||||
|
||||
appMessage, err := genutil.GenAppStateFromConfig(cdc, clientCtx.TxConfig, config, initCfg, appGenesis, validator, clientCtx.ValidatorAddressCodec, clientCtx.AddressCodec)
|
||||
appMessage, err := genutil.GenAppStateFromConfig(
|
||||
cdc, clientCtx.TxConfig, config, initCfg, appGenesis,
|
||||
validator, clientCtx.ValidatorAddressCodec, clientCtx.AddressCodec)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get genesis app state from config")
|
||||
}
|
||||
|
||||
@ -5,10 +5,10 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"cosmossdk.io/core/transaction"
|
||||
banktypes "cosmossdk.io/x/bank/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2"
|
||||
@ -19,17 +19,26 @@ type genesisMM interface {
|
||||
ValidateGenesis(genesisData map[string]json.RawMessage) error
|
||||
}
|
||||
|
||||
type ExportableApp interface {
|
||||
ExportAppStateAndValidators([]string) (v2.ExportedApp, error)
|
||||
LoadHeight(uint64) error
|
||||
}
|
||||
|
||||
// Commands adds core sdk's sub-commands into genesis command.
|
||||
func Commands(genutilModule genutil.AppModule, genMM genesisMM, appExport v2.AppExporter) *cobra.Command {
|
||||
return CommandsWithCustomMigrationMap(genutilModule, genMM, appExport, cli.MigrationMap)
|
||||
func Commands(
|
||||
genTxValidator func([]transaction.Msg) error,
|
||||
genMM genesisMM,
|
||||
exportable ExportableApp,
|
||||
) *cobra.Command {
|
||||
return CommandsWithCustomMigrationMap(genTxValidator, genMM, exportable, cli.MigrationMap)
|
||||
}
|
||||
|
||||
// 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,
|
||||
genTxValidator func([]transaction.Msg) error,
|
||||
genMM genesisMM,
|
||||
appExport v2.AppExporter,
|
||||
exportable ExportableApp,
|
||||
migrationMap genutiltypes.MigrationMap,
|
||||
) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
@ -42,10 +51,10 @@ func CommandsWithCustomMigrationMap(
|
||||
cmd.AddCommand(
|
||||
cli.GenTxCmd(genMM, banktypes.GenesisBalancesIterator{}),
|
||||
cli.MigrateGenesisCmd(migrationMap),
|
||||
cli.CollectGenTxsCmd(genutilModule.GenTxValidator()),
|
||||
cli.CollectGenTxsCmd(genTxValidator),
|
||||
cli.ValidateGenesisCmd(genMM),
|
||||
cli.AddGenesisAccountCmd(),
|
||||
ExportCmd(appExport),
|
||||
ExportCmd(exportable),
|
||||
)
|
||||
|
||||
return cmd
|
||||
|
||||
@ -13,7 +13,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -22,7 +21,7 @@ const (
|
||||
)
|
||||
|
||||
// ExportCmd dumps app state to JSON.
|
||||
func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
|
||||
func ExportCmd(app ExportableApp) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "export",
|
||||
Short: "Export state to JSON",
|
||||
@ -34,7 +33,7 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
if appExporter == nil {
|
||||
if app == nil {
|
||||
if _, err := fmt.Fprintln(cmd.ErrOrStderr(), "WARNING: App exporter not defined. Returning genesis file."); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -59,8 +58,12 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
|
||||
height, _ := cmd.Flags().GetInt64(flagHeight)
|
||||
jailAllowedAddrs, _ := cmd.Flags().GetStringSlice(flagJailAllowedAddrs)
|
||||
outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
|
||||
|
||||
exported, err := appExporter(cmd.Context(), height, jailAllowedAddrs)
|
||||
if height != -1 {
|
||||
if err := app.LoadHeight(uint64(height)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
exported, err := app.ExportAppStateAndValidators(jailAllowedAddrs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error exporting state: %w", err)
|
||||
}
|
||||
|
||||
@ -1,20 +1,11 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// AppExporter is a function that dumps all app state to
|
||||
// JSON-serializable structure and returns the current validator set.
|
||||
type AppExporter func(
|
||||
ctx context.Context,
|
||||
height int64,
|
||||
jailAllowedAddrs []string,
|
||||
) (ExportedApp, error)
|
||||
|
||||
// ExportedApp represents an exported app state, along with
|
||||
// validators, consensus params and latest app height.
|
||||
type ExportedApp struct {
|
||||
|
||||
@ -26,22 +26,31 @@ func (am AppModule) IsOnePerModuleType() {}
|
||||
|
||||
func init() {
|
||||
appconfig.RegisterModule(&modulev1.Module{},
|
||||
appconfig.Provide(ProvideModule),
|
||||
appconfig.Provide(ProvideModule, ProvideConfig),
|
||||
appconfig.Invoke(PopulateVersionMap),
|
||||
)
|
||||
}
|
||||
|
||||
func ProvideConfig(key depinject.OwnModuleKey) coreserver.ModuleConfigMap {
|
||||
return coreserver.ModuleConfigMap{
|
||||
Module: depinject.ModuleKey(key).Name(),
|
||||
Config: coreserver.ConfigMap{
|
||||
server.FlagUnsafeSkipUpgrades: []int{},
|
||||
flags.FlagHome: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Config *modulev1.Module
|
||||
ConfigMap coreserver.ConfigMap
|
||||
Environment appmodule.Environment
|
||||
Cdc codec.Codec
|
||||
AddressCodec address.Codec
|
||||
AppVersionModifier coreserver.VersionModifier
|
||||
ConsensusKeeper types.ConsensusKeeper
|
||||
|
||||
DynamicConfig coreserver.DynamicConfig `optional:"true"`
|
||||
}
|
||||
|
||||
type ModuleOutputs struct {
|
||||
@ -57,14 +66,15 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
skipUpgradeHeights = make(map[int64]bool)
|
||||
)
|
||||
|
||||
if in.DynamicConfig != nil {
|
||||
skipUpgrades := cast.ToIntSlice(in.DynamicConfig.Get(server.FlagUnsafeSkipUpgrades))
|
||||
for _, h := range skipUpgrades {
|
||||
skipUpgradeHeights[int64(h)] = true
|
||||
}
|
||||
|
||||
homePath = in.DynamicConfig.GetString(flags.FlagHome)
|
||||
skipUpgrades, ok := in.ConfigMap[server.FlagUnsafeSkipUpgrades]
|
||||
if !ok || skipUpgrades == nil {
|
||||
skipUpgrades = []int{}
|
||||
}
|
||||
heights := cast.ToIntSlice(skipUpgrades) // safe to use cast here as we've handled nil case
|
||||
for _, h := range heights {
|
||||
skipUpgradeHeights[int64(h)] = true
|
||||
}
|
||||
homePath = cast.ToString(in.ConfigMap[flags.FlagHome])
|
||||
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress(types.GovModuleName)
|
||||
|
||||
@ -3,6 +3,8 @@ package validate
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
|
||||
modulev1 "cosmossdk.io/api/cosmos/validate/module/v1"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/server"
|
||||
@ -25,17 +27,28 @@ const flagMinGasPricesV2 = "server.minimum-gas-prices"
|
||||
|
||||
func init() {
|
||||
appconfig.RegisterModule(&modulev1.Module{},
|
||||
appconfig.Provide(ProvideModule),
|
||||
appconfig.Provide(ProvideModule, ProvideConfig),
|
||||
)
|
||||
}
|
||||
|
||||
// ProvideConfig specifies the configuration key for the minimum gas prices.
|
||||
// During dependency injection, a configuration map is provided with the key set.
|
||||
func ProvideConfig(key depinject.OwnModuleKey) server.ModuleConfigMap {
|
||||
return server.ModuleConfigMap{
|
||||
Module: depinject.ModuleKey(key).Name(),
|
||||
Config: server.ConfigMap{
|
||||
flagMinGasPricesV2: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
ModuleConfig *modulev1.Module
|
||||
Environment appmodulev2.Environment
|
||||
TxConfig client.TxConfig
|
||||
DynamicConfig server.DynamicConfig `optional:"true"`
|
||||
ModuleConfig *modulev1.Module
|
||||
Environment appmodulev2.Environment
|
||||
TxConfig client.TxConfig
|
||||
ConfigMap server.ConfigMap
|
||||
|
||||
AccountKeeper ante.AccountKeeper
|
||||
BankKeeper authtypes.BankKeeper
|
||||
@ -69,17 +82,15 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
unorderedTxValidator *ante.UnorderedTxDecorator
|
||||
)
|
||||
|
||||
if 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))
|
||||
}
|
||||
|
||||
feeTxValidator = ante.NewDeductFeeDecorator(in.AccountKeeper, in.BankKeeper, in.FeeGrantKeeper, in.TxFeeChecker)
|
||||
feeTxValidator.SetMinGasPrices(minGasPrices) // set min gas price in deduct fee decorator
|
||||
minGasPricesStr := cast.ToString(in.ConfigMap[flagMinGasPricesV2])
|
||||
minGasPrices, err = sdk.ParseDecCoins(minGasPricesStr)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("invalid minimum gas prices: %v", err))
|
||||
}
|
||||
|
||||
feeTxValidator = ante.NewDeductFeeDecorator(in.AccountKeeper, in.BankKeeper, in.FeeGrantKeeper, in.TxFeeChecker)
|
||||
feeTxValidator.SetMinGasPrices(minGasPrices) // set min gas price in deduct fee decorator
|
||||
|
||||
if in.UnorderedTxManager != nil {
|
||||
unorderedTxValidator = ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, in.UnorderedTxManager, in.Environment, ante.DefaultSha256Cost)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user