Skip to content
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 reader mode and revert unnecessary changes to sunodo validator mode #566

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 10 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ 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.
It must be configured with an external Redis endpoint.

* **Type:** `bool`
* **Default:** `"false"`
Expand All @@ -164,7 +165,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 All @@ -187,6 +188,13 @@ You should only use host mode for development and debugging!
* **Type:** `bool`
* **Default:** `"false"`

## `CARTESI_FEATURE_READER_MODE_ENABLED`

If set to true, the node will not generate any claims.

* **Type:** `bool`
* **Default:** `"false"`

## `CARTESI_HTTP_ADDRESS`

HTTP address for the node.
Expand Down
6 changes: 4 additions & 2 deletions internal/node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type NodeConfig struct {
HttpAddress string
HttpPort int
FeatureHostMode bool
FeatureReaderModeEnabled bool
FeatureDisableClaimer bool
FeatureDisableMachineHashCheck bool
ExperimentalServerManagerBypassLog bool
Expand Down Expand Up @@ -96,13 +97,14 @@ func FromEnv() NodeConfig {
config.FeatureDisableMachineHashCheck = getFeatureDisableMachineHashCheck()
config.ExperimentalServerManagerBypassLog = getExperimentalServerManagerBypassLog()
config.FeatureDisableClaimer = getFeatureDisableClaimer()
config.FeatureReaderModeEnabled = getFeatureReaderModeEnabled()
config.ExperimentalSunodoValidatorEnabled = getExperimentalSunodoValidatorEnabled()
if config.ExperimentalSunodoValidatorEnabled {
config.ExperimentalSunodoValidatorRedisEndpoint =
Redacted[string]{getExperimentalSunodoValidatorRedisEndpoint()}
config.FeatureDisableClaimer = true
}
if !config.FeatureDisableClaimer && !getExperimentalSunodoValidatorEnabled() {
// Authentication is only available when the claimer is enabled
if !config.FeatureDisableClaimer {
config.Auth = authFromEnv()
}
return config
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())
}
11 changes: 9 additions & 2 deletions internal/node/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ If set to true, the node will run in host mode.
In host mode, computations will not be performed by the cartesi machine.
You should only use host mode for development and debugging!"""

[features.CARTESI_FEATURE_READER_MODE_ENABLED]
default = "false"
go-type = "bool"
description = """
If set to true, the node will not generate any claims."""

[features.CARTESI_FEATURE_DISABLE_CLAIMER]
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 @@ -225,7 +231,8 @@ 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.
It must be configured with an external Redis endpoint."""

[experimental.CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT]
go-type = "string"
Expand Down
12 changes: 12 additions & 0 deletions internal/node/config/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/node/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func newAdvanceRunner(c config.NodeConfig, workDir string) services.CommandServi
c.BlockchainHttpEndpoint.Value))
s.Env = append(s.Env, fmt.Sprintf("ADVANCE_RUNNER_HEALTHCHECK_PORT=%v",
getPort(c, portOffsetAdvanceRunner)))
s.Env = append(s.Env, fmt.Sprintf("READER_MODE=%v", c.FeatureDisableClaimer))
s.Env = append(s.Env, fmt.Sprintf("READER_MODE=%v", c.FeatureReaderModeEnabled))
if c.FeatureHostMode || c.FeatureDisableMachineHashCheck {
s.Env = append(s.Env, "SNAPSHOT_VALIDATION_ENABLED=false")
}
Expand Down
Loading