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

SKALED-1431 debug_getFutureTransactions call #1761

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions libethereum/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@
/// Retrieve pending transactions
Transactions pending() const override;

Transactions debugGetFutureTransactions() const { return m_tq.debugGetFutureTransactions(); }

Check warning on line 148 in libethereum/Client.h

View check run for this annotation

Codecov / codecov/patch

libethereum/Client.h#L148

Added line #L148 was not covered by tests

/// Queues a block for import.
ImportResult queueBlock( bytes const& _block, bool _isSafe = false );

Expand Down
11 changes: 11 additions & 0 deletions libethereum/TransactionQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,14 @@
MICROPROFILE_LEAVE();
}
}

Transactions TransactionQueue::debugGetFutureTransactions() const {
Transactions res;
ReadGuard l( m_lock );
for ( auto addressAndMap : m_future ) {
for ( auto nonceAndTransaction : addressAndMap.second ) {
res.push_back( nonceAndTransaction.second.transaction );

Check warning on line 546 in libethereum/TransactionQueue.cpp

View check run for this annotation

Codecov / codecov/patch

libethereum/TransactionQueue.cpp#L541-L546

Added lines #L541 - L546 were not covered by tests
} // for nonce
} // for address
return res;

Check warning on line 549 in libethereum/TransactionQueue.cpp

View check run for this annotation

Codecov / codecov/patch

libethereum/TransactionQueue.cpp#L549

Added line #L549 was not covered by tests
}
2 changes: 2 additions & 0 deletions libethereum/TransactionQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class TransactionQueue {
template < class... Args >
Transactions topTransactionsSync( unsigned _limit, Args... args );

Transactions debugGetFutureTransactions() const;

/// Get a hash set of transactions in the queue
/// @returns A hash set of all transactions in the queue
const h256Hash knownTransactions() const;
Expand Down
14 changes: 14 additions & 0 deletions libweb3jsonrpc/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@

TransactionSkeleton ts = toTransactionSkeleton( _call );

return m_eth.traceCall(
ts.from, ts.value, ts.to, ts.data, ts.gas, ts.gasPrice, bN, _jsonTraceConfig );

Check warning on line 243 in libweb3jsonrpc/Debug.cpp

View check run for this annotation

Codecov / codecov/patch

libweb3jsonrpc/Debug.cpp#L242-L243

Added lines #L242 - L243 were not covered by tests
} catch ( Exception const& _e ) {
BOOST_THROW_EXCEPTION( jsonrpc::JsonRpcException( _e.what() ) );
}
Expand Down Expand Up @@ -345,3 +345,17 @@

return boost::chrono::duration_cast< boost::chrono::milliseconds >( t2 - t1 ).count();
}

Json::Value Debug::debug_getFutureTransactions() {

Check warning on line 349 in libweb3jsonrpc/Debug.cpp

View check run for this annotation

Codecov / codecov/patch

libweb3jsonrpc/Debug.cpp#L349

Added line #L349 was not covered by tests
try {
checkPrivilegedAccess();
auto res = toJson( m_eth.debugGetFutureTransactions() );
for ( auto& t : res )
t.removeMember( "data" );
return res;
} catch ( std::exception const& _e ) {
BOOST_THROW_EXCEPTION( jsonrpc::JsonRpcException( _e.what() ) );
} catch ( ... ) {
BOOST_THROW_EXCEPTION( jsonrpc::JsonRpcException( "Unknown error" ) );

Check warning on line 359 in libweb3jsonrpc/Debug.cpp

View check run for this annotation

Codecov / codecov/patch

libweb3jsonrpc/Debug.cpp#L351-L359

Added lines #L351 - L359 were not covered by tests
} // catch
}
2 changes: 2 additions & 0 deletions libweb3jsonrpc/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class Debug : public DebugFace {
virtual uint64_t debug_doStateDbCompaction() override;
virtual uint64_t debug_doBlocksDbCompaction() override;

virtual Json::Value debug_getFutureTransactions() override;

private:
eth::Client& m_eth;
SkaleDebugInterface* m_debugInterface = nullptr;
Expand Down
10 changes: 10 additions & 0 deletions libweb3jsonrpc/DebugFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
this->bindAndAddMethod( jsonrpc::Procedure( "debug_doBlocksDbCompaction",
jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL ),
&dev::rpc::DebugFace::debug_doBlocksDbCompactionI );

this->bindAndAddMethod( jsonrpc::Procedure( "debug_getFutureTransactions",
jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL ),
&dev::rpc::DebugFace::debug_getFutureTransactionsI );
}
inline virtual void debug_accountRangeAtI( const Json::Value& request, Json::Value& response ) {
response = this->debug_accountRangeAt( request[0u].asString(), request[1u].asInt(),
Expand Down Expand Up @@ -179,6 +183,10 @@
response = this->debug_doBlocksDbCompaction();
}

virtual void debug_getFutureTransactionsI( const Json::Value&, Json::Value& response ) {
response = this->debug_getFutureTransactions();
}

Check warning on line 188 in libweb3jsonrpc/DebugFace.h

View check run for this annotation

Codecov / codecov/patch

libweb3jsonrpc/DebugFace.h#L186-L188

Added lines #L186 - L188 were not covered by tests

virtual Json::Value debug_accountRangeAt(
const std::string& param1, int param2, const std::string& param3, int param4 ) = 0;
virtual Json::Value debug_traceTransaction(
Expand Down Expand Up @@ -207,6 +215,8 @@

virtual uint64_t debug_doStateDbCompaction() = 0;
virtual uint64_t debug_doBlocksDbCompaction() = 0;

virtual Json::Value debug_getFutureTransactions() = 0;
};

} // namespace rpc
Expand Down
2 changes: 1 addition & 1 deletion libweb3jsonrpc/Net.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Net : public NetFace {
virtual bool net_listening() override;

private:
const dev::eth::ChainParams& m_chainParams;
const dev::eth::ChainParams m_chainParams;
};

} // namespace rpc
Expand Down
2 changes: 1 addition & 1 deletion skaled/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ int main( int argc, char** argv ) try {
#else
// debug interface is enabled on core node if bEnabledAPIs_debug is true
auto pDebugFace = bEnabledAPIs_debug ?
new rpc::Debug( *g_client, &debugInterface, argv_string ) :
new rpc::Debug( *g_client, &debugInterface, argv_string, true ) :
nullptr;
#endif

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ struct JsonRpcFixture : public TestOutputHelperFixture {
rpcServer.reset( new FullServer( ethFace , new rpc::Net( chainParams ),
new rpc::Web3( /*web3->clientVersion()*/ ), // TODO Add real version?
new rpc::AdminEth( *client, *gasPricer, keyManager, *sessionManager.get() ),
/*new rpc::AdminNet(*web3, *sessionManager), */ new rpc::Debug( *client ),
/*new rpc::AdminNet(*web3, *sessionManager), */ new rpc::Debug( *client, nullptr, "", true ),
new rpc::Test( *client ) ) );

//
Expand Down
Loading