-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for iavl options in cosmos config #9426
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that sure is a different kind of architecture we're dealing with. 🙃
Additional thoughts:
NewAgoricApp
is also called by appExport
; should that support/send DisableFastNode?
We should have protection against this kind of lapse in the future... maybe a test that imports "github.com/cosmos/cosmos-sdk/server"
and uses its functions to see what flags exist:
import (
"io"
"os"
"testing"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/spf13/pflag"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
)
type appOptionsFromFn func(string) interface{}
func (fn appOptionsFromFn) Get(name string) interface{} {
return fn(name)
}
func TestCLIFlags(t *testing.T) {
expectedFlagNames := map[string]interface{}{
"abci": "",
"abci-client-type": "",
"address": "",
"api.address": "",
"api.enable": "",
"api.enabled-unsafe-cors": "",
"api.max-open-connections": "",
"api.rpc-max-body-bytes": "",
"api.rpc-read-timeout": "",
"api.rpc-write-timeout": "",
"api.swagger": "",
"app-db-backend": "",
"consensus.create_empty_blocks": "",
"consensus.create_empty_blocks_interval": "",
"consensus.double_sign_check_height": "",
"cpu-profile": "",
"db_backend": "",
"db_dir": "",
"fast_sync": "",
"genesis_hash": "",
"grpc-only": "",
"grpc-web.address": "",
"grpc-web.enable": "",
"grpc.address": "",
"grpc.enable": "",
"halt-height": "",
"halt-time": "",
"home": "",
"iavl-cache-size": "",
"iavl-disable-fastnode": "",
"iavl-lazy-loading": "",
"index-events": "",
"inter-block-cache": "",
"inv-check-period": "",
"min-retain-blocks": "",
"minimum-gas-prices": "",
"moniker": "",
"p2p.external-address": "",
"p2p.laddr": "",
"p2p.persistent_peers": "",
"p2p.pex": "",
"p2p.private_peer_ids": "",
"p2p.seed_mode": "",
"p2p.seeds": "",
"p2p.unconditional_peer_ids": "",
"p2p.upnp": "",
"priv_validator_laddr": "",
"proxy_app": "",
"pruning": "default",
"pruning-interval": "",
"pruning-keep-recent": "",
"rpc.grpc_laddr": "",
"rpc.laddr": "",
"rpc.pprof_laddr": "",
"rpc.unsafe": "",
"state-sync.snapshot-interval": "",
"state-sync.snapshot-keep-recent": "",
"trace": "",
"trace-store": "",
"transport": "",
"unsafe-skip-upgrades": "",
"with-tendermint": "",
}
unknownFlagNames := []string{}
missingFlagNames := map[string]bool{}
for name, _ := range expectedFlagNames {
missingFlagNames[name] = true
}
readFlag := func(name string) interface{} {
if defaultValue, found := expectedFlagNames[name]; found {
delete(missingFlagNames, name)
return defaultValue
}
unknownFlagNames = append(unknownFlagNames, name)
return nil
}
homeDir, err := os.MkdirTemp("", "cosmos-sdk-home")
if err != nil {
panic(err)
}
defer os.RemoveAll(homeDir)
dummyAppCreator := func(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
appOpts servertypes.AppOptions,
) servertypes.Application {
return new(gaia.GaiaApp)
}
cmd := server.StartCmd(dummyAppCreator, homeDir)
flags := cmd.Flags()
flags.SortFlags = true
flags.VisitAll(func(flag *pflag.Flag) {
readFlag(flag.Name)
})
readBaseOptions := func() {
flagsRead := []string{}
logAndReadFlag := func(name string) interface{} {
flagsRead = append(flagsRead, name)
return readFlag(name)
}
defer func() {
if r := recover(); r != nil {
t.Error("panic after reading flags", flagsRead)
panic(r)
}
}()
server.DefaultBaseappOptions(appOptionsFromFn(logAndReadFlag))
}
readBaseOptions()
if len(unknownFlagNames) != 0 {
t.Error(
"unknown CLI flags in cosmos-sdk; incorporate as needed and update this test",
unknownFlagNames,
)
}
if len(missingFlagNames) != 0 {
missing := []string{}
for name, _ := range missingFlagNames {
missing = append(missing, name)
}
t.Error(
"expected CLI flags missing from cosmos-sdk; remove from this test",
missing,
)
}
}
We should, let's address that in #9425 |
Deploying agoric-sdk with Cloudflare Pages
|
@gibson042 I ended up tweaking your test to parse the default config file generated from template to get the full list of default options. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested a text/template
simplification, but LGTM!
4c6c083
to
6afa658
Compare
closes: #9424 ## Description Plumb the iavl options into the cosmos baseapp. Copied by comparing to `DefaultBaseappOptions` in cosmos-sdk `server/util.go`, which we should likely use directly instead (see #9425), but this is a minimal change we can easily adopt now. ### Security Considerations None ### Scaling Considerations None ### Documentation Considerations None. Change should explicitly be part of the release notes ### Testing Considerations Unsure about how to test this ### Upgrade Considerations Chain software, not consensus affecting.
closes: #9424
Description
Plumb the iavl options into the cosmos baseapp.
Copied by comparing to
DefaultBaseappOptions
in cosmos-sdkserver/util.go
, which we should likely use directly instead (see #9425), but this is a minimal change we can easily adopt now.Security Considerations
None
Scaling Considerations
None
Documentation Considerations
None. Change should explicitly be part of the release notes
Testing Considerations
Unsure about how to test this
Upgrade Considerations
Chain software, not consensus affecting.