-
Notifications
You must be signed in to change notification settings - Fork 79
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
Complete structure for BackEnd RPC services #601
Conversation
Complete structure for BackEnd RPC services Complete test client for for BackEnd RPCs
Codecov Report
@@ Coverage Diff @@
## master #601 +/- ##
==========================================
+ Coverage 81.55% 81.77% +0.21%
==========================================
Files 169 169
Lines 13768 13954 +186
==========================================
+ Hits 11229 11411 +182
- Misses 2539 2543 +4
Continue to review full report at Codecov.
|
Add server config unit tests Fix race condition in server unit test
@@ -58,8 +58,93 @@ void NetVersionService::process_rpc(NetVersionUnaryRpc& rpc, const remote::NetVe | |||
SILK_TRACE << "NetVersionService::process_rpc rsp: " << &response << " chain_id: " << chain_id_ << " sent: " << sent; | |||
} | |||
|
|||
void NetPeerCountService::process_rpc(NetPeerCountRpc& rpc, const remote::NetPeerCountRequest* request) { | |||
SILK_TRACE << "NetPeerCountService::process_rpc rpc: " << &rpc << " request: " << request; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why print reference to rpc ? I mean << &rpc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ... do rpc
and rsp
stand for request
and response
?
And again ... out of curiosity why don't write
SILK_TRACE << __FUNCTION__ << " rpc: " << &rpc << " request: " << request;
At least, should you change function naming, don't have to rewrite in the log lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why print reference to rpc ? I mean
<< &rpc
?
I'm printing the memory address of rpc
for tracing purposes, it is useful to debug RPC lifetime issues (live RPC objects are allocated and maintained on the heap, then deallocated on cleanup)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ... do
rpc
andrsp
stand forrequest
andresponse
?
rpc
stands for remote procedure call
, but you have a point here: naming is too much close between rpc
and rsp
in the trace log, I will amend it.
And again ... out of curiosity why don't write
SILK_TRACE << __FUNCTION__ << " rpc: " << &rpc << " request: " << request;
At least, should you change function naming, don't have to rewrite in the log lines
Yes, you're right, definitely better. Maybe we can go one step further and include __FUNCTION__
into a couple of extended SILK_TRACE
logging macros to avoid the repetition altogether:
#define SILK_TRACE_ENTER SILK_TRACE << __FUNCTION__ << " ENTER"
#define SILK_TRACE_EXIT SILK_TRACE << __FUNCTION__ << " EXIT"
or
#define SILK_TRACE_START SILK_TRACE << __FUNCTION__ << " START"
#define SILK_TRACE_END SILK_TRACE << __FUNCTION__ << " END"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't ... 🙏
Don't add another macro 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm ... I don't know on linux but at least on windows
__FUNCTION__
returns a FQDN of the function like in this exampleERROR [03-05|19:15:51.470 UTC] HashState function=silkworm::stagedsync::HashState::hash_from_account_changeset exception=kAborted
The problem here is probably that __FUNCTION__
is not standard (neither are the other options unfortunately)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSVC 1 - GCC 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is probably that
__FUNCTION__
is not standard (neither are the other options unfortunately)
maybe use this https://www.boost.org/doc/libs/1_38_0/libs/utility/current_function.html. Apparently it is a small header that doesn't depend on any other header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole header, or how to get the current function name in any compiler.
#ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
#define BOOST_CURRENT_FUNCTION_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/current_function.hpp - BOOST_CURRENT_FUNCTION
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// [http://www.boost.org/libs/assert/current_function.html](https://www.boost.org/doc/libs/1_63_0/libs/assert/current_function.html)
//
namespace boost
{
namespace detail
{
inline void current_function_helper()
{
#if defined( BOOST_DISABLE_CURRENT_FUNCTION )
# define BOOST_CURRENT_FUNCTION "(unknown)"
#elif defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__DMC__) && (__DMC__ >= 0x810)
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__FUNCSIG__)
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
# define BOOST_CURRENT_FUNCTION __FUNCTION__
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
# define BOOST_CURRENT_FUNCTION __FUNC__
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
# define BOOST_CURRENT_FUNCTION __func__
#elif defined(__cplusplus) && (__cplusplus >= 201103)
# define BOOST_CURRENT_FUNCTION __func__
#else
# define BOOST_CURRENT_FUNCTION "(unknown)"
#endif
}
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greg7mdp thanks for your suggestion, but for this use case (including class::method in a log trace) BOOST_CURRENT_FUNCTION
has the same drawback as __PRETTY_FUNCTION__
(obviously, because it is the same at least for GCC): too much verbose.
I think that sticking to the hard-coded class::method names in few log traces is not so bad, anyway.
IMO the readability of the class RpcService can be improved:
Also I note you are following the C++ Core Guidelines, where they say a raw pointer (T*) is non-owning . I don't like this point in the guidelines very much because it is a convention that not everyone knows and not everyone respects, so the reader of the signature, like me, do not know; moreover the compiler cannot reinforce it. I would put at least one custom attribute like Edit: I didn't realize that "add" takes ownership of rpc so I suggest you use unique_ptr<Rpc*> or gsl::owner<Rpc*> in the signature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (see my comments in the previous post).
Sure. Adding a
TBH I don't know if |
Add using directive to improve template readability Rename methods to improve template readability
Add server-streaming RPC support
Complete test client for for BackEnd RPCs