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

IS-711 Release consensusWorkingMutex in createBlock #1427

Merged
merged 3 commits into from
Feb 21, 2023
Merged
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
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