Skip to content

privVal: Improve SocketClient network code#1315

Merged
melekes merged 1 commit intodevelopfrom
1307/xla-prival-socket-followup
Mar 16, 2018
Merged

privVal: Improve SocketClient network code#1315
melekes merged 1 commit intodevelopfrom
1307/xla-prival-socket-followup

Conversation

@xla
Copy link
Contributor

@xla xla commented 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

Belongs to #1255 with the original issue being #1307

@xla xla added the T:validator Type: Validator related label Mar 14, 2018
@xla xla self-assigned this Mar 14, 2018
@xla xla requested review from ebuchman and melekes March 14, 2018 23:50
@xla xla force-pushed the 1307/xla-prival-socket-followup branch from 6f530a7 to 64a0717 Compare March 15, 2018 00:17
@codecov-io
Copy link

codecov-io commented Mar 15, 2018

Codecov Report

❗ No coverage uploaded for pull request base (develop@68e049d). Click here to learn what that means.
The diff coverage is 65.51%.

@@            Coverage Diff             @@
##             develop    #1315   +/-   ##
==========================================
  Coverage           ?   60.62%           
==========================================
  Files              ?      113           
  Lines              ?    10970           
  Branches           ?        0           
==========================================
  Hits               ?     6651           
  Misses             ?     3674           
  Partials           ?      645
Impacted Files Coverage Δ
node/node.go 63.27% <0%> (ø)
types/priv_validator/socket_tcp.go 60% <60%> (ø)
types/priv_validator/socket.go 72.87% <68.18%> (ø)

@xla xla force-pushed the 1307/xla-prival-socket-followup branch from 64a0717 to 90bc52a Compare March 15, 2018 02:58

// OnStop implements cmn.Service.
func (sc *SocketClient) OnStop() {
sc.BaseService.OnStop()
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed too

ErrConnWaitTimeout = errors.New("Error waiting for external connection")
ErrConnTimeout = errors.New("Error connection timed out")
ErrDialRetryMax = errors.New("dialed maximum retries")
ErrConnWaitTimeout = errors.New("waited for remote signer timed out")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe "waited for remote signer for too long" or smth else?


// tcpTimeoutListener wraps a *net.TCPListener to standardise protocol timeouts
// and potentially other tuning parameters.
// Implements net.Listener.
Copy link
Contributor

Choose a reason for hiding this comment

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

you can check that in compile time var _ net.Listener = (*tcpTimeoutListener)(nil)

period time.Duration
}

// tcpTimeoutListener wraps a *net.TCPListener to standardise protocol timeouts
Copy link
Contributor

Choose a reason for hiding this comment

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

why duplicate comment?


readyc <- struct{}{}
require.NoError(t, sc.Start())
defer sc.Stop()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove this and add a sleep somewhere

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 xla force-pushed the 1307/xla-prival-socket-followup branch from b1db841 to 6b380ee Compare March 15, 2018 18:26
@melekes melekes merged commit 9b9022f into develop Mar 16, 2018
@melekes melekes deleted the 1307/xla-prival-socket-followup branch March 16, 2018 12:32
cboh4 pushed a commit to scrtlabs/tendermint that referenced this pull request Apr 7, 2025
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergio Mena <sergio@informal.systems>
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.

3 participants