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

Enhancement/enable tx sync node #1160

Closed
wants to merge 9 commits into from
34 changes: 15 additions & 19 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ void ConsensusExtImpl::terminateApplication() {
}

SkaleHost::SkaleHost( dev::eth::Client& _client, const ConsensusFactory* _consFactory,
std::shared_ptr< InstanceMonitor > _instanceMonitor, const std::string& _gethURL,
bool _broadcastEnabled ) try : m_client( _client ),
m_tq( _client.m_tq ),
m_instanceMonitor( _instanceMonitor ),
total_sent( 0 ),
total_arrived( 0 ) {
std::shared_ptr< InstanceMonitor > _instanceMonitor, const std::string& _gethURL ) try
: m_client( _client ),
m_tq( _client.m_tq ),
m_instanceMonitor( _instanceMonitor ),
total_sent( 0 ),
total_arrived( 0 ) {
m_debugHandler = [this]( const std::string& arg ) -> std::string {
return DebugTracer_handler( arg, this->m_debugTracer );
};
Expand Down Expand Up @@ -739,26 +739,22 @@ void SkaleHost::startWorking() {
working = true;
m_exitedForcefully = false;

if ( !this->m_client.chainParams().nodeInfo.syncNode ) {
try {
m_broadcaster->startService();
} catch ( const Broadcaster::StartupException& ) {
working = false;
std::throw_with_nested( SkaleHost::CreationException() );
}

auto bcast_func = std::bind( &SkaleHost::broadcastFunc, this );
m_broadcastThread = std::thread( bcast_func );
try {
m_broadcaster->startService();
} catch ( const Broadcaster::StartupException& ) {
working = false;
std::throw_with_nested( SkaleHost::CreationException() );
}

auto bcast_func = std::bind( &SkaleHost::broadcastFunc, this );
m_broadcastThread = std::thread( bcast_func );

try {
m_consensus->startAll();
} catch ( const std::exception& ) {
// cleanup
m_exitNeeded = true;
if ( !this->m_client.chainParams().nodeInfo.syncNode ) {
m_broadcastThread.join();
}
m_broadcastThread.join();
throw;
}

Expand Down
3 changes: 1 addition & 2 deletions libethereum/SkaleHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SkaleHost {

SkaleHost( dev::eth::Client& _client, const ConsensusFactory* _consFactory = nullptr,
std::shared_ptr< InstanceMonitor > _instanceMonitor = nullptr,
const std::string& _gethURL = "", bool _broadcastEnabled = true );
const std::string& _gethURL = "" );
virtual ~SkaleHost();

void startWorking();
Expand Down Expand Up @@ -191,7 +191,6 @@ class SkaleHost {
dev::eth::Client& m_client;
dev::eth::TransactionQueue& m_tq; // transactions ready to go to consensus
std::shared_ptr< InstanceMonitor > m_instanceMonitor;
bool m_broadcastEnabled;

dev::Logger m_debugLogger{ dev::createLogger( dev::VerbosityDebug, "skale-host" ) };
dev::Logger m_traceLogger{ dev::createLogger( dev::VerbosityTrace, "skale-host" ) };
Expand Down
4 changes: 0 additions & 4 deletions libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ void Eth::setTransactionDefaults( TransactionSkeleton& _t ) {

string Eth::eth_sendTransaction( Json::Value const& _json ) {
try {
if ( !isEnabledTransactionSending() )
throw std::runtime_error( "transacton sending feature is disabled on this instance" );
TransactionSkeleton t = toTransactionSkeleton( _json );
setTransactionDefaults( t );
pair< bool, Secret > ar = m_ethAccounts.authenticate( t );
Expand Down Expand Up @@ -303,8 +301,6 @@ Json::Value Eth::eth_inspectTransaction( std::string const& _rlp ) {
// TODO Catch exceptions for all calls other eth_-calls in outer scope!
/// skale
string Eth::eth_sendRawTransaction( std::string const& _rlp ) {
if ( !isEnabledTransactionSending() )
throw JsonRpcException( "transacton sending feature is disabled on this instance" );
// Don't need to check the transaction signature (CheckTransaction::None) since it
// will be checked as a part of transaction import
Transaction t( jsToBytes( _rlp, OnFailed::Throw ), CheckTransaction::None );
Expand Down
4 changes: 0 additions & 4 deletions libweb3jsonrpc/Skale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,6 @@ Json::Value Skale::skale_getSnapshotSignature( unsigned blockNumber ) {

std::string Skale::oracle_submitRequest( std::string& request ) {
try {
if ( this->m_client.chainParams().nodeInfo.syncNode )
throw std::runtime_error( "Oracle is disabled on this instance" );
std::string receipt;
uint64_t status = this->m_client.submitOracleRequest( request, receipt );
if ( status != 0 ) {
Expand All @@ -504,8 +502,6 @@ std::string Skale::oracle_submitRequest( std::string& request ) {

std::string Skale::oracle_checkResult( std::string& receipt ) {
try {
if ( this->m_client.chainParams().nodeInfo.syncNode )
throw std::runtime_error( "Oracle is disabled on this instance" );
std::string result;
uint64_t status = this->m_client.checkOracleResult( receipt, result );
switch ( status ) {
Expand Down
3 changes: 1 addition & 2 deletions libweb3jsonrpc/SkaleStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,7 @@ bool txn_pending_tracker_system_impl::broadcast_txn_verify_signature( const char
cc::debug( " verification from node ID " ) + cc::num10( node_id ) +
cc::debug( " using ECDSA public key " ) + cc::info( strEcdsaPublicKey ) +
cc::debug( " and message/hash " ) + cc::info( strHashToSign ) +
cc::debug( " is " ) +
( isSignatureOK ? cc::success( "passed" ) : cc::fatal( "failed" ) ) );
cc::debug( " is " ) + cc::success( "passed" ) );
} catch ( const std::exception& ex ) {
isSignatureOK = false;
clog( VerbosityTrace, "IMA" )
Expand Down
3 changes: 1 addition & 2 deletions skaled/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1803,8 +1803,7 @@ int main( int argc, char** argv ) try {
setenv( "DATA_DIR", getDataDir().c_str(), 0 );

std::shared_ptr< SkaleHost > skaleHost = std::make_shared< SkaleHost >( *g_client,
&cons_fact, instanceMonitor, skutils::json_config_file_accessor::g_strImaMainNetURL,
!chainParams.nodeInfo.syncNode );
&cons_fact, instanceMonitor, skutils::json_config_file_accessor::g_strImaMainNetURL );
dev::eth::g_skaleHost = skaleHost;

// XXX nested lambdas and strlen hacks..
Expand Down
Loading