mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
HTTP Validator API: /eth/v1/keystores (#13113)
* WIP * fixing tests * fixing bazel * fixing api client * fixing tests * fixing more tests and bazel * fixing trace and more bazel issues * fixing router path function definitions * fixing more tests and deep source issues * adding delete test * if a route is provided, reregister before the catch all on the middleware. * fixing linting * fixing deepsource complaint * gaz * more deepsource issues * fixing missed err check * changing how routes are registered * radek reviews * Update validator/rpc/handlers_keymanager.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * Update validator/rpc/handlers_keymanager.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * fixing unit test after sammy's review * adding radek's comments --------- Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v4/async/event"
|
||||
"github.com/prysmaticlabs/prysm/v4/io/logs"
|
||||
"github.com/prysmaticlabs/prysm/v4/monitoring/tracing"
|
||||
ethpbservice "github.com/prysmaticlabs/prysm/v4/proto/eth/service"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
|
||||
"github.com/prysmaticlabs/prysm/v4/validator/accounts/wallet"
|
||||
@@ -103,7 +102,7 @@ type Server struct {
|
||||
// NewServer instantiates a new gRPC server.
|
||||
func NewServer(ctx context.Context, cfg *Config) *Server {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
return &Server{
|
||||
server := &Server{
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
logsStreamer: logs.NewStreamServer(),
|
||||
@@ -133,6 +132,11 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
||||
validatorGatewayPort: cfg.ValidatorGatewayPort,
|
||||
router: cfg.Router,
|
||||
}
|
||||
// immediately register routes to override any catchalls
|
||||
if err := server.InitializeRoutes(); err != nil {
|
||||
log.WithError(err).Fatal("Could not initialize routes")
|
||||
}
|
||||
return server
|
||||
}
|
||||
|
||||
// Start the gRPC server.
|
||||
@@ -184,12 +188,8 @@ func (s *Server) Start() {
|
||||
validatorpb.RegisterHealthServer(s.grpcServer, s)
|
||||
validatorpb.RegisterBeaconServer(s.grpcServer, s)
|
||||
validatorpb.RegisterAccountsServer(s.grpcServer, s)
|
||||
ethpbservice.RegisterKeyManagementServer(s.grpcServer, s)
|
||||
validatorpb.RegisterSlashingProtectionServer(s.grpcServer, s)
|
||||
|
||||
if err := s.InitializeRoutes(); err != nil {
|
||||
log.WithError(err).Fatal("Could not initialize routes")
|
||||
}
|
||||
// routes needs to be set before the server calls the server function
|
||||
go func() {
|
||||
if s.listener != nil {
|
||||
@@ -221,6 +221,9 @@ func (s *Server) InitializeRoutes() error {
|
||||
}
|
||||
// Register all services, HandleFunc calls, etc.
|
||||
// ...
|
||||
s.router.HandleFunc("/eth/v1/keystores", s.ListKeystores).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("/eth/v1/keystores", s.ImportKeystores).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("/eth/v1/keystores", s.DeleteKeystores).Methods(http.MethodDelete)
|
||||
s.router.HandleFunc("/eth/v1/remotekeys", s.ListRemoteKeys).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("/eth/v1/remotekeys", s.ImportRemoteKeys).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("/eth/v1/remotekeys", s.DeleteRemoteKeys).Methods(http.MethodDelete)
|
||||
|
||||
Reference in New Issue
Block a user