Skip to content

Commit

Permalink
1545 First pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Nov 25, 2024
1 parent 8cfbeac commit 2ee516e
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 73 deletions.
7 changes: 0 additions & 7 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,6 @@ void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _appro
out_txns.push_back( t );
m_debugTracer.tracepoint( "drop_good" );
m_tq.dropGood( t );

if ( SkaleDebugInterface::g_isEnabled && m_tq.isTransactionKnown( sha ) != 0 ) {
// this trace is expensive since it will aquire a read lock on transaction queue
LOG( m_traceLogger )
<< "Consensus returned future transaction that we didn't yet send";
m_debugTracer.tracepoint( "import_future" );
}
}

total_arrived += out_txns.size();
Expand Down
28 changes: 0 additions & 28 deletions libskale/SkaleDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,18 @@
#include <cassert>
#include <sstream>


std::atomic< bool > SkaleDebugInterface::g_isEnabled = true;

#define CHECK_ENABLED \
if ( !SkaleDebugInterface::g_isEnabled ) { \
return; \
};

#define CHECK_ENABLED_STR \
if ( !SkaleDebugInterface::g_isEnabled ) { \
return ""; \
};

#define CHECK_ENABLED_INT \
if ( !SkaleDebugInterface::g_isEnabled ) { \
return 0; \
};

SkaleDebugInterface::SkaleDebugInterface() {}

int SkaleDebugInterface::add_handler( handler h ) {
CHECK_ENABLED_INT;
handlers.push_back( h );
return handlers.size() - 1;
}

void SkaleDebugInterface::remove_handler( int pos ) {
CHECK_ENABLED
handlers.erase( handlers.begin() + pos );
}

