privval: Add IPCPV and fix SocketPV#2568
Conversation
9a954bb to
3e95047
Compare
Codecov Report
@@ Coverage Diff @@
## develop #2568 +/- ##
==========================================
+ Coverage 61.33% 61.4% +0.07%
==========================================
Files 203 207 +4
Lines 16781 16846 +65
==========================================
+ Hits 10292 10344 +52
- Misses 5621 5627 +6
- Partials 868 875 +7
|
xla
left a comment
There was a problem hiding this comment.
Hej @SLAMPER, thanks a lot for taking the time and putting together this changeset. Most of it should be good as is.
The RemoterSignerClient in its current form doesn't seem to be fit in entirely. I understand that it is the shared abstraction so the actual message handling doesn't need to be duplciated. What strikes me as odd that it is another piece that implements BaseService, besides that I firmly believe we need to drop the service idea as means for lifecycle management, we should not nest those services further. Ideally the RemoteSignerClient is stateless in nature, not shared and concerns like heartbeating (calling Ping) is handled by the wrapping implementation which already has to take care of listener setup and teardown and would be the perfect place to also have a ticker running which gets cleaned up.
Another issue we should address is to carefully craft and return errors so callers gain more control. Let me know if you need references.
privval/rs_client.go
Outdated
| connHeartbeat time.Duration | ||
|
|
||
| conn net.Conn | ||
| lock sync.Mutex |
There was a problem hiding this comment.
What is the reason for the lock? net.Conn is threadsafe.
There was a problem hiding this comment.
The idea was that if the KMS does asynchronous receive the following could happen:
TM sends a sign request.
TM send a getpubkey request.
The KMS handles both but for whichever reason it finishes the getpubkey request first.
Then the sign method would receive the packet for the getpubkey then since we have no package IDs etc.
As long as the KMS side does proper synchronizing this is not an issue but we should take care of this here.
Or do I have misconceptions about how this works ?
privval/rs_client.go
Outdated
| if resp.Error != nil { | ||
| return fmt.Errorf("remote error occurred: code: %v, description: %s", | ||
| resp.Error.Code, | ||
| resp.Error.Description) |
There was a problem hiding this comment.
Needs proper error type.
Odd formatting, should be in the form of:
return fmt.Errorf(
"remote error occurred: code: %v, description: %s",
resp.Error.Code,
resp.Error.Description,
)There was a problem hiding this comment.
I will create a dedicated error type.
|
@liamsi Could you review the proposed heartbeat messages in this PR? |
They are sane in the sense that they do the job: every |
|
@liamsi Also the pings are sent regularly at fixed intervals opposed to the Heartbeat (at least from what I have read). |
|
Thanks for the prompt reply! Although you are right and we do not have a go-routine or alike which periodically sends Although the reactor deals with a |
|
@liamsi What I saw was that the heartbeats are only sent if Lines 783 to 787 in cd172ac A connection relevant heartbeat/keepalive should not rely on a consensus reactor setting but have to sole purpose to maintain the connection also the period should be deterministic/fixed which the proposeHeartbeat is not from what I could see. |
|
Thanks again. Yeah, I was expecting that any remote signer implementation would periodically send (and sign) the following messages instead (not the Lines 571 to 579 in 4b2bf02 If this isn't the case and those do not work for all connection types (?), you are absolutely right and we'd probably need an actual heartbeat message (as the one you've introduced). |
|
@ebuchman |
|
Cool thanks - merged |
|
Btw this is still WIP since we decided to implement a simple MAC auth in IPCVal #2563 |
|
You could add the MAC in a separate PR :) |
|
@SLAMPER will you have time to address my comments? After these are fixed, we can merge this PR. |
|
@melekes I will do so today and then we can merge 👍 |
d10715a to
b42d258
Compare
|
Follow-up in #2651 |
Ref: #2563
I added IPC as an unencrypted alternative to SocketPV.
Besides I fixed the following aspects of SocketPV: