Skip to content

Priv val via sockets - #1060

Closed
ebuchman wants to merge 11 commits into
priv_valfrom
priv_val_socket
Closed

ebuchman wants to merge 11 commits into
priv_valfrom
priv_val_socket

Conversation

@ebuchman

@ebuchman ebuchman commented Jan 5, 2018

Copy link
Copy Markdown
Contributor

Support a socket client and server for the priv validator.

Dead simple synchronous server.

@xla @ethanfrey want to work on this ?

see #1044 for more context

@ebuchman
ebuchman requested a review from melekes as a code owner January 5, 2018 00:53
@xla

xla commented Jan 5, 2018

Copy link
Copy Markdown
Contributor

@ebuchman Can take this on after wrapping up #1056

@adrianbrink

Copy link
Copy Markdown
Contributor

implements #819

Comment thread types/priv_validator/socket.go Outdated
}

var n int
b = wire.ReadByteSlice(conn, 0, &n, &err) //XXX: no max

@melekes melekes Jan 8, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

check for err before calling decodeMsg

Comment thread types/priv_validator/socket.go Outdated
n := new(int)
r := bytes.NewReader(bz)
msgI := wire.ReadBinary(struct{ PrivValidatorSocketMsg }{}, r, 0, n, &err)
msg = msgI.(struct{ PrivValidatorSocketMsg }).PrivValidatorSocketMsg

@melekes melekes Jan 8, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is msgI guaranteed to be PrivValidatorSocketMsg in case of error?

Comment thread types/priv_validator/socket.go Outdated
pvss.Logger.Info("Accepted a new connection")

// read/write
for {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

only one connection at a time?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ebuchman Is one connection at a time by design, or should the server be able to hanlde multiple, if so are there any upper bounds we want to enforce, or any other limiting requirements?

Comment thread types/priv_validator/socket.go Outdated
}

func (pvss *PrivValidatorSocketServer) OnStart() error {
if err := pvss.BaseService.OnStart(); err != nil {

Copy link
Copy Markdown
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. no need to call it.

Comment thread types/priv_validator/socket.go Outdated
}

func (pvss *PrivValidatorSocketServer) OnStop() {
pvss.BaseService.OnStop()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BaseService#OnStop is empty. no need to call it.

Comment thread types/priv_validator/socket.go Outdated
pvss.Logger.Error("Error closing listener", "err", err)
}

if err := pvss.conn.Close(); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

check if pvss.conn != nil

@xla xla self-assigned this Jan 17, 2018
Alexander Simmerl added 2 commits January 17, 2018 17:12
* add comments to all public types
* fix comments to adhere to comment standards
@xla
xla force-pushed the priv_val_socket branch from ccf8cd9 to 6c63adf Compare January 17, 2018 16:22
@ebuchman

Copy link
Copy Markdown
Contributor Author

Thanks Alex.

Couple notes here.

  • Server should be on the Tendermint side. The signer should dial Tendermint.
  • Should be able to handle multiple connections, but let's cap it at something reasonable (maybe 3).
  • Let's use go-wire for serialization
  • Let's use the p2p.SecretConnection for authentication

@tarcieri is working on the signer itself in Rust

@xla

xla commented Jan 17, 2018

Copy link
Copy Markdown
Contributor

Thanks for follow-up.

Server should be on the Tendermint side. The signer should dial Tendermint.

Should the server exist as it's own binary under cmd/priv_validator or ultimately become a command of the tendermint cli?

Should be able to handle multiple connections, but let's cap it at something reasonable (maybe 3).

Seems like a good first baseline, maybe worth having it configurable.

@tarcieri is working on the signer itself in Rust

Going to sync with him to see if we can make each others work easier.

@ebuchman

Copy link
Copy Markdown
Contributor Author

Should the server exist as it's own binary under cmd/priv_validator or ultimately become a command of the tendermint cli?

No it should run in-process when tendermint node boots up. A tendermint node always needs a priv validator - either it's given a priv_validator.json with a private key direcetly (ie. useful for dev/testing) or it starts an in-process listener and waits to receive a connection from an external signing process

Going to sync with him to see if we can make each others work easier.

Sounds great

@xla

xla commented Feb 8, 2018

Copy link
Copy Markdown
Contributor

@ebuchman @melekes This is ready for review from my perspective. Tried to address all points.

When working with the protocol between client and server I was dearly missing some form of communicating errors, but I don't know how settle we are on the current protocol.

@melekes melekes changed the title wip: priv val via sockets Priv val via sockets Feb 9, 2018
@ebuchman

ebuchman commented Feb 9, 2018 •

Copy link
Copy Markdown
Contributor Author

Thanks Alex. I've moved this over to a fresh PR by rebasing on a fresh copy of the new validator code without integrating to the rest of the codebase. Let's take up review/discussion there

@ebuchman ebuchman closed this Feb 9, 2018
@xla
xla deleted the priv_val_socket branch September 18, 2018 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants