Skip to content

Commit

Permalink
fix(config): disable claimer on experimental mode
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstanley committed Aug 9, 2024
1 parent 30c4005 commit b34d902
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Disabled the `authority-claimer` when `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED` is set to `true`.

## [1.5.0] 2024-07-22

### Added
Expand Down
2 changes: 2 additions & 0 deletions build/compose-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ services:
CARTESI_FEATURE_DISABLE_CLAIMER: "false"
CARTESI_HTTP_ADDRESS: "0.0.0.0"
CARTESI_HTTP_PORT: "10000"
CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED: true
CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT: redis://default:[email protected]:6379
2 changes: 1 addition & 1 deletion 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.
When enabled, the node does not start the authority-claimer service, thus not making claims, and the Redis server.

* **Type:** `bool`
* **Default:** `"false"`
Expand Down
7 changes: 4 additions & 3 deletions internal/node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ func FromEnv() NodeConfig {
config.HttpAddress = getHttpAddress()
config.HttpPort = getHttpPort()
config.FeatureHostMode = getFeatureHostMode()
config.FeatureDisableClaimer = getFeatureDisableClaimer()
config.FeatureDisableMachineHashCheck = getFeatureDisableMachineHashCheck()
config.ExperimentalServerManagerBypassLog = getExperimentalServerManagerBypassLog()
config.FeatureDisableClaimer = getFeatureDisableClaimer()
config.ExperimentalSunodoValidatorEnabled = getExperimentalSunodoValidatorEnabled()
if getExperimentalSunodoValidatorEnabled() {
if config.ExperimentalSunodoValidatorEnabled {
config.ExperimentalSunodoValidatorRedisEndpoint =
getExperimentalSunodoValidatorRedisEndpoint()
config.FeatureDisableClaimer = true
}
if !getFeatureDisableClaimer() && !getExperimentalSunodoValidatorEnabled() {
if !config.FeatureDisableClaimer && !getExperimentalSunodoValidatorEnabled() {
config.Auth = authFromEnv()
}
return config
Expand Down
45 changes: 45 additions & 0 deletions internal/node/config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

package config

import (
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)

type ConfigTestSuite struct {
suite.Suite
}

func (s *ConfigTestSuite) SetupSuite() {
os.Setenv("CARTESI_BLOCKCHAIN_ID", "31337")
os.Setenv("CARTESI_BLOCKCHAIN_HTTP_ENDPOINT", "http://localhost:8545")
os.Setenv("CARTESI_BLOCKCHAIN_WS_ENDPOINT", "ws://localhost:8545")
os.Setenv("CARTESI_CONTRACTS_APPLICATION_ADDRESS", "0x")
os.Setenv("CARTESI_CONTRACTS_HISTORY_ADDRESS", "0x")
os.Setenv("CARTESI_CONTRACTS_AUTHORITY_ADDRESS", "0x")
os.Setenv("CARTESI_CONTRACTS_INPUT_BOX_ADDRESS", "0x")
os.Setenv("CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER", "0")
os.Setenv("CARTESI_SNAPSHOT_DIR", "/tmp")
}

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)
}
2 changes: 1 addition & 1 deletion internal/node/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,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."""
When enabled, the node does not start the authority-claimer service, thus not making claims, and the Redis server."""

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

0 comments on commit b34d902

Please sign in to comment.