Skip to content

Commit

Permalink
Merge pull request #1500 from skalenetwork/develop
Browse files Browse the repository at this point in the history
New beta
  • Loading branch information
DmytroNazarenko authored Apr 14, 2023
2 parents 95d454e + ba2af14 commit e200fed
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1512,11 +1512,12 @@ uint64_t Client::getHistoricRootsDbUsage() const {
}
#endif // HISTORIC_STATE

uint64_t Client::submitOracleRequest( const string& _spec, string& _receipt ) {
uint64_t Client::submitOracleRequest(
const string& _spec, string& _receipt, string& _errorMessage ) {
assert( m_skaleHost );
uint64_t status = -1;
if ( m_skaleHost )
status = m_skaleHost->submitOracleRequest( _spec, _receipt );
status = m_skaleHost->submitOracleRequest( _spec, _receipt, _errorMessage );
else
throw runtime_error( "Instance of SkaleHost was not properly created." );
return status;
Expand Down
2 changes: 1 addition & 1 deletion libethereum/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class Client : public ClientBase, protected Worker {
uint64_t getHistoricRootsDbUsage() const;
#endif // HISTORIC_STATE

uint64_t submitOracleRequest( const string& _spec, string& _receipt );
uint64_t submitOracleRequest( const string& _spec, string& _receipt, string& _errorMessage );
uint64_t checkOracleResult( const string& _receipt, string& _result );

SkaleDebugInterface::handler getDebugHandler() const { return m_debugHandler; }
Expand Down
5 changes: 3 additions & 2 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,9 @@ std::array< std::string, 4 > SkaleHost::getIMABLSPublicKey() const {
return m_client.getIMABLSPublicKey();
}

uint64_t SkaleHost::submitOracleRequest( const string& _spec, string& _receipt ) {
return m_consensus->submitOracleRequest( _spec, _receipt );
uint64_t SkaleHost::submitOracleRequest(
const string& _spec, string& _receipt, string& _errorMessage ) {
return m_consensus->submitOracleRequest( _spec, _receipt, _errorMessage );
}

uint64_t SkaleHost::checkOracleResult( const string& _receipt, string& _result ) {
Expand Down
2 changes: 1 addition & 1 deletion libethereum/SkaleHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class SkaleHost {
std::map< std::string, uint64_t > getConsensusDbUsage() const;
std::array< std::string, 4 > getIMABLSPublicKey() const;

uint64_t submitOracleRequest( const string& _spec, string& _receipt );
uint64_t submitOracleRequest( const string& _spec, string& _receipt, string& _errorMessage );
uint64_t checkOracleResult( const string& _receipt, string& _result );

void pauseConsensus( bool _pause ) {
Expand Down
11 changes: 7 additions & 4 deletions libweb3jsonrpc/Skale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,13 @@ std::string Skale::oracle_submitRequest( std::string& request ) {
if ( m_client.chainParams().nodeInfo.syncNode )
throw std::runtime_error( "Oracle is disabled on this instance" );
std::string receipt;
// this function is guaranteed not to throw exceptions
uint64_t status = m_client.submitOracleRequest( request, receipt );
std::string errorMessage;

clog( VerbosityDebug, "Oracle request:" ) << request;

uint64_t status = this->m_client.submitOracleRequest( request, receipt, errorMessage );
if ( status != ORACLE_SUCCESS ) {
throw jsonrpc::JsonRpcException(
status, skutils::tools::format( "Oracle request failed with status %zu", status ) );
throw jsonrpc::JsonRpcException( status, errorMessage );
}
return receipt;
} catch ( jsonrpc::JsonRpcException const& e ) {
Expand All @@ -550,6 +552,7 @@ std::string Skale::oracle_checkResult( std::string& receipt ) {
throw jsonrpc::JsonRpcException(
status, skutils::tools::format( "Oracle request failed with status %zu", status ) );
}
clog( VerbosityDebug, "Oracle result:" ) << result;
return result;
} catch ( jsonrpc::JsonRpcException const& e ) {
throw e;
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ConsensusTestStub : public ConsensusInterface {
}

uint64_t submitOracleRequest( const string& /*_spec*/, string&
/*_receipt*/) override {
/*_receipt*/, string& ) override {
return 0;
}

Expand Down

0 comments on commit e200fed

Please sign in to comment.