mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-28 03:46:33 +00:00
privval: add grpc (#5725)
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
This commit is contained in:
@@ -3,12 +3,14 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/tendermint/tendermint/abci/server"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
@@ -19,6 +21,8 @@ import (
|
||||
"github.com/tendermint/tendermint/node"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
grpcprivval "github.com/tendermint/tendermint/privval/grpc"
|
||||
privvalproto "github.com/tendermint/tendermint/proto/tendermint/privval"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
mcs "github.com/tendermint/tendermint/test/maverick/consensus"
|
||||
maverick "github.com/tendermint/tendermint/test/maverick/node"
|
||||
@@ -182,6 +186,24 @@ func startSigner(cfg *Config) error {
|
||||
dialFn = privval.DialTCPFn(address, 3*time.Second, ed25519.GenPrivKey())
|
||||
case "unix":
|
||||
dialFn = privval.DialUnixFn(address)
|
||||
case "grpc":
|
||||
lis, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ss := grpcprivval.NewSignerServer(cfg.ChainID, filePV, logger)
|
||||
|
||||
s := grpc.NewServer()
|
||||
|
||||
privvalproto.RegisterPrivValidatorAPIServer(s, ss)
|
||||
|
||||
go func() { // no need to clean up since we remove docker containers
|
||||
if err := s.Serve(lis); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("invalid privval protocol %q", protocol)
|
||||
}
|
||||
@@ -193,6 +215,7 @@ func startSigner(cfg *Config) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf("Remote signer connecting to %v", cfg.PrivValServer))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
nodeDatabases = uniformChoice{"goleveldb", "cleveldb", "rocksdb", "boltdb", "badgerdb"}
|
||||
// FIXME: grpc disabled due to https://github.com/tendermint/tendermint/issues/5439
|
||||
nodeABCIProtocols = uniformChoice{"unix", "tcp", "builtin"} // "grpc"
|
||||
nodePrivvalProtocols = uniformChoice{"file", "unix", "tcp"}
|
||||
nodePrivvalProtocols = uniformChoice{"file", "unix", "tcp", "grpc"}
|
||||
// FIXME: v2 disabled due to flake
|
||||
nodeFastSyncs = uniformChoice{"", "v0"} // "v2"
|
||||
nodeStateSyncs = uniformChoice{false, true}
|
||||
|
||||
@@ -51,7 +51,7 @@ seeds = ["seed01"]
|
||||
database = "badgerdb"
|
||||
# FIXME: should be grpc, disabled due to https://github.com/tendermint/tendermint/issues/5439
|
||||
#abci_protocol = "grpc"
|
||||
privval_protocol = "unix"
|
||||
privval_protocol = "grpc"
|
||||
persist_interval = 3
|
||||
retain_blocks = 3
|
||||
perturb = ["kill"]
|
||||
|
||||
@@ -78,8 +78,9 @@ type ManifestNode struct {
|
||||
ABCIProtocol string `toml:"abci_protocol"`
|
||||
|
||||
// PrivvalProtocol specifies the protocol used to sign consensus messages:
|
||||
// "file", "unix", or "tcp". Defaults to "file". For unix and tcp, the ABCI
|
||||
// "file", "unix", "tcp", or "grpc". Defaults to "file". For tcp and unix, the ABCI
|
||||
// application will launch a remote signer client in a separate goroutine.
|
||||
// For grpc the ABCI application will launch a remote signer server.
|
||||
// Only nodes with mode=validator will actually make use of this.
|
||||
PrivvalProtocol string `toml:"privval_protocol"`
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ func (n Node) Validate(testnet Testnet) error {
|
||||
return fmt.Errorf("invalid ABCI protocol setting %q", n.ABCIProtocol)
|
||||
}
|
||||
switch n.PrivvalProtocol {
|
||||
case ProtocolFile, ProtocolUNIX, ProtocolTCP:
|
||||
case ProtocolFile, ProtocolTCP, ProtocolGRPC, ProtocolUNIX:
|
||||
default:
|
||||
return fmt.Errorf("invalid privval protocol setting %q", n.PrivvalProtocol)
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ const (
|
||||
AppAddressUNIX = "unix:///var/run/app.sock"
|
||||
|
||||
PrivvalAddressTCP = "tcp://0.0.0.0:27559"
|
||||
PrivvalAddressGRPC = "grpc://0.0.0.0:27559"
|
||||
PrivvalAddressUNIX = "unix:///var/run/privval.sock"
|
||||
PrivvalKeyFile = "config/priv_validator_key.json"
|
||||
PrivvalStateFile = "data/priv_validator_state.json"
|
||||
@@ -265,6 +266,8 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) {
|
||||
cfg.PrivValidatorListenAddr = PrivvalAddressUNIX
|
||||
case e2e.ProtocolTCP:
|
||||
cfg.PrivValidatorListenAddr = PrivvalAddressTCP
|
||||
case e2e.ProtocolGRPC:
|
||||
cfg.PrivValidatorListenAddr = PrivvalAddressGRPC
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid privval protocol setting %q", node.PrivvalProtocol)
|
||||
}
|
||||
@@ -351,6 +354,10 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) {
|
||||
cfg["privval_server"] = PrivvalAddressUNIX
|
||||
cfg["privval_key"] = PrivvalKeyFile
|
||||
cfg["privval_state"] = PrivvalStateFile
|
||||
case e2e.ProtocolGRPC:
|
||||
cfg["privval_server"] = PrivvalAddressGRPC
|
||||
cfg["privval_key"] = PrivvalKeyFile
|
||||
cfg["privval_state"] = PrivvalStateFile
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected privval protocol setting %q", node.PrivvalProtocol)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user