diff --git a/gno.land/cmd/gnoland/config.go b/gno.land/cmd/gnoland/config.go index d5b61ea48b6..22d23e3ecb1 100644 --- a/gno.land/cmd/gnoland/config.go +++ b/gno.land/cmd/gnoland/config.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "reflect" + "strings" "github.com/gnolang/gno/tm2/pkg/commands" ) @@ -47,7 +48,7 @@ func (c *configCfg) RegisterFlags(fs *flag.FlagSet) { func getFieldAtPath(currentValue reflect.Value, path []string) (*reflect.Value, error) { // Look at the current section, and figure out if // it's a part of the current struct - field := currentValue.FieldByName(path[0]) + field := fieldByTOMLName(currentValue, path[0]) if !field.IsValid() || !field.CanSet() { return nil, newInvalidFieldError(path[0], currentValue) } @@ -67,24 +68,84 @@ func getFieldAtPath(currentValue reflect.Value, path []string) (*reflect.Value, return &field, nil } -// newInvalidFieldError creates an error for non-existent struct fields -// being passed as arguments to [getFieldAtPath] -func newInvalidFieldError(field string, value reflect.Value) error { - var ( - valueType = value.Type() - numFields = value.NumField() - ) - - fields := make([]string, 0, numFields) +func fieldByTOMLName(value reflect.Value, name string) reflect.Value { + var dst reflect.Value + eachTOMLField(value, func(val reflect.Value, tomlName string) bool { + if tomlName == name { + dst = val + return true + } + return false + }) + return dst +} - for i := 0; i < numFields; i++ { - valueField := valueType.Field(i) - if !valueField.IsExported() { +// eachTOMLField iterates over each field in value (assumed to be a struct). +// For every field within the struct, iterationCallback is called with the value +// of the field and the associated name in the TOML representation +// (through the `toml:"..."` struct field, or just the field's name as fallback). +// If iterationCallback returns true, the function returns immediately with +// true. If it always returns false, or no fields were processed, eachTOMLField +// will return false. +func eachTOMLField(value reflect.Value, iterationCallback func(val reflect.Value, tomlName string) bool) bool { + // For reference: + // https://github.com/pelletier/go-toml/blob/7dad87762adb203e30b96a46026d1428ef2491a2/unmarshaler.go#L1251-L1270 + + currentType := value.Type() + nf := currentType.NumField() + for i := 0; i < nf; i++ { + fld := currentType.Field(i) + tomlName := fld.Tag.Get("toml") + + // Ignore `toml:"-"`, strip away any "omitempty" or other options. + if tomlName == "-" || !fld.IsExported() { continue } + if pos := strings.IndexByte(tomlName, ','); pos != -1 { + tomlName = tomlName[:pos] + } + + // Handle anonymous (embedded) fields. + // Anonymous fields will be treated regularly if they have a tag. + if fld.Anonymous && tomlName == "" { + anon := fld.Type + if anon.Kind() == reflect.Ptr { + anon = anon.Elem() + } + + if anon.Kind() == reflect.Struct { + // NOTE: naive, if there is a conflict the embedder should take + // precedence over the embedded; but the TOML parser seems to + // ignore this, too, and this "unmarshaler" isn't fit for general + // purpose. + if eachTOMLField(value.Field(i), iterationCallback) { + return true + } + continue + } + // If it's not a struct, or *struct, it should be treated regularly. + } - fields = append(fields, valueField.Name) + // general case, simple struct field. + if tomlName == "" { + tomlName = fld.Name + } + if iterationCallback(value.Field(i), tomlName) { + return true + } } + return false +} + +// newInvalidFieldError creates an error for non-existent struct fields +// being passed as arguments to [getFieldAtPath] +func newInvalidFieldError(field string, value reflect.Value) error { + fields := make([]string, 0, value.NumField()) + + eachTOMLField(value, func(val reflect.Value, tomlName string) bool { + fields = append(fields, tomlName) + return false + }) return fmt.Errorf( "field %q, is not a valid configuration key, available keys: %s", diff --git a/gno.land/cmd/gnoland/config_get_test.go b/gno.land/cmd/gnoland/config_get_test.go index 93baa3d20ba..940842516d0 100644 --- a/gno.land/cmd/gnoland/config_get_test.go +++ b/gno.land/cmd/gnoland/config_get_test.go @@ -86,28 +86,28 @@ func TestConfig_Get_Base(t *testing.T) { testTable := []testGetCase{ { "root dir fetched", - "RootDir", + "home", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.RootDir, value) }, }, { "proxy app fetched", - "ProxyApp", + "proxy_app", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.ProxyApp, value) }, }, { "moniker fetched", - "Moniker", + "moniker", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.Moniker, value) }, }, { "fast sync mode fetched", - "FastSyncMode", + "fast_sync", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -117,70 +117,70 @@ func TestConfig_Get_Base(t *testing.T) { }, { "db backend fetched", - "DBBackend", + "db_backend", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.DBBackend, value) }, }, { "db path fetched", - "DBPath", + "db_dir", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.DBPath, value) }, }, { "genesis path fetched", - "Genesis", + "genesis_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.Genesis, value) }, }, { "validator key fetched", - "PrivValidatorKey", + "priv_validator_key_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.PrivValidatorKey, value) }, }, { "validator state file fetched", - "PrivValidatorState", + "priv_validator_state_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.PrivValidatorState, value) }, }, { "validator listen addr fetched", - "PrivValidatorListenAddr", + "priv_validator_laddr", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.PrivValidatorListenAddr, value) }, }, { "node key path fetched", - "NodeKey", + "node_key_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.NodeKey, value) }, }, { "abci fetched", - "ABCI", + "abci", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.ABCI, value) }, }, { "profiling listen address fetched", - "ProfListenAddress", + "prof_laddr", func(loadedCfg *config.Config, value string) { assert.Equal(t, loadedCfg.ProfListenAddress, value) }, }, { "filter peers flag fetched", - "FilterPeers", + "filter_peers", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -199,70 +199,70 @@ func TestConfig_Get_Consensus(t *testing.T) { testTable := []testGetCase{ { "root dir updated", - "Consensus.RootDir", + "consensus.home", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.RootDir) }, }, { "WAL path updated", - "Consensus.WALPath", + "consensus.wal_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.WALPath) }, }, { "propose timeout updated", - "Consensus.TimeoutPropose", + "consensus.timeout_propose", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutPropose.String()) }, }, { "propose timeout delta updated", - "Consensus.TimeoutProposeDelta", + "consensus.timeout_propose_delta", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutProposeDelta.String()) }, }, { "prevote timeout updated", - "Consensus.TimeoutPrevote", + "consensus.timeout_prevote", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutPrevote.String()) }, }, { "prevote timeout delta updated", - "Consensus.TimeoutPrevoteDelta", + "consensus.timeout_prevote_delta", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutPrevoteDelta.String()) }, }, { "precommit timeout updated", - "Consensus.TimeoutPrecommit", + "consensus.timeout_precommit", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutPrecommit.String()) }, }, { "precommit timeout delta updated", - "Consensus.TimeoutPrecommitDelta", + "consensus.timeout_precommit_delta", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutPrecommitDelta.String()) }, }, { "commit timeout updated", - "Consensus.TimeoutCommit", + "consensus.timeout_commit", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.TimeoutCommit.String()) }, }, { "skip commit timeout toggle updated", - "Consensus.SkipTimeoutCommit", + "consensus.skip_timeout_commit", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -272,7 +272,7 @@ func TestConfig_Get_Consensus(t *testing.T) { }, { "create empty blocks toggle updated", - "Consensus.CreateEmptyBlocks", + "consensus.create_empty_blocks", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -281,21 +281,21 @@ func TestConfig_Get_Consensus(t *testing.T) { }, { "create empty blocks interval updated", - "Consensus.CreateEmptyBlocksInterval", + "consensus.create_empty_blocks_interval", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.CreateEmptyBlocksInterval.String()) }, }, { "peer gossip sleep duration updated", - "Consensus.PeerGossipSleepDuration", + "consensus.peer_gossip_sleep_duration", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.PeerGossipSleepDuration.String()) }, }, { "peer query majority sleep duration updated", - "Consensus.PeerQueryMaj23SleepDuration", + "consensus.peer_query_maj23_sleep_duration", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Consensus.PeerQueryMaj23SleepDuration.String()) }, @@ -311,14 +311,14 @@ func TestConfig_Get_Events(t *testing.T) { testTable := []testGetCase{ { "event store type updated", - "TxEventStore.EventStoreType", + "tx_event_store.event_store_type", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.TxEventStore.EventStoreType) }, }, { "event store params updated", - "TxEventStore.Params", + "tx_event_store.event_store_params", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%v", loadedCfg.TxEventStore.Params)) }, @@ -334,42 +334,42 @@ func TestConfig_Get_P2P(t *testing.T) { testTable := []testGetCase{ { "root dir updated", - "P2P.RootDir", + "p2p.home", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.RootDir) }, }, { "listen address updated", - "P2P.ListenAddress", + "p2p.laddr", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.ListenAddress) }, }, { "external address updated", - "P2P.ExternalAddress", + "p2p.external_address", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.ExternalAddress) }, }, { "seeds updated", - "P2P.Seeds", + "p2p.seeds", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.Seeds) }, }, { "persistent peers updated", - "P2P.PersistentPeers", + "p2p.persistent_peers", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.PersistentPeers) }, }, { "upnp toggle updated", - "P2P.UPNP", + "p2p.upnp", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -379,49 +379,49 @@ func TestConfig_Get_P2P(t *testing.T) { }, { "max inbound peers updated", - "P2P.MaxNumInboundPeers", + "p2p.max_num_inbound_peers", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.P2P.MaxNumInboundPeers)) }, }, { "max outbound peers updated", - "P2P.MaxNumOutboundPeers", + "p2p.max_num_outbound_peers", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.P2P.MaxNumOutboundPeers)) }, }, { "flush throttle timeout updated", - "P2P.FlushThrottleTimeout", + "p2p.flush_throttle_timeout", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.FlushThrottleTimeout.String()) }, }, { "max package payload size updated", - "P2P.MaxPacketMsgPayloadSize", + "p2p.max_packet_msg_payload_size", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.P2P.MaxPacketMsgPayloadSize)) }, }, { "send rate updated", - "P2P.SendRate", + "p2p.send_rate", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.P2P.SendRate)) }, }, { "receive rate updated", - "P2P.RecvRate", + "p2p.recv_rate", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.P2P.RecvRate)) }, }, { "pex reactor toggle updated", - "P2P.PexReactor", + "p2p.pex", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -431,7 +431,7 @@ func TestConfig_Get_P2P(t *testing.T) { }, { "seed mode updated", - "P2P.SeedMode", + "p2p.seed_mode", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -441,14 +441,14 @@ func TestConfig_Get_P2P(t *testing.T) { }, { "private peer IDs updated", - "P2P.PrivatePeerIDs", + "p2p.private_peer_ids", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.PrivatePeerIDs) }, }, { - "allow duplicate IPs updated", - "P2P.AllowDuplicateIP", + "allow duplicate IP updated", + "p2p.allow_duplicate_ip", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -458,14 +458,14 @@ func TestConfig_Get_P2P(t *testing.T) { }, { "handshake timeout updated", - "P2P.HandshakeTimeout", + "p2p.handshake_timeout", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.HandshakeTimeout.String()) }, }, { "dial timeout updated", - "P2P.DialTimeout", + "p2p.dial_timeout", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.P2P.DialTimeout.String()) }, @@ -481,56 +481,56 @@ func TestConfig_Get_RPC(t *testing.T) { testTable := []testGetCase{ { "root dir updated", - "RPC.RootDir", + "rpc.home", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.RPC.RootDir) }, }, { "listen address updated", - "RPC.ListenAddress", + "rpc.laddr", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.RPC.ListenAddress) }, }, { "CORS Allowed Origins updated", - "RPC.CORSAllowedOrigins", + "rpc.cors_allowed_origins", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%v", loadedCfg.RPC.CORSAllowedOrigins)) }, }, { "CORS Allowed Methods updated", - "RPC.CORSAllowedMethods", + "rpc.cors_allowed_methods", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%v", loadedCfg.RPC.CORSAllowedMethods)) }, }, { "CORS Allowed Headers updated", - "RPC.CORSAllowedHeaders", + "rpc.cors_allowed_headers", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%v", loadedCfg.RPC.CORSAllowedHeaders)) }, }, { "GRPC listen address updated", - "RPC.GRPCListenAddress", + "rpc.grpc_laddr", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.RPC.GRPCListenAddress) }, }, { "GRPC max open connections updated", - "RPC.GRPCMaxOpenConnections", + "rpc.grpc_max_open_connections", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.RPC.GRPCMaxOpenConnections)) }, }, { "unsafe value updated", - "RPC.Unsafe", + "rpc.unsafe", func(loadedCfg *config.Config, value string) { boolVal, err := strconv.ParseBool(value) require.NoError(t, err) @@ -539,43 +539,43 @@ func TestConfig_Get_RPC(t *testing.T) { }, }, { - "RPC max open connections updated", - "RPC.MaxOpenConnections", + "rpc max open connections updated", + "rpc.max_open_connections", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.RPC.MaxOpenConnections)) }, }, { "tx commit broadcast timeout updated", - "RPC.TimeoutBroadcastTxCommit", + "rpc.timeout_broadcast_tx_commit", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.RPC.TimeoutBroadcastTxCommit.String()) }, }, { "max body bytes updated", - "RPC.MaxBodyBytes", + "rpc.max_body_bytes", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.RPC.MaxBodyBytes)) }, }, { "max header bytes updated", - "RPC.MaxHeaderBytes", + "rpc.max_header_bytes", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.RPC.MaxHeaderBytes)) }, }, { "TLS cert file updated", - "RPC.TLSCertFile", + "rpc.tls_cert_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.RPC.TLSCertFile) }, }, { "TLS key file updated", - "RPC.TLSKeyFile", + "rpc.tls_key_file", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.RPC.TLSKeyFile) }, @@ -591,14 +591,14 @@ func TestConfig_Get_Mempool(t *testing.T) { testTable := []testGetCase{ { "root dir updated", - "Mempool.RootDir", + "mempool.home", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Mempool.RootDir) }, }, { "recheck flag updated", - "Mempool.Recheck", + "mempool.recheck", func(loadedCfg *config.Config, value string) { boolVar, err := strconv.ParseBool(value) require.NoError(t, err) @@ -608,7 +608,7 @@ func TestConfig_Get_Mempool(t *testing.T) { }, { "broadcast flag updated", - "Mempool.Broadcast", + "mempool.broadcast", func(loadedCfg *config.Config, value string) { boolVar, err := strconv.ParseBool(value) require.NoError(t, err) @@ -618,28 +618,28 @@ func TestConfig_Get_Mempool(t *testing.T) { }, { "WAL path updated", - "Mempool.WalPath", + "mempool.wal_dir", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, loadedCfg.Mempool.WalPath) }, }, { "size updated", - "Mempool.Size", + "mempool.size", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.Mempool.Size)) }, }, { "max pending txs bytes updated", - "Mempool.MaxPendingTxsBytes", + "mempool.max_pending_txs_bytes", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.Mempool.MaxPendingTxsBytes)) }, }, { "cache size updated", - "Mempool.CacheSize", + "mempool.cache_size", func(loadedCfg *config.Config, value string) { assert.Equal(t, value, fmt.Sprintf("%d", loadedCfg.Mempool.CacheSize)) }, diff --git a/gno.land/cmd/gnoland/config_set_test.go b/gno.land/cmd/gnoland/config_set_test.go index 5824fa0ee06..87cfbfdfc4a 100644 --- a/gno.land/cmd/gnoland/config_set_test.go +++ b/gno.land/cmd/gnoland/config_set_test.go @@ -107,7 +107,7 @@ func TestConfig_Set_Invalid(t *testing.T) { "set", "--config-path", path, - "DBBackend", + "db_backend", "random db backend", } @@ -124,7 +124,7 @@ func TestConfig_Set_Base(t *testing.T) { { "root dir updated", []string{ - "RootDir", + "home", "example root dir", }, func(loadedCfg *config.Config, value string) { @@ -134,7 +134,7 @@ func TestConfig_Set_Base(t *testing.T) { { "proxy app updated", []string{ - "ProxyApp", + "proxy_app", "example proxy app", }, func(loadedCfg *config.Config, value string) { @@ -144,7 +144,7 @@ func TestConfig_Set_Base(t *testing.T) { { "moniker updated", []string{ - "Moniker", + "moniker", "example moniker", }, func(loadedCfg *config.Config, value string) { @@ -154,7 +154,7 @@ func TestConfig_Set_Base(t *testing.T) { { "fast sync mode updated", []string{ - "FastSyncMode", + "fast_sync", "false", }, func(loadedCfg *config.Config, value string) { @@ -167,7 +167,7 @@ func TestConfig_Set_Base(t *testing.T) { { "db backend updated", []string{ - "DBBackend", + "db_backend", db.GoLevelDBBackend.String(), }, func(loadedCfg *config.Config, value string) { @@ -177,7 +177,7 @@ func TestConfig_Set_Base(t *testing.T) { { "db path updated", []string{ - "DBPath", + "db_dir", "example path", }, func(loadedCfg *config.Config, value string) { @@ -187,7 +187,7 @@ func TestConfig_Set_Base(t *testing.T) { { "genesis path updated", []string{ - "Genesis", + "genesis_file", "example path", }, func(loadedCfg *config.Config, value string) { @@ -197,7 +197,7 @@ func TestConfig_Set_Base(t *testing.T) { { "validator key updated", []string{ - "PrivValidatorKey", + "priv_validator_key_file", "example path", }, func(loadedCfg *config.Config, value string) { @@ -207,7 +207,7 @@ func TestConfig_Set_Base(t *testing.T) { { "validator state file updated", []string{ - "PrivValidatorState", + "priv_validator_state_file", "example path", }, func(loadedCfg *config.Config, value string) { @@ -217,7 +217,7 @@ func TestConfig_Set_Base(t *testing.T) { { "validator listen addr updated", []string{ - "PrivValidatorListenAddr", + "priv_validator_laddr", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -227,7 +227,7 @@ func TestConfig_Set_Base(t *testing.T) { { "node key path updated", []string{ - "NodeKey", + "node_key_file", "example path", }, func(loadedCfg *config.Config, value string) { @@ -237,7 +237,7 @@ func TestConfig_Set_Base(t *testing.T) { { "abci updated", []string{ - "ABCI", + "abci", config.LocalABCI, }, func(loadedCfg *config.Config, value string) { @@ -247,7 +247,7 @@ func TestConfig_Set_Base(t *testing.T) { { "profiling listen address updated", []string{ - "ProfListenAddress", + "prof_laddr", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -257,7 +257,7 @@ func TestConfig_Set_Base(t *testing.T) { { "filter peers flag updated", []string{ - "FilterPeers", + "filter_peers", "true", }, func(loadedCfg *config.Config, value string) { @@ -279,7 +279,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "root dir updated", []string{ - "Consensus.RootDir", + "consensus.home", "example root dir", }, func(loadedCfg *config.Config, value string) { @@ -289,7 +289,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "WAL path updated", []string{ - "Consensus.WALPath", + "consensus.wal_file", "example WAL path", }, func(loadedCfg *config.Config, value string) { @@ -299,7 +299,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "propose timeout updated", []string{ - "Consensus.TimeoutPropose", + "consensus.timeout_propose", "1s", }, func(loadedCfg *config.Config, value string) { @@ -309,7 +309,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "propose timeout delta updated", []string{ - "Consensus.TimeoutProposeDelta", + "consensus.timeout_propose_delta", "1s", }, func(loadedCfg *config.Config, value string) { @@ -319,7 +319,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "prevote timeout updated", []string{ - "Consensus.TimeoutPrevote", + "consensus.timeout_prevote", "1s", }, func(loadedCfg *config.Config, value string) { @@ -329,7 +329,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "prevote timeout delta updated", []string{ - "Consensus.TimeoutPrevoteDelta", + "consensus.timeout_prevote_delta", "1s", }, func(loadedCfg *config.Config, value string) { @@ -339,7 +339,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "precommit timeout updated", []string{ - "Consensus.TimeoutPrecommit", + "consensus.timeout_precommit", "1s", }, func(loadedCfg *config.Config, value string) { @@ -349,7 +349,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "precommit timeout delta updated", []string{ - "Consensus.TimeoutPrecommitDelta", + "consensus.timeout_precommit_delta", "1s", }, func(loadedCfg *config.Config, value string) { @@ -359,7 +359,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "commit timeout updated", []string{ - "Consensus.TimeoutCommit", + "consensus.timeout_commit", "1s", }, func(loadedCfg *config.Config, value string) { @@ -369,7 +369,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "skip commit timeout toggle updated", []string{ - "Consensus.SkipTimeoutCommit", + "consensus.skip_timeout_commit", "true", }, func(loadedCfg *config.Config, value string) { @@ -382,7 +382,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "create empty blocks toggle updated", []string{ - "Consensus.CreateEmptyBlocks", + "consensus.create_empty_blocks", "false", }, func(loadedCfg *config.Config, value string) { @@ -394,7 +394,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "create empty blocks interval updated", []string{ - "Consensus.CreateEmptyBlocksInterval", + "consensus.create_empty_blocks_interval", "1s", }, func(loadedCfg *config.Config, value string) { @@ -404,7 +404,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "peer gossip sleep duration updated", []string{ - "Consensus.PeerGossipSleepDuration", + "consensus.peer_gossip_sleep_duration", "1s", }, func(loadedCfg *config.Config, value string) { @@ -414,7 +414,7 @@ func TestConfig_Set_Consensus(t *testing.T) { { "peer query majority sleep duration updated", []string{ - "Consensus.PeerQueryMaj23SleepDuration", + "consensus.peer_query_maj23_sleep_duration", "1s", }, func(loadedCfg *config.Config, value string) { @@ -433,7 +433,7 @@ func TestConfig_Set_Events(t *testing.T) { { "event store type updated", []string{ - "TxEventStore.EventStoreType", + "tx_event_store.event_store_type", file.EventStoreType, }, func(loadedCfg *config.Config, value string) { @@ -443,7 +443,7 @@ func TestConfig_Set_Events(t *testing.T) { { "event store params updated", []string{ - "TxEventStore.Params", + "tx_event_store.event_store_params", "key1=value1,key2=value2", }, func(loadedCfg *config.Config, value string) { @@ -468,7 +468,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "root dir updated", []string{ - "P2P.RootDir", + "p2p.home", "example root dir", }, func(loadedCfg *config.Config, value string) { @@ -478,7 +478,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "listen address updated", []string{ - "P2P.ListenAddress", + "p2p.laddr", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -488,7 +488,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "external address updated", []string{ - "P2P.ExternalAddress", + "p2p.external_address", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -498,7 +498,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "seeds updated", []string{ - "P2P.Seeds", + "p2p.seeds", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -508,7 +508,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "persistent peers updated", []string{ - "P2P.PersistentPeers", + "p2p.persistent_peers", "nodeID@0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -518,7 +518,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "upnp toggle updated", []string{ - "P2P.UPNP", + "p2p.upnp", "false", }, func(loadedCfg *config.Config, value string) { @@ -531,7 +531,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "max inbound peers updated", []string{ - "P2P.MaxNumInboundPeers", + "p2p.max_num_inbound_peers", "10", }, func(loadedCfg *config.Config, value string) { @@ -541,7 +541,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "max outbound peers updated", []string{ - "P2P.MaxNumOutboundPeers", + "p2p.max_num_outbound_peers", "10", }, func(loadedCfg *config.Config, value string) { @@ -551,7 +551,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "flush throttle timeout updated", []string{ - "P2P.FlushThrottleTimeout", + "p2p.flush_throttle_timeout", "1s", }, func(loadedCfg *config.Config, value string) { @@ -561,7 +561,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "max package payload size updated", []string{ - "P2P.MaxPacketMsgPayloadSize", + "p2p.max_packet_msg_payload_size", "10", }, func(loadedCfg *config.Config, value string) { @@ -571,7 +571,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "send rate updated", []string{ - "P2P.SendRate", + "p2p.send_rate", "10", }, func(loadedCfg *config.Config, value string) { @@ -581,7 +581,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "receive rate updated", []string{ - "P2P.RecvRate", + "p2p.recv_rate", "10", }, func(loadedCfg *config.Config, value string) { @@ -591,7 +591,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "pex reactor toggle updated", []string{ - "P2P.PexReactor", + "p2p.pex", "false", }, func(loadedCfg *config.Config, value string) { @@ -604,7 +604,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "seed mode updated", []string{ - "P2P.SeedMode", + "p2p.seed_mode", "false", }, func(loadedCfg *config.Config, value string) { @@ -617,7 +617,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "private peer IDs updated", []string{ - "P2P.PrivatePeerIDs", + "p2p.private_peer_ids", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -627,7 +627,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "allow duplicate IPs updated", []string{ - "P2P.AllowDuplicateIP", + "p2p.allow_duplicate_ip", "false", }, func(loadedCfg *config.Config, value string) { @@ -640,7 +640,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "handshake timeout updated", []string{ - "P2P.HandshakeTimeout", + "p2p.handshake_timeout", "1s", }, func(loadedCfg *config.Config, value string) { @@ -650,7 +650,7 @@ func TestConfig_Set_P2P(t *testing.T) { { "dial timeout updated", []string{ - "P2P.DialTimeout", + "p2p.dial_timeout", "1s", }, func(loadedCfg *config.Config, value string) { @@ -669,7 +669,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "root dir updated", []string{ - "RPC.RootDir", + "rpc.home", "example root dir", }, func(loadedCfg *config.Config, value string) { @@ -679,7 +679,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "listen address updated", []string{ - "RPC.ListenAddress", + "rpc.laddr", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -689,7 +689,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "CORS Allowed Origins updated", []string{ - "RPC.CORSAllowedOrigins", + "rpc.cors_allowed_origins", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -699,7 +699,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "CORS Allowed Methods updated", []string{ - "RPC.CORSAllowedMethods", + "rpc.cors_allowed_methods", "POST,GET", }, func(loadedCfg *config.Config, value string) { @@ -709,7 +709,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "CORS Allowed Headers updated", []string{ - "RPC.CORSAllowedHeaders", + "rpc.cors_allowed_headers", "*", }, func(loadedCfg *config.Config, value string) { @@ -719,7 +719,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "GRPC listen address updated", []string{ - "RPC.GRPCListenAddress", + "rpc.grpc_laddr", "0.0.0.0:0", }, func(loadedCfg *config.Config, value string) { @@ -729,7 +729,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "GRPC max open connections updated", []string{ - "RPC.GRPCMaxOpenConnections", + "rpc.grpc_max_open_connections", "10", }, func(loadedCfg *config.Config, value string) { @@ -739,7 +739,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "unsafe value updated", []string{ - "RPC.Unsafe", + "rpc.unsafe", "true", }, func(loadedCfg *config.Config, value string) { @@ -750,9 +750,9 @@ func TestConfig_Set_RPC(t *testing.T) { }, }, { - "RPC max open connections updated", + "rpc max open connections updated", []string{ - "RPC.MaxOpenConnections", + "rpc.max_open_connections", "10", }, func(loadedCfg *config.Config, value string) { @@ -762,7 +762,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "tx commit broadcast timeout updated", []string{ - "RPC.TimeoutBroadcastTxCommit", + "rpc.timeout_broadcast_tx_commit", (time.Second * 10).String(), }, func(loadedCfg *config.Config, value string) { @@ -772,7 +772,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "max body bytes updated", []string{ - "RPC.MaxBodyBytes", + "rpc.max_body_bytes", "10", }, func(loadedCfg *config.Config, value string) { @@ -782,7 +782,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "max header bytes updated", []string{ - "RPC.MaxHeaderBytes", + "rpc.max_header_bytes", "10", }, func(loadedCfg *config.Config, value string) { @@ -792,7 +792,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "TLS cert file updated", []string{ - "RPC.TLSCertFile", + "rpc.tls_cert_file", "example path", }, func(loadedCfg *config.Config, value string) { @@ -802,7 +802,7 @@ func TestConfig_Set_RPC(t *testing.T) { { "TLS key file updated", []string{ - "RPC.TLSKeyFile", + "rpc.tls_key_file", "example path", }, func(loadedCfg *config.Config, value string) { @@ -821,7 +821,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "root dir updated", []string{ - "Mempool.RootDir", + "mempool.home", "example root dir", }, func(loadedCfg *config.Config, value string) { @@ -831,7 +831,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "recheck flag updated", []string{ - "Mempool.Recheck", + "mempool.recheck", "false", }, func(loadedCfg *config.Config, value string) { @@ -844,7 +844,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "broadcast flag updated", []string{ - "Mempool.Broadcast", + "mempool.broadcast", "false", }, func(loadedCfg *config.Config, value string) { @@ -857,7 +857,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "WAL path updated", []string{ - "Mempool.WalPath", + "mempool.wal_dir", "example path", }, func(loadedCfg *config.Config, value string) { @@ -867,7 +867,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "size updated", []string{ - "Mempool.Size", + "mempool.size", "100", }, func(loadedCfg *config.Config, value string) { @@ -877,7 +877,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "max pending txs bytes updated", []string{ - "Mempool.MaxPendingTxsBytes", + "mempool.max_pending_txs_bytes", "100", }, func(loadedCfg *config.Config, value string) { @@ -887,7 +887,7 @@ func TestConfig_Set_Mempool(t *testing.T) { { "cache size updated", []string{ - "Mempool.CacheSize", + "mempool.cache_size", "100", }, func(loadedCfg *config.Config, value string) { diff --git a/tm2/pkg/bft/config/config.go b/tm2/pkg/bft/config/config.go index 729fafcffe5..1fb0fc87197 100644 --- a/tm2/pkg/bft/config/config.go +++ b/tm2/pkg/bft/config/config.go @@ -228,7 +228,7 @@ type BaseConfig struct { ProxyApp string `toml:"proxy_app" comment:"TCP or UNIX socket address of the ABCI application, \n or the name of an ABCI application compiled in with the Tendermint binary"` // Local application instance in lieu of remote app. - LocalApp abci.Application + LocalApp abci.Application `toml:"-"` // A custom human readable name for this node Moniker string `toml:"moniker" comment:"A custom human readable name for this node"`