Skip to content

Priv val via sockets#1060

Closed
ebuchman wants to merge 11 commits intopriv_valfrom
priv_val_socket
Closed

Priv val via sockets#1060
ebuchman wants to merge 11 commits intopriv_valfrom
priv_val_socket

Conversation

@ebuchman
Copy link
Contributor

@ebuchman ebuchman commented Jan 5, 2018

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
Copy link
Contributor

xla commented Jan 5, 2018

@ebuchman Can take this on after wrapping up #1056

@adrianbrink
Copy link
Contributor

implements #819

}

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

@melekes melekes Jan 8, 2018

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

n := new(int)
r := bytes.NewReader(bz)
msgI := wire.ReadBinary(struct{ PrivValidatorSocketMsg }{}, r, 0, n, &err)
msg = msgI.(struct{ PrivValidatorSocketMsg }).PrivValidatorSocketMsg
Copy link
Contributor

@melekes melekes Jan 8, 2018

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?

pvss.Logger.Info("Accepted a new connection")

// read/write
for {
Copy link
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
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?

}

func (pvss *PrivValidatorSocketServer) OnStart() error {
if err := pvss.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. no need to call it.

}

func (pvss *PrivValidatorSocketServer) OnStop() {
pvss.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.

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

pvss.Logger.Error("Error closing listener", "err", err)
}

if err := pvss.conn.Close(); 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.

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
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
Copy link
Contributor

xla commented Jan 17, 2018

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
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
Copy link
Contributor

xla commented Feb 8, 2018

@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
Copy link
Contributor Author

ebuchman commented Feb 9, 2018

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.

5 participants