diff --git a/.gitignore b/.gitignore index 76f8a315..08d680eb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ main tmp/ build/ + +*.swp diff --git a/Makefile b/Makefile index af93dd45..53d9c3e6 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ test-e2e: proto-all: proto-gen proto-gen: - sh ./valrpc/protocgen.sh + ./proto/scripts/protocgen.sh .PHONY: proto-gen diff --git a/bbnclient/bbncontroller.go b/bbnclient/bbncontroller.go index 0bb2c9db..fdcc0e91 100644 --- a/bbnclient/bbncontroller.go +++ b/bbnclient/bbncontroller.go @@ -3,11 +3,11 @@ package babylonclient import ( "context" "fmt" + "github.com/babylonchain/btc-validator/valcfg" "github.com/babylonchain/babylon/types" btcstakingtypes "github.com/babylonchain/babylon/x/btcstaking/types" "github.com/babylonchain/rpc-client/client" - bbncfg "github.com/babylonchain/rpc-client/config" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/sirupsen/logrus" ) @@ -20,11 +20,17 @@ type BabylonController struct { } func NewBabylonController( - cfg *bbncfg.BabylonConfig, + cfg *valcfg.BBNConfig, logger *logrus.Logger, ) (*BabylonController, error) { + babylonConfig := valcfg.BBNConfigToBabylonConfig(cfg) + + // TODO should be validated earlier + if err := babylonConfig.Validate(); err != nil { + return nil, err + } // create a Tendermint/Cosmos client for Babylon - rpcClient, err := client.New(cfg) + rpcClient, err := client.New(&babylonConfig) if err != nil { return nil, fmt.Errorf("unable to create Babylon rpc client: %w", err) } diff --git a/cmd/valcli/daemoncmd.go b/cmd/valcli/daemoncmd.go index a7be329d..a644ed6d 100644 --- a/cmd/valcli/daemoncmd.go +++ b/cmd/valcli/daemoncmd.go @@ -14,7 +14,7 @@ var daemonCommands = []cli.Command{ { Name: "daemon", ShortName: "dn", - Usage: "More advanced commands which require validator daemon to be running", + Usage: "More advanced commands which require validator daemon to be running.", Category: "Daemon commands", Subcommands: []cli.Command{ getDaemonInfo, @@ -33,11 +33,11 @@ var ( var getDaemonInfo = cli.Command{ Name: "get-info", ShortName: "gi", - Usage: "Get information of the running daemon", + Usage: "Get information of the running daemon.", Flags: []cli.Flag{ cli.StringFlag{ Name: validatorDaemonAddressFlag, - Usage: "full address of the validator daemon in format tcp://:", + Usage: "Full address of the validator daemon in format tcp://:", Value: defaultValidatorDaemonAddress, }, }, diff --git a/cmd/valcli/main.go b/cmd/valcli/main.go index b13014d3..277e003e 100644 --- a/cmd/valcli/main.go +++ b/cmd/valcli/main.go @@ -34,21 +34,21 @@ const ( func main() { app := cli.NewApp() app.Name = "valcli" - app.Usage = "control plane for your BTC Validator Daemon (vald)" + app.Usage = "Control plane for the Bitcoin Validator Daemon (vald)." app.Flags = []cli.Flag{ cli.StringFlag{ Name: dbTypeFlag, - Usage: "the type of the database", + Usage: "The type of the database", Value: valcfg.DefaultBackend, }, cli.StringFlag{ Name: dbPathFlag, - Usage: "the path of the database file", + Usage: "The path of the database file", Value: valcfg.DefaultDBPath, }, cli.StringFlag{ Name: dbNameFlag, - Usage: "the name of the database bucket", + Usage: "The name of the database bucket", Value: valcfg.DefaultDBName, }, } diff --git a/cmd/valcli/validators.go b/cmd/valcli/validators.go index 16b8e0d3..16f52b0a 100644 --- a/cmd/valcli/validators.go +++ b/cmd/valcli/validators.go @@ -3,17 +3,14 @@ package main import ( "context" "fmt" - "os" - "path" - "github.com/cosmos/cosmos-sdk/client" "github.com/urfave/cli" "github.com/babylonchain/btc-validator/codec" + "github.com/babylonchain/btc-validator/proto" dc "github.com/babylonchain/btc-validator/service/client" "github.com/babylonchain/btc-validator/val" "github.com/babylonchain/btc-validator/valcfg" - "github.com/babylonchain/btc-validator/valrpc" ) const ( @@ -21,9 +18,7 @@ const ( keyringDirFlag = "keyring-dir" keyringBackendFlag = "keyring-backend" keyNameFlag = "key-name" -) -var ( defaultChainID = "test-chain" defaultKeyringBackend = "test" ) @@ -32,7 +27,7 @@ var validatorsCommands = []cli.Command{ { Name: "validators", ShortName: "vals", - Usage: "Control BTC validators.", + Usage: "Control Bitcoin validators.", Category: "Validators", Subcommands: []cli.Command{ createValidator, listValidators, importValidator, registerValidator, @@ -43,26 +38,26 @@ var validatorsCommands = []cli.Command{ var createValidator = cli.Command{ Name: "create-validator", ShortName: "cv", - Usage: "create a BTC validator object and save it in database", + Usage: "Create a Bitcoin validator object and save it in database.", Flags: []cli.Flag{ cli.StringFlag{ Name: chainIdFlag, - Usage: "the chainID of the Babylonchain", + Usage: "The chainID of the Babylonchain", Value: defaultChainID, }, cli.StringFlag{ Name: keyNameFlag, - Usage: "the unique name of the validator key", + Usage: "The unique name of the validator key", Required: true, }, cli.StringFlag{ Name: keyringBackendFlag, - Usage: "select keyring's backend (os|file|test)", + Usage: "Select keyring's backend (os|file|test)", Value: defaultKeyringBackend, }, cli.StringFlag{ Name: keyringDirFlag, - Usage: "the directory where the keyring is stored", + Usage: "The directory where the keyring is stored", }, }, Action: createVal, @@ -84,7 +79,7 @@ func createVal(ctx *cli.Context) error { } if krController.KeyNameTaken() { - return fmt.Errorf("the key name is taken") + return fmt.Errorf("the key name %s is taken", krController.GetKeyName()) } validator, err := krController.CreateBTCValidator() @@ -104,7 +99,7 @@ func createVal(ctx *cli.Context) error { return err } - printRespJSON(&valrpc.CreateValidatorResponse{ + printRespJSON(&proto.CreateValidatorResponse{ BabylonPk: validator.BabylonPk, BtcPk: validator.BtcPk, }) @@ -115,7 +110,7 @@ func createVal(ctx *cli.Context) error { var listValidators = cli.Command{ Name: "list-validators", ShortName: "ls", - Usage: "list validators stored in the database", + Usage: "List validators stored in the database.", Action: lsVal, } @@ -133,7 +128,7 @@ func lsVal(ctx *cli.Context) error { return err } - printRespJSON(&valrpc.QueryValidatorListResponse{Validators: valList}) + printRespJSON(&proto.QueryValidatorListResponse{Validators: valList}) return nil } @@ -141,7 +136,7 @@ func lsVal(ctx *cli.Context) error { var importValidator = cli.Command{ Name: "import-validator", ShortName: "iv", - Usage: "import a BTC validator object with given BTC and Babylon addresses", + Usage: "Import a Bitcoin validator object with given Bitcoin and Babylon addresses.", Flags: []cli.Flag{ // TODO: add flags }, @@ -155,12 +150,12 @@ func importVal(ctx *cli.Context) error { var registerValidator = cli.Command{ Name: "register-validator", ShortName: "rv", - Usage: "register a created BTC validator to Babylon, requiring the validator daemon running", + Usage: "Register a created Bitcoin validator to Babylon, requiring the validator daemon running.", UsageText: "register-validator [Babylon public key]", Flags: []cli.Flag{ cli.StringFlag{ Name: validatorDaemonAddressFlag, - Usage: "full address of the validator daemon in format tcp://:", + Usage: "Full address of the validator daemon in format tcp://:", Value: defaultValidatorDaemonAddress, }, }, @@ -205,16 +200,9 @@ func getValStoreFromCtx(ctx *cli.Context) (*val.ValidatorStore, error) { } func createClientCtx(ctx *cli.Context) (client.Context, error) { - var err error - var homeDir string - dir := ctx.String(keyringDirFlag) if dir == "" { - homeDir, err = os.UserHomeDir() - if err != nil { - return client.Context{}, err - } - dir = path.Join(homeDir, ".btc-validator") + dir = valcfg.DefaultValidatordDir } return client.Context{}. diff --git a/cmd/vald/main.go b/cmd/vald/main.go index 3d813c22..90d4c7d0 100644 --- a/cmd/vald/main.go +++ b/cmd/vald/main.go @@ -4,7 +4,6 @@ import ( "fmt" "os" - "github.com/babylonchain/rpc-client/config" "github.com/jessevdk/go-flags" "github.com/lightningnetwork/lnd/signal" @@ -35,8 +34,7 @@ func main() { } // TODO: use default babylon config for now - bbnCfg := config.DefaultBabylonConfig() - bbnClient, err := babylonclient.NewBabylonController(&bbnCfg, cfgLogger) + bbnClient, err := babylonclient.NewBabylonController(cfg.BabylonConfig, cfgLogger) if err != nil { cfgLogger.Errorf("failed to create Babylon rpc client: %v", err) os.Exit(1) diff --git a/go.mod b/go.mod index 5fe4687f..9c33930b 100644 --- a/go.mod +++ b/go.mod @@ -9,12 +9,11 @@ require ( github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cosmos/cosmos-sdk v0.47.2 github.com/cosmos/go-bip39 v1.0.0 - github.com/gogo/protobuf v1.3.3 + github.com/cosmos/gogoproto v1.4.10 github.com/golang/mock v1.6.0 github.com/jessevdk/go-flags v1.5.0 github.com/lightningnetwork/lnd v0.16.4-beta.rc1 github.com/sirupsen/logrus v1.9.3 - github.com/strangelove-ventures/lens v0.5.2-0.20230418174104-735a2a0195eb github.com/stretchr/testify v1.8.4 github.com/urfave/cli v1.22.14 go.etcd.io/bbolt v1.3.7 @@ -78,7 +77,6 @@ require ( github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.2 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/gogoproto v1.4.10 // indirect github.com/cosmos/iavl v0.20.0 // indirect github.com/cosmos/ibc-go/v7 v7.0.1 // indirect github.com/cosmos/ics23/go v0.9.1-0.20221207100636-b1abd8678aab // indirect @@ -112,6 +110,7 @@ require ( github.com/go-stack/stack v1.8.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect + github.com/gogo/protobuf v1.3.3 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect github.com/golang/glog v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -224,6 +223,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.15.0 // indirect + github.com/strangelove-ventures/lens v0.5.2-0.20230418174104-735a2a0195eb // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/supranational/blst v0.3.8 // indirect diff --git a/valrpc/.clang-format b/proto/.clang-format similarity index 100% rename from valrpc/.clang-format rename to proto/.clang-format diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml new file mode 100644 index 00000000..7461833c --- /dev/null +++ b/proto/buf.gen.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - plugin: go + out: . + opt: paths=source_relative + - name: go-grpc + out: . + opt: paths=source_relative diff --git a/proto/buf.lock b/proto/buf.lock new file mode 100644 index 00000000..a7016bb1 --- /dev/null +++ b/proto/buf.lock @@ -0,0 +1,13 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: gogo + repository: protobuf + commit: 4df00b267f944190a229ce3695781e99 + digest: shake256:de60e0534d11dfd7a1817909618e847e15d4ab6f5cc6d71154a9735af651c7bda2232b33f3fb6a4daf23f64a3fe80270e99d42d77c551bb9a69ab5dc48ec2e04 + - remote: buf.build + owner: googleapis + repository: googleapis + commit: 8d7204855ec14631a499bd7393ce1970 + digest: shake256:40bf4112960cad01281930beed85829910768e32e80e986791596853eccd42c0cbd9d96690b918f658020d2d427e16f8b6514e2ac7f4a10306fd32e77be44329 diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 00000000..94e821ae --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,26 @@ +version: v1 +name: buf.build/babylonchain/btc-validator +deps: + - buf.build/googleapis/googleapis:8d7204855ec14631a499bd7393ce1970 + - buf.build/gogo/protobuf:b03c65ea87cdc3521ede29f62fe3ce239267c1bc +breaking: + use: + - FILE +lint: + use: + - DEFAULT + - COMMENTS + - FILE_LOWER_SNAKE_CASE + - COMMENT_MESSAGE + - COMMENT_ENUM_VALUE + - COMMENT_ENUM + - COMMENT_RPC + - COMMENT_ONEOF + except: + - UNARY_RPC + - COMMENT_FIELD + - SERVICE_SUFFIX + - PACKAGE_VERSION_SUFFIX + - RPC_REQUEST_STANDARD_NAME + - ENUM_VALUE_PREFIX + - ENUM_ZERO_VALUE_SUFFIX diff --git a/proto/scripts/protocgen.sh b/proto/scripts/protocgen.sh new file mode 100755 index 00000000..0abf8d40 --- /dev/null +++ b/proto/scripts/protocgen.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -eo pipefail + +cd proto +buf mod update +buf generate . +cd .. diff --git a/valrpc/validators.pb.go b/proto/validators.pb.go similarity index 68% rename from valrpc/validators.pb.go rename to proto/validators.pb.go index f10a93c4..fc809aac 100644 --- a/valrpc/validators.pb.go +++ b/proto/validators.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.3 +// protoc-gen-go v1.28.0 +// protoc (unknown) // source: validators.proto -package valrpc +package proto import ( _ "github.com/gogo/protobuf/gogoproto" @@ -23,19 +23,18 @@ const ( // ValidatorStatus is the status of a BTC validator // a Validator object has 4 states: -// - Created - created and managed by validator client, not registered to -// babylon yet -// - Registered - created and registered to Babylon, but not voting yet (No -// delegated stake) -// - Active - created and registered to Babylon with stake to vote -// - Inactive - created and registered to Babylon with no stake to vote. -// Validator was already active. -// +// - Created - created and managed by validator client, not registered to +// babylon yet +// - Registered - created and registered to Babylon, but not voting yet (No +// delegated stake) +// - Active - created and registered to Babylon with stake to vote +// - Inactive - created and registered to Babylon with no stake to vote. +// Validator was already active. // Valid State Transactions: -// - Created -> Registered -// - Registered -> Active -// - Active -> Inactive -// - Inactive -> Active +// - Created -> Registered +// - Registered -> Active +// - Active -> Inactive +// - Inactive -> Active type ValidatorStatus int32 const ( @@ -557,10 +556,10 @@ type Validator struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // TODO: will use cosmos-sdk types to replace this + // TODO: Use Babylon types to replace this // babylon_pk is the Babylon secp256k1 PK of this BTC validator BabylonPk []byte `protobuf:"bytes,1,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,omitempty"` - // TODO: will use btcstking types to replace this + // TODO: Use Babylon types to replace this // btc_pk is the BTC secp256k1 PK of the validator encoded in BIP-340 spec BtcPk []byte `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3" json:"btc_pk,omitempty"` // pop is the proof of possession of babylon_pk and btc_pk @@ -574,7 +573,7 @@ type Validator struct { // to which the validator committed a randomness pair LastCommittedHeight uint64 `protobuf:"varint,6,opt,name=last_committed_height,json=lastCommittedHeight,proto3" json:"last_committed_height,omitempty"` // status defines the current validator status - Status ValidatorStatus `protobuf:"varint,7,opt,name=status,proto3,enum=valrpc.ValidatorStatus" json:"status,omitempty"` + Status ValidatorStatus `protobuf:"varint,7,opt,name=status,proto3,enum=proto.ValidatorStatus" json:"status,omitempty"` } func (x *Validator) Reset() { @@ -828,116 +827,118 @@ var File_validators_proto protoreflect.FileDescriptor var file_validators_proto_rawDesc = []byte{ 0x0a, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x06, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x1a, 0x2d, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, - 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x10, 0x0a, 0x0e, 0x47, 0x65, 0x74, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2b, 0x0a, 0x0f, 0x47, - 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x22, 0x4f, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, - 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x70, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x50, 0x6b, 0x12, 0x15, 0x0a, 0x06, - 0x62, 0x74, 0x63, 0x5f, 0x70, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x74, - 0x63, 0x50, 0x6b, 0x22, 0x39, 0x0a, 0x18, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x70, 0x6b, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x50, 0x6b, 0x22, 0x34, - 0x0a, 0x19, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x74, - 0x78, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x74, 0x78, - 0x48, 0x61, 0x73, 0x68, 0x22, 0x36, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, - 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x70, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x50, 0x6b, 0x22, 0x49, 0x0a, 0x16, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x61, 0x6c, 0x72, - 0x70, 0x63, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x09, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x1b, 0x0a, 0x19, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x4f, 0x0a, 0x1a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x31, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0x9a, 0x02, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x70, + 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x10, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x2b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x18, + 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4f, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x70, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x50, 0x6b, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x74, 0x63, 0x5f, 0x70, 0x6b, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x62, 0x74, 0x63, 0x50, 0x6b, 0x12, 0x2b, 0x0a, 0x03, 0x70, 0x6f, 0x70, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, - 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x03, 0x70, 0x6f, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x64, 0x5f, - 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x6c, 0x61, - 0x73, 0x74, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x32, 0x0a, - 0x15, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x5f, - 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x6c, 0x61, - 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x17, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x22, 0x4d, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x66, 0x50, 0x6f, 0x73, - 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x61, 0x62, 0x79, 0x6c, - 0x6f, 0x6e, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x62, 0x61, - 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x53, 0x69, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x62, 0x74, 0x63, 0x5f, - 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x62, 0x74, 0x63, 0x53, 0x69, - 0x67, 0x22, 0x47, 0x0a, 0x0f, 0x53, 0x63, 0x68, 0x6e, 0x6f, 0x72, 0x72, 0x52, 0x61, 0x6e, 0x64, - 0x50, 0x61, 0x69, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x75, 0x62, 0x5f, 0x72, 0x61, 0x6e, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x75, 0x62, 0x52, 0x61, 0x6e, 0x64, 0x12, - 0x19, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x07, 0x73, 0x65, 0x63, 0x52, 0x61, 0x6e, 0x64, 0x22, 0x40, 0x0a, 0x11, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x52, 0x61, 0x6e, 0x64, 0x50, 0x61, 0x69, 0x72, 0x12, - 0x2b, 0x0a, 0x04, 0x70, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, - 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x63, 0x68, 0x6e, 0x6f, 0x72, 0x72, 0x52, 0x61, - 0x6e, 0x64, 0x50, 0x61, 0x69, 0x72, 0x52, 0x04, 0x70, 0x61, 0x69, 0x72, 0x2a, 0xc9, 0x01, 0x0a, - 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x29, 0x0a, 0x18, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, - 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x10, 0x00, 0x1a, 0x0b, - 0x8a, 0x9d, 0x20, 0x07, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2f, 0x0a, 0x1b, 0x56, - 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x10, 0x01, 0x1a, 0x0e, 0x8a, 0x9d, - 0x20, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x12, 0x27, 0x0a, 0x17, - 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, - 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x41, - 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x2b, 0x0a, 0x19, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, - 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x41, 0x43, 0x54, 0x49, - 0x56, 0x45, 0x10, 0x03, 0x1a, 0x0c, 0x8a, 0x9d, 0x20, 0x08, 0x49, 0x6e, 0x61, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x32, 0xa7, 0x03, 0x0a, 0x0d, 0x42, 0x74, 0x63, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x3a, 0x0a, 0x07, 0x47, 0x65, - 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x47, - 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, - 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1e, 0x2e, 0x76, 0x61, 0x6c, 0x72, - 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x76, 0x61, 0x6c, 0x72, - 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, - 0x20, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x28, 0x0c, 0x52, 0x05, 0x62, 0x74, 0x63, 0x50, 0x6b, 0x22, 0x39, 0x0a, 0x18, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, + 0x5f, 0x70, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, 0x79, 0x6c, + 0x6f, 0x6e, 0x50, 0x6b, 0x22, 0x34, 0x0a, 0x19, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x78, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x06, 0x74, 0x78, 0x48, 0x61, 0x73, 0x68, 0x22, 0x36, 0x0a, 0x15, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x70, + 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, + 0x50, 0x6b, 0x22, 0x48, 0x0a, 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x09, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x1b, 0x0a, 0x19, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4e, 0x0a, 0x1a, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0x98, 0x02, 0x0a, 0x09, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x62, 0x79, 0x6c, + 0x6f, 0x6e, 0x5f, 0x70, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x61, 0x62, + 0x79, 0x6c, 0x6f, 0x6e, 0x50, 0x6b, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x74, 0x63, 0x5f, 0x70, 0x6b, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x74, 0x63, 0x50, 0x6b, 0x12, 0x2a, 0x0a, + 0x03, 0x70, 0x6f, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x66, 0x50, 0x6f, 0x73, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x70, 0x6f, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x65, 0x79, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x76, 0x6f, 0x74, + 0x65, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x12, 0x32, 0x0a, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, + 0x65, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x13, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x48, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x12, 0x2e, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x22, 0x4d, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x66, 0x50, + 0x6f, 0x73, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x61, 0x62, + 0x79, 0x6c, 0x6f, 0x6e, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, + 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x53, 0x69, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x62, 0x74, + 0x63, 0x5f, 0x73, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x62, 0x74, 0x63, + 0x53, 0x69, 0x67, 0x22, 0x47, 0x0a, 0x0f, 0x53, 0x63, 0x68, 0x6e, 0x6f, 0x72, 0x72, 0x52, 0x61, + 0x6e, 0x64, 0x50, 0x61, 0x69, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x75, 0x62, 0x5f, 0x72, 0x61, + 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x75, 0x62, 0x52, 0x61, 0x6e, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x73, 0x65, 0x63, 0x52, 0x61, 0x6e, 0x64, 0x22, 0x3f, 0x0a, 0x11, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x52, 0x61, 0x6e, 0x64, 0x50, 0x61, 0x69, + 0x72, 0x12, 0x2a, 0x0a, 0x04, 0x70, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x63, 0x68, 0x6e, 0x6f, 0x72, 0x72, 0x52, + 0x61, 0x6e, 0x64, 0x50, 0x61, 0x69, 0x72, 0x52, 0x04, 0x70, 0x61, 0x69, 0x72, 0x2a, 0x8d, 0x02, + 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x3a, 0x0a, 0x18, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x10, 0x00, 0x1a, + 0x1c, 0x8a, 0x9d, 0x20, 0x18, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x12, 0x40, 0x0a, + 0x1b, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, + 0x53, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x10, 0x01, 0x1a, 0x1f, + 0x8a, 0x9d, 0x20, 0x1b, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x45, 0x44, 0x12, + 0x38, 0x0a, 0x17, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, + 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x1a, 0x1b, 0x8a, 0x9d, + 0x20, 0x17, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x55, 0x53, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x12, 0x3c, 0x0a, 0x19, 0x56, 0x41, 0x4c, + 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, + 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x03, 0x1a, 0x1d, 0x8a, 0x9d, 0x20, 0x19, 0x56, 0x41, + 0x4c, 0x49, 0x44, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, + 0x4e, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x32, 0x9d, 0x03, + 0x0a, 0x0d, 0x42, 0x74, 0x63, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, + 0x38, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x11, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x0e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x21, 0x2e, 0x76, 0x61, - 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, - 0x2e, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x62, 0x74, - 0x63, 0x2d, 0x76, 0x61, 0x6c, 0x2f, 0x76, 0x61, 0x6c, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, + 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x0e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x59, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, + 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x62, 0x79, + 0x6c, 0x6f, 0x6e, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x62, 0x74, 0x63, 0x2d, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -956,38 +957,38 @@ func file_validators_proto_rawDescGZIP() []byte { var file_validators_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_validators_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_validators_proto_goTypes = []interface{}{ - (ValidatorStatus)(0), // 0: valrpc.ValidatorStatus - (*GetInfoRequest)(nil), // 1: valrpc.GetInfoRequest - (*GetInfoResponse)(nil), // 2: valrpc.GetInfoResponse - (*CreateValidatorRequest)(nil), // 3: valrpc.CreateValidatorRequest - (*CreateValidatorResponse)(nil), // 4: valrpc.CreateValidatorResponse - (*RegisterValidatorRequest)(nil), // 5: valrpc.RegisterValidatorRequest - (*RegisterValidatorResponse)(nil), // 6: valrpc.RegisterValidatorResponse - (*QueryValidatorRequest)(nil), // 7: valrpc.QueryValidatorRequest - (*QueryValidatorResponse)(nil), // 8: valrpc.QueryValidatorResponse - (*QueryValidatorListRequest)(nil), // 9: valrpc.QueryValidatorListRequest - (*QueryValidatorListResponse)(nil), // 10: valrpc.QueryValidatorListResponse - (*Validator)(nil), // 11: valrpc.Validator - (*ProofOfPossession)(nil), // 12: valrpc.ProofOfPossession - (*SchnorrRandPair)(nil), // 13: valrpc.SchnorrRandPair - (*CommittedRandPair)(nil), // 14: valrpc.CommittedRandPair + (ValidatorStatus)(0), // 0: proto.ValidatorStatus + (*GetInfoRequest)(nil), // 1: proto.GetInfoRequest + (*GetInfoResponse)(nil), // 2: proto.GetInfoResponse + (*CreateValidatorRequest)(nil), // 3: proto.CreateValidatorRequest + (*CreateValidatorResponse)(nil), // 4: proto.CreateValidatorResponse + (*RegisterValidatorRequest)(nil), // 5: proto.RegisterValidatorRequest + (*RegisterValidatorResponse)(nil), // 6: proto.RegisterValidatorResponse + (*QueryValidatorRequest)(nil), // 7: proto.QueryValidatorRequest + (*QueryValidatorResponse)(nil), // 8: proto.QueryValidatorResponse + (*QueryValidatorListRequest)(nil), // 9: proto.QueryValidatorListRequest + (*QueryValidatorListResponse)(nil), // 10: proto.QueryValidatorListResponse + (*Validator)(nil), // 11: proto.Validator + (*ProofOfPossession)(nil), // 12: proto.ProofOfPossession + (*SchnorrRandPair)(nil), // 13: proto.SchnorrRandPair + (*CommittedRandPair)(nil), // 14: proto.CommittedRandPair } var file_validators_proto_depIdxs = []int32{ - 11, // 0: valrpc.QueryValidatorResponse.validator:type_name -> valrpc.Validator - 11, // 1: valrpc.QueryValidatorListResponse.validators:type_name -> valrpc.Validator - 12, // 2: valrpc.Validator.pop:type_name -> valrpc.ProofOfPossession - 0, // 3: valrpc.Validator.status:type_name -> valrpc.ValidatorStatus - 13, // 4: valrpc.CommittedRandPair.pair:type_name -> valrpc.SchnorrRandPair - 1, // 5: valrpc.BtcValidators.GetInfo:input_type -> valrpc.GetInfoRequest - 3, // 6: valrpc.BtcValidators.CreateValidator:input_type -> valrpc.CreateValidatorRequest - 5, // 7: valrpc.BtcValidators.RegisterValidator:input_type -> valrpc.RegisterValidatorRequest - 7, // 8: valrpc.BtcValidators.QueryValidator:input_type -> valrpc.QueryValidatorRequest - 9, // 9: valrpc.BtcValidators.QueryValidatorList:input_type -> valrpc.QueryValidatorListRequest - 2, // 10: valrpc.BtcValidators.GetInfo:output_type -> valrpc.GetInfoResponse - 4, // 11: valrpc.BtcValidators.CreateValidator:output_type -> valrpc.CreateValidatorResponse - 6, // 12: valrpc.BtcValidators.RegisterValidator:output_type -> valrpc.RegisterValidatorResponse - 8, // 13: valrpc.BtcValidators.QueryValidator:output_type -> valrpc.QueryValidatorResponse - 10, // 14: valrpc.BtcValidators.QueryValidatorList:output_type -> valrpc.QueryValidatorListResponse + 11, // 0: proto.QueryValidatorResponse.validator:type_name -> proto.Validator + 11, // 1: proto.QueryValidatorListResponse.validators:type_name -> proto.Validator + 12, // 2: proto.Validator.pop:type_name -> proto.ProofOfPossession + 0, // 3: proto.Validator.status:type_name -> proto.ValidatorStatus + 13, // 4: proto.CommittedRandPair.pair:type_name -> proto.SchnorrRandPair + 1, // 5: proto.BtcValidators.GetInfo:input_type -> proto.GetInfoRequest + 3, // 6: proto.BtcValidators.CreateValidator:input_type -> proto.CreateValidatorRequest + 5, // 7: proto.BtcValidators.RegisterValidator:input_type -> proto.RegisterValidatorRequest + 7, // 8: proto.BtcValidators.QueryValidator:input_type -> proto.QueryValidatorRequest + 9, // 9: proto.BtcValidators.QueryValidatorList:input_type -> proto.QueryValidatorListRequest + 2, // 10: proto.BtcValidators.GetInfo:output_type -> proto.GetInfoResponse + 4, // 11: proto.BtcValidators.CreateValidator:output_type -> proto.CreateValidatorResponse + 6, // 12: proto.BtcValidators.RegisterValidator:output_type -> proto.RegisterValidatorResponse + 8, // 13: proto.BtcValidators.QueryValidator:output_type -> proto.QueryValidatorResponse + 10, // 14: proto.BtcValidators.QueryValidatorList:output_type -> proto.QueryValidatorListResponse 10, // [10:15] is the sub-list for method output_type 5, // [5:10] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name diff --git a/valrpc/validators.proto b/proto/validators.proto similarity index 91% rename from valrpc/validators.proto rename to proto/validators.proto index a5f47a7e..ab04e89d 100644 --- a/valrpc/validators.proto +++ b/proto/validators.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package valrpc; +package proto; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/btc-val/valrpc"; +option go_package = "github.com/babylonchain/btc-validator/proto"; service BtcValidators { // GetInfo returns the information of the daemon @@ -73,10 +73,10 @@ message QueryValidatorListResponse { } message Validator { - // TODO: will use cosmos-sdk types to replace this + // TODO: Use Babylon types to replace this // babylon_pk is the Babylon secp256k1 PK of this BTC validator bytes babylon_pk = 1; - // TODO: will use btcstking types to replace this + // TODO: Use Babylon types to replace this // btc_pk is the BTC secp256k1 PK of the validator encoded in BIP-340 spec bytes btc_pk = 2; // pop is the proof of possession of babylon_pk and btc_pk @@ -135,15 +135,15 @@ enum ValidatorStatus { // VALIDATOR_STATUS_CREATED defines a validator that is awaiting // registration - VALIDATOR_STATUS_CREATED = 0 [(gogoproto.enumvalue_customname) = "Created"]; + VALIDATOR_STATUS_CREATED = 0 [(gogoproto.enumvalue_customname) = "VALIDATOR_STATUS_CREATED"]; // VALIDATOR_STATUS_REGISTERED defines a validator that has been registered // to Babylon but has no delegated stake VALIDATOR_STATUS_REGISTERED = 1 - [(gogoproto.enumvalue_customname) = "Registered"]; + [(gogoproto.enumvalue_customname) = "VALIDATOR_STATUS_REGISTERED"]; // VALIDATOR_STATUS_ACTIVE defines a validator that is delegated to vote - VALIDATOR_STATUS_ACTIVE = 2 [(gogoproto.enumvalue_customname) = "Active"]; + VALIDATOR_STATUS_ACTIVE = 2 [(gogoproto.enumvalue_customname) = "VALIDATOR_STATUS_ACTIVE"]; // VALIDATOR_STATUS_INACTIVE defines a validator whose delegations are // reduced to zero VALIDATOR_STATUS_INACTIVE = 3 - [(gogoproto.enumvalue_customname) = "Inactive"]; + [(gogoproto.enumvalue_customname) = "VALIDATOR_STATUS_INACTIVE"]; } diff --git a/valrpc/validators_grpc.pb.go b/proto/validators_grpc.pb.go similarity index 95% rename from valrpc/validators_grpc.pb.go rename to proto/validators_grpc.pb.go index fbc2d483..a93719d7 100644 --- a/valrpc/validators_grpc.pb.go +++ b/proto/validators_grpc.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.3 +// - protoc (unknown) // source: validators.proto -package valrpc +package proto import ( context "context" @@ -19,11 +19,11 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - BtcValidators_GetInfo_FullMethodName = "/valrpc.BtcValidators/GetInfo" - BtcValidators_CreateValidator_FullMethodName = "/valrpc.BtcValidators/CreateValidator" - BtcValidators_RegisterValidator_FullMethodName = "/valrpc.BtcValidators/RegisterValidator" - BtcValidators_QueryValidator_FullMethodName = "/valrpc.BtcValidators/QueryValidator" - BtcValidators_QueryValidatorList_FullMethodName = "/valrpc.BtcValidators/QueryValidatorList" + BtcValidators_GetInfo_FullMethodName = "/proto.BtcValidators/GetInfo" + BtcValidators_CreateValidator_FullMethodName = "/proto.BtcValidators/CreateValidator" + BtcValidators_RegisterValidator_FullMethodName = "/proto.BtcValidators/RegisterValidator" + BtcValidators_QueryValidator_FullMethodName = "/proto.BtcValidators/QueryValidator" + BtcValidators_QueryValidatorList_FullMethodName = "/proto.BtcValidators/QueryValidatorList" ) // BtcValidatorsClient is the client API for BtcValidators service. @@ -240,7 +240,7 @@ func _BtcValidators_QueryValidatorList_Handler(srv interface{}, ctx context.Cont // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var BtcValidators_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "valrpc.BtcValidators", + ServiceName: "proto.BtcValidators", HandlerType: (*BtcValidatorsServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/service/client/rpcclient.go b/service/client/rpcclient.go index 7f688ec5..eba72592 100644 --- a/service/client/rpcclient.go +++ b/service/client/rpcclient.go @@ -7,11 +7,11 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "github.com/babylonchain/btc-validator/valrpc" + "github.com/babylonchain/btc-validator/proto" ) type ValidatorServiceGRpcClient struct { - client valrpc.BtcValidatorsClient + client proto.BtcValidatorsClient } func NewValidatorServiceGRpcClient(remoteAddr string) (*ValidatorServiceGRpcClient, func(), error) { @@ -25,12 +25,12 @@ func NewValidatorServiceGRpcClient(remoteAddr string) (*ValidatorServiceGRpcClie } return &ValidatorServiceGRpcClient{ - client: valrpc.NewBtcValidatorsClient(conn), + client: proto.NewBtcValidatorsClient(conn), }, cleanUp, nil } -func (c *ValidatorServiceGRpcClient) GetInfo(ctx context.Context) (*valrpc.GetInfoResponse, error) { - req := &valrpc.GetInfoRequest{} +func (c *ValidatorServiceGRpcClient) GetInfo(ctx context.Context) (*proto.GetInfoResponse, error) { + req := &proto.GetInfoRequest{} res, err := c.client.GetInfo(ctx, req) if err != nil { return nil, err @@ -39,8 +39,8 @@ func (c *ValidatorServiceGRpcClient) GetInfo(ctx context.Context) (*valrpc.GetIn return res, nil } -func (c *ValidatorServiceGRpcClient) RegisterValidator(ctx context.Context, bbnPkBytes []byte) (*valrpc.RegisterValidatorResponse, error) { - req := &valrpc.RegisterValidatorRequest{BabylonPk: bbnPkBytes} +func (c *ValidatorServiceGRpcClient) RegisterValidator(ctx context.Context, bbnPkBytes []byte) (*proto.RegisterValidatorResponse, error) { + req := &proto.RegisterValidatorRequest{BabylonPk: bbnPkBytes} res, err := c.client.RegisterValidator(ctx, req) if err != nil { return nil, err diff --git a/service/rpcserver.go b/service/rpcserver.go index 15d4c836..7b9f71eb 100644 --- a/service/rpcserver.go +++ b/service/rpcserver.go @@ -9,8 +9,8 @@ import ( "github.com/sirupsen/logrus" "google.golang.org/grpc" + "github.com/babylonchain/btc-validator/proto" "github.com/babylonchain/btc-validator/valcfg" - "github.com/babylonchain/btc-validator/valrpc" "github.com/babylonchain/btc-validator/version" ) @@ -20,7 +20,7 @@ type rpcServer struct { started int32 shutdown int32 - valrpc.UnimplementedBtcValidatorsServer + proto.UnimplementedBtcValidatorsServer interceptor signal.Interceptor @@ -82,44 +82,44 @@ func (r *rpcServer) Stop() error { // server. func (r *rpcServer) RegisterWithGrpcServer(grpcServer *grpc.Server) error { // Register the main RPC server. - valrpc.RegisterBtcValidatorsServer(grpcServer, r) + proto.RegisterBtcValidatorsServer(grpcServer, r) return nil } // GetInfo returns general information relating to the active daemon -func (r *rpcServer) GetInfo(context.Context, *valrpc.GetInfoRequest) (*valrpc.GetInfoResponse, error) { +func (r *rpcServer) GetInfo(context.Context, *proto.GetInfoRequest) (*proto.GetInfoResponse, error) { - return &valrpc.GetInfoResponse{ + return &proto.GetInfoResponse{ Version: version.Version(), }, nil } // CreateValidator generates a validator object and saves it in the database -func (r *rpcServer) CreateValidator(ctx context.Context, req *valrpc.CreateValidatorRequest) ( - *valrpc.CreateValidatorResponse, error) { +func (r *rpcServer) CreateValidator(ctx context.Context, req *proto.CreateValidatorRequest) ( + *proto.CreateValidatorResponse, error) { panic("implement me") } // RegisterValidator sends a transactions to Babylon to register a BTC validator -func (r *rpcServer) RegisterValidator(ctx context.Context, req *valrpc.RegisterValidatorRequest) ( - *valrpc.RegisterValidatorResponse, error) { +func (r *rpcServer) RegisterValidator(ctx context.Context, req *proto.RegisterValidatorRequest) ( + *proto.RegisterValidatorResponse, error) { txHash, err := r.app.RegisterValidator(req.BabylonPk) if err != nil { return nil, err } - return &valrpc.RegisterValidatorResponse{TxHash: txHash}, nil + return &proto.RegisterValidatorResponse{TxHash: txHash}, nil } // QueryValidator queries the information of the validator -func (r *rpcServer) QueryValidator(ctx context.Context, req *valrpc.QueryValidatorRequest) ( - *valrpc.QueryValidatorResponse, error) { +func (r *rpcServer) QueryValidator(ctx context.Context, req *proto.QueryValidatorRequest) ( + *proto.QueryValidatorResponse, error) { panic("implement me") } // QueryValidatorList queries the information of a list of validators -func (r *rpcServer) QueryValidatorList(ctx context.Context, req *valrpc.QueryValidatorListRequest) ( - *valrpc.QueryValidatorListResponse, error) { +func (r *rpcServer) QueryValidatorList(ctx context.Context, req *proto.QueryValidatorListRequest) ( + *proto.QueryValidatorListResponse, error) { panic("implement me") } diff --git a/testutil/datagen.go b/testutil/datagen.go index 50bbf4ce..00977466 100644 --- a/testutil/datagen.go +++ b/testutil/datagen.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/require" "github.com/babylonchain/btc-validator/codec" + "github.com/babylonchain/btc-validator/proto" "github.com/babylonchain/btc-validator/valcfg" - "github.com/babylonchain/btc-validator/valrpc" ) func GenRandomByteArray(r *rand.Rand, length uint64) []byte { @@ -38,7 +38,7 @@ func AddRandomSeedsToFuzzer(f *testing.F, num uint) { } } -func GenRandomValidator(r *rand.Rand, t *testing.T) *valrpc.Validator { +func GenRandomValidator(r *rand.Rand, t *testing.T) *proto.Validator { // generate BTC key pair btcSK, btcPK, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) @@ -54,12 +54,12 @@ func GenRandomValidator(r *rand.Rand, t *testing.T) *valrpc.Validator { err = pop.Verify(babylonPK, bip340PK) require.NoError(t, err) - return &valrpc.Validator{ + return &proto.Validator{ KeyName: GenRandomHexStr(r, 4), BabylonPk: babylonPK.Bytes(), BtcPk: bip340PK.MustMarshal(), // TODO use btcstaking types directly to avoid conversion - Pop: &valrpc.ProofOfPossession{ + Pop: &proto.ProofOfPossession{ BabylonSig: pop.BabylonSig, BtcSig: pop.BtcSig.MustMarshal(), }, diff --git a/tools/go.mod b/tools/go.mod index f2d8b739..f6c030c9 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,4 +1,4 @@ -module github.com/babylonchain/vigilante/tools +module github.com/babylonchain/btc-validator/tools go 1.20 diff --git a/tools/tools.go b/tools/tools.go index 21594468..213715c3 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,7 +1,7 @@ //go:build tools // +build tools -package vigilante +package btcvalidator import ( _ "github.com/babylonchain/babylon/cmd/babylond" diff --git a/val/keyringcontroller.go b/val/keyringcontroller.go index ac6d509a..8ec12d5c 100644 --- a/val/keyringcontroller.go +++ b/val/keyringcontroller.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/go-bip39" - "github.com/babylonchain/btc-validator/valrpc" + "github.com/babylonchain/btc-validator/proto" ) const ( @@ -62,7 +62,7 @@ func NewKeyringController(ctx client.Context, name string, keyringBackend string } // CreateBTCValidator creates a BTC validator object using the keyring -func (kc *KeyringController) CreateBTCValidator() (*valrpc.Validator, error) { +func (kc *KeyringController) CreateBTCValidator() (*proto.Validator, error) { // create babylon key pair stored in the keyring babylonPubKey, err := kc.createBabylonKeyPair() if err != nil { diff --git a/val/validator.go b/val/validator.go index 1f8efe1d..adb4d56b 100644 --- a/val/validator.go +++ b/val/validator.go @@ -5,20 +5,20 @@ import ( bstypes "github.com/babylonchain/babylon/x/btcstaking/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/babylonchain/btc-validator/valrpc" + "github.com/babylonchain/btc-validator/proto" ) -func NewValidator(babylonPk *secp256k1.PubKey, btcPk *types.BIP340PubKey, keyName string, pop *bstypes.ProofOfPossession) *valrpc.Validator { - return &valrpc.Validator{ +func NewValidator(babylonPk *secp256k1.PubKey, btcPk *types.BIP340PubKey, keyName string, pop *bstypes.ProofOfPossession) *proto.Validator { + return &proto.Validator{ // TODO change the validator to accept public key types directly KeyName: keyName, BabylonPk: babylonPk.Bytes(), BtcPk: btcPk.MustMarshal(), // TODO will use btcstaking types to avoid conversion - Pop: &valrpc.ProofOfPossession{ + Pop: &proto.ProofOfPossession{ BabylonSig: pop.BabylonSig, BtcSig: pop.BtcSig.MustMarshal(), }, - Status: valrpc.ValidatorStatus_VALIDATOR_STATUS_CREATED, + Status: proto.ValidatorStatus_VALIDATOR_STATUS_CREATED, } } diff --git a/val/valstore.go b/val/valstore.go index 8d0fed4a..3568a096 100644 --- a/val/valstore.go +++ b/val/valstore.go @@ -3,11 +3,11 @@ package val import ( "fmt" - "google.golang.org/protobuf/proto" + gproto "google.golang.org/protobuf/proto" + "github.com/babylonchain/btc-validator/proto" "github.com/babylonchain/btc-validator/store" "github.com/babylonchain/btc-validator/valcfg" - "github.com/babylonchain/btc-validator/valrpc" ) type ValidatorStore struct { @@ -23,9 +23,9 @@ func NewValidatorStore(dbcfg *valcfg.DatabaseConfig) (*ValidatorStore, error) { return &ValidatorStore{s: s}, nil } -func (vs *ValidatorStore) SaveValidator(val *valrpc.Validator) error { +func (vs *ValidatorStore) SaveValidator(val *proto.Validator) error { k := val.BabylonPk - v, err := proto.Marshal(val) + v, err := gproto.Marshal(val) if err != nil { return fmt.Errorf("failed to marshal the created validator object: %w", err) } @@ -37,14 +37,14 @@ func (vs *ValidatorStore) SaveValidator(val *valrpc.Validator) error { return nil } -func (vs *ValidatorStore) GetValidator(pk []byte) (*valrpc.Validator, error) { +func (vs *ValidatorStore) GetValidator(pk []byte) (*proto.Validator, error) { valsBytes, err := vs.s.Get(pk) if err != nil { return nil, err } - val := new(valrpc.Validator) - err = proto.Unmarshal(valsBytes, val) + val := new(proto.Validator) + err = gproto.Unmarshal(valsBytes, val) if err != nil { panic(fmt.Errorf("unable to unmarshal validator object: %w", err)) } @@ -52,16 +52,16 @@ func (vs *ValidatorStore) GetValidator(pk []byte) (*valrpc.Validator, error) { return val, nil } -func (vs *ValidatorStore) ListValidators() ([]*valrpc.Validator, error) { +func (vs *ValidatorStore) ListValidators() ([]*proto.Validator, error) { valsBytes, err := vs.s.List(nil) if err != nil { return nil, err } - valsList := make([]*valrpc.Validator, len(valsBytes)) + valsList := make([]*proto.Validator, len(valsBytes)) for i := 0; i < len(valsBytes); i++ { - val := new(valrpc.Validator) - err := proto.Unmarshal(valsBytes[i].Value, val) + val := new(proto.Validator) + err := gproto.Unmarshal(valsBytes[i].Value, val) if err != nil { panic(fmt.Errorf("failed to unmarshal validator from the database: %w", err)) } diff --git a/valcfg/babylon.go b/valcfg/babylon.go new file mode 100644 index 00000000..19b5b9a0 --- /dev/null +++ b/valcfg/babylon.go @@ -0,0 +1,68 @@ +package valcfg + +import ( + bbncfg "github.com/babylonchain/rpc-client/config" + "time" +) + +type BBNConfig struct { + Key string `long:"key" description:"name of the key to sign transactions with"` + ChainID string `long:"chain-id" description:"chain id of the chain to connect to"` + RPCAddr string `long:"rpc-address" description:"address of the rpc server to connect to"` + GRPCAddr string `long:"grpc-address" description:"address of the grpc server to connect to"` + AccountPrefix string `long:"acc-prefix" description:"account prefix to use for addresses"` + KeyringBackend string `long:"keyring-type" description:"type of keyring to use"` + GasAdjustment float64 `long:"gas-adjustment" description:"adjustment factor when using gas estimation"` + GasPrices string `long:"gas-prices" description:"comma separated minimum gas prices to accept for transactions"` + KeyDirectory string `long:"key-dir" description:"directory to store keys in"` + Debug bool `long:"debug" description:"flag to print debug output"` + Timeout time.Duration `long:"timeout" description:"client timeout when doing queries"` + BlockTimeout time.Duration `long:"block-timeout" description:"block timeout when waiting for block events"` + OutputFormat string `long:"output-format" description:"default output when printint responses"` + SignModeStr string `long:"sign-mode" description:"sign mode to use"` +} + +func DefaultBBNConfig() BBNConfig { + dc := bbncfg.DefaultBabylonConfig() + //fill up the config from dc config + return BBNConfig{ + Key: dc.Key, + ChainID: dc.ChainID, + RPCAddr: dc.RPCAddr, + GRPCAddr: dc.GRPCAddr, + AccountPrefix: dc.AccountPrefix, + KeyringBackend: dc.KeyringBackend, + GasAdjustment: dc.GasAdjustment, + GasPrices: dc.GasPrices, + KeyDirectory: DefaultValidatordDir, + Debug: dc.Debug, + Timeout: dc.Timeout, + // Setting this to relatively low value, out currnet babylon client (lens) will + // block for this amout of time to wait for transaction inclusion in block + BlockTimeout: 1 * time.Minute, + OutputFormat: dc.OutputFormat, + SignModeStr: dc.SignModeStr, + } +} + +func BBNConfigToBabylonConfig(bc *BBNConfig) bbncfg.BabylonConfig { + return bbncfg.BabylonConfig{ + Key: bc.Key, + ChainID: bc.ChainID, + RPCAddr: bc.RPCAddr, + GRPCAddr: bc.GRPCAddr, + AccountPrefix: bc.AccountPrefix, + KeyringBackend: bc.KeyringBackend, + GasAdjustment: bc.GasAdjustment, + GasPrices: bc.GasPrices, + KeyDirectory: bc.KeyDirectory, + Debug: bc.Debug, + Timeout: bc.Timeout, + BlockTimeout: bc.BlockTimeout, + OutputFormat: bc.OutputFormat, + SignModeStr: bc.SignModeStr, + // it is weird that this is client config, as this is address which is put into + // checkpoint, and has nothing to do with rpc client + SubmitterAddress: "", + } +} diff --git a/valcfg/config.go b/valcfg/config.go index efe77bec..29f86ae5 100644 --- a/valcfg/config.go +++ b/valcfg/config.go @@ -10,7 +10,6 @@ import ( "strconv" "strings" - bbncfg "github.com/babylonchain/rpc-client/config" "github.com/btcsuite/btcd/btcutil" "github.com/jessevdk/go-flags" "github.com/lightningnetwork/lnd/lncfg" @@ -38,7 +37,7 @@ var ( defaultLogDir = filepath.Join(DefaultValidatordDir, defaultLogDirname) ) -// Config is the main config for the tapd cli command +// Config is the main config for the validatord cli command type Config struct { DebugLevel string `long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, fatal}"` ValidatordDir string `long:"validatorddir" description:"The base directory that contains validator's data, logs, configuration file, etc."` @@ -47,24 +46,25 @@ type Config struct { LogDir string `long:"logdir" description:"Directory to log output."` DumpCfg bool `long:"dumpcfg" description:"If config file does not exist, create it with current settings"` - *DatabaseConfig `group:"databaseconfig" namespace:"databaserpcconfig"` + DatabaseConfig *DatabaseConfig `group:"databaseconfig" namespace:"databaserpcconfig"` - *bbncfg.BabylonConfig + BabylonConfig *BBNConfig `group:"babylon" namespace:"babylon"` - *GRpcServerConfig + GRpcServerConfig *GRpcServerConfig RpcListeners []net.Addr } func DefaultConfig() Config { - bbnCfg := bbncfg.DefaultBabylonConfig() + bbnCfg := DefaultBBNConfig() + dbCfg := DefaultDatabaseConfig() return Config{ ValidatordDir: DefaultValidatordDir, ConfigFile: DefaultConfigFile, DataDir: defaultDataDir, DebugLevel: defaultLogLevel, LogDir: defaultLogDir, - DatabaseConfig: DefaultDatabaseConfig(), + DatabaseConfig: &dbCfg, BabylonConfig: &bbnCfg, } } @@ -243,7 +243,7 @@ func ValidateConfig(cfg Config) (*Config, error) { // Create the validatord directory and all other subdirectories if they // don't already exist. This makes sure that directory trees are also - // created for files that point to outside the validatorddir. + // created for files that point to outside the validatord dir. dirs := []string{ validatordDir, cfg.DataDir, cfg.LogDir, } diff --git a/valcfg/dbcfg.go b/valcfg/dbcfg.go index 139aa0f8..6a42d6e1 100644 --- a/valcfg/dbcfg.go +++ b/valcfg/dbcfg.go @@ -35,8 +35,8 @@ func NewDatabaseConfig(backend string, path string, name string) (*DatabaseConfi }, nil } -func DefaultDatabaseConfig() *DatabaseConfig { - return &DatabaseConfig{ +func DefaultDatabaseConfig() DatabaseConfig { + return DatabaseConfig{ Backend: DefaultBackend, Path: DefaultDBPath, Name: DefaultDBName, diff --git a/valrpc/protocgen.sh b/valrpc/protocgen.sh deleted file mode 100755 index 24e1a93d..00000000 --- a/valrpc/protocgen.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -set -e - -# generate compiles the *.pb.go stubs from the *.proto files. -function generate() { - echo "Generating root gRPC server protos" - - PROTOS="validators.proto" - - # For each of the sub-servers, we then generate their protos, but a restricted - # set as they don't yet require REST proxies, or swagger docs. - for file in $PROTOS; do - DIRECTORY=$(dirname "${file}") - echo "Generating protos from ${file}, into ${DIRECTORY}" - - # Generate the protos. - protoc --go_out . --go_opt paths=source_relative \ - --go-grpc_out . --go-grpc_opt paths=source_relative \ - "${file}" --proto_path=$GOPATH/src/ --proto_path=. - done -} - -# format formats the *.proto files with the clang-format utility. -function format() { - find . -name "*.proto" -print0 | xargs -0 clang-format --style=file -i -} - -# Compile and format the taprpc package. -pushd valrpc -format -generate -popd - -if [[ "$COMPILE_MOBILE" == "1" ]]; then - pushd mobile - ./gen_bindings.sh $FALAFEL_VERSION - popd -fi