Skip to content
Closed
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
3 changes: 3 additions & 0 deletions cmd/algocfg/profileCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
participation = configUpdater{
description: "Participate in consensus or simply ensure chain health by validating blocks.",
updateFunc: func(cfg config.Local) config.Local {
cfg.EnableP2PHybridMode = false

Check warning on line 65 in cmd/algocfg/profileCommand.go

View check run for this annotation

Codecov / codecov/patch

cmd/algocfg/profileCommand.go#L65

Added line #L65 was not covered by tests
return cfg
},
}
Expand All @@ -75,6 +76,7 @@
cfg.EnableLedgerService = true
cfg.EnableBlockService = true
cfg.NetAddress = ":4160"
cfg.EnableP2PHybridMode = false

Check warning on line 79 in cmd/algocfg/profileCommand.go

View check run for this annotation

Codecov / codecov/patch

cmd/algocfg/profileCommand.go#L79

Added line #L79 was not covered by tests
return cfg
},
}
Expand All @@ -87,6 +89,7 @@
cfg.EnableBlockService = true
cfg.NetAddress = ":4160"
cfg.EnableGossipService = false
cfg.EnableP2PHybridMode = false
return cfg
},
}
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ func TestLocal_IsGossipServer(t *testing.T) {
require.False(t, cfg.IsHybridServer())

cfg.EnableP2P = true
cfg.EnableP2PHybridMode = false
cfg.NetAddress = ":4160"
require.True(t, cfg.IsGossipServer())
require.False(t, cfg.IsWsGossipServer())
Expand Down
2 changes: 1 addition & 1 deletion config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ type Local struct {

// EnableP2PHybridMode turns on both websockets and P2P networking.
// Enabling this setting also requires PublicAddress to be set.
EnableP2PHybridMode bool `version[34]:"false"`
EnableP2PHybridMode bool `version[34]:"false" version[36]:"true"`

// P2PHybridNetAddress sets the listen address used for P2P networking, if hybrid mode is set.
P2PHybridNetAddress string `version[34]:""`
Expand Down
2 changes: 1 addition & 1 deletion config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var defaultLocal = Local{
EnableNetDevMetrics: false,
EnableOutgoingNetworkMessageFiltering: true,
EnableP2P: false,
EnableP2PHybridMode: false,
EnableP2PHybridMode: true,
EnablePingHandler: true,
EnablePrivateNetworkAccessHeader: false,
EnableProcessBlockStats: false,
Expand Down
2 changes: 1 addition & 1 deletion installer/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"EnableNetDevMetrics": false,
"EnableOutgoingNetworkMessageFiltering": true,
"EnableP2P": false,
"EnableP2PHybridMode": false,
"EnableP2PHybridMode": true,
"EnablePingHandler": true,
"EnablePrivateNetworkAccessHeader": false,
"EnableProcessBlockStats": false,
Expand Down
17 changes: 17 additions & 0 deletions netdeploy/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@
}
}

// OverrideHybridMode turns off the mode
func OverrideHybridMode(template *NetworkTemplate) {
for i := range template.Nodes {
jsonOverride := template.Nodes[i].ConfigJSONOverride
if jsonOverride == "" {
jsonOverride = `{"EnableP2PHybridMode": false}`
} else {
result := make(map[string]interface{})
_ = json.Unmarshal([]byte(jsonOverride), &result) // jsonOverride is presumable a valid json
result["EnableP2PHybridMode"] = false
data, _ := json.Marshal(result)
jsonOverride = string(data)

Check warning on line 85 in netdeploy/network.go

View check run for this annotation

Codecov / codecov/patch

netdeploy/network.go#L75-L85

Added lines #L75 - L85 were not covered by tests
}
template.Nodes[i].ConfigJSONOverride = jsonOverride

Check warning on line 87 in netdeploy/network.go

View check run for this annotation

Codecov / codecov/patch

netdeploy/network.go#L87

Added line #L87 was not covered by tests
}
}

// OverrideConsensusVersion changes the protocol version of a template.
func OverrideConsensusVersion(ver protocol.ConsensusVersion) TemplateOverride {
return func(template *NetworkTemplate) {
Expand Down
6 changes: 4 additions & 2 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func setupFullNodes(t *testing.T, proto protocol.ConsensusVersion, customConsens

configHook := func(ni nodeInfo, cfg config.Local) (nodeInfo, config.Local) {
cfg.NetAddress = ni.wsNetAddr()
cfg.P2PHybridNetAddress = ni.p2pNetAddr() // since EnableP2PHybridMode is on by default
return ni, cfg
}

Expand Down Expand Up @@ -239,11 +240,11 @@ func setupFullNodesEx(
}

cfg, err := config.LoadConfigFromDisk(rootDirectory)
phonebook := phonebookHook(nodeInfos, i)
require.NoError(t, err)
phonebook := phonebookHook(nodeInfos, i)
node, err := MakeFull(logging.Base().With("net", fmt.Sprintf("node%d", i)), rootDirectory, cfg, phonebook, g)
nodes[i] = node
require.NoError(t, err)
nodes[i] = node
}

return nodes, wallets
Expand Down Expand Up @@ -999,6 +1000,7 @@ func TestNodeP2PRelays(t *testing.T) {
configHook := func(ni nodeInfo, cfg config.Local) (nodeInfo, config.Local) {
cfg = config.GetDefaultLocal()
cfg.BaseLoggerDebugLevel = uint32(logging.Debug)
cfg.EnableP2PHybridMode = false
cfg.EnableP2P = true
cfg.NetAddress = ""
cfg.EnableDHTProviders = true
Expand Down
4 changes: 4 additions & 0 deletions test/e2e-go/cli/algoh/expect/algohTimeoutTest.exp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ if { [catch {

::Algoh::CreateNetwork $NETWORK_NAME $NETWORK_TEMPLATE $TEST_ROOT_DIR

exec -- cat "$TEST_ROOT_DIR/Primary/config.json" | jq {. |= . + {"PublicAddress": "abc", "P2PHybridNetAddress": ":4190"}} > $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

::Algoh::StartNode $TEST_PRIMARY_NODE_DIR

puts "Successfully started node"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-go/cli/goal/expect/catchpointCatchupTest.exp
Original file line number Diff line number Diff line change
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,"Archival":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,"PublicAddress":"abc","P2PHybridNetAddress":":4190"}} > $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
8 changes: 8 additions & 0 deletions test/e2e-go/cli/goal/expect/goalExpectCommon.exp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ proc ::AlgorandGoal::CreateNetwork { NETWORK_NAME NETWORK_TEMPLATE TEST_ALGO_DIR
puts "ERROR in CreateNetwork: $EXCEPTION"
exit 1
}

# Update the Primary Node configuration for TwoNodes50Each/ThreeNodesEvenDist templates in order to satisfy hybrid mode defaults
set RELAY_NAME ""
if {[string match "*TwoNodes50Each*" $NETWORK_TEMPLATE] || [string match "*ThreeNodesEvenDist*" $NETWORK_TEMPLATE]} {
exec -- cat "$TEST_ROOT_DIR/Primary/config.json" | jq {. |= . + {"PublicAddress": "abc", "P2PHybridNetAddress": ":4190"}} > $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
}
}

# Start the network
Expand Down
2 changes: 1 addition & 1 deletion test/framework/fixtures/libgoalFixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (f *LibGoalFixture) setup(test TestingTB, testName string, templateFile str
kmdConfOverride := netdeploy.OverrideKmdConfig(netdeploy.TemplateKMDConfig{SessionLifetimeSecs: 300})
// copy overrides to prevent caller's data from being modified
extraOverrides := append([]netdeploy.TemplateOverride(nil), overrides...)
extraOverrides = append(extraOverrides, kmdConfOverride)
extraOverrides = append(extraOverrides, kmdConfOverride, netdeploy.OverrideHybridMode)

network, err := netdeploy.CreateNetworkFromTemplate("test", f.rootDir, file, f.binDir, importKeys, f.nodeExitWithError, f.consensus, extraOverrides...)
f.failOnError(err, "CreateNetworkFromTemplate failed: %v")
Expand Down
2 changes: 2 additions & 0 deletions test/scripts/e2e_client_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,14 @@ def main():
primaryDataDir = os.path.join(netdir, 'Primary')

# Set EnableDeveloperAPI to true for both nodes
# and disable the hybrid mode since it is irrelevant for the tests
for dataDir in (nodeDataDir, primaryDataDir):
configFile = os.path.join(dataDir, 'config.json')
with open(configFile, 'r') as f:
configOptions = json.load(f)

configOptions['EnableDeveloperAPI'] = True
configOptions['EnableP2PHybridMode'] = False

with open(configFile, 'w') as f:
json.dump(configOptions, f)
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/configs/config-v36.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"EnableNetDevMetrics": false,
"EnableOutgoingNetworkMessageFiltering": true,
"EnableP2P": false,
"EnableP2PHybridMode": false,
"EnableP2PHybridMode": true,
"EnablePingHandler": true,
"EnablePrivateNetworkAccessHeader": false,
"EnableProcessBlockStats": false,
Expand Down
Loading