-
Notifications
You must be signed in to change notification settings - Fork 492
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
SpecificNodeBlockProvider
: Modify handshake warning logging
#12949
SpecificNodeBlockProvider
: Modify handshake warning logging
#12949
Conversation
@@ -110,7 +115,8 @@ private async Task ReconnectingLoopAsync() | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is OperationCanceledException && connectCts.Token.IsCancellationRequested) |
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.
I believe that connectCts.Token.IsCancellationRequested
should not be here as that looks like a bug to me. I replaced it with !shutdownToken.IsCancellationRequested
as that makes more sense to me.
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.
You are right it looks like it made no sense
bf7ded4
to
42e9db2
Compare
42e9db2
to
f7aee44
Compare
SpecificNodeBlockProvider
: Log warning only the first time or after a successful connectionSpecificNodeBlockProvider
: Modify handshake warning logging
@@ -110,14 +116,17 @@ private async Task ReconnectingLoopAsync() | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is OperationCanceledException && connectCts.Token.IsCancellationRequested) | |||
// In general, we do do not log a message if we fail to connect to the bitcoin core endpoint. The only exception is when a handshake error occurs. |
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.
This is current behavior. I find it it weird though. I would expect that we log once that we cannot log to the specified bitcoin node (i.e. to log when SocketException
is thrown`).
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.
We are logging, simply in Trace
. We could move to Warning
and extend logWarningOnHandshakeError
to any type of exception.
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.
We are logging, simply in
Trace
.
Ah, I see now.
We are logging, simply in
Trace
. We could move toWarning
and extendlogWarningOnHandshakeError
to any type of exception.
Do you want me to change it in this PR or is like an idea?
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.
I can do it in a subsequent PR
if (ex is OperationCanceledException && connectCts.Token.IsCancellationRequested) | ||
// In general, we do do not log a message if we fail to connect to the bitcoin core endpoint. The only exception is when a handshake error occurs. | ||
// If we are not shutting down the application and if this is not a repeated-handshake failure, then log a warning. | ||
if (ex is OperationCanceledException && !shutdownToken.IsCancellationRequested && logWarningOnHandshakeError) |
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.
Catching OperationCanceledException
seems like it's some sort of workaround, I tried to modify requirements of the local node (I required a nonsense witness version) and this warning was not shown.
So I'm not too sure how we ended up with this condition.
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.
I don't get a full node, so I can't test it, but code changes LGTM
You can test it with a RegTest node as well. That's what I did. |
Co-authored-by: adamPetho <45069029+adamPetho@users.noreply.github.com>
Wasabi + backend + Knots are running, everything is fine. I couldn't manage to get this warning log
|
It sounds like this: https://github.com/zkSNACKs/WalletWasabi/pull/12949/files#r1583684668 |
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.
t(rust)ACK, I wasn't able to repro the original issue. Code still LGTM
@@ -156,6 +165,9 @@ private async Task ReconnectingLoopAsync() | |||
} | |||
} | |||
|
|||
/// <exception cref="SocketException">When connecting to the node fails.</exception> | |||
/// <exception cref="OperationCanceledException">When handshake protocol with the node fails.</exception> |
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.
According to your previous comment, isn't this statement incorrect?
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.
I have removed that line. I've been looking into NBitcoin and its Node.VersionHandshake
and it throws InvalidOperationException
in multiple scenarios. But it's a mess because NBitcoin is such a sh* library (Try*
methods throw, convert one exception to another one, etc.).
How exactly it throws OperationCanceledException
, I don't know.
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.
My best guess is that this:
can throw an OCE and then the scenario is: You send a handshake and you don't get a response (which can presumably happen if you are starting Bitcoin Core and it is not fully initialized).
But like who knows. NBitcoin has been written in an adhoc way so it's hard to say what's intentional and what is a bug.
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.
Yeah I see the problem... I will make a new PR to log in all cases, just waiting for CI
Fixes #11184
This PR is basically just what @turbolay suggested here.
Testing