Skip to content

Invert privVal socket communication#1286

Merged
ebuchman merged 1 commit intodevelopfrom
feature/xla-priv-val-invert-dial
Mar 12, 2018
Merged

Invert privVal socket communication#1286
ebuchman merged 1 commit intodevelopfrom
feature/xla-priv-val-invert-dial

Conversation

@xla
Copy link
Contributor

@xla xla commented Mar 7, 2018

Follow-up to #1255 aligning with the expectation that the external signing process connects to the node. The SocketClient will block on start until one connection has been established, support for multiple signers connected simultaneously is a planned future extension.

  • SocketClient accepts connection
  • PrivValSocketServer renamed to RemoteSigner
  • extend tests

@xla xla added the T:validator Type: Validator related label Mar 7, 2018
@xla xla self-assigned this Mar 7, 2018
@xla xla requested review from ebuchman, melekes and odeke-em March 7, 2018 01:08
@codecov-io
Copy link

codecov-io commented Mar 7, 2018

Codecov Report

Merging #1286 into develop will decrease coverage by 0.05%.
The diff coverage is 67.18%.

@@             Coverage Diff             @@
##           develop    #1286      +/-   ##
===========================================
- Coverage    60.58%   60.53%   -0.06%     
===========================================
  Files          112      112              
  Lines        10863    10902      +39     
===========================================
+ Hits          6581     6599      +18     
- Misses        3644     3657      +13     
- Partials       638      646       +8
Impacted Files Coverage Δ
types/priv_validator/socket.go 67.9% <67.18%> (+3.68%) ⬆️
consensus/state.go 77.26% <0%> (-1.09%) ⬇️
consensus/reactor.go 71.97% <0%> (-0.86%) ⬇️
blockchain/pool.go 69.64% <0%> (-0.72%) ⬇️
p2p/peer.go 63.38% <0%> (ø) ⬆️


// OnStart implements cmn.Service.
func (sc *SocketClient) OnStart() error {
if err := sc.BaseService.OnStart(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseService.OnStart is empty and can be removed


RETRY_LOOP:
for retries > 0 {
if retries != defaultDialRetries {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a comment like sleep if it's not our first retry

@xla xla force-pushed the feature/xla-priv-val-invert-dial branch from 5dc1561 to 5897817 Compare March 7, 2018 11:36
Follow-up to #1255 aligning with the expectation that the external
signing process connects to the node. The SocketClient will block on
start until one connection has been established, support for multiple
signers connected simultaneously is a planned future extension.

* SocketClient accepts connection
* PrivValSocketServer renamed to RemoteSigner
* extend tests
@xla xla mentioned this pull request Mar 7, 2018
7 tasks
func (sc *SocketClient) OnStart() error {
if err := sc.BaseService.OnStart(); err != nil {
return err
if sc.listener == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont think we need this check.

}

continue RETRY_LOOP
if sc.privKey != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets require the privKey always :)

return
}

connc <- conn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we include a way to exit this routine if the timeout triggerS ?

for {
conn, err := pvss.listener.Accept()
func (rs *RemoteSigner) connect() (net.Conn, error) {
retries := defaultDialRetries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use rs.connRetries

retries := defaultDialRetries

RETRY_LOOP:
for retries > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets put the retries := and the retries -- in the one liner

RETRY_LOOP:
for retries > 0 {
// Don't sleep if it is the first retry.
if retries != defaultDialRetries {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rs.connRetries


if pvss.privKey != nil {
conn, err = p2pconn.MakeSecretConnection(conn, pvss.privKey.Wrap())
if rs.privKey != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also probably want to authenticate. ie. we should be dialing a ID@host:port and then after the secret connection is setup, check that the ID (ie. hash of the remote pubkey) of the connection matches the ID we dialed (see how p2p does it)

@ebuchman ebuchman merged commit cd2ba4a into develop Mar 12, 2018
@ebuchman ebuchman deleted the feature/xla-priv-val-invert-dial branch March 12, 2018 15:49
xla added a commit that referenced this pull request Mar 14, 2018
Follow-up to feedback from #1286, this change simplifies the connection
handling in the SocketClient and makes the communication via TCP more
robust. It introduces the tcpTimeoutListener to encapsulate accept and
i/o timeout handling as well as connection keep-alive, this type could
likely be upgraded to handle more fine-grained tuning of the tcp stack
(linger, nodelay, etc.) according to the properties we desire. The same
methods should be applied to the RemoteSigner which will be overhauled
when the priv_val_server is fleshed out.

* require private key
* simplify connect logic
* break out conn upgrades to tcpTimeoutListener
* extend test coverage and simplify component setup
xla added a commit that referenced this pull request Mar 15, 2018
Follow-up to feedback from #1286, this change simplifies the connection
handling in the SocketClient and makes the communication via TCP more
robust. It introduces the tcpTimeoutListener to encapsulate accept and
i/o timeout handling as well as connection keep-alive, this type could
likely be upgraded to handle more fine-grained tuning of the tcp stack
(linger, nodelay, etc.) according to the properties we desire. The same
methods should be applied to the RemoteSigner which will be overhauled
when the priv_val_server is fleshed out.

* require private key
* simplify connect logic
* break out conn upgrades to tcpTimeoutListener
* extend test coverage and simplify component setup
xla added a commit that referenced this pull request Mar 15, 2018
Follow-up to feedback from #1286, this change simplifies the connection
handling in the SocketClient and makes the communication via TCP more
robust. It introduces the tcpTimeoutListener to encapsulate accept and
i/o timeout handling as well as connection keep-alive, this type could
likely be upgraded to handle more fine-grained tuning of the tcp stack
(linger, nodelay, etc.) according to the properties we desire. The same
methods should be applied to the RemoteSigner which will be overhauled
when the priv_val_server is fleshed out.

* require private key
* simplify connect logic
* break out conn upgrades to tcpTimeoutListener
* extend test coverage and simplify component setup
xla added a commit that referenced this pull request Mar 15, 2018
Follow-up to feedback from #1286, this change simplifies the connection
handling in the SocketClient and makes the communication via TCP more
robust. It introduces the tcpTimeoutListener to encapsulate accept and
i/o timeout handling as well as connection keep-alive, this type could
likely be upgraded to handle more fine-grained tuning of the tcp stack
(linger, nodelay, etc.) according to the properties we desire. The same
methods should be applied to the RemoteSigner which will be overhauled
when the priv_val_server is fleshed out.

* require private key
* simplify connect logic
* break out conn upgrades to tcpTimeoutListener
* extend test coverage and simplify component setup
melekes pushed a commit that referenced this pull request Mar 16, 2018
Follow-up to feedback from #1286, this change simplifies the connection
handling in the SocketClient and makes the communication via TCP more
robust. It introduces the tcpTimeoutListener to encapsulate accept and
i/o timeout handling as well as connection keep-alive, this type could
likely be upgraded to handle more fine-grained tuning of the tcp stack
(linger, nodelay, etc.) according to the properties we desire. The same
methods should be applied to the RemoteSigner which will be overhauled
when the priv_val_server is fleshed out.

* require private key
* simplify connect logic
* break out conn upgrades to tcpTimeoutListener
* extend test coverage and simplify component setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T:validator Type: Validator related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants