mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Add customizable endpoints for the validator's REST API (#11633)
* WIP * Refactor to use iface.ValidatorClient instead of ethpb.BeaconNodeValidatorClient * Add mocks for iface.ValidatorClient * Fix mocks * Update update-mockgen.sh * Fix warnings * Fix config_setting syntax * Use custom build settings * WIP * WIP * WIP * WIP * WIP * WIP * Fix endpoint address and reduce timeout * Revert most e2e changes * Use e2e.TestParams.Ports.PrysmBeaconNodeGatewayPort * Fix BeaconRESTApiProviderFlag port * Revert e2e changes
This commit is contained in:
@@ -33,6 +33,7 @@ func accountsBackup(c *cli.Context) error {
|
||||
accounts.WithKeymanager(km),
|
||||
accounts.WithGRPCDialOpts(dialOpts),
|
||||
accounts.WithBeaconRPCProvider(c.String(flags.BeaconRPCProviderFlag.Name)),
|
||||
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
|
||||
accounts.WithGRPCHeaders(grpcHeaders),
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ func accountsDelete(c *cli.Context) error {
|
||||
accounts.WithKeymanager(km),
|
||||
accounts.WithGRPCDialOpts(dialOpts),
|
||||
accounts.WithBeaconRPCProvider(c.String(flags.BeaconRPCProviderFlag.Name)),
|
||||
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
|
||||
accounts.WithGRPCHeaders(grpcHeaders),
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ func AccountsExit(c *cli.Context, r io.Reader) error {
|
||||
accounts.WithKeymanager(km),
|
||||
accounts.WithGRPCDialOpts(dialOpts),
|
||||
accounts.WithBeaconRPCProvider(beaconRPCProvider),
|
||||
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
|
||||
accounts.WithGRPCHeaders(grpcHeaders),
|
||||
}
|
||||
// Get full set of public keys from the keymanager.
|
||||
|
||||
@@ -39,6 +39,7 @@ func accountsImport(c *cli.Context) error {
|
||||
accounts.WithKeymanager(km),
|
||||
accounts.WithGRPCDialOpts(dialOpts),
|
||||
accounts.WithBeaconRPCProvider(c.String(flags.BeaconRPCProviderFlag.Name)),
|
||||
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
|
||||
accounts.WithGRPCHeaders(grpcHeaders),
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ func accountsList(c *cli.Context) error {
|
||||
accounts.WithKeymanager(km),
|
||||
accounts.WithGRPCDialOpts(dialOpts),
|
||||
accounts.WithBeaconRPCProvider(c.String(flags.BeaconRPCProviderFlag.Name)),
|
||||
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
|
||||
accounts.WithGRPCHeaders(grpcHeaders),
|
||||
}
|
||||
if c.IsSet(flags.ShowDepositDataFlag.Name) {
|
||||
|
||||
@@ -5,7 +5,10 @@ go_library(
|
||||
srcs = [
|
||||
"flags.go",
|
||||
"interop.go",
|
||||
],
|
||||
] + select({
|
||||
"//validator/client/validator-client-factory:beacon_api_usage": ["beacon_api_flags.go"],
|
||||
"//conditions:default": ["grpc_flags.go"],
|
||||
}),
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/cmd/validator/flags",
|
||||
visibility = [
|
||||
"//cmd/prysmctl:__subpackages__",
|
||||
|
||||
8
cmd/validator/flags/beacon_api_flags.go
Normal file
8
cmd/validator/flags/beacon_api_flags.go
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build use_beacon_api
|
||||
// +build use_beacon_api
|
||||
|
||||
package flags
|
||||
|
||||
const (
|
||||
BuiltWithBeaconApi = true
|
||||
)
|
||||
@@ -40,6 +40,12 @@ var (
|
||||
Usage: "Beacon node RPC gateway provider endpoint",
|
||||
Value: "127.0.0.1:3500",
|
||||
}
|
||||
// BeaconRESTApiProviderFlag defines a beacon node REST API endpoint.
|
||||
BeaconRESTApiProviderFlag = &cli.StringFlag{
|
||||
Name: "beacon-rest-api-provider",
|
||||
Usage: "Beacon node REST API provider endpoint",
|
||||
Value: "http://127.0.0.1:3500",
|
||||
}
|
||||
// CertFlag defines a flag for the node's TLS certificate.
|
||||
CertFlag = &cli.StringFlag{
|
||||
Name: "tls-cert",
|
||||
|
||||
8
cmd/validator/flags/grpc_flags.go
Normal file
8
cmd/validator/flags/grpc_flags.go
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build !use_beacon_api
|
||||
// +build !use_beacon_api
|
||||
|
||||
package flags
|
||||
|
||||
const (
|
||||
BuiltWithBeaconApi = false
|
||||
)
|
||||
@@ -112,6 +112,11 @@ var appFlags = []cli.Flag{
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Append the Beacon REST API flags
|
||||
if flags.BuiltWithBeaconApi {
|
||||
appFlags = append(appFlags, flags.BeaconRESTApiProviderFlag)
|
||||
}
|
||||
|
||||
appFlags = cmd.WrapFlags(append(appFlags, features.ValidatorFlags...))
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,16 @@ var appHelpFlagGroups = []flagGroup{
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Append the Beacon REST API flags
|
||||
if flags.BuiltWithBeaconApi {
|
||||
for groupIndex := range appHelpFlagGroups {
|
||||
group := &appHelpFlagGroups[groupIndex]
|
||||
if group.Name == "validator" {
|
||||
group.Flags = append(group.Flags, flags.BeaconRESTApiProviderFlag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cli.AppHelpTemplate = appHelpTemplate
|
||||
|
||||
type helpData struct {
|
||||
|
||||
Reference in New Issue
Block a user