mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
WebFix develop (#14040)
* fixing issues introduced by PR 13593 * missed setting db * linting
This commit is contained in:
@@ -4,6 +4,6 @@ const (
|
|||||||
WebUrlPrefix = "/v2/validator/"
|
WebUrlPrefix = "/v2/validator/"
|
||||||
WebApiUrlPrefix = "/api/v2/validator/"
|
WebApiUrlPrefix = "/api/v2/validator/"
|
||||||
KeymanagerApiPrefix = "/eth/v1"
|
KeymanagerApiPrefix = "/eth/v1"
|
||||||
|
SystemLogsPrefix = "health/logs"
|
||||||
AuthTokenFileName = "auth-token"
|
AuthTokenFileName = "auth-token"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -614,6 +614,16 @@ func (c *ValidatorClient) registerRPCService(router *mux.Router) error {
|
|||||||
if err := c.services.FetchService(&vs); err != nil {
|
if err := c.services.FetchService(&vs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
authTokenPath := c.cliCtx.String(flags.AuthTokenPathFlag.Name)
|
||||||
|
walletDir := c.cliCtx.String(flags.WalletDirFlag.Name)
|
||||||
|
// if no auth token path flag was passed try to set a default value
|
||||||
|
if authTokenPath == "" {
|
||||||
|
authTokenPath = flags.AuthTokenPathFlag.Value
|
||||||
|
// if a wallet dir is passed without an auth token then override the default with the wallet dir
|
||||||
|
if walletDir != "" {
|
||||||
|
authTokenPath = filepath.Join(walletDir, api.AuthTokenFileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
s := rpc.NewServer(c.cliCtx.Context, &rpc.Config{
|
s := rpc.NewServer(c.cliCtx.Context, &rpc.Config{
|
||||||
Host: c.cliCtx.String(flags.RPCHost.Name),
|
Host: c.cliCtx.String(flags.RPCHost.Name),
|
||||||
Port: fmt.Sprintf("%d", c.cliCtx.Int(flags.RPCPort.Name)),
|
Port: fmt.Sprintf("%d", c.cliCtx.Int(flags.RPCPort.Name)),
|
||||||
@@ -624,14 +634,15 @@ func (c *ValidatorClient) registerRPCService(router *mux.Router) error {
|
|||||||
GRPCRetryDelay: c.cliCtx.Duration(flags.GrpcRetryDelayFlag.Name),
|
GRPCRetryDelay: c.cliCtx.Duration(flags.GrpcRetryDelayFlag.Name),
|
||||||
GRPCHeaders: strings.Split(c.cliCtx.String(flags.GrpcHeadersFlag.Name), ","),
|
GRPCHeaders: strings.Split(c.cliCtx.String(flags.GrpcHeadersFlag.Name), ","),
|
||||||
BeaconNodeGRPCEndpoint: c.cliCtx.String(flags.BeaconRPCProviderFlag.Name),
|
BeaconNodeGRPCEndpoint: c.cliCtx.String(flags.BeaconRPCProviderFlag.Name),
|
||||||
BeaconApiEndpoint: c.cliCtx.String(flags.BeaconRPCGatewayProviderFlag.Name),
|
BeaconApiEndpoint: c.cliCtx.String(flags.BeaconRESTApiProviderFlag.Name),
|
||||||
BeaconApiTimeout: time.Second * 30,
|
BeaconApiTimeout: time.Second * 30,
|
||||||
BeaconNodeCert: c.cliCtx.String(flags.CertFlag.Name),
|
BeaconNodeCert: c.cliCtx.String(flags.CertFlag.Name),
|
||||||
DB: c.db,
|
DB: c.db,
|
||||||
Wallet: c.wallet,
|
Wallet: c.wallet,
|
||||||
WalletDir: c.cliCtx.String(flags.WalletDirFlag.Name),
|
WalletDir: walletDir,
|
||||||
WalletInitializedFeed: c.walletInitializedFeed,
|
WalletInitializedFeed: c.walletInitializedFeed,
|
||||||
ValidatorService: vs,
|
ValidatorService: vs,
|
||||||
|
AuthTokenPath: authTokenPath,
|
||||||
Router: router,
|
Router: router,
|
||||||
})
|
})
|
||||||
return c.services.RegisterService(s)
|
return c.services.RegisterService(s)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func (s *Server) AuthTokenInterceptor() grpc.UnaryServerInterceptor {
|
|||||||
func (s *Server) AuthTokenHandler(next http.Handler) http.Handler {
|
func (s *Server) AuthTokenHandler(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
// if it's not initialize or has a web prefix
|
// if it's not initialize or has a web prefix
|
||||||
if strings.Contains(r.URL.Path, api.WebApiUrlPrefix) || strings.Contains(r.URL.Path, api.KeymanagerApiPrefix) {
|
if (strings.Contains(r.URL.Path, api.WebApiUrlPrefix) || strings.Contains(r.URL.Path, api.KeymanagerApiPrefix)) && !strings.Contains(r.URL.Path, api.SystemLogsPrefix) {
|
||||||
// ignore some routes
|
// ignore some routes
|
||||||
reqToken := r.Header.Get("Authorization")
|
reqToken := r.Header.Get("Authorization")
|
||||||
if reqToken == "" {
|
if reqToken == "" {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ type Config struct {
|
|||||||
WalletDir string
|
WalletDir string
|
||||||
WalletInitializedFeed *event.Feed
|
WalletInitializedFeed *event.Feed
|
||||||
ValidatorService *client.ValidatorService
|
ValidatorService *client.ValidatorService
|
||||||
|
AuthTokenPath string
|
||||||
Router *mux.Router
|
Router *mux.Router
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +93,8 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
|||||||
server := &Server{
|
server := &Server{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
|
logStreamer: logs.NewStreamServer(),
|
||||||
|
logStreamerBufferSize: 1000, // Enough to handle most bursts of logs in the validator client.
|
||||||
host: cfg.Host,
|
host: cfg.Host,
|
||||||
port: cfg.Port,
|
port: cfg.Port,
|
||||||
grpcGatewayHost: cfg.GRPCGatewayHost,
|
grpcGatewayHost: cfg.GRPCGatewayHost,
|
||||||
@@ -100,6 +103,17 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
|||||||
grpcRetries: cfg.GRPCRetries,
|
grpcRetries: cfg.GRPCRetries,
|
||||||
grpcRetryDelay: cfg.GRPCRetryDelay,
|
grpcRetryDelay: cfg.GRPCRetryDelay,
|
||||||
grpcHeaders: cfg.GRPCHeaders,
|
grpcHeaders: cfg.GRPCHeaders,
|
||||||
|
validatorService: cfg.ValidatorService,
|
||||||
|
authTokenPath: cfg.AuthTokenPath,
|
||||||
|
db: cfg.DB,
|
||||||
|
walletDir: cfg.WalletDir,
|
||||||
|
walletInitializedFeed: cfg.WalletInitializedFeed,
|
||||||
|
walletInitialized: cfg.Wallet != nil,
|
||||||
|
wallet: cfg.Wallet,
|
||||||
|
beaconApiTimeout: cfg.BeaconApiTimeout,
|
||||||
|
beaconApiEndpoint: cfg.BeaconApiEndpoint,
|
||||||
|
beaconNodeEndpoint: cfg.BeaconNodeGRPCEndpoint,
|
||||||
|
router: cfg.Router,
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.authTokenPath == "" && server.walletDir != "" {
|
if server.authTokenPath == "" && server.walletDir != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user