Skip to content

Commit

Permalink
Merge pull request #1427 from skalenetwork/bug/IS-711-exit-from-creat…
Browse files Browse the repository at this point in the history
…eBlock

IS-711 Release consensusWorkingMutex in createBlock
  • Loading branch information
DmytroNazarenko authored Feb 21, 2023
2 parents d592b2f + 467eaf6 commit 9d9553d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ ConsensusExtFace::transactions_vector SkaleHost::pendingTransactions(
u256 gasAcc = 0;
auto first_to_drop_it = txns.begin();
for ( ; first_to_drop_it != txns.end(); ++first_to_drop_it ) {
// TODO log something here!?
gasAcc += first_to_drop_it->gas();
if ( gasAcc > blockGasLimit )
break;
Expand Down Expand Up @@ -593,6 +594,8 @@ ConsensusExtFace::transactions_vector SkaleHost::pendingTransactions(
void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _approvedTransactions,
uint64_t _timeStamp, uint64_t _blockID, u256 _gasPrice, u256 _stateRoot,
uint64_t _winningNodeIndex ) try {
unlock_guard< std::timed_mutex > unlocker( m_consensusWorkingMutex );

//
static std::atomic_size_t g_nCreateBlockTaskNumber = 0;
size_t nCreateBlockTaskNumber = g_nCreateBlockTaskNumber++;
Expand Down Expand Up @@ -762,8 +765,13 @@ void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _appro
m_consensus->exitGracefully();
ExitHandler::exitHandler( SIGTERM, ExitHandler::ec_rotation_complete );
clog( VerbosityInfo, "skale-host" ) << "Rotation is completed. Instance is exiting";
unlocker.will_exit();
}
}

if ( m_exitNeeded )
unlocker.will_exit();

} catch ( const std::exception& ex ) {
cerror << "CRITICAL " << ex.what() << " (in createBlock)";
cerror << "\n" << skutils::signal::generate_stack_trace() << "\n" << std::endl;
Expand Down

0 comments on commit 9d9553d

Please sign in to comment.