mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 07:03:58 -05:00
moving web flag to feature (#15382)
This commit is contained in:
3
changelog/james-prysm_move-web-flag.md
Normal file
3
changelog/james-prysm_move-web-flag.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Ignored
|
||||
|
||||
- Code cleanup by moving the web flag as a feature flag so that we don't need to pass a variable throughout the code base.
|
||||
@@ -325,12 +325,7 @@ var (
|
||||
Usage: "Skips the y/n confirmation userprompt for sending a deposit to the deposit contract.",
|
||||
Value: false,
|
||||
}
|
||||
// EnableWebFlag enables controlling the validator client via the Prysm web ui. This is a work in progress.
|
||||
EnableWebFlag = &cli.BoolFlag{
|
||||
Name: "web",
|
||||
Usage: "(Work in progress): Enables the web portal for the validator client.",
|
||||
Value: false,
|
||||
}
|
||||
|
||||
// SlashingProtectionExportDirFlag allows specifying the output directory
|
||||
// for a validator's slashing protection history.
|
||||
SlashingProtectionExportDirFlag = &cli.StringFlag{
|
||||
|
||||
@@ -72,7 +72,6 @@ var appFlags = []cli.Flag{
|
||||
flags.SlasherCertFlag,
|
||||
flags.WalletPasswordFileFlag,
|
||||
flags.WalletDirFlag,
|
||||
flags.EnableWebFlag,
|
||||
flags.GraffitiFileFlag,
|
||||
flags.EnableDistributed,
|
||||
flags.AuthTokenPathFlag,
|
||||
|
||||
@@ -136,7 +136,6 @@ var appHelpFlagGroups = []flagGroup{
|
||||
{
|
||||
Name: "misc",
|
||||
Flags: []cli.Flag{
|
||||
flags.EnableWebFlag,
|
||||
flags.DisablePenaltyRewardLogFlag,
|
||||
flags.DisableAccountMetricsFlag,
|
||||
flags.EnableDistributed,
|
||||
|
||||
@@ -51,6 +51,7 @@ type Flags struct {
|
||||
EnableBeaconRESTApi bool // EnableBeaconRESTApi enables experimental usage of the beacon REST API by the validator when querying a beacon node
|
||||
EnableExperimentalAttestationPool bool // EnableExperimentalAttestationPool enables an experimental attestation pool design.
|
||||
EnableDutiesV2 bool // EnableDutiesV2 sets validator client to use the get Duties V2 endpoint
|
||||
EnableWeb bool // EnableWeb enables the webui on the validator client
|
||||
// Logging related toggles.
|
||||
DisableGRPCConnectionLogs bool // Disables logging when a new grpc client has connected.
|
||||
EnableFullSSZDataLogging bool // Enables logging for full ssz data on rejected gossip messages
|
||||
@@ -339,6 +340,10 @@ func ConfigureValidator(ctx *cli.Context) error {
|
||||
logEnabled(EnableDutiesV2)
|
||||
cfg.EnableDutiesV2 = true
|
||||
}
|
||||
if ctx.Bool(EnableWebFlag.Name) {
|
||||
logEnabled(EnableWebFlag)
|
||||
cfg.EnableWeb = true
|
||||
}
|
||||
cfg.KeystoreImportDebounceInterval = ctx.Duration(dynamicKeyReloadDebounceInterval.Name)
|
||||
Init(cfg)
|
||||
return nil
|
||||
|
||||
@@ -194,6 +194,13 @@ var (
|
||||
Name: "enable-duties-v2",
|
||||
Usage: "Forces use of get duties v2 endpoint.",
|
||||
}
|
||||
|
||||
// EnableWebFlag enables controlling the validator client via the Prysm web ui. This is a work in progress.
|
||||
EnableWebFlag = &cli.BoolFlag{
|
||||
Name: "web",
|
||||
Usage: "(Work in progress): Enables the web portal for the validator client.",
|
||||
Value: false,
|
||||
}
|
||||
)
|
||||
|
||||
// devModeFlags holds list of flags that are set when development mode is on.
|
||||
@@ -215,6 +222,7 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{
|
||||
enableDoppelGangerProtection,
|
||||
EnableBeaconRESTApi,
|
||||
EnableDutiesV2,
|
||||
EnableWebFlag,
|
||||
}...)
|
||||
|
||||
// E2EValidatorFlags contains a list of the validator feature flags to be tested in E2E.
|
||||
|
||||
@@ -437,7 +437,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
|
||||
Web3SignerConfig: web3signerConfig,
|
||||
ProposerSettings: ps,
|
||||
ValidatorsRegBatchSize: cliCtx.Int(flags.ValidatorsRegistrationBatchSizeFlag.Name),
|
||||
EnableAPI: cliCtx.Bool(flags.EnableWebFlag.Name) || cliCtx.Bool(flags.EnableRPCFlag.Name),
|
||||
EnableAPI: features.Get().EnableWeb || cliCtx.Bool(flags.EnableRPCFlag.Name),
|
||||
LogValidatorPerformance: !cliCtx.Bool(flags.DisablePenaltyRewardLogFlag.Name),
|
||||
EmitAccountMetrics: !cliCtx.Bool(flags.DisableAccountMetricsFlag.Name),
|
||||
Distributed: cliCtx.Bool(flags.EnableDistributed.Name),
|
||||
@@ -501,7 +501,7 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*proposer.Sett
|
||||
}
|
||||
|
||||
func (c *ValidatorClient) registerRPCService(cliCtx *cli.Context) error {
|
||||
serveWebUI := cliCtx.IsSet(flags.EnableWebFlag.Name)
|
||||
serveWebUI := features.Get().EnableWeb
|
||||
if !cliCtx.IsSet(flags.EnableRPCFlag.Name) && !serveWebUI {
|
||||
return nil
|
||||
}
|
||||
@@ -557,7 +557,6 @@ func (c *ValidatorClient) registerRPCService(cliCtx *cli.Context) error {
|
||||
AuthTokenPath: authTokenPath,
|
||||
Middlewares: middlewares,
|
||||
Router: http.NewServeMux(),
|
||||
ServeWebUI: serveWebUI,
|
||||
})
|
||||
return c.services.RegisterService(s)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/api"
|
||||
"github.com/OffchainLabs/prysm/v6/config/features"
|
||||
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
|
||||
"github.com/OffchainLabs/prysm/v6/io/file"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
@@ -32,7 +33,7 @@ func CreateAuthToken(authPath, validatorWebAddr string) error {
|
||||
if err := saveAuthToken(authPath, token); err != nil {
|
||||
return err
|
||||
}
|
||||
logValidatorWebAuth(true, validatorWebAddr, token, authPath)
|
||||
logValidatorWebAuth(validatorWebAddr, token, authPath)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ func (s *Server) refreshAuthTokenFromFileChanges(ctx context.Context, authTokenP
|
||||
continue
|
||||
}
|
||||
validatorWebAddr := fmt.Sprintf("%s:%d", s.httpHost, s.httpPort)
|
||||
logValidatorWebAuth(s.serveWebUI, validatorWebAddr, s.authToken, authTokenPath)
|
||||
logValidatorWebAuth(validatorWebAddr, s.authToken, authTokenPath)
|
||||
case err := <-watcher.Errors:
|
||||
log.WithError(err).Errorf("Could not watch for file changes for: %s", authTokenPath)
|
||||
case <-ctx.Done():
|
||||
@@ -114,8 +115,8 @@ func (s *Server) refreshAuthTokenFromFileChanges(ctx context.Context, authTokenP
|
||||
}
|
||||
}
|
||||
|
||||
func logValidatorWebAuth(useWeb bool, validatorWebAddr, token, tokenPath string) {
|
||||
if useWeb {
|
||||
func logValidatorWebAuth(validatorWebAddr, token, tokenPath string) {
|
||||
if features.Get().EnableWeb {
|
||||
webAuthURLTemplate := "http://%s/initialize?token=%s"
|
||||
webAuthURL := fmt.Sprintf(
|
||||
webAuthURLTemplate,
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/OffchainLabs/prysm/v6/api/server/httprest"
|
||||
"github.com/OffchainLabs/prysm/v6/api/server/middleware"
|
||||
"github.com/OffchainLabs/prysm/v6/async/event"
|
||||
"github.com/OffchainLabs/prysm/v6/config/features"
|
||||
"github.com/OffchainLabs/prysm/v6/io/logs"
|
||||
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
|
||||
"github.com/OffchainLabs/prysm/v6/validator/accounts/wallet"
|
||||
@@ -43,12 +44,10 @@ type Config struct {
|
||||
AuthTokenPath string
|
||||
Middlewares []middleware.Middleware
|
||||
Router *http.ServeMux
|
||||
ServeWebUI bool
|
||||
}
|
||||
|
||||
// Server defining a HTTP server for the remote signer API and registering clients
|
||||
type Server struct {
|
||||
serveWebUI bool
|
||||
walletInitialized bool
|
||||
logStreamerBufferSize int
|
||||
grpcMaxCallRecvMsgSize int
|
||||
@@ -106,7 +105,6 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
||||
beaconApiEndpoint: cfg.BeaconApiEndpoint,
|
||||
beaconNodeEndpoint: cfg.BeaconNodeGRPCEndpoint,
|
||||
router: cfg.Router,
|
||||
serveWebUI: cfg.ServeWebUI,
|
||||
}
|
||||
|
||||
if server.authTokenPath == "" && server.walletDir != "" {
|
||||
@@ -119,7 +117,7 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
||||
log.WithError(err).Error("Could not initialize web auth token")
|
||||
}
|
||||
validatorWebAddr := fmt.Sprintf("%s:%d", server.httpHost, server.httpPort)
|
||||
logValidatorWebAuth(server.serveWebUI, validatorWebAddr, server.authToken, server.authTokenPath)
|
||||
logValidatorWebAuth(validatorWebAddr, server.authToken, server.authTokenPath)
|
||||
go server.refreshAuthTokenFromFileChanges(server.ctx, server.authTokenPath)
|
||||
}
|
||||
|
||||
@@ -166,7 +164,7 @@ func (s *Server) InitializeRoutesWithWebHandler() error {
|
||||
s.router.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
if s.serveWebUI {
|
||||
if features.Get().EnableWeb {
|
||||
web.Handler(w, r)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user