Skip to content

Commit

Permalink
Config: Archival mode is no longer automatically enabled when netAddr…
Browse files Browse the repository at this point in the history
…ess is s… (#5904)
  • Loading branch information
gmalouf authored Jan 19, 2024
1 parent d8dfaad commit 877090b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 51 deletions.
4 changes: 3 additions & 1 deletion cmd/algocfg/profileCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ var (
relay = configUpdater{
description: "Relay consensus messages across the network and support catchup.",
updateFunc: func(cfg config.Local) config.Local {
cfg.Archival = true
cfg.MaxBlockHistoryLookback = 20000
cfg.CatchpointFileHistoryLength = 3
cfg.CatchpointTracking = 2
cfg.EnableLedgerService = true
cfg.EnableBlockService = true
cfg.NetAddress = ":4160"
Expand Down
3 changes: 0 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ func mergeConfigFromFile(configpath string, source Local) (Local, error) {

err = loadConfig(f, &source)

// For now, all relays (listening for incoming connections) are also Archival
// We can change this logic in the future, but it's currently the sanest default.
if source.NetAddress != "" {
source.Archival = true
source.EnableLedgerService = true
source.EnableBlockService = true

Expand Down
47 changes: 2 additions & 45 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ func TestLocal_MergeConfig(t *testing.T) {
c2, err := mergeConfigFromDir(tempDir, defaultConfig)

require.NoError(t, err)
require.Equal(t, defaultConfig.Archival || c1.NetAddress != "", c2.Archival)
require.Equal(t, defaultConfig.EnableLedgerService || c1.NetAddress != "", c2.EnableLedgerService)
require.Equal(t, defaultConfig.EnableBlockService || c1.NetAddress != "", c2.EnableBlockService)
require.Equal(t, defaultConfig.IncomingConnectionsLimit, c2.IncomingConnectionsLimit)
require.Equal(t, defaultConfig.BaseLoggerDebugLevel, c2.BaseLoggerDebugLevel)

Expand Down Expand Up @@ -165,50 +166,6 @@ func TestLoadPhonebookMissing(t *testing.T) {
require.True(t, os.IsNotExist(err))
}

func TestArchivalIfRelay(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

testArchivalIfRelay(t, true)
}

func TestArchivalIfNotRelay(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

testArchivalIfRelay(t, false)
}

func testArchivalIfRelay(t *testing.T, relay bool) {
tempDir := t.TempDir()

c1 := struct {
NetAddress string
}{}
if relay {
c1.NetAddress = ":1234"
}

// write our reduced version of the Local struct
fileToMerge := filepath.Join(tempDir, ConfigFilename)
f, err := os.OpenFile(fileToMerge, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err == nil {
enc := json.NewEncoder(f)
err = enc.Encode(c1)
f.Close()
}
require.NoError(t, err)
require.False(t, defaultConfig.Archival, "Default should be non-archival")

c2, err := mergeConfigFromDir(tempDir, defaultConfig)
require.NoError(t, err)
if relay {
require.True(t, c2.Archival, "Relay should be archival")
} else {
require.False(t, c2.Archival, "Non-relay should still be non-archival")
}
}

func TestLocal_ConfigExampleIsCorrect(t *testing.T) {
partitiontest.PartitionTest(t)

Expand Down
4 changes: 2 additions & 2 deletions test/e2e-go/cli/goal/expect/catchpointCatchupTest.exp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ log_user 1
#
# The goal of the test is to demonstrate the catchpoint catchup functionality using the goal command line interface.
# It does that by deploying a single relay, which advances until it generates a catchpoint.
# Once it does, another node is started, and instructred to catchup using the catchpoint from the first relay.
# Once it does, another node is started, and instructed to catchup using the catchpoint from the first relay.
# To make sure that the second node won't be using the "regular" catchup, we tunnel all the communication between the two using a proxy.
# The proxy is responsible to filter out block number 2. This would prevent the "regular" catchup from working,
# and would be a good test ground for the catchpoint catchup.
Expand Down Expand Up @@ -64,7 +64,7 @@ if { [catch {
::AlgorandGoal::CreateNetwork $NETWORK_NAME $NETWORK_TEMPLATE $TEST_ALGO_DIR $TEST_ROOT_DIR

# Update the Primary Node configuration
exec -- cat "$TEST_ROOT_DIR/Primary/config.json" | jq {. |= . + {"MaxAcctLookback": 2, "CatchpointInterval": 4,"EnableRequestLogger":true}} > $TEST_ROOT_DIR/Primary/config.json.new
exec -- cat "$TEST_ROOT_DIR/Primary/config.json" | jq {. |= . + {"MaxAcctLookback": 2, "CatchpointInterval": 4,"EnableRequestLogger":true,"Archival":true}} > $TEST_ROOT_DIR/Primary/config.json.new
exec rm $TEST_ROOT_DIR/Primary/config.json
exec mv $TEST_ROOT_DIR/Primary/config.json.new $TEST_ROOT_DIR/Primary/config.json

Expand Down

0 comments on commit 877090b

Please sign in to comment.