Skip to content

Commit 5033d9f

Browse files
Merge pull request #849 from skalenetwork/IS-495-catchup-timeout
IS 945 increase timeouts for catchup
2 parents b79c8cb + 725345e commit 5033d9f

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
174174
- name: verify jsonrpc has been built
175175
run: ls libBLS/deps/deps_inst/x86_or_x64/include/jsonrpccpp/client.h
176-
176+
177177
- name: build consensus
178178
run: |
179179
cd scripts && ./build.py Debug

SkaleCommon.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ static constexpr uint64_t WAIT_AFTER_NETWORK_ERROR_MS = 3000;
183183

184184
static constexpr uint64_t CONNECTION_REFUSED_LOG_INTERVAL_MS = 10 * 60 * 1000;
185185

186+
static constexpr uint64_t CATCHUP_TIMEOUT_SEC = 30;
187+
188+
static constexpr uint64_t SYNC_NODE_CATCHUP_TIMEOUT_SEC = 300;
189+
190+
static constexpr uint64_t READ_JSON_HEADER_TIMEOUT_SEC = 6;
191+
192+
static constexpr uint64_t SYNC_NODE_READ_JSON_HEADER_TIMEOUT_SEC = 300;
193+
186194
// Non-tunable params
187195

188196
static constexpr uint32_t SOCKET_BACKLOG = 64;

catchup/client/CatchupClientAgent.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ nlohmann::json CatchupClientAgent::readCatchupResponseHeader(
7575
const ptr< ClientSocket >& _socket, ptr< CatchupRequestHeader > _requestHeader ) {
7676
CHECK_ARGUMENT( _socket )
7777
CHECK_ARGUMENT( _requestHeader )
78+
uint32_t timeoutSec = getNode()->isSyncOnlyNode() ? getNode()->getsyncNodeCatchupTimeoutSec() :
79+
getNode()->getCatchupTimeoutSec();
7880
auto result = sChain->getIo()->readJsonHeader( _socket->getDescriptor(),
79-
"Read catchup response", 30, _socket->getIP(), MAX_CATCHUP_DOWNLOAD_BYTES );
81+
"Read catchup response", timeoutSec, _socket->getIP(), MAX_CATCHUP_DOWNLOAD_BYTES );
8082
return result;
8183
}
8284

network/IO.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ nlohmann::json IO::readJsonHeader( file_descriptor descriptor, const char* _erro
264264
auto buf2 = make_shared< vector< uint8_t > >( sizeof( uint64_t ) );
265265

266266
try {
267-
readBytes( descriptor, buf2, msg_len( sizeof( uint64_t ) ), 6 );
267+
uint32_t timeoutSec = sChain->getNode()->isSyncOnlyNode() ?
268+
sChain->getNode()->getsyncNodeReadJsonHeaderTimeoutSec() :
269+
sChain->getNode()->getReadJsonHeaderTimeoutSec();
270+
readBytes( descriptor, buf2, msg_len( sizeof( uint64_t ) ), timeoutSec );
268271
} catch ( ExitRequestedException& ) {
269272
throw;
270273
} catch ( ... ) {

node/Node.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ void Node::initParamsFromConfig() {
252252
maxTransactionsPerBlock =
253253
getParamUint64( "maxTransactionsPerBlock", MAX_TRANSACTIONS_PER_BLOCK );
254254
minBlockIntervalMs = getParamUint64( "minBlockIntervalMs", MIN_BLOCK_INTERVAL_MS );
255+
catchupTimeoutSec = getParamUint64( "catchupTimeoutSec", CATCHUP_TIMEOUT_SEC );
256+
syncNodeCatchupTimeoutSec =
257+
getParamUint64( "syncNodeCatchupTimeoutSec", SYNC_NODE_CATCHUP_TIMEOUT_SEC );
258+
readJsonHeaderTimeoutSec =
259+
getParamUint64( "readJsonHeaderTimeoutSec", READ_JSON_HEADER_TIMEOUT_SEC );
260+
syncNodeReadJsonHeaderTimeoutSec =
261+
getParamUint64( "syncNodeReadJsonHeaderTimeoutSec", SYNC_NODE_READ_JSON_HEADER_TIMEOUT_SEC );
255262
testNet = ( getParamUint64( "isTestNet", 0 ) > 0 );
256263

257264
blockDBSize = storageLimits->getBlockDbSize();

node/Node.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ class Node {
202202
uint64_t minBlockIntervalMs = 0;
203203

204204
uint64_t blockDBSize = 0;
205+
206+
uint64_t catchupTimeoutSec = 0;
207+
208+
uint64_t syncNodeCatchupTimeoutSec = 0;
209+
210+
uint64_t readJsonHeaderTimeoutSec = 0;
211+
212+
uint64_t syncNodeReadJsonHeaderTimeoutSec = 0;
205213
;
206214
uint64_t proposalHashDBSize = 0;
207215
uint64_t proposalVectorDBSize = 0;
@@ -397,6 +405,14 @@ class Node {
397405
uint64_t getMaxTransactionsPerBlock() const;
398406

399407
uint64_t getMinBlockIntervalMs() const;
408+
409+
uint64_t getCatchupTimeoutSec() const;
410+
411+
uint64_t getsyncNodeCatchupTimeoutSec() const;
412+
413+
uint64_t getReadJsonHeaderTimeoutSec() const;
414+
415+
uint64_t getsyncNodeReadJsonHeaderTimeoutSec() const;
400416

401417
uint64_t getWaitAfterNetworkErrorMs();
402418

node/NodeGettersSetters.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,19 @@ void Node::setExitOnBlockBoundaryRequested() {
429429
LOG( info, "Set exit on block boundary" );
430430
exitOnBlockBoundaryRequested = true;
431431
}
432+
433+
uint64_t Node::getCatchupTimeoutSec() const {
434+
return catchupTimeoutSec;
435+
}
436+
437+
uint64_t Node::getsyncNodeCatchupTimeoutSec() const {
438+
return syncNodeCatchupTimeoutSec;
439+
}
440+
441+
uint64_t Node::getReadJsonHeaderTimeoutSec() const {
442+
return readJsonHeaderTimeoutSec;
443+
}
444+
445+
uint64_t Node::getsyncNodeReadJsonHeaderTimeoutSec() const {
446+
return syncNodeReadJsonHeaderTimeoutSec;
447+
}

0 commit comments

Comments
 (0)