Skip to content

Commit

Permalink
fix(config): claimer not disabled on experimental mode
Browse files Browse the repository at this point in the history
Reverts change that forced the claimer to be disabled when the sunodo
validator mode is enabled. Both configurations must be set separately as
usual.
  • Loading branch information
marcelstanley committed Aug 16, 2024
1 parent d544f0b commit bc86a9b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Disabled the `authority-claimer` when `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED` is set to `true`.
- Redacted the contents of `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT`.

## [1.5.0] 2024-07-22
Expand Down
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ All other log configurations are ignored.

## `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED`

When enabled, the node does not start the authority-claimer service and the Redis server, thus not making claims.
When enabled, the node does not start Redis and should be configured with an external Redis endpoint.

* **Type:** `bool`
* **Default:** `"false"`
Expand All @@ -164,7 +164,7 @@ External Redis endpoint for the node when running in the experimental sunodo val

## `CARTESI_FEATURE_DISABLE_CLAIMER`

If set to true, the node will not make claims.
If set to true, the authority-claimer service is disabled.

* **Type:** `bool`
* **Default:** `"false"`
Expand Down
2 changes: 1 addition & 1 deletion internal/node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func FromEnv() NodeConfig {
config.FeatureDisableClaimer = getFeatureDisableClaimer()
config.FeatureReaderModeEnabled = getFeatureReaderModeEnabled()
config.ExperimentalSunodoValidatorEnabled = getExperimentalSunodoValidatorEnabled()
// The experimental mode overrides the reader mode and claimer configuration
if config.ExperimentalSunodoValidatorEnabled {
config.ExperimentalSunodoValidatorRedisEndpoint =
Redacted[string]{getExperimentalSunodoValidatorRedisEndpoint()}
config.FeatureDisableClaimer = true
}
if !config.FeatureDisableClaimer && !getExperimentalSunodoValidatorEnabled() {
config.Auth = authFromEnv()
Expand Down
15 changes: 6 additions & 9 deletions internal/node/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,20 @@ func TestConfigTest(t *testing.T) {
suite.Run(t, new(ConfigTestSuite))
}

func (s *ConfigTestSuite) TestExperimentalSunodoValidatorModeDisablesClaimer() {
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED", "true")
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT", "redis://")
c := FromEnv()
assert.Equal(s.T(), true, c.FeatureDisableClaimer)
}

func (s *ConfigTestSuite) TestAuthIsNotSetWhenClaimerIsDisabled() {
os.Setenv("CARTESI_FEATURE_DISABLE_CLAIMER", "true")
c := FromEnv()
assert.Nil(s.T(), c.Auth)
}

func (s *ConfigTestSuite) TestExperimentalSunodoValidatorRedisEndpointIsRedacted() {
enableSunodoValidatorMode()
c := FromEnv()
assert.Equal(s.T(), "[REDACTED]", c.ExperimentalSunodoValidatorRedisEndpoint.String())
}

func enableSunodoValidatorMode() {
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED", "true")
os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT",
"redis://username:p@ssw0rd@hostname:9999")
c := FromEnv()
assert.Equal(s.T(), "[REDACTED]", c.ExperimentalSunodoValidatorRedisEndpoint.String())
}
4 changes: 2 additions & 2 deletions internal/node/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If set to true, the node will not generating any claims."""
default = "false"
go-type = "bool"
description = """
If set to true, the node will not make claims."""
If set to true, the authority-claimer service is disabled."""

[features.CARTESI_FEATURE_DISABLE_MACHINE_HASH_CHECK]
default = "false"
Expand Down Expand Up @@ -231,7 +231,7 @@ The node will also use the 20 ports after this one for internal services."""
default = "false"
go-type = "bool"
description = """
When enabled, the node does not start the authority-claimer service and the Redis server, thus not making claims."""
When enabled, the node does not start Redis and should be configured with an external Redis endpoint."""

[experimental.CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT]
go-type = "string"
Expand Down

0 comments on commit bc86a9b

Please sign in to comment.