Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

774 and 775 incorrect exit #777

Merged
merged 24 commits into from
May 22, 2023
Merged
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
175 changes: 85 additions & 90 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Consensusd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions Consensust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

#define CATCH_CONFIG_MAIN

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>


#include <cryptopp/eccrypto.h>
#include <cryptopp/osrng.h>
#include <cryptopp/sha.h>
Expand Down Expand Up @@ -121,6 +126,11 @@ void testLog( const char* message ) {
printf( "TEST_LOG: %s\n", message );
}

void abort_handler( int ) {
printf( "cought SIGABRT, exiting.\n" );
exit( 0 );
}

block_id basicRun( int64_t _lastId = 0 ) {
try {
REQUIRE( ConsensusEngine::getEngineVersion().size() > 0 );
Expand Down Expand Up @@ -154,7 +164,13 @@ block_id basicRun( int64_t _lastId = 0 ) {
REQUIRE( timestampS > 0 );

cerr << price << ":" << stateRoot << endl;
engine->exitGracefullyBlocking();
signal( SIGABRT, abort_handler );
engine->exitGracefully();

while ( engine->getStatus() != CONSENSUS_EXITED ) {
usleep( 100 * 1000 );
}

delete engine;
return lastId;
} catch ( SkaleException& e ) {
Expand All @@ -168,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 );
}
}


Expand Down
17 changes: 14 additions & 3 deletions chains/Schain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,22 @@ 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 ) {
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
Expand Down
4 changes: 4 additions & 0 deletions chains/Schain.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Schain : public Agent {
TimeStamp lastCommittedBlockTimeStamp;
mutex lastCommittedBlockInfoMutex;
atomic< uint64_t > proposalReceiptTime = 0;
atomic< bool > inCreateBlock = false;


atomic< uint64_t > bootstrapBlockID = 0;
Expand Down Expand Up @@ -347,6 +348,9 @@ class Schain : public Agent {
uint64_t getVerifyDaSigsPatchTimestampS() const;


bool isInCreateBlock() const;


void finalizeDecidedAndSignedBlock( block_id _blockId, schain_index _proposerIndex,
const ptr< ThresholdSignature >& _thresholdSig );

Expand Down
4 changes: 4 additions & 0 deletions chains/SchainGettersSetters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,7 @@ void Schain::setLastCommittedBlockId( uint64_t _lastCommittedBlockId ) {
const ptr< OracleClient > Schain::getOracleClient() const {
return oracleClient;
}

bool Schain::isInCreateBlock() const {
return inCreateBlock;
}
Loading