Skip to content

Commit 1b41b0f

Browse files
committed
#985 add config field to allow disabling ZMQ for block finalize download & fallback to TCP
1 parent 0cdc081 commit 1b41b0f

15 files changed

Lines changed: 67 additions & 57 deletions

File tree

blockfinalize/client/BlockFinalizeDownloader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void BlockFinalizeDownloader::downloadFragment(
299299
}
300300

301301
// If ZMQ disabled - try TCP right away
302-
if ( !getNode()->getTestConfig()->isBlockFinalizeZmqClientEnabled() ) {
302+
if ( !getNode()->isBlockFinalizeZmqEnabled() ) {
303303
downloadFragmentTCP( _dstIndex, _fragmentIndex, header );
304304
return;
305305
}

chains/Schain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ void Schain::constructServers(const ptr<Sockets> &_sockets) {
15071507

15081508
catchupServerAgent = make_shared<CatchupServerAgent>(*this, _sockets->catchupSocket);
15091509

1510-
if ( getNode()->getTestConfig()->isBlockFinalizeZmqServerEnabled() ) {
1510+
if ( getNode()->isBlockFinalizeZmqEnabled() ) {
15111511
blockFinalizeZmqServerAgent =
15121512
make_shared<BlockFinalizeZmqServerAgent>(*this, _sockets->getBulkDataZMQSockets());
15131513
}

chains/TestConfig.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ bool TestConfig::isFinalizationDownloadOnly() const {
3030
return finalizationDownloadOnly;
3131
}
3232

33-
bool TestConfig::isBlockFinalizeZmqClientEnabled() const {
34-
return blockFinalizeZmqClientEnabled;
35-
}
36-
37-
bool TestConfig::isBlockFinalizeZmqServerEnabled() const {
38-
return blockFinalizeZmqServerEnabled;
39-
}
40-
4133
bool TestConfig::isBlockFinalizeTransportStatsEnabled() const {
4234
return blockFinalizeTransportStatsEnabled;
4335
}
@@ -47,10 +39,6 @@ TestConfig::TestConfig( nlohmann::json cgf ) {
4739
finalizationDownloadOnly = ( option != nullptr );
4840

4941
if ( cgf.is_object() ) {
50-
blockFinalizeZmqClientEnabled =
51-
cgf.value( "testBlockFinalizeZmqClientEnabled", true );
52-
blockFinalizeZmqServerEnabled =
53-
cgf.value( "testBlockFinalizeZmqServerEnabled", true );
5442
blockFinalizeTransportStatsEnabled =
5543
cgf.value( "testBlockFinalizeTransportStatsEnabled", false );
5644
}
@@ -59,14 +47,6 @@ TestConfig::TestConfig( nlohmann::json cgf ) {
5947
CONS_LOG( info, "Testing the case of only finalization download" );
6048
}
6149

62-
if ( !blockFinalizeZmqClientEnabled ) {
63-
CONS_LOG( info, "Testing BlockFinalize with ZMQ client disabled" );
64-
}
65-
66-
if ( !blockFinalizeZmqServerEnabled ) {
67-
CONS_LOG( info, "Testing BlockFinalize with ZMQ server disabled" );
68-
}
69-
7050
if ( blockFinalizeTransportStatsEnabled ) {
7151
CONS_LOG( info, "Testing BlockFinalize transport stats collection enabled" );
7252
}

chains/TestConfig.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@
2727

2828
class TestConfig {
2929
bool finalizationDownloadOnly = false;
30-
bool blockFinalizeZmqClientEnabled = true;
31-
bool blockFinalizeZmqServerEnabled = true;
3230
bool blockFinalizeTransportStatsEnabled = false;
3331

3432
public:
3533
bool isFinalizationDownloadOnly() const;
36-
bool isBlockFinalizeZmqClientEnabled() const;
37-
bool isBlockFinalizeZmqServerEnabled() const;
3834
bool isBlockFinalizeTransportStatsEnabled() const;
3935

4036
TestConfig( nlohmann::json cgf );

node/Node.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ void Node::initParamsFromConfig() {
294294
syncNodeReadJsonHeaderTimeoutSec =
295295
getParamUint64( "syncNodeReadJsonHeaderTimeoutSec", SYNC_NODE_READ_JSON_HEADER_TIMEOUT_SEC );
296296
testNet = ( getParamUint64( "isTestNet", 0 ) > 0 );
297+
298+
if ( cfg.find( "blockFinalizeZmqEnabled" ) != cfg.end() ) {
299+
blockFinalizeZmqEnabled =
300+
cfg.at( "blockFinalizeZmqEnabled" ).get< bool >();
301+
}
297302

298303
blockDBSize = storageLimits->getBlockDbSize();
299304
proposalHashDBSize = storageLimits->getProposalHashDbSize();

node/Node.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ class Node {
221221

222222
uint64_t blockFinalizeDownloadTcpFallbackMs = 0;
223223

224+
bool blockFinalizeZmqEnabled = true;
225+
224226
uint64_t emptyBlockIntervalMs = 0;
225227

226228
uint64_t emptyBlockIntervalAfterCatchupMs = 0;
@@ -333,6 +335,8 @@ class Node {
333335

334336
bool isTestNet() const;
335337

338+
bool isBlockFinalizeZmqEnabled() const;
339+
336340
[[nodiscard]] const ptr< TestConfig >& getTestConfig() const;
337341

338342
ptr< BlockDB > getBlockDB() const;

node/NodeGettersSetters.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ bool Node::isTestNet() const {
463463
return testNet;
464464
}
465465

466+
bool Node::isBlockFinalizeZmqEnabled() const {
467+
return blockFinalizeZmqEnabled;
468+
}
469+
466470
void Node::setExitOnBlockBoundaryRequested() {
467471
CONS_LOG( info, "Set exit on block boundary" );
468472
exitOnBlockBoundaryRequested = true;

test/twonodes_blockfinalize_both_new_zmq/node1/Node.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"basePort": 1231,
66
"logLevel": "info",
77
"simulateNetworkWriteDelayMs": 100,
8-
"testBlockFinalizeZmqClientEnabled": true,
9-
"testBlockFinalizeZmqServerEnabled": true,
8+
"blockFinalizeZmqEnabled": true,
109
"testBlockFinalizeTransportStatsEnabled": true
1110
}

test/twonodes_blockfinalize_both_new_zmq/node2/Node.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"basePort": 2231,
66
"logLevel": "info",
77
"simulateNetworkWriteDelayMs": 100,
8-
"testBlockFinalizeZmqClientEnabled": true,
9-
"testBlockFinalizeZmqServerEnabled": true,
8+
"blockFinalizeZmqEnabled": true,
109
"testBlockFinalizeTransportStatsEnabled": true
1110
}

test/twonodes_blockfinalize_new_client_old_server/node1/Node.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"basePort": 1231,
66
"logLevel": "info",
77
"simulateNetworkWriteDelayMs": 100,
8-
"testBlockFinalizeZmqClientEnabled": true,
9-
"testBlockFinalizeZmqServerEnabled": false,
8+
"blockFinalizeZmqEnabled": true,
109
"testBlockFinalizeTransportStatsEnabled": true
1110
}

0 commit comments

Comments
 (0)