From 2c89d9aa724bc915f6468a3a03f461c5dc467aef Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 16 May 2023 16:11:00 +0100 Subject: [PATCH 01/24] 774 incorrect exit --- chains/Schain.cpp | 14 +++++++++++--- chains/Schain.h | 5 +++++ chains/SchainGettersSetters.cpp | 4 ++++ node/Node.cpp | 5 +++++ pendingqueue/PendingTransactionsAgent.cpp | 6 ++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/chains/Schain.cpp b/chains/Schain.cpp index 0c9bb6d1..757b57de 100644 --- a/chains/Schain.cpp +++ b/chains/Schain.cpp @@ -734,9 +734,17 @@ void Schain::pushBlockToExtFace( const ptr< CommittedBlock >& _block ) { if ( extFace ) { - extFace->createBlock( *tv, _block->getTimeStampS(), _block->getTimeStampMs(), - ( __uint64_t ) _block->getBlockID(), currentPrice, _block->getStateRoot(), - ( uint64_t ) _block->getProposerIndex() ); + try { + inCreateBlock = true; + extFace->createBlock( *tv, _block->getTimeStampS(), _block->getTimeStampMs(), + ( __uint64_t ) _block->getBlockID(), currentPrice, _block->getStateRoot(), + ( uint64_t ) _block->getProposerIndex() ); + inCreateBlock = false; + } catch (...) { + inCreateBlock = false; + throw; + } + } // block boundary is the safesf place for exit diff --git a/chains/Schain.h b/chains/Schain.h index 2acec381..127914f2 100644 --- a/chains/Schain.h +++ b/chains/Schain.h @@ -154,6 +154,7 @@ class Schain : public Agent { TimeStamp lastCommittedBlockTimeStamp; mutex lastCommittedBlockInfoMutex; atomic< uint64_t > proposalReceiptTime = 0; + atomic inCreateBlock = false; atomic< uint64_t > bootstrapBlockID = 0; @@ -171,6 +172,7 @@ class Schain : public Agent { uint64_t tpsAverage = 0; atomic< bool > isStateInitialized = false; + atomic< bool > isSt = false; ptr< NodeInfo > thisNodeInfo = nullptr; @@ -347,6 +349,9 @@ class Schain : public Agent { uint64_t getVerifyDaSigsPatchTimestampS() const; + bool isInCreateBlock() const; + + void finalizeDecidedAndSignedBlock( block_id _blockId, schain_index _proposerIndex, const ptr< ThresholdSignature >& _thresholdSig ); diff --git a/chains/SchainGettersSetters.cpp b/chains/SchainGettersSetters.cpp index 157876bf..9acd8dec 100644 --- a/chains/SchainGettersSetters.cpp +++ b/chains/SchainGettersSetters.cpp @@ -332,3 +332,7 @@ void Schain::setLastCommittedBlockId( uint64_t _lastCommittedBlockId ) { const ptr< OracleClient > Schain::getOracleClient() const { return oracleClient; } + +bool Schain::isInCreateBlock() const { + return inCreateBlock; +} \ No newline at end of file diff --git a/node/Node.cpp b/node/Node.cpp index 488f6370..d9e1a6b8 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -524,6 +524,11 @@ void Node::doSoftAndThenHardExit() { exitOnBlockBoundaryRequested = true; + //wait until block completes EVM processing + while (getSchain()->isInCreateBlock()) { + usleep(100 * 1000); + } + auto startTimeMs = Time::getCurrentTimeMs(); LOG( info, "Node::exit() will to exit on block boundary for " + diff --git a/pendingqueue/PendingTransactionsAgent.cpp b/pendingqueue/PendingTransactionsAgent.cpp index f775140f..9d0a9b0c 100644 --- a/pendingqueue/PendingTransactionsAgent.cpp +++ b/pendingqueue/PendingTransactionsAgent.cpp @@ -111,11 +111,13 @@ PendingTransactionsAgent::createTransactionsListForProposal() { if ( sChain->getExtFace() ) { txVector = sChain->getExtFace()->pendingTransactions( needMax, stateRoot ); - getSchain()->getNode()->exitCheck(); + // block boundary is the safest place for exit + // exit immediately if exit has been requested + // this will initiate immediate exit and throw ExitRequestedException + getSchain()->getNode()->checkForExitOnBlockBoundaryAndExitIfNeeded(); } else { stateRootSample++; stateRoot = 7; - txVector = sChain->getTestMessageGeneratorAgent()->pendingTransactions( needMax ); } From 62ab0dd883b8dc20ad19d36b896a3fdb6a4e0ec7 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 16 May 2023 16:15:27 +0100 Subject: [PATCH 02/24] 774 and 775 incorrect exit --- chains/Schain.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chains/Schain.cpp b/chains/Schain.cpp index 757b57de..f606852c 100644 --- a/chains/Schain.cpp +++ b/chains/Schain.cpp @@ -740,11 +740,10 @@ void Schain::pushBlockToExtFace( const ptr< CommittedBlock >& _block ) { ( __uint64_t ) _block->getBlockID(), currentPrice, _block->getStateRoot(), ( uint64_t ) _block->getProposerIndex() ); inCreateBlock = false; - } catch (...) { - inCreateBlock = false; + } catch ( ... ) { + inCreateBlock = false; throw; } - } // block boundary is the safesf place for exit From 519778973c8d256b2bb7d7e8901a474672c95019 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 16 May 2023 16:16:47 +0100 Subject: [PATCH 03/24] 774 and 775 incorrect exit --- .idea/workspace.xml | 46 ++++++++++++++++++++++----------------------- node/Node.cpp | 6 +++--- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 31a1a5b0..b72be2c0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -45,7 +45,8 @@ - + + @@ -877,12 +875,16 @@ + - - @@ -955,7 +952,8 @@ - diff --git a/node/Node.cpp b/node/Node.cpp index d9e1a6b8..d3b42b3e 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -524,9 +524,9 @@ void Node::doSoftAndThenHardExit() { exitOnBlockBoundaryRequested = true; - //wait until block completes EVM processing - while (getSchain()->isInCreateBlock()) { - usleep(100 * 1000); + // wait until block completes EVM processing + while ( getSchain()->isInCreateBlock() ) { + usleep( 100 * 1000 ); } auto startTimeMs = Time::getCurrentTimeMs(); From dcdb526e0ffec5f24e07244720e78b8a1338d4ea Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 16 May 2023 16:17:52 +0100 Subject: [PATCH 04/24] 774 and 775 incorrect exit --- chains/Schain.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chains/Schain.h b/chains/Schain.h index 127914f2..4b5c40f6 100644 --- a/chains/Schain.h +++ b/chains/Schain.h @@ -154,7 +154,7 @@ class Schain : public Agent { TimeStamp lastCommittedBlockTimeStamp; mutex lastCommittedBlockInfoMutex; atomic< uint64_t > proposalReceiptTime = 0; - atomic inCreateBlock = false; + atomic< bool > inCreateBlock = false; atomic< uint64_t > bootstrapBlockID = 0; From 358b021da672b06d1e9acfbee617f54b37552e7c Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 16 May 2023 16:19:08 +0100 Subject: [PATCH 05/24] 774 and 775 incorrect exit --- chains/Schain.h | 1 - 1 file changed, 1 deletion(-) diff --git a/chains/Schain.h b/chains/Schain.h index 4b5c40f6..1405e03f 100644 --- a/chains/Schain.h +++ b/chains/Schain.h @@ -172,7 +172,6 @@ class Schain : public Agent { uint64_t tpsAverage = 0; atomic< bool > isStateInitialized = false; - atomic< bool > isSt = false; ptr< NodeInfo > thisNodeInfo = nullptr; From c850c0aa0ad602a3acb529caaa2ba1ecf681326f Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Wed, 17 May 2023 11:44:10 +0100 Subject: [PATCH 06/24] 774 and 775 incorrect exit --- network/ZMQNetwork.cpp | 6 ------ network/ZMQSockets.cpp | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/network/ZMQNetwork.cpp b/network/ZMQNetwork.cpp index 01f4e918..592a38cd 100644 --- a/network/ZMQNetwork.cpp +++ b/network/ZMQNetwork.cpp @@ -80,7 +80,6 @@ uint64_t ZMQNetwork::interruptableRecv( void* _socket, void* _buf, size_t _len ) for ( ;; ) { if ( this->getNode()->isExitRequested() ) { - zmq_close( _socket ); LOG( debug, getThreadName() + "zmq debug: closing = " + to_string( ( uint64_t ) _socket ) ); BOOST_THROW_EXCEPTION( ExitRequestedException( __CLASS_NAME__ ) ); @@ -90,7 +89,6 @@ uint64_t ZMQNetwork::interruptableRecv( void* _socket, void* _buf, size_t _len ) rc = zmq_recv( _socket, _buf, _len, 0 ); if ( this->getNode()->isExitRequested() ) { - // zmq_close(_socket); LOG( debug, getThreadName() + " zmq debug: closing = " + to_string( ( uint64_t ) _socket ) ); BOOST_THROW_EXCEPTION( ExitRequestedException( __CLASS_NAME__ ) ); @@ -119,8 +117,6 @@ bool ZMQNetwork::interruptableSend( void* _socket, void* _buf, size_t _len ) { int flags = ZMQ_DONTWAIT; if ( this->getNode()->isExitRequested() ) { - zmq_close( _socket ); - LOG( debug, getThreadName() + "zmq debug: closing = " + to_string( ( uint64_t ) _socket ) ); BOOST_THROW_EXCEPTION( ExitRequestedException( __CLASS_NAME__ ) ); } @@ -128,8 +124,6 @@ bool ZMQNetwork::interruptableSend( void* _socket, void* _buf, size_t _len ) { rc = zmq_send( _socket, _buf, _len, flags ); if ( this->getNode()->isExitRequested() ) { - zmq_close( _socket ); - LOG( debug, getThreadName() + "zmq debug: closing = " + to_string( ( uint64_t ) _socket ) ); BOOST_THROW_EXCEPTION( ExitRequestedException( __CLASS_NAME__ ) ); } diff --git a/network/ZMQSockets.cpp b/network/ZMQSockets.cpp index 06fb8c70..778e3811 100644 --- a/network/ZMQSockets.cpp +++ b/network/ZMQSockets.cpp @@ -59,6 +59,8 @@ void* ZMQSockets::getDestinationSocket( const ptr< NodeInfo >& _remoteNodeInfo ) void* requester = zmq_socket( context, ZMQ_CLIENT ); + CHECK_STATE2(requester, "Could not create ZMQ send socket"); + int val = CONSENSUS_ZMQ_HWM; auto rc = zmq_setsockopt( requester, ZMQ_RCVHWM, &val, sizeof( val ) ); CHECK_STATE( rc == 0 ); @@ -97,10 +99,13 @@ void* ZMQSockets::getReceiveSocket() { if ( !receiveSocket ) { receiveSocket = zmq_socket( context, ZMQ_SERVER ); + CHECK_STATE2(receiveSocket, "Could not create ZMQ receive socket"); + int val = CONSENSUS_ZMQ_HWM; auto rc = zmq_setsockopt( receiveSocket, ZMQ_RCVHWM, &val, sizeof( val ) ); CHECK_STATE( rc == 0 ); val = CONSENSUS_ZMQ_HWM; + val = CONSENSUS_ZMQ_HWM; rc = zmq_setsockopt( receiveSocket, ZMQ_SNDHWM, &val, sizeof( val ) ); CHECK_STATE( rc == 0 ); @@ -138,7 +143,9 @@ void ZMQSockets::closeReceive() { LOG( info, "consensus engine exiting: closing receive sockets" ); if ( receiveSocket ) { - zmq_close( receiveSocket ); + if (zmq_close( receiveSocket ) != 0) { + LOG(err, "zmq_close returned an error on receiveSocket;"); + } } } @@ -152,7 +159,9 @@ void ZMQSockets::closeSend() { if ( item.second ) { LOG( debug, getThreadName() + " zmq debug in closeSend(): closing " + to_string( ( uint64_t ) item.second ) ); - zmq_close( item.second ); + if (zmq_close( item.second ) != 0) { + LOG(err, "zmq_close returned an error on sendSocket;"); + } } } } @@ -185,7 +194,7 @@ void ZMQSockets::closeAndCleanupAll() { LOG( err, "Unknown exception in zmq_ctx_term" ); } - LOG( info, "Closed ZMQ" ); + LOG( info, "Closed ZMQ context" ); } From a369f746e43d0b222845120686ecea987762fb8c Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Wed, 17 May 2023 11:54:58 +0100 Subject: [PATCH 07/24] 774 and 775 incorrect exit --- network/ZMQSockets.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/network/ZMQSockets.cpp b/network/ZMQSockets.cpp index 778e3811..4caba0c2 100644 --- a/network/ZMQSockets.cpp +++ b/network/ZMQSockets.cpp @@ -59,7 +59,7 @@ void* ZMQSockets::getDestinationSocket( const ptr< NodeInfo >& _remoteNodeInfo ) void* requester = zmq_socket( context, ZMQ_CLIENT ); - CHECK_STATE2(requester, "Could not create ZMQ send socket"); + CHECK_STATE2( requester, "Could not create ZMQ send socket" ); int val = CONSENSUS_ZMQ_HWM; auto rc = zmq_setsockopt( requester, ZMQ_RCVHWM, &val, sizeof( val ) ); @@ -99,7 +99,7 @@ void* ZMQSockets::getReceiveSocket() { if ( !receiveSocket ) { receiveSocket = zmq_socket( context, ZMQ_SERVER ); - CHECK_STATE2(receiveSocket, "Could not create ZMQ receive socket"); + CHECK_STATE2( receiveSocket, "Could not create ZMQ receive socket" ); int val = CONSENSUS_ZMQ_HWM; auto rc = zmq_setsockopt( receiveSocket, ZMQ_RCVHWM, &val, sizeof( val ) ); @@ -143,8 +143,8 @@ void ZMQSockets::closeReceive() { LOG( info, "consensus engine exiting: closing receive sockets" ); if ( receiveSocket ) { - if (zmq_close( receiveSocket ) != 0) { - LOG(err, "zmq_close returned an error on receiveSocket;"); + if ( zmq_close( receiveSocket ) != 0 ) { + LOG( err, "zmq_close returned an error on receiveSocket;" ); } } } @@ -159,8 +159,8 @@ void ZMQSockets::closeSend() { if ( item.second ) { LOG( debug, getThreadName() + " zmq debug in closeSend(): closing " + to_string( ( uint64_t ) item.second ) ); - if (zmq_close( item.second ) != 0) { - LOG(err, "zmq_close returned an error on sendSocket;"); + if ( zmq_close( item.second ) != 0 ) { + LOG( err, "zmq_close returned an error on sendSocket;" ); } } } @@ -199,6 +199,4 @@ void ZMQSockets::closeAndCleanupAll() { ZMQSockets::~ZMQSockets() { - // last resort - closeAndCleanupAll(); } From 0629f85ca1e6ab95ce4ef426aa96eb5d3ece89e8 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Wed, 17 May 2023 12:23:45 +0100 Subject: [PATCH 08/24] 774 and 775 incorrect exit --- network/ZMQNetwork.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/network/ZMQNetwork.cpp b/network/ZMQNetwork.cpp index 592a38cd..3eb0ae6f 100644 --- a/network/ZMQNetwork.cpp +++ b/network/ZMQNetwork.cpp @@ -68,20 +68,8 @@ bool ZMQNetwork::sendMessage( uint64_t ZMQNetwork::interruptableRecv( void* _socket, void* _buf, size_t _len ) { int rc; - - /* - - zmq_pollitem_t items[1]; - items[0].socket = _socket; - items[0].events = ZMQ_POLLIN; - - */ - - for ( ;; ) { if ( this->getNode()->isExitRequested() ) { - LOG( debug, - getThreadName() + "zmq debug: closing = " + to_string( ( uint64_t ) _socket ) ); BOOST_THROW_EXCEPTION( ExitRequestedException( __CLASS_NAME__ ) ); } @@ -89,8 +77,6 @@ uint64_t ZMQNetwork::interruptableRecv( void* _socket, void* _buf, size_t _len ) rc = zmq_recv( _socket, _buf, _len, 0 ); if ( this->getNode()->isExitRequested() ) { - LOG( debug, - getThreadName() + " zmq debug: closing = " + to_string( ( uint64_t ) _socket ) ); BOOST_THROW_EXCEPTION( ExitRequestedException( __CLASS_NAME__ ) ); } From 571d17df62d250ca22b568cd73bd5f955fcafd82 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Wed, 17 May 2023 12:25:44 +0100 Subject: [PATCH 09/24] 774 and 775 incorrect exit --- .idea/workspace.xml | 138 ++++++++++++++++++++--------------------- network/ZMQSockets.cpp | 3 +- 2 files changed, 70 insertions(+), 71 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b72be2c0..e63d9d1a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -44,9 +44,9 @@ - + - + - { - "keyToString": { - "Git.Branch.Popup.ShowAllRemotes": "true", - "Git.Branch.Popup.ShowAllRepositories": "true", - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.cidr.known.project.marker": "true", - "WebServerToolWindowFactoryState": "false", - "cf.advertisement.text.has.clang-format": "true", - "cf.advertisement.text.overridden": "true", - "cf.first.check.clang-format": "false", - "cidr.known.project.marker": "true", - "last_opened_file_path": "/d/skale-consensus", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "editor.preferences.fonts.default", - "vue.rearranger.settings.migration": "true" + +}]]> @@ -506,49 +506,7 @@ - - - - 1682089268995 - - - 1682089371147 - - - 1682089532041 - - - 1682091667339 - - - 1682093021000 - - - 1682095213256 - 1682097320357 @@ -851,7 +809,49 @@ - @@ -928,7 +928,6 @@ - @@ -953,7 +952,8 @@ - diff --git a/network/ZMQSockets.cpp b/network/ZMQSockets.cpp index 4caba0c2..2a6e0784 100644 --- a/network/ZMQSockets.cpp +++ b/network/ZMQSockets.cpp @@ -198,5 +198,4 @@ void ZMQSockets::closeAndCleanupAll() { } -ZMQSockets::~ZMQSockets() { -} +ZMQSockets::~ZMQSockets() {} From 751d76bb8b4c2833d7c6b71af24ecc411e35787e Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Wed, 17 May 2023 13:00:42 +0100 Subject: [PATCH 10/24] 774 and 775 incorrect exit --- network/ZMQSockets.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/network/ZMQSockets.cpp b/network/ZMQSockets.cpp index 2a6e0784..bc66a649 100644 --- a/network/ZMQSockets.cpp +++ b/network/ZMQSockets.cpp @@ -146,6 +146,7 @@ void ZMQSockets::closeReceive() { if ( zmq_close( receiveSocket ) != 0 ) { LOG( err, "zmq_close returned an error on receiveSocket;" ); } + receiveSocket = nullptr; } } From 1983a2b43f61fe6cbc36ac35d9deceaefea98fcc Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 18 May 2023 11:57:49 +0100 Subject: [PATCH 11/24] 774 and 775 incorrect exit --- chains/Schain.cpp | 4 ++++ node/ConsensusEngine.cpp | 2 +- node/Node.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chains/Schain.cpp b/chains/Schain.cpp index f606852c..f7d3e871 100644 --- a/chains/Schain.cpp +++ b/chains/Schain.cpp @@ -732,6 +732,10 @@ void Schain::pushBlockToExtFace( const ptr< CommittedBlock >& _block ) { auto currentPrice = this->pricingAgent->readPrice( _block->getBlockID() - 1 ); + // block boundary is the safesf place for exit + // exit immediately if exit has been requested + // this will initiate immediate exit and throw ExitRequestedException + getSchain()->getNode()->checkForExitOnBlockBoundaryAndExitIfNeeded(); if ( extFace ) { try { diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index 4894b075..de9ca208 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -760,7 +760,7 @@ void ConsensusEngine::exitGracefullyBlocking() { void ConsensusEngine::exitGracefully() { - LOG( info, "Consensus engine exiting: blocking exit exitGracefully called by skaled" ); + LOG( info, "Consensus engine exiting: asynchronous exit exitGracefully called by skaled" ); cerr << "Here is exitGracefullyBlocking() stack trace for your information:" << endl; cerr << boost::stacktrace::stacktrace() << endl; diff --git a/node/Node.cpp b/node/Node.cpp index d3b42b3e..5ae9cb28 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -531,7 +531,7 @@ void Node::doSoftAndThenHardExit() { auto startTimeMs = Time::getCurrentTimeMs(); - LOG( info, "Node::exit() will to exit on block boundary for " + + LOG( info, "Node::exit() will try to exit on block boundary for " + to_string( CONSENSUS_WAIT_TIME_BEFORE_HARD_EXIT_MS / 1000 ) + " seconds" ); while ( Time::getCurrentTimeMs() < startTimeMs + CONSENSUS_WAIT_TIME_BEFORE_HARD_EXIT_MS ) { From 254a52c3b7afd334d2d5800cbb34e8255e12c3b5 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 18 May 2023 12:07:20 +0100 Subject: [PATCH 12/24] 774 and 775 incorrect exit --- Consensust.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Consensust.cpp b/Consensust.cpp index 06ffc907..38ee8564 100644 --- a/Consensust.cpp +++ b/Consensust.cpp @@ -23,6 +23,11 @@ #define CATCH_CONFIG_MAIN +#include +#include +#include + + #include #include #include @@ -53,6 +58,8 @@ #endif + + ConsensusEngine* engine; @@ -121,6 +128,11 @@ void testLog( const char* message ) { printf( "TEST_LOG: %s\n", message ); } +void abort_handler(int signal) { + printf("cought SIGABRT, exiting.\n"); + exit(0); +} + block_id basicRun( int64_t _lastId = 0 ) { try { REQUIRE( ConsensusEngine::getEngineVersion().size() > 0 ); @@ -154,6 +166,7 @@ block_id basicRun( int64_t _lastId = 0 ) { REQUIRE( timestampS > 0 ); cerr << price << ":" << stateRoot << endl; + signal(SIGABRT, abort_handler); engine->exitGracefullyBlocking(); delete engine; return lastId; @@ -172,5 +185,7 @@ void exit_check() { } + + #include "unittests/consensus_tests.cpp" #include "unittests/sgx_tests.cpp" From 1ea9e96b11de4bd567f7201dd4361932610ff33c Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 18 May 2023 12:08:35 +0100 Subject: [PATCH 13/24] 774 and 775 incorrect exit --- Consensust.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Consensust.cpp b/Consensust.cpp index 38ee8564..411cdcba 100644 --- a/Consensust.cpp +++ b/Consensust.cpp @@ -58,8 +58,6 @@ #endif - - ConsensusEngine* engine; @@ -128,9 +126,9 @@ void testLog( const char* message ) { printf( "TEST_LOG: %s\n", message ); } -void abort_handler(int signal) { - printf("cought SIGABRT, exiting.\n"); - exit(0); +void abort_handler( int ) { + printf( "cought SIGABRT, exiting.\n" ); + exit( 0 ); } block_id basicRun( int64_t _lastId = 0 ) { @@ -166,7 +164,7 @@ block_id basicRun( int64_t _lastId = 0 ) { REQUIRE( timestampS > 0 ); cerr << price << ":" << stateRoot << endl; - signal(SIGABRT, abort_handler); + signal( SIGABRT, abort_handler ); engine->exitGracefullyBlocking(); delete engine; return lastId; @@ -185,7 +183,5 @@ void exit_check() { } - - #include "unittests/consensus_tests.cpp" #include "unittests/sgx_tests.cpp" From 0ea0caec0b9ac8e38f9f852dd6145501938ae533 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 18 May 2023 12:18:45 +0100 Subject: [PATCH 14/24] 774 and 775 incorrect exit --- pendingqueue/PendingTransactionsAgent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/pendingqueue/PendingTransactionsAgent.cpp b/pendingqueue/PendingTransactionsAgent.cpp index 9d0a9b0c..b42fe78d 100644 --- a/pendingqueue/PendingTransactionsAgent.cpp +++ b/pendingqueue/PendingTransactionsAgent.cpp @@ -110,6 +110,7 @@ PendingTransactionsAgent::createTransactionsListForProposal() { getSchain()->getNode()->exitCheck(); if ( sChain->getExtFace() ) { + getSchain()->getNode()->checkForExitOnBlockBoundaryAndExitIfNeeded(); txVector = sChain->getExtFace()->pendingTransactions( needMax, stateRoot ); // block boundary is the safest place for exit // exit immediately if exit has been requested From 6e985ec39bea54435d420c0b1bfe3cbd56ad91aa Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Fri, 19 May 2023 18:54:20 +0100 Subject: [PATCH 15/24] 774 and 775 incorrect exit --- node/ConsensusEngine.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index de9ca208..c50463f1 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -760,16 +760,19 @@ void ConsensusEngine::exitGracefullyBlocking() { void ConsensusEngine::exitGracefully() { - LOG( info, "Consensus engine exiting: asynchronous exit exitGracefully called by skaled" ); - cerr << "Here is exitGracefullyBlocking() stack trace for your information:" << endl; - cerr << boost::stacktrace::stacktrace() << endl; - if ( getStatus() == CONSENSUS_EXITED ) - return; + // guaranteedd to be called once RETURN_IF_PREVIOUSLY_CALLED( exitGracefullyCalled ) + LOG( info, "Consensus exiting: exitGracefully called by skaled" ); + cerr << "Here is stack trace for your info:" << endl; + cerr << boost::stacktrace::stacktrace() << endl; + + if ( getStatus() == CONSENSUS_EXITED ) + return; + // run and forget thread( [this]() { exitGracefullyAsync(); } ).detach(); From 062983bde207605b8af7f372cda84b587d77a7f8 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Fri, 19 May 2023 19:40:47 +0100 Subject: [PATCH 16/24] 774 and 775 incorrect exit --- Consensusd.cpp | 5 +-- Consensust.cpp | 13 ++++++-- node/ConsensusEngine.cpp | 57 +++++++++++------------------------ node/ConsensusEngine.h | 15 ++++----- unittests/consensus_tests.cpp | 6 ++-- 5 files changed, 42 insertions(+), 54 deletions(-) diff --git a/Consensusd.cpp b/Consensusd.cpp index 98741401..78b4afbb 100644 --- a/Consensusd.cpp +++ b/Consensusd.cpp @@ -65,9 +65,10 @@ int main( int argc, char** argv ) { engine.slowStartBootStrapTest(); - sleep( 20 ); + while ( engine.getStatus() != CONSENSUS_EXITED ) { + usleep( 100 * 1000 ); + } - engine.exitGracefullyBlocking(); cerr << "Exited" << endl; #ifdef GOOGLE_PROFILE diff --git a/Consensust.cpp b/Consensust.cpp index 411cdcba..39d8f67c 100644 --- a/Consensust.cpp +++ b/Consensust.cpp @@ -165,7 +165,12 @@ block_id basicRun( int64_t _lastId = 0 ) { cerr << price << ":" << stateRoot << endl; signal( SIGABRT, abort_handler ); - engine->exitGracefullyBlocking(); + engine->exitGracefully(); + + while ( engine->getStatus() != CONSENSUS_EXITED ) { + usleep( 100 * 1000 ); + } + delete engine; return lastId; } catch ( SkaleException& e ) { @@ -179,7 +184,11 @@ bool success = false; void exit_check() { sleep( STUCK_TEST_TIME ); - engine->exitGracefullyBlocking(); + engine->exitGracefully(); + + while ( engine->getStatus() != CONSENSUS_EXITED ) { + usleep( 100 * 1000 ); + } } diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index c50463f1..cacdaa26 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -735,65 +735,38 @@ ConsensusExtFace* ConsensusEngine::getExtFace() const { return extFace; } - -void ConsensusEngine::exitGracefullyBlocking() { - LOG( info, "Consensus engine exiting: exitGracefullyBlocking called by skaled" ); - - cout << "Here is exitGracefullyBlocking() stack trace for your information:" << endl; - - cerr << boost::stacktrace::stacktrace() << endl; - - - // !! if we don't check this - exitGracefullyAsync() - // will try to exit on deleted object! - - - if ( getStatus() == CONSENSUS_EXITED ) - return; - - exitGracefully(); - - while ( getStatus() != CONSENSUS_EXITED ) { - usleep( 100 * 1000 ); - } -} - - void ConsensusEngine::exitGracefully() { - - - - // guaranteedd to be called once + // guaranteed to be called only once RETURN_IF_PREVIOUSLY_CALLED( exitGracefullyCalled ) LOG( info, "Consensus exiting: exitGracefully called by skaled" ); cerr << "Here is stack trace for your info:" << endl; cerr << boost::stacktrace::stacktrace() << endl; - if ( getStatus() == CONSENSUS_EXITED ) - return; - - // run and forget thread( [this]() { exitGracefullyAsync(); } ).detach(); } +// used in tests only +void ConsensusEngine::testExitGracefullyBlocking() { + exitGracefully(); + while ( getStatus() != CONSENSUS_EXITED ) { + usleep( 100 * 1000 ); + } +} consensus_engine_status ConsensusEngine::getStatus() const { return status; } void ConsensusEngine::exitGracefullyAsync() { - LOG( info, "Consensus engine exiting: exitGracefullyAsync called by skaled" ); - - // guaranteed to be executed once RETURN_IF_PREVIOUSLY_CALLED( exitGracefullyAsyncCalled ) + LOG( info, "Consensus engine exiting: exitGracefullyAsync called by skaled" ); try { LOG( info, "exitGracefullyAsync running" ); - for ( auto&& it : nodes ) { // run and forget @@ -830,13 +803,17 @@ void ConsensusEngine::exitGracefullyAsync() { } ConsensusEngine::~ConsensusEngine() { - exitGracefullyBlocking(); + /* the time ConsensusEngine destructor is called, exitGracefully must have been + called. This is just precaution to make sure we do not destroy Consensus engine + and all of its fields before all consensus threads exited. */ - nodes.clear(); + exitGracefully(); - curl_global_cleanup(); + while ( getStatus() != CONSENSUS_EXITED ) { + usleep( 100 * 1000 ); + } - std::cerr << "ConsensusEngine terminated." << std::endl; + curl_global_cleanup(); } diff --git a/node/ConsensusEngine.h b/node/ConsensusEngine.h index 65fbe4dc..a1a17b99 100644 --- a/node/ConsensusEngine.h +++ b/node/ConsensusEngine.h @@ -114,15 +114,15 @@ class ConsensusEngine : public ConsensusInterface { atomic< bool > exitGracefullyCalled = false; -public: - const map< string, uint64_t >& getPatchTimestamps() const; - -private: ptr< StorageLimits > storageLimits = nullptr; map< string, uint64_t > patchTimestamps; + void exitGracefullyAsync(); + public: + const map< string, uint64_t >& getPatchTimestamps() const; + // used for testing only ptr< map< uint64_t, ptr< NodeInfo > > > testNodeInfosByIndex; ptr< map< uint64_t, ptr< NodeInfo > > > testNodeInfosById; @@ -238,12 +238,13 @@ class ConsensusEngine : public ConsensusInterface { void parseTestConfigsAndCreateAllNodes( const fs_path& dirname, bool _useBlockIDFromConsensus = false ); - void exitGracefullyBlocking(); - - void exitGracefullyAsync(); virtual void exitGracefully() override; + + // used in tests + void testExitGracefullyBlocking(); + /* consensus status for now can be CONSENSUS_ACTIVE and CONSENSUS_EXITED */ virtual consensus_engine_status getStatus() const override; diff --git a/unittests/consensus_tests.cpp b/unittests/consensus_tests.cpp index 13e81f7a..5bcbae39 100644 --- a/unittests/consensus_tests.cpp +++ b/unittests/consensus_tests.cpp @@ -46,7 +46,7 @@ TEST_CASE_METHOD( REQUIRE( engine->nodesCount() > 0 ); REQUIRE( engine->getLargestCommittedBlockID() > 0 ); - engine->exitGracefullyBlocking(); + engine->testExitGracefullyBlocking(); delete engine; SUCCEED(); } @@ -68,7 +68,7 @@ TEST_CASE_METHOD( StartFromScratch, "Get consensus to stuck", "[consensus-stuck] } catch ( ... ) { timer.join(); } - engine->exitGracefullyBlocking(); + engine->testExitGracefullyBlocking(); delete engine; SUCCEED(); } @@ -85,7 +85,7 @@ TEST_CASE_METHOD( REQUIRE( engine->nodesCount() > 0 ); REQUIRE( engine->getLargestCommittedBlockID() == 0 ); - engine->exitGracefullyBlocking(); + engine->testExitGracefullyBlocking(); delete engine; } catch ( SkaleException& e ) { SkaleException::logNested( e ); From 47fc29eec60ac07e9e48c24e2edb3310a9e30ccc Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Fri, 19 May 2023 23:11:28 +0100 Subject: [PATCH 17/24] 774 and 775 incorrect exit --- node/ConsensusEngine.cpp | 2 ++ node/Node.cpp | 5 ++++- node/Node.h | 8 +++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index cacdaa26..4741c776 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -739,6 +739,8 @@ void ConsensusEngine::exitGracefully() { // guaranteed to be called only once RETURN_IF_PREVIOUSLY_CALLED( exitGracefullyCalled ) + Node::exitOnBlockBoundaryRequested = true; + LOG( info, "Consensus exiting: exitGracefully called by skaled" ); cerr << "Here is stack trace for your info:" << endl; cerr << boost::stacktrace::stacktrace() << endl; diff --git a/node/Node.cpp b/node/Node.cpp index 5ae9cb28..4de0f430 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -506,6 +506,8 @@ void Node::doSoftAndThenHardExit() { // guaranteed to execute only once RETURN_IF_PREVIOUSLY_CALLED( exitCalled ) + exitOnBlockBoundaryRequested = true; + // this handles the case when exit is called very early // so that the start barriers were not released yet // then they have to be released for system to start working @@ -522,7 +524,6 @@ void Node::doSoftAndThenHardExit() { return; } - exitOnBlockBoundaryRequested = true; // wait until block completes EVM processing while ( getSchain()->isInCreateBlock() ) { @@ -719,3 +720,5 @@ bool Node::verifyRealSignatures() const { const map< string, uint64_t >& Node::getPatchTimestamps() const { return patchTimestamps; } + +atomic_bool Node::exitOnBlockBoundaryRequested(false); diff --git a/node/Node.h b/node/Node.h index f77ccf06..30f0471a 100644 --- a/node/Node.h +++ b/node/Node.h @@ -92,17 +92,12 @@ class Node { atomic_bool fatalErrorOccured = false; - atomic_bool exitOnBlockBoundaryRequested = false; - atomic_bool closeAllSocketsCalled = false; - void exitImmediately(); - bool isExitOnBlockBoundaryRequested() const; - ptr< SkaleLog > log = nullptr; string name = ""; @@ -238,6 +233,9 @@ class Node { void closeAllSocketsAndNotifyAllAgentsAndThreads(); public: + + static atomic exitOnBlockBoundaryRequested; + void checkForExitOnBlockBoundaryAndExitIfNeeded(); From feb357df5abeb5ccc90dfb89afb1cbd2b58ee141 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Fri, 19 May 2023 23:15:17 +0100 Subject: [PATCH 18/24] 774 and 775 incorrect exit --- node/Node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/Node.cpp b/node/Node.cpp index 4de0f430..32850087 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -574,7 +574,7 @@ void Node::exitImmediately() { void Node::checkForExitOnBlockBoundaryAndExitIfNeeded() { if ( getSchain()->getNode()->isExitOnBlockBoundaryRequested() ) { // do immediate exit since we are at the safe point - auto msg = "Exiting on block boundary after processing block " + + auto msg = "Exiting on block boundary for block " + to_string( getSchain()->getLastCommittedBlockID() ); LOG( info, msg ); getSchain()->getNode()->exitImmediately(); From 18ae3081578b1fbaaf4f3b7e509927ef791f6df0 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Fri, 19 May 2023 23:16:47 +0100 Subject: [PATCH 19/24] 774 and 775 incorrect exit --- node/Node.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/Node.h b/node/Node.h index 30f0471a..eb4fbf29 100644 --- a/node/Node.h +++ b/node/Node.h @@ -233,8 +233,7 @@ class Node { void closeAllSocketsAndNotifyAllAgentsAndThreads(); public: - - static atomic exitOnBlockBoundaryRequested; + static atomic< bool > exitOnBlockBoundaryRequested; void checkForExitOnBlockBoundaryAndExitIfNeeded(); From d5b767e6b9379870a47e36eb307bce3a3aa2b2be Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Fri, 19 May 2023 23:18:01 +0100 Subject: [PATCH 20/24] 774 and 775 incorrect exit --- node/Node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/Node.cpp b/node/Node.cpp index 32850087..ee0caca5 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -721,4 +721,4 @@ const map< string, uint64_t >& Node::getPatchTimestamps() const { return patchTimestamps; } -atomic_bool Node::exitOnBlockBoundaryRequested(false); +atomic_bool Node::exitOnBlockBoundaryRequested( false ); From 150cd5e7a4b98f351a7529779bc3815d1b2f20cc Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Mon, 22 May 2023 15:32:43 +0100 Subject: [PATCH 21/24] 774 and 775 incorrect exit --- node/ConsensusEngine.cpp | 50 +++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index 4741c776..3b352aa9 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -769,6 +769,13 @@ void ConsensusEngine::exitGracefullyAsync() { try { LOG( info, "exitGracefullyAsync running" ); + // if there is onlu one node we can all + // doSoftAndHardExit in the same + // thread for tests, we have many node objects and + // need many threads + + uint64_t counter = 0; + for ( auto&& it : nodes ) { // run and forget @@ -778,7 +785,10 @@ void ConsensusEngine::exitGracefullyAsync() { // run and forget - thread( [node]() { + counter++; + + if ( counter == nodes.size() ) { + // do the last node in the same thread try { LOG( info, "Node exit called" ); node->doSoftAndThenHardExit(); @@ -787,7 +797,18 @@ void ConsensusEngine::exitGracefullyAsync() { SkaleException::logNested( e ); } catch ( ... ) { }; - } ).detach(); + } else { + thread( [node]() { + try { + LOG( info, "Node exit called" ); + node->doSoftAndThenHardExit(); + } catch ( exception& e ) { + SkaleException::logNested( e ); + LOG( info, "Node exit completed" ); + } catch ( ... ) { + }; + } ).detach(); + } } CHECK_STATE( threadRegistry ); @@ -798,7 +819,9 @@ void ConsensusEngine::exitGracefullyAsync() { it.second->getSchain()->joinMonitorAndTimeoutThreads(); } } catch ( exception& e ) { - SkaleException::logNested( e ); + SkaleException::logNested( < e ); + status = CONSENSUS_EXITED; + } catch ( ... ) { status = CONSENSUS_EXITED; } status = CONSENSUS_EXITED; @@ -886,16 +909,21 @@ map< string, uint64_t > ConsensusEngine::getConsensusDbUsage() const { // map< string, uint64_t > ret; // ret["blocks.db_disk_usage"] = node->getBlockDB()->getActiveDBSize(); // ret["block_proposal.db_disk_usage"] = - // node->getBlockProposalDB()->getBlockProposalDBSize(); ret["block_sigshare.db_disk_usage"] - // = node->getBlockSigShareDB()->getActiveDBSize(); ret["consensus_state.db_disk_usage"] = - // node->getConsensusStateDB()->getActiveDBSize(); ret["da_proof.db_disk_usage"] = - // node->getDaProofDB()->getDaProofDBSize(); ret["da_sigshare.db_disk_usage"] = - // node->getDaSigShareDB()->getActiveDBSize(); ret["incoming_msg.db_disk_usage"] = - // node->getIncomingMsgDB()->getActiveDBSize(); ret["interna_info.db_disk_usage"] = - // node->getInternalInfoDB()->getActiveDBSize(); ret["outgoing_msg.db_disk_usage"] = + // node->getBlockProposalDB()->getBlockProposalDBSize(); + // ret["block_sigshare.db_disk_usage"] = + // node->getBlockSigShareDB()->getActiveDBSize(); + // ret["consensus_state.db_disk_usage"] = + // node->getConsensusStateDB()->getActiveDBSize(); ret["da_proof.db_disk_usage"] + // = node->getDaProofDB()->getDaProofDBSize(); ret["da_sigshare.db_disk_usage"] = + // node->getDaSigShareDB()->getActiveDBSize(); ret["incoming_msg.db_disk_usage"] + // = node->getIncomingMsgDB()->getActiveDBSize(); + // ret["interna_info.db_disk_usage"] = + // node->getInternalInfoDB()->getActiveDBSize(); + // ret["outgoing_msg.db_disk_usage"] = // node->getOutgoingMsgDB()->getActiveDBSize(); ret["price.db_disk_usage"] = // node->getPriceDB()->getActiveDBSize(); ret["proposal_hash.db_disk_usage"] = - // node->getProposalHashDB()->getProposalHashDBSize(); ret["proposal_vector.db_disk_usage"] = + // node->getProposalHashDB()->getProposalHashDBSize(); + // ret["proposal_vector.db_disk_usage"] = // node->getProposalVectorDB()->getActiveDBSize(); ret["random.db_disk_usage"] = // node->getRandomDB()->getActiveDBSize(); From 1e6fba28933cdb963583a5be28d8d2f0a5d27dbf Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Mon, 22 May 2023 15:45:08 +0100 Subject: [PATCH 22/24] 774 and 775 incorrect exit --- node/ConsensusEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index 3b352aa9..6f8f609a 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -819,7 +819,7 @@ void ConsensusEngine::exitGracefullyAsync() { it.second->getSchain()->joinMonitorAndTimeoutThreads(); } } catch ( exception& e ) { - SkaleException::logNested( < e ); + SkaleException::logNested( e ); status = CONSENSUS_EXITED; } catch ( ... ) { status = CONSENSUS_EXITED; From bbdb37e54c3329cfc108b7e0ccd66b952088abd9 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Mon, 22 May 2023 16:25:48 +0100 Subject: [PATCH 23/24] 774 and 775 incorrect exit --- .idea/workspace.xml | 73 ++++++++++++++++++++-------------------- node/ConsensusEngine.cpp | 2 +- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e63d9d1a..9c28edf8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -46,7 +46,6 @@ - - { + "keyToString": { + "Git.Branch.Popup.ShowAllRemotes": "true", + "Git.Branch.Popup.ShowAllRepositories": "true", + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.cidr.known.project.marker": "true", + "WebServerToolWindowFactoryState": "false", + "cf.advertisement.text.has.clang-format": "true", + "cf.advertisement.text.overridden": "true", + "cf.first.check.clang-format": "false", + "cidr.known.project.marker": "true", + "last_opened_file_path": "/d/skaled", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "editor.preferences.fonts.default", + "vue.rearranger.settings.migration": "true" } -}]]> +} @@ -508,20 +507,6 @@ - - 1682097320357 - - - 1682099353248 - 1682100801512 - diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index 6f8f609a..5d0e1b55 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -788,7 +788,7 @@ void ConsensusEngine::exitGracefullyAsync() { counter++; if ( counter == nodes.size() ) { - // do the last node in the same thread + // run exit for the last node in the same thread try { LOG( info, "Node exit called" ); node->doSoftAndThenHardExit(); From 03b8dadef0ec9851bf6230513d8d5e331e17c217 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Mon, 22 May 2023 18:02:18 +0100 Subject: [PATCH 24/24] 774 and 775 incorrect exit --- .idea/workspace.xml | 20 +++++++++----------- node/ConsensusEngine.cpp | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9c28edf8..df0281e3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -44,9 +44,7 @@ - - - + diff --git a/node/ConsensusEngine.cpp b/node/ConsensusEngine.cpp index 5d0e1b55..0ec2c0bd 100644 --- a/node/ConsensusEngine.cpp +++ b/node/ConsensusEngine.cpp @@ -802,9 +802,9 @@ void ConsensusEngine::exitGracefullyAsync() { try { LOG( info, "Node exit called" ); node->doSoftAndThenHardExit(); + LOG( info, "Node exit completed" ); } catch ( exception& e ) { SkaleException::logNested( e ); - LOG( info, "Node exit completed" ); } catch ( ... ) { }; } ).detach();