diff --git a/cmd/cartesi-rollups-node/handlers.go b/cmd/cartesi-rollups-node/handlers.go index 75c27806a..5239b77d4 100644 --- a/cmd/cartesi-rollups-node/handlers.go +++ b/cmd/cartesi-rollups-node/handlers.go @@ -16,19 +16,28 @@ func newHttpServiceHandler(nodeConfig config.NodeConfig) http.Handler { handler := http.NewServeMux() handler.Handle("/healthz", http.HandlerFunc(healthcheckHandler)) - graphqlProxy, err := newReverseProxy(nodeConfig, getPort(nodeConfig, portOffsetGraphQLServer)) + graphqlProxy, err := newReverseProxy( + nodeConfig.CartesiHttpAddress, + getPort(nodeConfig.CartesiHttpPort, portOffsetGraphQLServer), + ) if err != nil { config.ErrorLogger.Fatal(err) } handler.Handle("/graphql", graphqlProxy) - dispatcherProxy, err := newReverseProxy(nodeConfig, getPort(nodeConfig, portOffsetDispatcher)) + dispatcherProxy, err := newReverseProxy( + nodeConfig.CartesiHttpAddress, + getPort(nodeConfig.CartesiHttpPort, portOffsetDispatcher), + ) if err != nil { config.ErrorLogger.Fatal(err) } handler.Handle("/metrics", dispatcherProxy) - inspectProxy, err := newReverseProxy(nodeConfig, getPort(nodeConfig, portOffsetInspectServer)) + inspectProxy, err := newReverseProxy( + nodeConfig.CartesiHttpAddress, + getPort(nodeConfig.CartesiHttpPort, portOffsetInspectServer), + ) if err != nil { config.ErrorLogger.Fatal(err) } @@ -36,8 +45,10 @@ func newHttpServiceHandler(nodeConfig config.NodeConfig) http.Handler { handler.Handle("/inspect/", inspectProxy) if nodeConfig.CartesiFeatureHostMode { - hostProxy, err := newReverseProxy(nodeConfig, - getPort(nodeConfig, portOffsetHostRunnerRollups)) + hostProxy, err := newReverseProxy( + nodeConfig.CartesiHttpAddress, + getPort(nodeConfig.CartesiHttpPort, portOffsetHostRunnerRollups), + ) if err != nil { config.ErrorLogger.Fatal(err) } @@ -51,10 +62,10 @@ func healthcheckHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } -func newReverseProxy(nodeConfig config.NodeConfig, port int) (*httputil.ReverseProxy, error) { +func newReverseProxy(httpAddress string, port int) (*httputil.ReverseProxy, error) { urlStr := fmt.Sprintf( "http://%v:%v/", - nodeConfig.CartesiHttpAddress, + httpAddress, port, ) diff --git a/cmd/cartesi-rollups-node/services.go b/cmd/cartesi-rollups-node/services.go index 926c82c67..ed169338d 100644 --- a/cmd/cartesi-rollups-node/services.go +++ b/cmd/cartesi-rollups-node/services.go @@ -37,8 +37,8 @@ const ( ) // Get the port of the given service. -func getPort(nodeConfig config.NodeConfig, offset portOffset) int { - return nodeConfig.CartesiHttpPort + int(offset) +func getPort(httpPort int, offset portOffset) int { + return httpPort + int(offset) } // Get the redis endpoint based on whether the experimental sunodo validator mode is enabled. @@ -46,7 +46,11 @@ func getRedisEndpoint(nodeConfig config.NodeConfig) string { if nodeConfig.CartesiExperimentalSunodoValidatorEnabled { return nodeConfig.CartesiExperimentalSunodoValidatorRedisEndpoint } else { - return fmt.Sprintf("redis://%v:%v", localhost, getPort(nodeConfig, portOffsetRedis)) + return fmt.Sprintf( + "redis://%v:%v", + localhost, + getPort(nodeConfig.CartesiHttpPort, portOffsetRedis), + ) } } @@ -70,7 +74,7 @@ func getRustLog(nodeConfig config.NodeConfig, rustModule string) string { func newAdvanceRunner(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "advance-runner" - s.HealthcheckPort = getPort(nodeConfig, portOffsetAdvanceRunner) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetAdvanceRunner) s.Path = "cartesi-rollups-advance-runner" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") @@ -78,7 +82,9 @@ func newAdvanceRunner(nodeConfig config.NodeConfig) services.CommandService { s.Env = append(s.Env, fmt.Sprintf("SERVER_MANAGER_ENDPOINT=http://%v:%v", localhost, - getPort(nodeConfig, portOffsetServerManager))) + getPort(nodeConfig.CartesiHttpPort, portOffsetServerManager), + ), + ) s.Env = append(s.Env, fmt.Sprintf("SESSION_ID=%v", serverManagerSessionId)) s.Env = append(s.Env, @@ -91,7 +97,9 @@ func newAdvanceRunner(nodeConfig config.NodeConfig) services.CommandService { fmt.Sprintf("PROVIDER_HTTP_ENDPOINT=%v", nodeConfig.CartesiBlockchainHttpEndpoint)) s.Env = append(s.Env, fmt.Sprintf("ADVANCE_RUNNER_HEALTHCHECK_PORT=%v", - getPort(nodeConfig, portOffsetAdvanceRunner))) + getPort(nodeConfig.CartesiHttpPort, portOffsetAdvanceRunner), + ), + ) s.Env = append(s.Env, fmt.Sprintf("READER_MODE=%v", nodeConfig.CartesiFeatureDisableClaimer)) if nodeConfig.CartesiFeatureHostMode || nodeConfig.CartesiFeatureDisableMachineHashCheck { @@ -108,7 +116,7 @@ func newAdvanceRunner(nodeConfig config.NodeConfig) services.CommandService { func newAuthorityClaimer(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "authority-claimer" - s.HealthcheckPort = getPort(nodeConfig, portOffsetAuthorityClaimer) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetAuthorityClaimer) s.Path = "cartesi-rollups-authority-claimer" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") @@ -132,9 +140,12 @@ func newAuthorityClaimer(nodeConfig config.NodeConfig) services.CommandService { s.Env = append(s.Env, fmt.Sprintf("GENESIS_BLOCK=%v", nodeConfig.CartesiContractsInputBoxDeploymentBlockNumber)) s.Env = append(s.Env, - fmt.Sprintf("AUTHORITY_CLAIMER_HTTP_SERVER_PORT=%v", - getPort(nodeConfig, portOffsetAuthorityClaimer))) - switch auth := config.GetAuth().(type) { + fmt.Sprintf( + "AUTHORITY_CLAIMER_HTTP_SERVER_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetAuthorityClaimer), + ), + ) + switch auth := nodeConfig.CartesiAuth.(type) { case config.AuthMnemonic: s.Env = append(s.Env, fmt.Sprintf("TX_SIGNING_MNEMONIC=%v", auth.Mnemonic)) @@ -155,14 +166,17 @@ func newAuthorityClaimer(nodeConfig config.NodeConfig) services.CommandService { func newDispatcher(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "dispatcher" - s.HealthcheckPort = getPort(nodeConfig, portOffsetDispatcher) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetDispatcher) s.Path = "cartesi-rollups-dispatcher" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") s.Env = append(s.Env, getRustLog(nodeConfig, "dispatcher")) s.Env = append(s.Env, - fmt.Sprintf("SC_GRPC_ENDPOINT=http://%v:%v", - localhost, getPort(nodeConfig, portOffsetStateServer))) + fmt.Sprintf( + "SC_GRPC_ENDPOINT=http://%v:%v", + localhost, getPort(nodeConfig.CartesiHttpPort, portOffsetStateServer), + ), + ) s.Env = append(s.Env, fmt.Sprintf("SC_DEFAULT_CONFIRMATIONS=%v", nodeConfig.CartesiBlockchainFinalityOffset)) s.Env = append(s.Env, @@ -183,7 +197,11 @@ func newDispatcher(nodeConfig config.NodeConfig) services.CommandService { s.Env = append(s.Env, fmt.Sprintf("CHAIN_ID=%v", nodeConfig.CartesiBlockchainId)) s.Env = append(s.Env, - fmt.Sprintf("DISPATCHER_HTTP_SERVER_PORT=%v", getPort(nodeConfig, portOffsetDispatcher))) + fmt.Sprintf( + "DISPATCHER_HTTP_SERVER_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetDispatcher), + ), + ) s.Env = append(s.Env, os.Environ()...) return s } @@ -191,7 +209,7 @@ func newDispatcher(nodeConfig config.NodeConfig) services.CommandService { func newGraphQLServer(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "graphql-server" - s.HealthcheckPort = getPort(nodeConfig, portOffsetGraphQLHealthcheck) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetGraphQLHealthcheck) s.Path = "cartesi-rollups-graphql-server" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") @@ -200,10 +218,13 @@ func newGraphQLServer(nodeConfig config.NodeConfig) services.CommandService { fmt.Sprintf("POSTGRES_ENDPOINT=%v", nodeConfig.CartesiPostgresEndpoint)) s.Env = append(s.Env, fmt.Sprintf("GRAPHQL_HOST=%v", localhost)) s.Env = append(s.Env, - fmt.Sprintf("GRAPHQL_PORT=%v", getPort(nodeConfig, portOffsetGraphQLServer))) + fmt.Sprintf( + "GRAPHQL_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetGraphQLServer)), + ) s.Env = append(s.Env, fmt.Sprintf("GRAPHQL_HEALTHCHECK_PORT=%v", - getPort(nodeConfig, portOffsetGraphQLHealthcheck))) + getPort(nodeConfig.CartesiHttpPort, portOffsetGraphQLHealthcheck))) s.Env = append(s.Env, os.Environ()...) return s } @@ -211,20 +232,27 @@ func newGraphQLServer(nodeConfig config.NodeConfig) services.CommandService { func newHostRunner(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "host-runner" - s.HealthcheckPort = getPort(nodeConfig, portOffsetHostRunnerHealthcheck) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetHostRunnerHealthcheck) s.Path = "cartesi-rollups-host-runner" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") s.Env = append(s.Env, getRustLog(nodeConfig, "host_runner")) s.Env = append(s.Env, fmt.Sprintf("GRPC_SERVER_MANAGER_ADDRESS=%v", localhost)) s.Env = append(s.Env, - fmt.Sprintf("GRPC_SERVER_MANAGER_PORT=%v", getPort(nodeConfig, portOffsetServerManager))) + fmt.Sprintf( + "GRPC_SERVER_MANAGER_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetServerManager), + ), + ) s.Env = append(s.Env, fmt.Sprintf("HTTP_ROLLUP_SERVER_ADDRESS=%v", localhost)) s.Env = append(s.Env, - fmt.Sprintf("HTTP_ROLLUP_SERVER_PORT=%v", getPort(nodeConfig, portOffsetHostRunnerRollups))) + fmt.Sprintf("HTTP_ROLLUP_SERVER_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetHostRunnerRollups), + ), + ) s.Env = append(s.Env, fmt.Sprintf("HOST_RUNNER_HEALTHCHECK_PORT=%v", - getPort(nodeConfig, portOffsetHostRunnerHealthcheck))) + getPort(nodeConfig.CartesiHttpPort, portOffsetHostRunnerHealthcheck))) s.Env = append(s.Env, os.Environ()...) return s } @@ -232,7 +260,7 @@ func newHostRunner(nodeConfig config.NodeConfig) services.CommandService { func newIndexer(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "indexer" - s.HealthcheckPort = getPort(nodeConfig, portOffsetIndexer) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetIndexer) s.Path = "cartesi-rollups-indexer" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") @@ -246,7 +274,11 @@ func newIndexer(nodeConfig config.NodeConfig) services.CommandService { s.Env = append(s.Env, fmt.Sprintf("REDIS_ENDPOINT=%v", getRedisEndpoint(nodeConfig))) s.Env = append(s.Env, - fmt.Sprintf("INDEXER_HEALTHCHECK_PORT=%v", getPort(nodeConfig, portOffsetIndexer))) + fmt.Sprintf( + "INDEXER_HEALTHCHECK_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetIndexer), + ), + ) s.Env = append(s.Env, os.Environ()...) return s } @@ -254,22 +286,33 @@ func newIndexer(nodeConfig config.NodeConfig) services.CommandService { func newInspectServer(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "inspect-server" - s.HealthcheckPort = getPort(nodeConfig, portOffsetInspectHealthcheck) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetInspectHealthcheck) s.Path = "cartesi-rollups-inspect-server" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") s.Env = append(s.Env, getRustLog(nodeConfig, "inspect_server")) s.Env = append(s.Env, - fmt.Sprintf("INSPECT_SERVER_ADDRESS=%v:%v", - localhost, getPort(nodeConfig, portOffsetInspectServer))) + fmt.Sprintf( + "INSPECT_SERVER_ADDRESS=%v:%v", + localhost, + getPort(nodeConfig.CartesiHttpPort, portOffsetInspectServer), + ), + ) s.Env = append(s.Env, - fmt.Sprintf("SERVER_MANAGER_ADDRESS=%v:%v", - localhost, getPort(nodeConfig, portOffsetServerManager))) + fmt.Sprintf( + "SERVER_MANAGER_ADDRESS=%v:%v", + localhost, + getPort(nodeConfig.CartesiHttpPort, portOffsetServerManager), + ), + ) s.Env = append(s.Env, fmt.Sprintf("SESSION_ID=%v", serverManagerSessionId)) s.Env = append(s.Env, - fmt.Sprintf("INSPECT_SERVER_HEALTHCHECK_PORT=%v", - getPort(nodeConfig, portOffsetInspectHealthcheck))) + fmt.Sprintf( + "INSPECT_SERVER_HEALTHCHECK_PORT=%v", + getPort(nodeConfig.CartesiHttpPort, portOffsetInspectHealthcheck), + ), + ) s.Env = append(s.Env, os.Environ()...) return s } @@ -277,9 +320,12 @@ func newInspectServer(nodeConfig config.NodeConfig) services.CommandService { func newRedis(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "redis" - s.HealthcheckPort = getPort(nodeConfig, portOffsetRedis) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetRedis) s.Path = "redis-server" - s.Args = append(s.Args, "--port", fmt.Sprint(getPort(nodeConfig, portOffsetRedis))) + s.Args = append(s.Args, + "--port", + fmt.Sprint(getPort(nodeConfig.CartesiHttpPort, portOffsetRedis)), + ) // Disable persistence with --save and --appendonly config s.Args = append(s.Args, "--save", "") s.Args = append(s.Args, "--appendonly", "no") @@ -290,11 +336,15 @@ func newRedis(nodeConfig config.NodeConfig) services.CommandService { func newServerManager(nodeConfig config.NodeConfig) services.ServerManager { var s services.ServerManager s.Name = "server-manager" - s.HealthcheckPort = getPort(nodeConfig, portOffsetServerManager) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetServerManager) s.Path = "server-manager" s.Args = append(s.Args, - fmt.Sprintf("--manager-address=%v:%v", - localhost, getPort(nodeConfig, portOffsetServerManager))) + fmt.Sprintf( + "--manager-address=%v:%v", + localhost, + getPort(nodeConfig.CartesiHttpPort, portOffsetServerManager), + ), + ) s.Env = append(s.Env, "REMOTE_CARTESI_MACHINE_LOG_LEVEL=info") if nodeConfig.CartesiLogLevel == config.LogLevelDebug { s.Env = append(s.Env, "SERVER_MANAGER_LOG_LEVEL=info") @@ -308,15 +358,17 @@ func newServerManager(nodeConfig config.NodeConfig) services.ServerManager { func newStateServer(nodeConfig config.NodeConfig) services.CommandService { var s services.CommandService s.Name = "state-server" - s.HealthcheckPort = getPort(nodeConfig, portOffsetStateServer) + s.HealthcheckPort = getPort(nodeConfig.CartesiHttpPort, portOffsetStateServer) s.Path = "cartesi-rollups-state-server" s.Env = append(s.Env, "LOG_ENABLE_TIMESTAMP=false") s.Env = append(s.Env, "LOG_ENABLE_COLOR=false") s.Env = append(s.Env, getRustLog(nodeConfig, "state_server")) s.Env = append(s.Env, "SF_CONCURRENT_EVENTS_FETCH=1") s.Env = append(s.Env, - fmt.Sprintf("SF_GENESIS_BLOCK=%v", - nodeConfig.CartesiContractsInputBoxDeploymentBlockNumber)) + fmt.Sprintf( + "SF_GENESIS_BLOCK=%v", + nodeConfig.CartesiContractsInputBoxDeploymentBlockNumber), + ) s.Env = append(s.Env, fmt.Sprintf("SF_SAFETY_MARGIN=%v", nodeConfig.CartesiBlockchainFinalityOffset)) s.Env = append(s.Env, @@ -326,8 +378,11 @@ func newStateServer(nodeConfig config.NodeConfig) services.CommandService { s.Env = append(s.Env, fmt.Sprintf("BLOCKCHAIN_BLOCK_TIMEOUT=%v", nodeConfig.CartesiBlockchainBlockTimeout)) s.Env = append(s.Env, - fmt.Sprintf("SS_SERVER_ADDRESS=%v:%v", - localhost, getPort(nodeConfig, portOffsetStateServer))) + fmt.Sprintf( + "SS_SERVER_ADDRESS=%v:%v", + localhost, getPort(nodeConfig.CartesiHttpPort, portOffsetStateServer), + ), + ) s.Env = append(s.Env, os.Environ()...) return s } @@ -340,8 +395,11 @@ func newSupervisorService(s []services.Service) services.SupervisorService { } func newHttpService(nodeConfig config.NodeConfig) services.HttpService { - addr := fmt.Sprintf("%v:%v", nodeConfig.CartesiHttpAddress, - getPort(nodeConfig, portOffsetProxy)) + addr := fmt.Sprintf( + "%v:%v", + nodeConfig.CartesiHttpAddress, + getPort(nodeConfig.CartesiHttpPort, portOffsetProxy), + ) handler := newHttpServiceHandler(nodeConfig) return services.HttpService{ Name: "http", diff --git a/docs/config.md b/docs/config.md index 80d986e81..30db14afa 100644 --- a/docs/config.md +++ b/docs/config.md @@ -143,6 +143,7 @@ When enabled, the node does not start the authority-claimer service and the Redi External Redis endpoint for the node when running in the experimental sunodo validator mode. * **Type:** `string` +* **Default:** `""` ## `CARTESI_FEATURE_DISABLE_CLAIMER` diff --git a/internal/config/config.go b/internal/config/config.go index 717cedd51..603e93f95 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -52,7 +52,7 @@ var ( // Custom GETs // ------------------------------------------------------------------------------------------------ -func GetAuth() Auth { +func getAuth() Auth { // getting the (optional) account index index, _ := getCartesiAuthMnemonicAccountIndex() diff --git a/internal/config/generate/Config.toml b/internal/config/generate/Config.toml index 5901676b5..ea3d3449f 100644 --- a/internal/config/generate/Config.toml +++ b/internal/config/generate/Config.toml @@ -234,6 +234,7 @@ description = """ When enabled, the node does not start the authority-claimer service and the Redis server.""" [experimental.CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT] +default = "" go-type = "string" description = """ External Redis endpoint for the node when running in the experimental sunodo validator mode.""" diff --git a/internal/config/generate/main.go b/internal/config/generate/main.go index 30c2432e4..db295d3b5 100644 --- a/internal/config/generate/main.go +++ b/internal/config/generate/main.go @@ -56,7 +56,7 @@ func writeCode(envs []Env) { addLine(&code, env.toStructMember()) } } - addLine(&code, "CartesiAuth Auth") + addLine(&code, "CartesiAuth Auth") addLine(&code, "}") //Add init function from System Environment @@ -70,36 +70,33 @@ func writeCode(envs []Env) { } } addLine(&code, "}") - addLine(&code, "nodeConfig.CartesiAuth = GetAuth()") + addLine(&code, "nodeConfig.CartesiAuth = getAuth()") addLine(&code, "return nodeConfig") addLine(&code, "}") //Add init function from Default Values addLine(&code, "") - addLine(&code, "func NewtNodeConfigDefault() (NodeConfig){") + addLine(&code, "func NewNodeConfig() (NodeConfig){") addLine(&code, "nodeConfig := NodeConfig{}") for _, env := range envs { if *env.Export && env.Default != nil && *env.Default != "" { name := toStructMemberName(env.Name) varName := toVarName(name) - errorName := name + "Error" - addLine(&code, varName+", "+errorName+" := "+ - toToFuncName(env.GoType)+`("`+*env.Default+`")`) - addLine(&code, "if "+errorName+" != nil {") - addLine(&code, "panic("+errorName+")") + addLine(&code, varName+", err := "+toToFuncName(env.GoType)+`("`+*env.Default+`")`) + addLine(&code, "if err != nil {") + addLine(&code, "panic(err)") addLine(&code, "}") addLine(&code, "nodeConfig."+name+" = "+varName) - } } - - addLine(&code, - `nodeConfig.CartesiAuth = AuthMnemonic{Mnemonic: `+ - `"test test test test test test test test test test test junk", AccountIndex: 0}`) + addLine(&code, `nodeConfig.CartesiAuth = AuthMnemonic{`) + addLine(&code, `Mnemonic: "test test test test test test test test test test test junk",`) + addLine(&code, `AccountIndex: 0,`) + addLine(&code, "}") addLine(&code, "return nodeConfig") addLine(&code, "}") - writeToFile("configstruct.go", formatCode(code.String())) + writeToFile("nodeconfig.go", formatCode(code.String())) } func writeDoc(envs []Env) { @@ -191,13 +188,10 @@ func (e Env) toFunction() string { // Generates the Config Struct member for the envrionemnt variable. func (e Env) toStructMember() string { name := toStructMemberName(e.Name) - if !*e.Export { name = toVarName(name) } - return name + " " + e.GoType - } // Generates the documentation entry for the environment variable. diff --git a/internal/config/configstruct.go b/internal/config/nodeconfig.go similarity index 79% rename from internal/config/configstruct.go rename to internal/config/nodeconfig.go index 88354e69c..65421fdf3 100644 --- a/internal/config/configstruct.go +++ b/internal/config/nodeconfig.go @@ -105,7 +105,7 @@ func getCartesiExperimentalSunodoValidatorEnabled() bool { } func getCartesiExperimentalSunodoValidatorRedisEndpoint() string { - v := get("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT", "", false, false, toString) + v := get("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT", "", true, false, toString) return v } @@ -214,72 +214,75 @@ func NewNodeConfigFromEnv() NodeConfig { CartesiEpochDuration: getCartesiEpochDuration(), CartesiSnapshotDir: getCartesiSnapshotDir(), } - nodeConfig.CartesiAuth = GetAuth() + nodeConfig.CartesiAuth = getAuth() return nodeConfig } -func NewtNodeConfigDefault() NodeConfig { +func NewNodeConfig() NodeConfig { nodeConfig := NodeConfig{} - cartesiBlockchainBlockTimeout, CartesiBlockchainBlockTimeoutError := toInt("60") - if CartesiBlockchainBlockTimeoutError != nil { - panic(CartesiBlockchainBlockTimeoutError) + cartesiBlockchainBlockTimeout, err := toInt("60") + if err != nil { + panic(err) } nodeConfig.CartesiBlockchainBlockTimeout = cartesiBlockchainBlockTimeout - cartesiBlockchainFinalityOffset, CartesiBlockchainFinalityOffsetError := toInt("10") - if CartesiBlockchainFinalityOffsetError != nil { - panic(CartesiBlockchainFinalityOffsetError) + cartesiBlockchainFinalityOffset, err := toInt("10") + if err != nil { + panic(err) } nodeConfig.CartesiBlockchainFinalityOffset = cartesiBlockchainFinalityOffset - cartesiBlockchainIsLegacy, CartesiBlockchainIsLegacyError := toBool("false") - if CartesiBlockchainIsLegacyError != nil { - panic(CartesiBlockchainIsLegacyError) + cartesiBlockchainIsLegacy, err := toBool("false") + if err != nil { + panic(err) } nodeConfig.CartesiBlockchainIsLegacy = cartesiBlockchainIsLegacy - cartesiExperimentalSunodoValidatorEnabled, CartesiExperimentalSunodoValidatorEnabledError := toBool("false") - if CartesiExperimentalSunodoValidatorEnabledError != nil { - panic(CartesiExperimentalSunodoValidatorEnabledError) + cartesiExperimentalSunodoValidatorEnabled, err := toBool("false") + if err != nil { + panic(err) } nodeConfig.CartesiExperimentalSunodoValidatorEnabled = cartesiExperimentalSunodoValidatorEnabled - cartesiFeatureDisableClaimer, CartesiFeatureDisableClaimerError := toBool("false") - if CartesiFeatureDisableClaimerError != nil { - panic(CartesiFeatureDisableClaimerError) + cartesiFeatureDisableClaimer, err := toBool("false") + if err != nil { + panic(err) } nodeConfig.CartesiFeatureDisableClaimer = cartesiFeatureDisableClaimer - cartesiFeatureDisableMachineHashCheck, CartesiFeatureDisableMachineHashCheckError := toBool("false") - if CartesiFeatureDisableMachineHashCheckError != nil { - panic(CartesiFeatureDisableMachineHashCheckError) + cartesiFeatureDisableMachineHashCheck, err := toBool("false") + if err != nil { + panic(err) } nodeConfig.CartesiFeatureDisableMachineHashCheck = cartesiFeatureDisableMachineHashCheck - cartesiFeatureHostMode, CartesiFeatureHostModeError := toBool("false") - if CartesiFeatureHostModeError != nil { - panic(CartesiFeatureHostModeError) + cartesiFeatureHostMode, err := toBool("false") + if err != nil { + panic(err) } nodeConfig.CartesiFeatureHostMode = cartesiFeatureHostMode - cartesiHttpAddress, CartesiHttpAddressError := toString("127.0.0.1") - if CartesiHttpAddressError != nil { - panic(CartesiHttpAddressError) + cartesiHttpAddress, err := toString("127.0.0.1") + if err != nil { + panic(err) } nodeConfig.CartesiHttpAddress = cartesiHttpAddress - cartesiHttpPort, CartesiHttpPortError := toInt("10000") - if CartesiHttpPortError != nil { - panic(CartesiHttpPortError) + cartesiHttpPort, err := toInt("10000") + if err != nil { + panic(err) } nodeConfig.CartesiHttpPort = cartesiHttpPort - cartesiLogLevel, CartesiLogLevelError := toLogLevel("info") - if CartesiLogLevelError != nil { - panic(CartesiLogLevelError) + cartesiLogLevel, err := toLogLevel("info") + if err != nil { + panic(err) } nodeConfig.CartesiLogLevel = cartesiLogLevel - cartesiLogTimestamp, CartesiLogTimestampError := toBool("false") - if CartesiLogTimestampError != nil { - panic(CartesiLogTimestampError) + cartesiLogTimestamp, err := toBool("false") + if err != nil { + panic(err) } nodeConfig.CartesiLogTimestamp = cartesiLogTimestamp - cartesiEpochDuration, CartesiEpochDurationError := toDuration("86400") - if CartesiEpochDurationError != nil { - panic(CartesiEpochDurationError) + cartesiEpochDuration, err := toDuration("86400") + if err != nil { + panic(err) } nodeConfig.CartesiEpochDuration = cartesiEpochDuration - nodeConfig.CartesiAuth = AuthMnemonic{Mnemonic: "test test test test test test test test test test test junk", AccountIndex: 0} + nodeConfig.CartesiAuth = AuthMnemonic{ + Mnemonic: "test test test test test test test test test test test junk", + AccountIndex: 0, + } return nodeConfig }