std::string SkaleDebugInterface::call( const std::string& arg ) {
CHECK_ENABLED_STR;
for ( auto handler : handlers ) {
std::string res = handler( arg );
if ( !res.empty() )
Expand All @@ -48,13 +27,11 @@ std::string SkaleDebugInterface::call( const std::string& arg ) {

void SkaleDebugTracer::call_on_tracepoint(
const std::function< void( const std::string& ) >& callee ) {
CHECK_ENABLED;
global_callbacks.push_back( callee );
}

void SkaleDebugTracer::call_on_tracepoint(
const std::string& name, const std::function< void( const std::string& ) >& callee ) {
CHECK_ENABLED;
tracepoint_struct& tp_obj = find_by_name( name );

std::lock_guard< std::mutex > thread_lock( tp_obj.thread_mutex );
Expand All @@ -63,7 +40,6 @@ void SkaleDebugTracer::call_on_tracepoint(
}

void SkaleDebugTracer::break_on_tracepoint( const std::string& name, int count ) {
CHECK_ENABLED;
tracepoint_struct& tp_obj = find_by_name( name );

std::lock_guard< std::mutex > thread_lock( tp_obj.thread_mutex );
Expand All @@ -75,15 +51,13 @@ void SkaleDebugTracer::break_on_tracepoint( const std::string& name, int count )
}

void SkaleDebugTracer::wait_for_tracepoint( const std::string& name ) {
CHECK_ENABLED;
tracepoint_struct& tp_obj = find_by_name( name );

std::unique_lock< std::mutex > lock2( tp_obj.caller_mutex );
tp_obj.caller_cond.wait( lock2 );
}

void SkaleDebugTracer::continue_on_tracepoint( const std::string& name ) {
CHECK_ENABLED;
tracepoint_struct& tp_obj = find_by_name( name );

std::lock_guard< std::mutex > thread_lock( tp_obj.thread_mutex );
Expand All @@ -92,7 +66,6 @@ void SkaleDebugTracer::continue_on_tracepoint( const std::string& name ) {
}

void SkaleDebugTracer::tracepoint( const std::string& name ) {
CHECK_ENABLED;
tracepoint_struct& tp_obj = find_by_name( name );

std::unique_lock< std::mutex > lock2( tp_obj.thread_mutex );
Expand All @@ -119,7 +92,6 @@ void SkaleDebugTracer::tracepoint( const std::string& name ) {
}

std::string DebugTracer_handler( const std::string& arg, SkaleDebugTracer& tracer ) {
CHECK_ENABLED_STR;
using namespace std;

if ( arg.find( "trace " ) == 0 ) {
Expand Down
7 changes: 5 additions & 2 deletions libskale/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,13 @@ std::pair< ExecutionResult, TransactionReceipt > State::execute( EnvInfo const&
totalStorageUsed_ += currentStorageUsed_;
updateStorageUsage();
}
// TODO: review logic|^

h256 shaLastTx = _t.sha3();

h256 shaLastTx = _t.sha3(); // _t.hasSignature() ? _t.sha3() : _t.sha3(
// dev::eth::WithoutSignature );
this->m_db_ptr->setLastExecutedTransactionHash( shaLastTx );
// std::cout << "--- saving \"safeLastExecutedTransactionHash\" = " <<
// shaLastTx.hex() << "\n";

TransactionReceipt receipt =
TransactionReceipt( statusCode, startGasUsed + e.gasUsed(), e.logs() );
Expand Down
1 change: 0 additions & 1 deletion libskale/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ using ChangeLog = std::vector< Change >;
*
* Any atomic change to any account is registered and appended in the changelog.
* In case some changes must be reverted, the changes are popped from the
* In case some changes must be reverted, the changes are popped from the
* changelog and undone. For possible atomic changes list @see Change::Kind.
* The changelog is managed by savepoint(), rollback() and commit() methods.
*/
Expand Down
23 changes: 2 additions & 21 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# do not use new CMP0110 feature of cmake
if(POLICY CMP0110)
cmake_policy(SET CMP0110 OLD)
endif()


macro(assert condition)
if (NOT ${condition})
message(FATAL_ERROR "Assertion failed: ${condition}")
endif()
endmacro()

file(GLOB_RECURSE sources "*.cpp" "*.h" "*.sol")

if( NOT CONSENSUS )
Expand All @@ -26,31 +14,24 @@ foreach(file ${sources})
file(STRINGS ${file} test_list_raw REGEX "BOOST_.*TEST_(SUITE|CASE|SUITE_END)")
set(TestSuite "DEFAULT")
set(TestSuitePath "")
# read source of each test file into a list of string
foreach(test_raw ${test_list_raw})
# we match strings like BOOST_AUTO_TEST_SUITE(JsonRpcSuite) and strip beginning turning them into
# string "SUITE JsonRpcSuite"
string(REGEX REPLACE ".*TEST_(SUITE|CASE)\\(( [^ ,\\)]*).*" "\\1 \\2" test ${test_raw})
assert(test)

#skip disabled
if (";${excludeSuites};" MATCHES ";${TestSuite};")
continue()
endif()

# we match string like SUITE JsonRpcSuite These are suite names
if(test MATCHES "^SUITE .*")
# now we cut the beginning to get just JsonRpcSuite

string(SUBSTRING ${test} 6 -1 TestSuite)
assert(TestSuite)
set(TestSuitePath "${TestSuitePath}/${TestSuite}")
assert(TestSuitePath)

if(FASTCTEST)
if (";${excludeSuites};" MATCHES ";${TestSuite};")
continue()
endif()
if (NOT ";${allSuites};" MATCHES ";${TestSuite};")
message(STATUS "TestSuite value: ${TestSuite}")
string(SUBSTRING ${TestSuitePath} 1 -1 TestSuitePathFixed)
list(APPEND allSuites ${TestSuite})
separate_arguments(TESTETH_ARGS)
Expand Down
1 change: 1 addition & 0 deletions test/unittests/libskutils/test_skutils_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <skutils/multifunction.h>
#include <skutils/multithreading.h>
#include <skutils/network.h>
#include <skutils/stats.h>
#include <skutils/thread_pool.h>
#include <skutils/url.h>
#include <skutils/utils.h>
Expand Down
11 changes: 0 additions & 11 deletions test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,6 @@ std::string WebThreeStubClient::skale_protocolVersion() {
jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString() );
}


std::string WebThreeStubClient::skale_stats() {
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod( "skale_stats", p );
return result.toStyledString();
}




std::string WebThreeStubClient::eth_protocolVersion() {
Json::Value p;
p = Json::nullValue;
Expand Down
1 change: 0 additions & 1 deletion test/unittests/libweb3jsonrpc/WebThreeStubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class WebThreeStubClient : public jsonrpc::Client {
bool net_listening() noexcept( false );
std::string skale_receiveTransaction( const Json::Value& param1 ) noexcept( false );
std::string skale_protocolVersion() noexcept( false );
std::string skale_stats();
std::string eth_protocolVersion() noexcept( false );
std::string skale_shutdownInstance() noexcept( false );
std::string eth_hashrate() noexcept( false );
Expand Down
2 changes: 0 additions & 2 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4407,8 +4407,6 @@ BOOST_AUTO_TEST_CASE( eth_signAndSendRawTransaction,
fixture.splitAccountInHalves( firstAccount, dst, gasPrice,
TransactionWait::WAIT_FOR_COMPLETION);
}

cout << fixture.rpcClient()->skale_stats() << endl;
}

BOOST_AUTO_TEST_CASE( perf_sendManyParalelEthTransfers,
Expand Down

0 comments on commit 2ee516e

Please sign in to comment.