Skip to content

Commit

Permalink
format; #1755
Browse files Browse the repository at this point in the history
  • Loading branch information
PropzSaladaz committed Jan 24, 2025
1 parent f833e40 commit 3320426
Show file tree
Hide file tree
Showing 29 changed files with 268 additions and 265 deletions.
1 change: 0 additions & 1 deletion libdevcore/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ std::string innermost_exception_what( const std::exception& ex ) {
}

void rethrow_most_nested( const std::exception& ex ) {

const std::nested_exception* nested_ptr = dynamic_cast< const std::nested_exception* >( &ex );
if ( nested_ptr == nullptr ) {
throw; // TODO can we make this func to be called without arguments? what does it really
Expand Down
2 changes: 1 addition & 1 deletion libethereum/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ void Block::commitToSeal(
// State::CommitBehaviour::KeepEmptyAccounts);

LOG( m_loggerTrace ) << "Post-reward stateRoot: "
<< "is not calculated in Skale state";
<< "is not calculated in Skale state";
LOG( m_loggerTrace ) << m_state;

m_currentBlock.setLogBloom( logBloom() );
Expand Down
12 changes: 6 additions & 6 deletions libethereum/BlockChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void BlockChain::checkBlockTimestamp( BlockHeader const& _header ) const {
// Check it's not crazy
if ( _header.timestamp() > utcTime() && !m_params.allowFutureBlocks ) {
LOG( m_loggerTrace ) << _header.hash() << " : Future time " << _header.timestamp()
<< " (now at " << utcTime() << ")";
<< " (now at " << utcTime() << ")";
// Block has a timestamp in the future. This is no good.
BOOST_THROW_EXCEPTION( FutureTime() );
}
Expand Down Expand Up @@ -899,7 +899,7 @@ void BlockChain::recomputeExistingOccupiedSpaceForBlockRotation() try {
extrasBatchSize +=
( 4147 + 34 ) / 16 + ( 4147 + 34 ) / 256 + 2; // 1+1/16th big bloom per block
LOG( m_loggerTrace ) << "Computed block " << i
<< " DB usage = " << blocksBatchSize + extrasBatchSize;
<< " DB usage = " << blocksBatchSize + extrasBatchSize;
} // for block

uint64_t pieceUsageBytes = 0;
Expand Down Expand Up @@ -970,9 +970,9 @@ ImportRoute BlockChain::insertBlockAndExtras( VerifiedBlockRef const& _block,
newLastBlockNumber = ( unsigned ) _block.info.number();

LOG( m_loggerTrace ) << " Imported and best " << _totalDifficulty << " ("
<< "#" << _block.info.number() << "). Has "
<< ( details( _block.info.parentHash() ).children.size() - 1 )
<< " siblings.";
<< "#" << _block.info.number() << "). Has "
<< ( details( _block.info.parentHash() ).children.size() - 1 )
<< " siblings.";

#if ETH_PARANOIA
if ( isKnown( _block.info.hash() ) && !details( _block.info.hash() ) ) {
Expand Down Expand Up @@ -1045,7 +1045,7 @@ ImportRoute BlockChain::insertBlockAndExtras( VerifiedBlockRef const& _block,
fresh.push_back( tbi.hash() );

LOG( m_loggerTrace ) << "Insterted block with " << _block.transactions.size()
<< " transactions";
<< " transactions";

return ImportRoute{ dead, fresh, _block.transactions };
}
Expand Down
4 changes: 2 additions & 2 deletions libethereum/BlockQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ImportResult BlockQueue::import( bytesConstRef _block, bool _isOurs ) {
}

LOG( m_loggerTrace ) << "Block " << h << " is " << bi.number() << " parent is "
<< bi.parentHash();
<< bi.parentHash();

// Check block doesn't already exist first!
if ( m_bc->isKnown( h ) ) {
Expand All @@ -232,7 +232,7 @@ ImportResult BlockQueue::import( bytesConstRef _block, bool _isOurs ) {
if ( strftime( buf, 24, "%X", localtime( &bit ) ) == 0 )
buf[0] = '\0'; // empty if case strftime fails
LOG( m_loggerTrace ) << "OK - queued for future [" << bi.timestamp() << " vs " << utcTime()
<< "] - will wait until " << buf;
<< "] - will wait until " << buf;
m_difficulty += bi.difficulty();
h256 const parentHash = bi.parentHash();
bool const unknown = !contains( m_readySet, parentHash ) &&
Expand Down
34 changes: 17 additions & 17 deletions libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Client::Client( ChainParams const& _params, int _networkID,

m_debugTracer.call_on_tracepoint( [this]( const std::string& name ) {
LOG( m_loggerTrace ) << "TRACEPOINT " << name << " "
<< m_debugTracer.get_tracepoint_count( name );
<< m_debugTracer.get_tracepoint_count( name );
} );

m_debugHandler = [this]( const std::string& arg ) -> std::string {
Expand Down Expand Up @@ -351,7 +351,8 @@ void Client::onBadBlock( Exception& _ex ) const {
// BAD BLOCK
bytes const* block = boost::get_error_info< errinfo_block >( _ex );
if ( !block ) {
LOG( m_loggerWarning ) << "ODD: onBadBlock called but exception (" << _ex.what() << ") has no block in it.";
LOG( m_loggerWarning ) << "ODD: onBadBlock called but exception (" << _ex.what()
<< ") has no block in it.";
LOG( m_loggerWarning ) << boost::diagnostic_information( _ex );
return;
}
Expand Down Expand Up @@ -536,10 +537,10 @@ size_t Client::importTransactionsAsBlock(

if ( !UnsafeRegion::isActive() ) {
LOG( m_loggerTrace ) << "Total unsafe time so far = "
<< std::chrono::duration_cast< std::chrono::seconds >(
UnsafeRegion::getTotalTime() )
.count()
<< " seconds";
<< std::chrono::duration_cast< std::chrono::seconds >(
UnsafeRegion::getTotalTime() )
.count()
<< " seconds";
} else
LOG( m_loggerWarning ) << "Warning: UnsafeRegion still active!";

Expand Down Expand Up @@ -592,8 +593,7 @@ size_t Client::syncTransactions(
m_skaleHost->noteNewTransactions();

LOG( m_loggerTrace ) << "Processed " << newPendingReceipts.size() << " transactions in "
<< timer.elapsed() * 1000 << "(" << ( bool ) m_syncTransactionQueue
<< ")";
<< timer.elapsed() * 1000 << "(" << ( bool ) m_syncTransactionQueue << ")";

#ifdef HISTORIC_STATE
LOG( m_loggerInfo )
Expand All @@ -608,9 +608,9 @@ void Client::onDeadBlocks( h256s const& _blocks, h256Hash& io_changed ) {
LOG( m_loggerTrace ) << "Dead block: " << h;
for ( auto const& t : bc().transactions( h ) ) {
LOG( m_loggerTrace ) << "Resubmitting dead-block transaction "
<< Transaction( t, CheckTransaction::None );
<< Transaction( t, CheckTransaction::None );
LOG( m_loggerTrace ) << "Resubmitting dead-block transaction "
<< Transaction( t, CheckTransaction::None );
<< Transaction( t, CheckTransaction::None );
m_tq.import( t, IfDropped::Retry );
}
}
Expand Down Expand Up @@ -730,7 +730,7 @@ void Client::rejigSealing() {
}
// TODO is that needed? we have "Generating seal on" below
LOG( m_loggerTrace ) << "Starting to seal block"
<< " #" << m_working.info().number();
<< " #" << m_working.info().number();

// TODO Deduplicate code
dev::h256 stateRootToSet;
Expand Down Expand Up @@ -765,7 +765,7 @@ void Client::rejigSealing() {
LOG( m_loggerInfo ) << "Submitting block failed...";
} );
LOG( m_loggerTrace ) << "Generating seal on " << m_sealingInfo.hash( WithoutSeal )
<< " #" << m_sealingInfo.number();
<< " #" << m_sealingInfo.number();
sealEngine()->generateSeal( m_sealingInfo );
}
} else
Expand All @@ -786,7 +786,7 @@ void Client::sealUnconditionally( bool submitToBlockChain ) {
}
// TODO is that needed? we have "Generating seal on" below
LOG( m_loggerTrace ) << "Starting to seal block"
<< " #" << m_working.info().number();
<< " #" << m_working.info().number();
// latest hash is really updated after NEXT snapshot already started hash computation
// TODO Deduplicate code
dev::h256 stateRootToSet;
Expand Down Expand Up @@ -956,10 +956,10 @@ void Client::checkWatchGarbage() {
{
toUninstall.push_back( key );
LOG( m_loggerTrace ) << "GC: Uninstall " << key << " ("
<< chrono::duration_cast< chrono::seconds >(
chrono::system_clock::now() - m_watches[key].lastPoll )
.count()
<< " s old)";
<< chrono::duration_cast< chrono::seconds >(
chrono::system_clock::now() - m_watches[key].lastPoll )
.count()
<< " s old)";
}
for ( auto i : toUninstall )
uninstallWatch( i );
Expand Down
3 changes: 2 additions & 1 deletion libethereum/SkaleHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class DefaultConsensusFactory : public ConsensusFactory {
const dev::eth::Client& m_client;

/// Loggers
mutable dev::Logger m_loggerInfo{ dev::createLogger( dev::VerbosityInfo, "DefaultConsensusFactory" ) };
mutable dev::Logger m_loggerInfo{ dev::createLogger(
dev::VerbosityInfo, "DefaultConsensusFactory" ) };
#if CONSENSUS
void fillSgxInfo( ConsensusEngine& consensus ) const;
void fillPublicKeyInfo( ConsensusEngine& consensus ) const;
Expand Down
2 changes: 1 addition & 1 deletion libevm/LegacyVMConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace eth {

// Executive swallows exceptions in some circumstances
#if 0
#define THROW_EXCEPTION( X ) ( ( cerr << "EVM EXCEPTION " << ( X ).what() << "\n" ), abort() )
#define THROW_EXCEPTION( X ) ( ( cerr << "EVM EXCEPTION " << ( X ).what() << "\n" ), abort() )
#else
#if EVM_TRACE > 0
#define THROW_EXCEPTION( X ) \
Expand Down
3 changes: 2 additions & 1 deletion libskale/AmsterdamFixPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ void AmsterdamFixPatch::initOnChain( batched_io::db_operations_face& _blocksDB,

if ( bn == start_block + 1 || old_hash == best_hash || transactions.size() ||
bn % 1000 == 0 )
LOG( m_loggerInfo ) << "Repairing block " << bn << " " << old_hash << " -> " << new_hash;
LOG( m_loggerInfo ) << "Repairing block " << bn << " " << old_hash << " -> "
<< new_hash;

TransactionAddress ta;
ta.blockHash = new_hash;
Expand Down
41 changes: 19 additions & 22 deletions libskale/OverlayDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ dev::db::Slice toSlice( std::string const& _s ) {
}; // namespace slicing

OverlayDB::OverlayDB( std::unique_ptr< batched_io::db_face > _db_face )
: m_db_face( _db_face.release(), []( batched_io::db_face* db ) {
delete db;
} ) {}
: m_db_face( _db_face.release(), []( batched_io::db_face* db ) { delete db; } ) {}

dev::h256 OverlayDB::getLastExecutedTransactionHash() const {
if ( lastExecutedTransactionHash.has_value() )
Expand Down Expand Up @@ -333,7 +331,6 @@ void OverlayDB::insertAuxiliary(
}

std::unordered_map< h160, string > OverlayDB::accounts() const {

LOG( m_loggerInfo ) << "Iterating over all accounts in state";
unordered_map< h160, string > accounts;
if ( m_db_face ) {
Expand All @@ -357,24 +354,25 @@ std::unordered_map< u256, u256 > OverlayDB::storage( const dev::h160& _address )
if ( m_db_face ) {
// iterate of a keys that start with the given substring
string prefix( ( const char* ) _address.data(), _address.size );
m_db_face->forEachWithPrefix( prefix, [this, &storage, &_address]( Slice key, Slice value ) {
if ( key.size() == h160::size + h256::size ) {
// key is storage address
string keyString( key.begin(), key.end() );
h160 address = h160(
keyString.substr( 0, h160::size ), h160::ConstructFromStringType::FromBinary );
if ( address == _address ) {
h256 memoryAddress = h256(
keyString.substr( h160::size ), h256::ConstructFromStringType::FromBinary );
u256 memoryValue = h256( string( value.begin(), value.end() ),
h256::ConstructFromStringType::FromBinary );
storage[memoryAddress] = memoryValue;
} else {
LOG( m_loggerError ) << "Address mismatch in:" << __FUNCTION__;
m_db_face->forEachWithPrefix(
prefix, [this, &storage, &_address]( Slice key, Slice value ) {
if ( key.size() == h160::size + h256::size ) {
// key is storage address
string keyString( key.begin(), key.end() );
h160 address = h160( keyString.substr( 0, h160::size ),
h160::ConstructFromStringType::FromBinary );
if ( address == _address ) {
h256 memoryAddress = h256( keyString.substr( h160::size ),
h256::ConstructFromStringType::FromBinary );
u256 memoryValue = h256( string( value.begin(), value.end() ),
h256::ConstructFromStringType::FromBinary );
storage[memoryAddress] = memoryValue;
} else {
LOG( m_loggerError ) << "Address mismatch in:" << __FUNCTION__;
}
}
}
return true;
} );
return true;
} );
} else {
cerror << "Try to load account's storage but connection to database is not established";
}
Expand Down Expand Up @@ -403,7 +401,6 @@ void OverlayDB::copyStorageIntoAccountMap( dev::eth::AccountMap& _map ) const {
_map.at( address ).setStorage( memoryAddress, memoryValue );
counter++;
if ( counter % 1000000 == 0 ) {

LOG( m_loggerDebug ) << ".";
LOG( m_loggerDebug ).flush();
}
Expand Down
9 changes: 6 additions & 3 deletions libskale/SnapshotHashAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ class SnapshotHashAgent {
size_t verifyAllData() const;

/// Loggers
mutable dev::Logger m_loggerDebug{ dev::createLogger( dev::VerbosityDebug, "SnapshotHashAgent" ) };
mutable dev::Logger m_loggerInfo{ dev::createLogger( dev::VerbosityInfo, "SnapshotHashAgent" ) };
mutable dev::Logger m_loggerError{ dev::createLogger( dev::VerbosityError, "SnapshotHashAgent" ) };
mutable dev::Logger m_loggerDebug{ dev::createLogger(
dev::VerbosityDebug, "SnapshotHashAgent" ) };
mutable dev::Logger m_loggerInfo{ dev::createLogger(
dev::VerbosityInfo, "SnapshotHashAgent" ) };
mutable dev::Logger m_loggerError{ dev::createLogger(
dev::VerbosityError, "SnapshotHashAgent" ) };
};

#endif // SNAPSHOTHASHAGENT_H
2 changes: 1 addition & 1 deletion libskale/SnapshotManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ void SnapshotManager::addLastPriceToHash( unsigned _blockNumber, secp256k1_sha25
}

dev::h256 last_price_hash = dev::sha256( last_price.str() );

LOG( m_loggerInfo ) << "Latest price hash is: " << last_price_hash;
secp256k1_sha256_write( ctx, last_price_hash.data(), last_price_hash.size );
}
Expand Down
3 changes: 2 additions & 1 deletion libskale/broadcaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class ZmqBroadcaster : public Broadcaster {

/// Logger
mutable dev::Logger m_loggerInfo{ dev::createLogger( dev::VerbosityInfo, "ZmqBroadcaster" ) };
mutable dev::Logger m_loggerWarning{ dev::createLogger( dev::VerbosityWarning, "ZmqBroadcaster" ) };
mutable dev::Logger m_loggerWarning{ dev::createLogger(
dev::VerbosityWarning, "ZmqBroadcaster" ) };
mutable dev::Logger m_loggerDebug{ dev::createLogger( dev::VerbosityDebug, "ZmqBroadcaster" ) };
mutable dev::Logger m_loggerError{ dev::createLogger( dev::VerbosityError, "ZmqBroadcaster" ) };
};
Expand Down
Loading

0 comments on commit 3320426

Please sign in to comment.