Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate privval gRPC server and provide a high-level pluggable default implementation #1134

Open
1 of 2 tasks
tomtau opened this issue May 26, 2022 · 4 comments · May be fixed by #1152
Open
1 of 2 tasks

generate privval gRPC server and provide a high-level pluggable default implementation #1134

tomtau opened this issue May 26, 2022 · 4 comments · May be fixed by #1152
Labels
enhancement New feature or request

Comments

@tomtau
Copy link
Contributor

tomtau commented May 26, 2022

Version(s) of tendermint-rs: v0.24.0-pre.2

Description

"privval" is an interface used by a Tendermint process (on validator nodes) to communicate with a signing backend (e.g. YubiHSM).
Previously, "privval" was over a custom socket protocol (implemented e.g. in tmkms) that leveraged Unix domain sockets or Tendermint P2P over TCP where Tendermint acted as a server, and a signing backend connected to it as a client.
In Tendermint 0.35, a new method for "privval" was introduced: the signer is a standard gRPC server/service, and Tendermint connects to it as a client.
In Tendermint 0.36, we expect the old "privval" custom socket protocol will be removed and only the gRPC-based "privval" interface will be provided.

Given these circumstances, I think it makes sense for tendermint-rs to support this interface via the following features:

  1. provide a "raw" service API definition by enabling build_server(true) in tonic_build, probably via a feature-flag (as not every usage of tendermint-proto needs it)
  2. provide a high-level wrapper over the raw service (likely in a new "tendermint-validator" crate) which should do the following:
  • provide a basic gRPC server construction options for tonic's Server (e.g. TLS)
  • do basic validation of requests:
  • return a cached public key or request a signature from a signing backend, and return corresponding responses
  • provide a simple interface that can be implemented by different signer backends

Here's a sketch of the potential interface:

#[async_trait]
pub trait SignerProvider {
    async fn sign(&self, signable_bytes: &[u8]) -> Result<Signature, Error>;
    async fn load_pubkey(&self) -> Result<PublicKey, Error>;
    async fn load_state(&self) -> Result<consensus::State, Error>;
    async fn persist_state(&mut self, new_state: &consensus::State) -> Result<(), Error>;
}

load_state and persist_state could potentially be in a separate trait, so that one can e.g. have a default file-based state persistence, but different signer backends are free to implement what makes sense in their context (e.g. write to CPU monotonic counters or an external service).

Definition of "done"

  • a feature-flag in tendermint-proto to generate gRPC server definitions (PrivValidatorApi, PrivValidatorApiServer...): tendermint-proto: Add a feature flag and generate gRPC server definitions #1137
  • a new "tendermint-validator" crate that provides a default PrivValidatorApi implementation (validation of types via domain types, basic double signing checking, chain-id verification) with basic common constructors or configurations (e.g. to load the certificates for TLS) and an extensible way to plug in different signer providers (with a software signer given as a sample implementation)

Related issues:

@tomtau tomtau added the enhancement New feature or request label May 26, 2022
@tomtau
Copy link
Contributor Author

tomtau commented May 26, 2022

CC @marbar3778 @tony-iqlusion

@tony-iqlusion
Copy link
Collaborator

This is definitely something I'm interested in, although there is presently no integration with tonic whatsoever in tendermint-proto, and nearly no gRPC support (aside from this).

tomtau added a commit to tomtau/tendermint-rs that referenced this issue May 30, 2022
…ions

- `proto-compiler` uses `tonic-build`
- tendermint-proto can be compiled with std for the `grpc` feature
(as required by the generated `tonic` code)
- the primary motivation is the new gRPC-based PrivVal interface
in Tendermint 0.35
(see informalsystems#1134)
tomtau added a commit to tomtau/tendermint-rs that referenced this issue Jun 10, 2022
a proposed follow-up after
informalsystems#1137
is merged.
ref: informalsystems#1134
@tomtau tomtau mentioned this issue Jun 10, 2022
5 tasks
thanethomson pushed a commit that referenced this issue Jun 11, 2022
…ions (#1137)

- `proto-compiler` uses `tonic-build`
- tendermint-proto can be compiled with std for the `grpc` feature
(as required by the generated `tonic` code)
- the primary motivation is the new gRPC-based PrivVal interface
in Tendermint 0.35
(see #1134)
tomtau added a commit to tomtau/tendermint-rs that referenced this issue Jun 30, 2022
@tomtau tomtau linked a pull request Jun 30, 2022 that will close this issue
5 tasks
@adizere
Copy link
Member

adizere commented Mar 14, 2023

The work here depends on cometbft/cometbft#476 right?

@tomtau
Copy link
Contributor Author

tomtau commented Mar 15, 2023

that's right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants