mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Replaced mux with http.Servemux (#14416)
* Replaced mux with http.Servmux * updated change log * james suggestions * lint * lint fix 2 * passed middlewares from validatorclient * gazelle fix * fixed issue * added middlewares field to rpc config * suggestions applied * updated godoc * fixed TestCors * refactor * godoc added * cli code removed and lint fixed --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
This commit is contained in:
@@ -31,6 +31,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
|
||||
- `api-timeout` is changed from int flag to duration flag, default value updated.
|
||||
- Light client support: abstracted out the light client headers with different versions.
|
||||
- `ApplyToEveryValidator` has been changed to prevent misuse bugs, it takes a closure that takes a `ReadOnlyValidator` and returns a raw pointer to a `Validator`.
|
||||
- Removed gorilla mux library and replaced it with net/http updates in go 1.22
|
||||
|
||||
### Deprecated
|
||||
- `--disable-grpc-gateway` flag is deprecated due to grpc gateway removal.
|
||||
|
||||
@@ -10,8 +10,8 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/api/server/httprest",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//api/server/middleware:go_default_library",
|
||||
"//runtime:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
@@ -25,7 +25,6 @@ go_test(
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -3,12 +3,22 @@ package httprest
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/middleware"
|
||||
)
|
||||
|
||||
// Option is a http rest server functional parameter type.
|
||||
type Option func(g *Server) error
|
||||
|
||||
// WithMiddlewares sets the list of middlewares to be applied on routes.
|
||||
func WithMiddlewares(mw []middleware.Middleware) Option {
|
||||
return func(g *Server) error {
|
||||
g.cfg.middlewares = mw
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithHTTPAddr sets the full address ( host and port ) of the server.
|
||||
func WithHTTPAddr(addr string) Option {
|
||||
return func(g *Server) error {
|
||||
@@ -18,7 +28,7 @@ func WithHTTPAddr(addr string) Option {
|
||||
}
|
||||
|
||||
// WithRouter sets the internal router of the server, this is required.
|
||||
func WithRouter(r *mux.Router) Option {
|
||||
func WithRouter(r *http.ServeMux) Option {
|
||||
return func(g *Server) error {
|
||||
g.cfg.router = r
|
||||
return nil
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/middleware"
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime"
|
||||
)
|
||||
|
||||
@@ -15,7 +15,8 @@ var _ runtime.Service = (*Server)(nil)
|
||||
// Config parameters for setting up the http-rest service.
|
||||
type config struct {
|
||||
httpAddr string
|
||||
router *mux.Router
|
||||
middlewares []middleware.Middleware
|
||||
router http.Handler
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
@@ -44,11 +45,10 @@ func New(ctx context.Context, opts ...Option) (*Server, error) {
|
||||
}
|
||||
var handler http.Handler
|
||||
defaultReadHeaderTimeout := time.Second
|
||||
handler = middleware.MiddlewareChain(g.cfg.router, g.cfg.middlewares)
|
||||
if g.cfg.timeout > 0*time.Second {
|
||||
defaultReadHeaderTimeout = g.cfg.timeout
|
||||
handler = http.TimeoutHandler(g.cfg.router, g.cfg.timeout, "request timed out")
|
||||
} else {
|
||||
handler = g.cfg.router
|
||||
handler = http.TimeoutHandler(handler, g.cfg.timeout, "request timed out")
|
||||
}
|
||||
g.server = &http.Server{
|
||||
Addr: g.cfg.httpAddr,
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/flags"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
@@ -25,12 +25,13 @@ func TestServer_StartStop(t *testing.T) {
|
||||
ctx := cli.NewContext(&app, set, nil)
|
||||
|
||||
port := ctx.Int(flags.HTTPServerPort.Name)
|
||||
portStr := fmt.Sprintf("%d", port) // Convert port to string
|
||||
host := ctx.String(flags.HTTPServerHost.Name)
|
||||
address := fmt.Sprintf("%s:%d", host, port)
|
||||
|
||||
address := net.JoinHostPort(host, portStr)
|
||||
handler := http.NewServeMux()
|
||||
opts := []Option{
|
||||
WithHTTPAddr(address),
|
||||
WithRouter(mux.NewRouter()),
|
||||
WithRouter(handler),
|
||||
}
|
||||
|
||||
g, err := New(context.Background(), opts...)
|
||||
@@ -50,13 +51,15 @@ func TestServer_NilHandler_NotFoundHandlerRegistered(t *testing.T) {
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
ctx := cli.NewContext(&app, set, nil)
|
||||
|
||||
handler := http.NewServeMux()
|
||||
port := ctx.Int(flags.HTTPServerPort.Name)
|
||||
portStr := fmt.Sprintf("%d", port) // Convert port to string
|
||||
host := ctx.String(flags.HTTPServerHost.Name)
|
||||
address := fmt.Sprintf("%s:%d", host, port)
|
||||
address := net.JoinHostPort(host, portStr)
|
||||
|
||||
opts := []Option{
|
||||
WithHTTPAddr(address),
|
||||
WithRouter(mux.NewRouter()),
|
||||
WithRouter(handler),
|
||||
}
|
||||
|
||||
g, err := New(context.Background(), opts...)
|
||||
|
||||
@@ -8,10 +8,7 @@ go_library(
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/api/server/middleware",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_rs_cors//:go_default_library",
|
||||
],
|
||||
deps = ["@com_github_rs_cors//:go_default_library"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
|
||||
type Middleware func(http.Handler) http.Handler
|
||||
|
||||
// NormalizeQueryValuesHandler normalizes an input query of "key=value1,value2,value3" to "key=value1&key=value2&key=value3"
|
||||
func NormalizeQueryValuesHandler(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -21,7 +22,7 @@ func NormalizeQueryValuesHandler(next http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
// CorsHandler sets the cors settings on api endpoints
|
||||
func CorsHandler(allowOrigins []string) mux.MiddlewareFunc {
|
||||
func CorsHandler(allowOrigins []string) Middleware {
|
||||
c := cors.New(cors.Options{
|
||||
AllowedOrigins: allowOrigins,
|
||||
AllowedMethods: []string{http.MethodPost, http.MethodGet, http.MethodDelete, http.MethodOptions},
|
||||
@@ -34,7 +35,7 @@ func CorsHandler(allowOrigins []string) mux.MiddlewareFunc {
|
||||
}
|
||||
|
||||
// ContentTypeHandler checks request for the appropriate media types otherwise returning a http.StatusUnsupportedMediaType error
|
||||
func ContentTypeHandler(acceptedMediaTypes []string) mux.MiddlewareFunc {
|
||||
func ContentTypeHandler(acceptedMediaTypes []string) Middleware {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// skip the GET request
|
||||
@@ -67,7 +68,7 @@ func ContentTypeHandler(acceptedMediaTypes []string) mux.MiddlewareFunc {
|
||||
}
|
||||
|
||||
// AcceptHeaderHandler checks if the client's response preference is handled
|
||||
func AcceptHeaderHandler(serverAcceptedTypes []string) mux.MiddlewareFunc {
|
||||
func AcceptHeaderHandler(serverAcceptedTypes []string) Middleware {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
acceptHeader := r.Header.Get("Accept")
|
||||
@@ -110,3 +111,15 @@ func AcceptHeaderHandler(serverAcceptedTypes []string) mux.MiddlewareFunc {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func MiddlewareChain(h http.Handler, mw []Middleware) http.Handler {
|
||||
if len(mw) < 1 {
|
||||
return h
|
||||
}
|
||||
|
||||
wrapped := h
|
||||
for i := len(mw) - 1; i >= 0; i-- {
|
||||
wrapped = mw[i](wrapped)
|
||||
}
|
||||
return wrapped
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ go_library(
|
||||
"//runtime/prereqs:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
@@ -82,6 +81,7 @@ go_test(
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//api/server/middleware:go_default_library",
|
||||
"//beacon-chain/blockchain:go_default_library",
|
||||
"//beacon-chain/builder:go_default_library",
|
||||
"//beacon-chain/core/feed/state:go_default_library",
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
@@ -17,7 +18,6 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/httprest"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/middleware"
|
||||
@@ -361,7 +361,7 @@ func registerServices(cliCtx *cli.Context, beacon *BeaconNode, synchronizer *sta
|
||||
}
|
||||
|
||||
log.Debugln("Registering RPC Service")
|
||||
router := newRouter(cliCtx)
|
||||
router := http.NewServeMux()
|
||||
if err := beacon.registerRPCService(router); err != nil {
|
||||
return errors.Wrap(err, "could not register RPC service")
|
||||
}
|
||||
@@ -397,19 +397,6 @@ func initSyncWaiter(ctx context.Context, complete chan struct{}) func() error {
|
||||
}
|
||||
}
|
||||
|
||||
func newRouter(cliCtx *cli.Context) *mux.Router {
|
||||
var allowedOrigins []string
|
||||
if cliCtx.IsSet(flags.HTTPServerCorsDomain.Name) {
|
||||
allowedOrigins = strings.Split(cliCtx.String(flags.HTTPServerCorsDomain.Name), ",")
|
||||
} else {
|
||||
allowedOrigins = strings.Split(flags.HTTPServerCorsDomain.Value, ",")
|
||||
}
|
||||
r := mux.NewRouter()
|
||||
r.Use(middleware.NormalizeQueryValuesHandler)
|
||||
r.Use(middleware.CorsHandler(allowedOrigins))
|
||||
return r
|
||||
}
|
||||
|
||||
// StateFeed implements statefeed.Notifier.
|
||||
func (b *BeaconNode) StateFeed() *event.Feed {
|
||||
return b.stateFeed
|
||||
@@ -916,7 +903,7 @@ func (b *BeaconNode) registerSlasherService() error {
|
||||
return b.services.RegisterService(slasherSrv)
|
||||
}
|
||||
|
||||
func (b *BeaconNode) registerRPCService(router *mux.Router) error {
|
||||
func (b *BeaconNode) registerRPCService(router *http.ServeMux) error {
|
||||
var chainService *blockchain.Service
|
||||
if err := b.services.FetchService(&chainService); err != nil {
|
||||
return err
|
||||
@@ -1043,13 +1030,26 @@ func (b *BeaconNode) registerPrometheusService(_ *cli.Context) error {
|
||||
return b.services.RegisterService(service)
|
||||
}
|
||||
|
||||
func (b *BeaconNode) registerHTTPService(router *mux.Router) error {
|
||||
func (b *BeaconNode) registerHTTPService(router *http.ServeMux) error {
|
||||
host := b.cliCtx.String(flags.HTTPServerHost.Name)
|
||||
port := b.cliCtx.Int(flags.HTTPServerPort.Name)
|
||||
address := net.JoinHostPort(host, strconv.Itoa(port))
|
||||
var allowedOrigins []string
|
||||
if b.cliCtx.IsSet(flags.HTTPServerCorsDomain.Name) {
|
||||
allowedOrigins = strings.Split(b.cliCtx.String(flags.HTTPServerCorsDomain.Name), ",")
|
||||
} else {
|
||||
allowedOrigins = strings.Split(flags.HTTPServerCorsDomain.Value, ",")
|
||||
}
|
||||
|
||||
middlewares := []middleware.Middleware{
|
||||
middleware.NormalizeQueryValuesHandler,
|
||||
middleware.CorsHandler(allowedOrigins),
|
||||
}
|
||||
|
||||
opts := []httprest.Option{
|
||||
httprest.WithRouter(router),
|
||||
httprest.WithHTTPAddr(address),
|
||||
httprest.WithMiddlewares(middlewares),
|
||||
}
|
||||
if b.cliCtx.IsSet(cmd.ApiTimeoutFlag.Name) {
|
||||
opts = append(opts, httprest.WithTimeout(b.cliCtx.Duration(cmd.ApiTimeoutFlag.Name)))
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/middleware"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/builder"
|
||||
statefeed "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed/state"
|
||||
@@ -252,19 +253,19 @@ func Test_hasNetworkFlag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCORS(t *testing.T) {
|
||||
// Mock CLI context with a test CORS domain
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.String(flags.HTTPServerCorsDomain.Name, "http://allowed-example.com", "")
|
||||
cliCtx := cli.NewContext(&app, set, nil)
|
||||
require.NoError(t, cliCtx.Set(flags.HTTPServerCorsDomain.Name, "http://allowed-example.com"))
|
||||
|
||||
router := newRouter(cliCtx)
|
||||
|
||||
router := http.NewServeMux()
|
||||
// Ensure a test route exists
|
||||
router.HandleFunc("/some-path", func(w http.ResponseWriter, _ *http.Request) {
|
||||
router.HandleFunc("/some-path", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}).Methods(http.MethodGet)
|
||||
} else {
|
||||
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
|
||||
// Register the CORS middleware on mux Router
|
||||
allowedOrigins := []string{"http://allowed-example.com"}
|
||||
handler := middleware.CorsHandler(allowedOrigins)(router)
|
||||
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
@@ -285,7 +286,7 @@ func TestCORS(t *testing.T) {
|
||||
rr := httptest.NewRecorder()
|
||||
|
||||
// Serve HTTP
|
||||
router.ServeHTTP(rr, req)
|
||||
handler.ServeHTTP(rr, req)
|
||||
|
||||
// Check the CORS headers based on the expected outcome
|
||||
if tc.expectAllow && rr.Header().Get("Access-Control-Allow-Origin") != tc.origin {
|
||||
|
||||
@@ -55,7 +55,6 @@ go_library(
|
||||
"//io/logs:go_default_library",
|
||||
"//monitoring/tracing:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
|
||||
"@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library",
|
||||
"@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library",
|
||||
@@ -88,7 +87,6 @@ go_test(
|
||||
"//beacon-chain/sync/initial-sync/testing:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
],
|
||||
|
||||
@@ -3,7 +3,6 @@ package rpc
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
@@ -30,7 +29,7 @@ import (
|
||||
type endpoint struct {
|
||||
template string
|
||||
name string
|
||||
middleware []mux.MiddlewareFunc
|
||||
middleware []middleware.Middleware
|
||||
handler http.HandlerFunc
|
||||
methods []string
|
||||
}
|
||||
@@ -93,7 +92,7 @@ func (s *Service) rewardsEndpoints(blocker lookup.Blocker, stater lookup.Stater,
|
||||
{
|
||||
template: "/eth/v1/beacon/rewards/blocks/{block_id}",
|
||||
name: namespace + ".BlockRewards",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.BlockRewards,
|
||||
@@ -102,7 +101,7 @@ func (s *Service) rewardsEndpoints(blocker lookup.Blocker, stater lookup.Stater,
|
||||
{
|
||||
template: "/eth/v1/beacon/rewards/attestations/{epoch}",
|
||||
name: namespace + ".AttestationRewards",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -112,7 +111,7 @@ func (s *Service) rewardsEndpoints(blocker lookup.Blocker, stater lookup.Stater,
|
||||
{
|
||||
template: "/eth/v1/beacon/rewards/sync_committee/{block_id}",
|
||||
name: namespace + ".SyncCommitteeRewards",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -134,7 +133,7 @@ func (s *Service) builderEndpoints(stater lookup.Stater) []endpoint {
|
||||
{
|
||||
template: "/eth/v1/builder/states/{state_id}/expected_withdrawals",
|
||||
name: namespace + ".ExpectedWithdrawals",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.ExpectedWithdrawals,
|
||||
@@ -153,7 +152,7 @@ func (*Service) blobEndpoints(blocker lookup.Blocker) []endpoint {
|
||||
{
|
||||
template: "/eth/v1/beacon/blob_sidecars/{block_id}",
|
||||
name: namespace + ".Blobs",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.Blobs,
|
||||
@@ -194,7 +193,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/aggregate_attestation",
|
||||
name: namespace + ".GetAggregateAttestation",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetAggregateAttestation,
|
||||
@@ -203,7 +202,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/contribution_and_proofs",
|
||||
name: namespace + ".SubmitContributionAndProofs",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -213,7 +212,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/aggregate_and_proofs",
|
||||
name: namespace + ".SubmitAggregateAndProofs",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -223,7 +222,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/sync_committee_contribution",
|
||||
name: namespace + ".ProduceSyncCommitteeContribution",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.ProduceSyncCommitteeContribution,
|
||||
@@ -232,7 +231,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/sync_committee_subscriptions",
|
||||
name: namespace + ".SubmitSyncCommitteeSubscription",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -242,7 +241,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/beacon_committee_subscriptions",
|
||||
name: namespace + ".SubmitBeaconCommitteeSubscription",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -252,7 +251,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/attestation_data",
|
||||
name: namespace + ".GetAttestationData",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetAttestationData,
|
||||
@@ -261,7 +260,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/register_validator",
|
||||
name: namespace + ".RegisterValidator",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -271,7 +270,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/duties/attester/{epoch}",
|
||||
name: namespace + ".GetAttesterDuties",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -281,7 +280,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/duties/proposer/{epoch}",
|
||||
name: namespace + ".GetProposerDuties",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetProposerDuties,
|
||||
@@ -290,7 +289,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/duties/sync/{epoch}",
|
||||
name: namespace + ".GetSyncCommitteeDuties",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -300,7 +299,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/prepare_beacon_proposer",
|
||||
name: namespace + ".PrepareBeaconProposer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -310,7 +309,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/liveness/{epoch}",
|
||||
name: namespace + ".GetLiveness",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -320,7 +319,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v2/validator/blocks/{slot}",
|
||||
name: namespace + ".ProduceBlockV2",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.ProduceBlockV2,
|
||||
@@ -329,7 +328,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/blinded_blocks/{slot}",
|
||||
name: namespace + ".ProduceBlindedBlock",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.ProduceBlindedBlock,
|
||||
@@ -338,7 +337,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v3/validator/blocks/{slot}",
|
||||
name: namespace + ".ProduceBlockV3",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.ProduceBlockV3,
|
||||
@@ -347,7 +346,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/beacon_committee_selections",
|
||||
name: namespace + ".BeaconCommitteeSelections",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.BeaconCommitteeSelections,
|
||||
@@ -356,7 +355,7 @@ func (s *Service) validatorEndpoints(
|
||||
{
|
||||
template: "/eth/v1/validator/sync_committee_selections",
|
||||
name: namespace + ".SyncCommittee Selections",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.SyncCommitteeSelections,
|
||||
@@ -384,7 +383,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/syncing",
|
||||
name: namespace + ".GetSyncStatus",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetSyncStatus,
|
||||
@@ -393,7 +392,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/identity",
|
||||
name: namespace + ".GetIdentity",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetIdentity,
|
||||
@@ -402,7 +401,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/peers/{peer_id}",
|
||||
name: namespace + ".GetPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetPeer,
|
||||
@@ -411,7 +410,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/peers",
|
||||
name: namespace + ".GetPeers",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetPeers,
|
||||
@@ -420,7 +419,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/peer_count",
|
||||
name: namespace + ".GetPeerCount",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetPeerCount,
|
||||
@@ -429,7 +428,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/version",
|
||||
name: namespace + ".GetVersion",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetVersion,
|
||||
@@ -438,7 +437,7 @@ func (s *Service) nodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/node/health",
|
||||
name: namespace + ".GetHealth",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetHealth,
|
||||
@@ -486,7 +485,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/committees",
|
||||
name: namespace + ".GetCommittees",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetCommittees,
|
||||
@@ -495,7 +494,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/fork",
|
||||
name: namespace + ".GetStateFork",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetStateFork,
|
||||
@@ -504,7 +503,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/root",
|
||||
name: namespace + ".GetStateRoot",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetStateRoot,
|
||||
@@ -513,7 +512,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/sync_committees",
|
||||
name: namespace + ".GetSyncCommittees",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetSyncCommittees,
|
||||
@@ -522,7 +521,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/randao",
|
||||
name: namespace + ".GetRandao",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetRandao,
|
||||
@@ -531,7 +530,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/blocks",
|
||||
name: namespace + ".PublishBlock",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -541,7 +540,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/blinded_blocks",
|
||||
name: namespace + ".PublishBlindedBlock",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -551,7 +550,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v2/beacon/blocks",
|
||||
name: namespace + ".PublishBlockV2",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -561,7 +560,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v2/beacon/blinded_blocks",
|
||||
name: namespace + ".PublishBlindedBlockV2",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -571,7 +570,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v2/beacon/blocks/{block_id}",
|
||||
name: namespace + ".GetBlockV2",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetBlockV2,
|
||||
@@ -580,7 +579,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/blocks/{block_id}/attestations",
|
||||
name: namespace + ".GetBlockAttestations",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetBlockAttestations,
|
||||
@@ -589,7 +588,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/blinded_blocks/{block_id}",
|
||||
name: namespace + ".GetBlindedBlock",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetBlindedBlock,
|
||||
@@ -598,7 +597,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/blocks/{block_id}/root",
|
||||
name: namespace + ".GetBlockRoot",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetBlockRoot,
|
||||
@@ -607,7 +606,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/attestations",
|
||||
name: namespace + ".ListAttestations",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.ListAttestations,
|
||||
@@ -616,7 +615,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/attestations",
|
||||
name: namespace + ".SubmitAttestations",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -626,7 +625,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/voluntary_exits",
|
||||
name: namespace + ".ListVoluntaryExits",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.ListVoluntaryExits,
|
||||
@@ -635,7 +634,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/voluntary_exits",
|
||||
name: namespace + ".SubmitVoluntaryExit",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -645,7 +644,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/sync_committees",
|
||||
name: namespace + ".SubmitSyncCommitteeSignatures",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -655,7 +654,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/bls_to_execution_changes",
|
||||
name: namespace + ".ListBLSToExecutionChanges",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.ListBLSToExecutionChanges,
|
||||
@@ -664,7 +663,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/bls_to_execution_changes",
|
||||
name: namespace + ".SubmitBLSToExecutionChanges",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -674,7 +673,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/attester_slashings",
|
||||
name: namespace + ".GetAttesterSlashings",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetAttesterSlashings,
|
||||
@@ -683,7 +682,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/attester_slashings",
|
||||
name: namespace + ".SubmitAttesterSlashing",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -693,7 +692,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/proposer_slashings",
|
||||
name: namespace + ".GetProposerSlashings",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetProposerSlashings,
|
||||
@@ -702,7 +701,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/pool/proposer_slashings",
|
||||
name: namespace + ".SubmitProposerSlashing",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -712,7 +711,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/headers",
|
||||
name: namespace + ".GetBlockHeaders",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetBlockHeaders,
|
||||
@@ -721,7 +720,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/headers/{block_id}",
|
||||
name: namespace + ".GetBlockHeader",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetBlockHeader,
|
||||
@@ -730,7 +729,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/genesis",
|
||||
name: namespace + ".GetGenesis",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetGenesis,
|
||||
@@ -739,7 +738,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/finality_checkpoints",
|
||||
name: namespace + ".GetFinalityCheckpoints",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetFinalityCheckpoints,
|
||||
@@ -748,7 +747,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/validators",
|
||||
name: namespace + ".GetValidators",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -758,7 +757,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/validators/{validator_id}",
|
||||
name: namespace + ".GetValidator",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetValidator,
|
||||
@@ -767,7 +766,7 @@ func (s *Service) beaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/validator_balances",
|
||||
name: namespace + ".GetValidatorBalances",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -783,7 +782,7 @@ func (*Service) configEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/config/deposit_contract",
|
||||
name: namespace + ".GetDepositContract",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: config.GetDepositContract,
|
||||
@@ -792,7 +791,7 @@ func (*Service) configEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/config/fork_schedule",
|
||||
name: namespace + ".GetForkSchedule",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: config.GetForkSchedule,
|
||||
@@ -801,7 +800,7 @@ func (*Service) configEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/config/spec",
|
||||
name: namespace + ".GetSpec",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: config.GetSpec,
|
||||
@@ -823,7 +822,7 @@ func (s *Service) lightClientEndpoints(blocker lookup.Blocker, stater lookup.Sta
|
||||
{
|
||||
template: "/eth/v1/beacon/light_client/bootstrap/{block_root}",
|
||||
name: namespace + ".GetLightClientBootstrap",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetLightClientBootstrap,
|
||||
@@ -832,7 +831,7 @@ func (s *Service) lightClientEndpoints(blocker lookup.Blocker, stater lookup.Sta
|
||||
{
|
||||
template: "/eth/v1/beacon/light_client/updates",
|
||||
name: namespace + ".GetLightClientUpdatesByRange",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetLightClientUpdatesByRange,
|
||||
@@ -841,7 +840,7 @@ func (s *Service) lightClientEndpoints(blocker lookup.Blocker, stater lookup.Sta
|
||||
{
|
||||
template: "/eth/v1/beacon/light_client/finality_update",
|
||||
name: namespace + ".GetLightClientFinalityUpdate",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetLightClientFinalityUpdate,
|
||||
@@ -850,7 +849,7 @@ func (s *Service) lightClientEndpoints(blocker lookup.Blocker, stater lookup.Sta
|
||||
{
|
||||
template: "/eth/v1/beacon/light_client/optimistic_update",
|
||||
name: namespace + ".GetLightClientOptimisticUpdate",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetLightClientOptimisticUpdate,
|
||||
@@ -876,7 +875,7 @@ func (s *Service) debugEndpoints(stater lookup.Stater) []endpoint {
|
||||
{
|
||||
template: "/eth/v2/debug/beacon/states/{state_id}",
|
||||
name: namespace + ".GetBeaconStateV2",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType, api.OctetStreamMediaType}),
|
||||
},
|
||||
handler: server.GetBeaconStateV2,
|
||||
@@ -885,7 +884,7 @@ func (s *Service) debugEndpoints(stater lookup.Stater) []endpoint {
|
||||
{
|
||||
template: "/eth/v2/debug/beacon/heads",
|
||||
name: namespace + ".GetForkChoiceHeadsV2",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetForkChoiceHeadsV2,
|
||||
@@ -894,7 +893,7 @@ func (s *Service) debugEndpoints(stater lookup.Stater) []endpoint {
|
||||
{
|
||||
template: "/eth/v1/debug/fork_choice",
|
||||
name: namespace + ".GetForkChoice",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetForkChoice,
|
||||
@@ -917,7 +916,7 @@ func (s *Service) eventsEndpoints() []endpoint {
|
||||
{
|
||||
template: "/eth/v1/events",
|
||||
name: namespace + ".StreamEvents",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.EventStreamMediaType}),
|
||||
},
|
||||
handler: server.StreamEvents,
|
||||
@@ -950,7 +949,7 @@ func (s *Service) prysmBeaconEndpoints(
|
||||
{
|
||||
template: "/prysm/v1/beacon/weak_subjectivity",
|
||||
name: namespace + ".GetWeakSubjectivity",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetWeakSubjectivity,
|
||||
@@ -959,7 +958,7 @@ func (s *Service) prysmBeaconEndpoints(
|
||||
{
|
||||
template: "/eth/v1/beacon/states/{state_id}/validator_count",
|
||||
name: namespace + ".GetValidatorCount",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetValidatorCount,
|
||||
@@ -968,7 +967,7 @@ func (s *Service) prysmBeaconEndpoints(
|
||||
{
|
||||
template: "/prysm/v1/beacon/states/{state_id}/validator_count",
|
||||
name: namespace + ".GetValidatorCount",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetValidatorCount,
|
||||
@@ -977,7 +976,7 @@ func (s *Service) prysmBeaconEndpoints(
|
||||
{
|
||||
template: "/prysm/v1/beacon/individual_votes",
|
||||
name: namespace + ".GetIndividualVotes",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -987,7 +986,7 @@ func (s *Service) prysmBeaconEndpoints(
|
||||
{
|
||||
template: "/prysm/v1/beacon/chain_head",
|
||||
name: namespace + ".GetChainHead",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetChainHead,
|
||||
@@ -1014,7 +1013,7 @@ func (s *Service) prysmNodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/prysm/node/trusted_peers",
|
||||
name: namespace + ".ListTrustedPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.ListTrustedPeer,
|
||||
@@ -1023,7 +1022,7 @@ func (s *Service) prysmNodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/prysm/v1/node/trusted_peers",
|
||||
name: namespace + ".ListTrustedPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.ListTrustedPeer,
|
||||
@@ -1032,7 +1031,7 @@ func (s *Service) prysmNodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/prysm/node/trusted_peers",
|
||||
name: namespace + ".AddTrustedPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -1042,7 +1041,7 @@ func (s *Service) prysmNodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/prysm/v1/node/trusted_peers",
|
||||
name: namespace + ".AddTrustedPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -1052,7 +1051,7 @@ func (s *Service) prysmNodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/prysm/node/trusted_peers/{peer_id}",
|
||||
name: namespace + ".RemoveTrustedPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.RemoveTrustedPeer,
|
||||
@@ -1061,7 +1060,7 @@ func (s *Service) prysmNodeEndpoints() []endpoint {
|
||||
{
|
||||
template: "/prysm/v1/node/trusted_peers/{peer_id}",
|
||||
name: namespace + ".RemoveTrustedPeer",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.RemoveTrustedPeer,
|
||||
@@ -1082,7 +1081,7 @@ func (s *Service) prysmValidatorEndpoints(stater lookup.Stater, coreService *cor
|
||||
{
|
||||
template: "/prysm/validators/performance",
|
||||
name: namespace + ".GetPerformance",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -1092,7 +1091,7 @@ func (s *Service) prysmValidatorEndpoints(stater lookup.Stater, coreService *cor
|
||||
{
|
||||
template: "/prysm/v1/validators/performance",
|
||||
name: namespace + ".GetPerformance",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
@@ -1102,7 +1101,7 @@ func (s *Service) prysmValidatorEndpoints(stater lookup.Stater, coreService *cor
|
||||
{
|
||||
template: "/prysm/v1/validators/participation",
|
||||
name: namespace + ".GetParticipation",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetParticipation,
|
||||
@@ -1111,7 +1110,7 @@ func (s *Service) prysmValidatorEndpoints(stater lookup.Stater, coreService *cor
|
||||
{
|
||||
template: "/prysm/v1/validators/active_set_changes",
|
||||
name: namespace + ".GetActiveSetChanges",
|
||||
middleware: []mux.MiddlewareFunc{
|
||||
middleware: []middleware.Middleware{
|
||||
middleware.AcceptHeaderHandler([]string{api.JsonMediaType}),
|
||||
},
|
||||
handler: server.GetActiveSetChanges,
|
||||
|
||||
@@ -57,7 +57,6 @@ go_library(
|
||||
"//runtime/version:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prysmaticlabs_fastssz//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
@@ -120,7 +119,6 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
ssz "github.com/prysmaticlabs/fastssz"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
@@ -54,7 +53,7 @@ func (s *Server) GetBlockV2(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetBlockV2")
|
||||
defer span.End()
|
||||
|
||||
blockId := mux.Vars(r)["block_id"]
|
||||
blockId := r.PathValue("block_id")
|
||||
if blockId == "" {
|
||||
httputil.HandleError(w, "block_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -85,7 +84,7 @@ func (s *Server) GetBlindedBlock(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetBlindedBlock")
|
||||
defer span.End()
|
||||
|
||||
blockId := mux.Vars(r)["block_id"]
|
||||
blockId := r.PathValue("block_id")
|
||||
if blockId == "" {
|
||||
httputil.HandleError(w, "block_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -201,7 +200,7 @@ func (s *Server) GetBlockAttestations(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetBlockAttestations")
|
||||
defer span.End()
|
||||
|
||||
blockId := mux.Vars(r)["block_id"]
|
||||
blockId := r.PathValue("block_id")
|
||||
if blockId == "" {
|
||||
httputil.HandleError(w, "block_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -1037,7 +1036,7 @@ func (s *Server) GetBlockRoot(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err error
|
||||
var root []byte
|
||||
blockID := mux.Vars(r)["block_id"]
|
||||
blockID := r.PathValue("block_id")
|
||||
if blockID == "" {
|
||||
httputil.HandleError(w, "block_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -1149,7 +1148,8 @@ func (s *Server) GetBlockRoot(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) GetStateFork(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetStateFork")
|
||||
defer span.End()
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -1189,7 +1189,7 @@ func (s *Server) GetCommittees(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetCommittees")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -1374,7 +1374,7 @@ func (s *Server) GetBlockHeader(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetBlockHeader")
|
||||
defer span.End()
|
||||
|
||||
blockID := mux.Vars(r)["block_id"]
|
||||
blockID := r.PathValue("block_id")
|
||||
if blockID == "" {
|
||||
httputil.HandleError(w, "block_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -1432,7 +1432,7 @@ func (s *Server) GetFinalityCheckpoints(w http.ResponseWriter, r *http.Request)
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetFinalityCheckpoints")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/altair"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
@@ -34,7 +33,7 @@ func (s *Server) GetStateRoot(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetStateRoot")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -85,7 +84,7 @@ func (s *Server) GetRandao(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetRandao")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -151,7 +150,7 @@ func (s *Server) GetSyncCommittees(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetSyncCommittees")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
chainMock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
dbTest "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/testing"
|
||||
@@ -56,7 +55,7 @@ func TestGetStateRoot(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/root", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -80,7 +79,7 @@ func TestGetStateRoot(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/root", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -111,7 +110,7 @@ func TestGetStateRoot(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/root", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -158,7 +157,7 @@ func TestGetRandao(t *testing.T) {
|
||||
|
||||
t.Run("no epoch requested", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/randao", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -170,7 +169,7 @@ func TestGetRandao(t *testing.T) {
|
||||
})
|
||||
t.Run("current epoch requested", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://example.com//eth/v1/beacon/states/{state_id}/randao?epoch=%d", epochCurrent), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -182,7 +181,7 @@ func TestGetRandao(t *testing.T) {
|
||||
})
|
||||
t.Run("old epoch requested", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://example.com//eth/v1/beacon/states/{state_id}/randao?epoch=%d", epochOld), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -198,7 +197,7 @@ func TestGetRandao(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/randao", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -211,7 +210,7 @@ func TestGetRandao(t *testing.T) {
|
||||
t.Run("epoch too old", func(t *testing.T) {
|
||||
epochTooOld := primitives.Epoch(100000 - st.RandaoMixesLength())
|
||||
request := httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://example.com//eth/v1/beacon/states/{state_id}/randao?epoch=%d", epochTooOld), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -225,7 +224,7 @@ func TestGetRandao(t *testing.T) {
|
||||
t.Run("epoch in the future", func(t *testing.T) {
|
||||
futureEpoch := primitives.Epoch(100000 + 1)
|
||||
request := httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://example.com//eth/v1/beacon/states/{state_id}/randao?epoch=%d", futureEpoch), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -257,7 +256,7 @@ func TestGetRandao(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/randao", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -294,7 +293,7 @@ func TestGetRandao(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/randao", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -453,7 +452,7 @@ func TestGetSyncCommittees(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/sync_committees", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": hexutil.Encode(stRoot[:])})
|
||||
request.SetPathValue("state_id", hexutil.Encode(stRoot[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -503,7 +502,7 @@ func TestGetSyncCommittees(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/sync_committees", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": hexutil.Encode(stRoot[:])})
|
||||
request.SetPathValue("state_id", hexutil.Encode(stRoot[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -547,7 +546,7 @@ func TestGetSyncCommittees(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com//eth/v1/beacon/states/{state_id}/sync_committees", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": hexutil.Encode(stRoot[:])})
|
||||
request.SetPathValue("state_id", hexutil.Encode(stRoot[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -613,7 +612,7 @@ func TestGetSyncCommittees_Future(t *testing.T) {
|
||||
|
||||
epoch := 2 * params.BeaconConfig().EpochsPerSyncCommitteePeriod
|
||||
request := httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://example.com//eth/v1/beacon/states/{state_id}/sync_committees?epoch=%d", epoch), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
s.GetSyncCommittees(writer, request)
|
||||
@@ -625,7 +624,7 @@ func TestGetSyncCommittees_Future(t *testing.T) {
|
||||
|
||||
epoch = 2*params.BeaconConfig().EpochsPerSyncCommitteePeriod - 1
|
||||
request = httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://example.com//eth/v1/beacon/states/{state_id}/sync_committees?epoch=%d", epoch), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer = httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
s.GetSyncCommittees(writer, request)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
@@ -96,7 +95,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "123552314"})
|
||||
request.SetPathValue("block_id", "123552314")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -118,7 +117,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -151,7 +150,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -185,7 +184,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -219,7 +218,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -253,7 +252,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -287,7 +286,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -314,7 +313,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": hexutil.Encode(r[:])})
|
||||
request.SetPathValue("block_id", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -333,7 +332,7 @@ func TestGetBlockV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": hexutil.Encode(r[:])})
|
||||
request.SetPathValue("block_id", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -358,7 +357,7 @@ func TestGetBlockSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -381,7 +380,7 @@ func TestGetBlockSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -404,7 +403,7 @@ func TestGetBlockSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -427,7 +426,7 @@ func TestGetBlockSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -450,7 +449,7 @@ func TestGetBlockSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -517,7 +516,7 @@ func TestGetBlockAttestations(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}/attestations", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -551,7 +550,7 @@ func TestGetBlockAttestations(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}/attestations", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -578,7 +577,7 @@ func TestGetBlockAttestations(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}/attestations", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -597,7 +596,7 @@ func TestGetBlockAttestations(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}/attestations", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -622,7 +621,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -651,7 +650,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -682,7 +681,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -713,7 +712,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -744,7 +743,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -777,7 +776,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -803,7 +802,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": hexutil.Encode(root[:])})
|
||||
request.SetPathValue("block_id", hexutil.Encode(root[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -829,7 +828,7 @@ func TestGetBlindedBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": hexutil.Encode(root[:])})
|
||||
request.SetPathValue("block_id", hexutil.Encode(root[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -852,7 +851,7 @@ func TestGetBlindedBlockSSZ(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -874,7 +873,7 @@ func TestGetBlindedBlockSSZ(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -896,7 +895,7 @@ func TestGetBlindedBlockSSZ(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -918,7 +917,7 @@ func TestGetBlindedBlockSSZ(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -940,7 +939,7 @@ func TestGetBlindedBlockSSZ(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blinded_blocks/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -2803,8 +2802,9 @@ func TestServer_GetBlockRoot(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
blockID := tt.blockID
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, tt.blockID)
|
||||
request.SetPathValue("block_id", blockID["block_id"])
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -2847,7 +2847,7 @@ func TestServer_GetBlockRoot(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2882,7 +2882,7 @@ func TestServer_GetBlockRoot(t *testing.T) {
|
||||
}
|
||||
t.Run("true", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "32"})
|
||||
request.SetPathValue("block_id", "32")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2894,7 +2894,7 @@ func TestServer_GetBlockRoot(t *testing.T) {
|
||||
})
|
||||
t.Run("false", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "64"})
|
||||
request.SetPathValue("block_id", "64")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2910,7 +2910,7 @@ func TestServer_GetBlockRoot(t *testing.T) {
|
||||
func TestGetStateFork(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/states/{state_id}/fork", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", "application/octet-stream")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -2949,7 +2949,7 @@ func TestGetStateFork(t *testing.T) {
|
||||
assert.DeepEqual(t, hexutil.Encode(expectedFork.PreviousVersion), stateForkReponse.Data.PreviousVersion)
|
||||
t.Run("execution optimistic", func(t *testing.T) {
|
||||
request = httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/states/{state_id}/fork", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", "application/octet-stream")
|
||||
writer = httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -2980,7 +2980,7 @@ func TestGetStateFork(t *testing.T) {
|
||||
|
||||
t.Run("finalized", func(t *testing.T) {
|
||||
request = httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/states/{state_id}/fork", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", "application/octet-stream")
|
||||
writer = httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3038,7 +3038,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
|
||||
t.Run("Head all committees", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3059,7 +3059,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
t.Run("Head all committees of epoch 10", func(t *testing.T) {
|
||||
query := url + "?epoch=10"
|
||||
request := httptest.NewRequest(http.MethodGet, query, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3076,7 +3076,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
t.Run("Head all committees of slot 4", func(t *testing.T) {
|
||||
query := url + "?slot=4"
|
||||
request := httptest.NewRequest(http.MethodGet, query, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3102,7 +3102,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
t.Run("Head all committees of index 1", func(t *testing.T) {
|
||||
query := url + "?index=1"
|
||||
request := httptest.NewRequest(http.MethodGet, query, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3128,7 +3128,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
t.Run("Head all committees of slot 2, index 1", func(t *testing.T) {
|
||||
query := url + "?slot=2&index=1"
|
||||
request := httptest.NewRequest(http.MethodGet, query, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3171,7 +3171,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3208,7 +3208,7 @@ func TestGetCommittees(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -3481,7 +3481,7 @@ func TestServer_GetBlockHeader(t *testing.T) {
|
||||
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/headers/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3525,7 +3525,7 @@ func TestServer_GetBlockHeader(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/headers/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": "head"})
|
||||
request.SetPathValue("block_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3549,7 +3549,7 @@ func TestServer_GetBlockHeader(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/headers/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": hexutil.Encode(r[:])})
|
||||
request.SetPathValue("block_id", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3569,7 +3569,7 @@ func TestServer_GetBlockHeader(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/headers/{block_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"block_id": hexutil.Encode(r[:])})
|
||||
request.SetPathValue("block_id", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3621,7 +3621,7 @@ func TestGetFinalityCheckpoints(t *testing.T) {
|
||||
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3651,7 +3651,7 @@ func TestGetFinalityCheckpoints(t *testing.T) {
|
||||
})
|
||||
t.Run("state not found", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "foobar"})
|
||||
request.SetPathValue("state_id", "foobar")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3674,7 +3674,7 @@ func TestGetFinalityCheckpoints(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -3702,7 +3702,7 @@ func TestGetFinalityCheckpoints(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
@@ -30,7 +29,7 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetValidators")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -179,12 +178,12 @@ func (s *Server) GetValidator(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetValidator")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
valId := mux.Vars(r)["validator_id"]
|
||||
valId := r.PathValue("validator_id")
|
||||
if valId == "" {
|
||||
httputil.HandleError(w, "validator_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -244,7 +243,7 @@ func (s *Server) GetValidatorBalances(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetValidatorBalances")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
chainMock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/lookup"
|
||||
@@ -47,7 +46,7 @@ func TestGetValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -86,7 +85,7 @@ func TestGetValidators(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators?id=0&id=1",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -118,7 +117,7 @@ func TestGetValidators(t *testing.T) {
|
||||
fmt.Sprintf("http://example.com/eth/v1/beacon/states/{state_id}/validators?id=%s&id=%s", hexPubkey1, hexPubkey2),
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -148,7 +147,7 @@ func TestGetValidators(t *testing.T) {
|
||||
fmt.Sprintf("http://example.com/eth/v1/beacon/states/{state_id}/validators?id=%s&id=1", hexPubkey),
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -197,7 +196,7 @@ func TestGetValidators(t *testing.T) {
|
||||
fmt.Sprintf("http://example.com/eth/v1/beacon/states/{state_id}/validators?id=%s&id=%s", hexPubkey, hexutil.Encode([]byte(strings.Repeat("x", fieldparams.BLSPubkeyLength)))),
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -220,7 +219,7 @@ func TestGetValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators?id=1&id=99999", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -243,7 +242,7 @@ func TestGetValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -271,7 +270,7 @@ func TestGetValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -306,7 +305,7 @@ func TestGetValidators(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators",
|
||||
&body,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -342,7 +341,7 @@ func TestGetValidators(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators",
|
||||
&body,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -368,7 +367,7 @@ func TestGetValidators(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -398,7 +397,7 @@ func TestGetValidators(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators",
|
||||
&body,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -492,7 +491,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators?status=active", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -523,7 +522,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators?status=active_ongoing", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -553,7 +552,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators?status=exited", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -586,7 +585,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators?status=pending_initialized&status=exited_unslashed",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -619,7 +618,7 @@ func TestGetValidators_FilterByStatus(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validators?status=pending&status=exited_slashed",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -654,7 +653,8 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head", "validator_id": "0"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.SetPathValue("validator_id", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -689,7 +689,8 @@ func TestGetValidator(t *testing.T) {
|
||||
pubKey := st.PubkeyAtIndex(primitives.ValidatorIndex(0))
|
||||
hexPubkey := hexutil.Encode(pubKey[:])
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head", "validator_id": hexPubkey})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.SetPathValue("validator_id", hexPubkey)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -708,7 +709,7 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"validator_id": "1"})
|
||||
request.SetPathValue("validator_id", "1")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -728,7 +729,7 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -748,7 +749,8 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head", "validator_id": "99999"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.SetPathValue("validator_id", "99999")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -768,7 +770,8 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head", "validator_id": hexutil.Encode([]byte(strings.Repeat("x", fieldparams.BLSPubkeyLength)))})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.SetPathValue("validator_id", hexutil.Encode([]byte(strings.Repeat("x", fieldparams.BLSPubkeyLength))))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -791,7 +794,8 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head", "validator_id": "0"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.SetPathValue("validator_id", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -819,7 +823,8 @@ func TestGetValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validators/{validator_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head", "validator_id": "0"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.SetPathValue("validator_id", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -853,7 +858,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validator_balances", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -882,7 +887,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validator_balances?id=0&id=1",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -914,7 +919,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
fmt.Sprintf("http://example.com/eth/v1/beacon/states/{state_id}/validator_balances?id=%s&id=%s", hexPubkey1, hexPubkey2),
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -944,7 +949,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
fmt.Sprintf("http://example.com/eth/v1/beacon/states/{state_id}/validators?id=%s&id=1", hexPubkey),
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -974,7 +979,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
fmt.Sprintf("http://example.com/eth/v1/beacon/states/{state_id}/validator_balances?id=%s&id=%s", hexPubkey, hexutil.Encode([]byte(strings.Repeat("x", fieldparams.BLSPubkeyLength)))),
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -997,7 +1002,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/beacon/states/{state_id}/validator_balances?id=1&id=99999", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1043,7 +1048,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validator_balances?id=0",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1075,7 +1080,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validator_balances?id=0",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1108,7 +1113,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validator_balances",
|
||||
&body,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1136,7 +1141,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validator_balances",
|
||||
nil,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1166,7 +1171,7 @@ func TestGetValidatorBalances(t *testing.T) {
|
||||
"http://example.com/eth/v1/beacon/states/{state_id}/validator_balances",
|
||||
&body,
|
||||
)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ go_library(
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -44,6 +43,5 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
@@ -21,7 +20,7 @@ import (
|
||||
// ExpectedWithdrawals get the withdrawals computed from the specified state, that will be included in the block that gets built on the specified state.
|
||||
func (s *Server) ExpectedWithdrawals(w http.ResponseWriter, r *http.Request) {
|
||||
// Retrieve beacon state
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.WriteError(w, &httputil.DefaultJsonError{
|
||||
Message: "state_id is required in URL params",
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
mock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/testutil"
|
||||
@@ -91,7 +90,7 @@ func TestExpectedWithdrawals_BadRequest(t *testing.T) {
|
||||
Stater: &testutil.MockStater{BeaconState: testCase.state},
|
||||
}
|
||||
request := httptest.NewRequest("GET", testCase.path, nil)
|
||||
request = mux.SetURLVars(request, testCase.urlParams)
|
||||
request.SetPathValue("state_id", testCase.urlParams["state_id"])
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -172,7 +171,7 @@ func TestExpectedWithdrawals(t *testing.T) {
|
||||
request := httptest.NewRequest(
|
||||
"GET", "/eth/v1/builder/states/{state_id}/expected_withdrawals?proposal_slot="+
|
||||
strconv.FormatUint(uint64(currentSlot+params.BeaconConfig().SlotsPerEpoch), 10), nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ go_library(
|
||||
"//network/httputil:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@io_opencensus_go//trace:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -42,6 +41,5 @@ go_test(
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
@@ -24,7 +23,7 @@ func (s *Server) GetBeaconStateV2(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "debug.GetBeaconStateV2")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
blockchainmock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
@@ -43,7 +42,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -71,7 +70,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -99,7 +98,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -127,7 +126,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -155,7 +154,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -191,7 +190,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -230,7 +229,7 @@ func TestGetBeaconStateV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -255,7 +254,7 @@ func TestGetBeaconStateSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -279,7 +278,7 @@ func TestGetBeaconStateSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -303,7 +302,7 @@ func TestGetBeaconStateSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -327,7 +326,7 @@ func TestGetBeaconStateSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
@@ -351,7 +350,7 @@ func TestGetBeaconStateSSZV2(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v2/debug/beacon/states/{state_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
request.Header.Set("Accept", api.OctetStreamMediaType)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -32,7 +32,6 @@ go_library(
|
||||
"//runtime/version:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_wealdtech_go_bytesutil//:go_default_library",
|
||||
"@io_opencensus_go//trace:go_default_library",
|
||||
@@ -66,6 +65,5 @@ go_test(
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
@@ -29,7 +28,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques
|
||||
defer span.End()
|
||||
|
||||
// Get the block
|
||||
blockRootParam, err := hexutil.Decode(mux.Vars(req)["block_root"])
|
||||
blockRootParam, err := hexutil.Decode(req.PathValue("block_root"))
|
||||
if err != nil {
|
||||
httputil.HandleError(w, "invalid block root: "+err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
mock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
@@ -61,10 +60,8 @@ func TestLightClientHandler_GetLightClientBootstrap_Altair(t *testing.T) {
|
||||
Blocker: mockBlocker,
|
||||
HeadFetcher: mockChainService,
|
||||
}
|
||||
muxVars := make(map[string]string)
|
||||
muxVars["block_root"] = hexutil.Encode(r[:])
|
||||
request := httptest.NewRequest("GET", "http://foo.com/", nil)
|
||||
request = mux.SetURLVars(request, muxVars)
|
||||
request.SetPathValue("block_root", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -116,10 +113,8 @@ func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) {
|
||||
Blocker: mockBlocker,
|
||||
HeadFetcher: mockChainService,
|
||||
}
|
||||
muxVars := make(map[string]string)
|
||||
muxVars["block_root"] = hexutil.Encode(r[:])
|
||||
request := httptest.NewRequest("GET", "http://foo.com/", nil)
|
||||
request = mux.SetURLVars(request, muxVars)
|
||||
request.SetPathValue("block_root", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -171,10 +166,8 @@ func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) {
|
||||
Blocker: mockBlocker,
|
||||
HeadFetcher: mockChainService,
|
||||
}
|
||||
muxVars := make(map[string]string)
|
||||
muxVars["block_root"] = hexutil.Encode(r[:])
|
||||
request := httptest.NewRequest("GET", "http://foo.com/", nil)
|
||||
request = mux.SetURLVars(request, muxVars)
|
||||
request.SetPathValue("block_root", hexutil.Encode(r[:]))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ go_library(
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@io_opencensus_go//trace:go_default_library",
|
||||
@@ -58,7 +57,6 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/network:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//p2p/host/peerstore/test:go_default_library",
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
@@ -23,7 +22,7 @@ func (s *Server) GetPeer(w http.ResponseWriter, r *http.Request) {
|
||||
_, span := trace.StartSpan(r.Context(), "node.GetPeer")
|
||||
defer span.End()
|
||||
|
||||
rawId := mux.Vars(r)["peer_id"]
|
||||
rawId := r.PathValue("peer_id")
|
||||
if rawId == "" {
|
||||
httputil.HandleError(w, "peer_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
libp2ptest "github.com/libp2p/go-libp2p/p2p/host/peerstore/test"
|
||||
@@ -43,7 +42,7 @@ func TestGetPeer(t *testing.T) {
|
||||
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/node/peers/{peer_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"peer_id": rawId})
|
||||
request.SetPathValue("peer_id", rawId)
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -60,7 +59,7 @@ func TestGetPeer(t *testing.T) {
|
||||
|
||||
t.Run("Invalid ID", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/node/peers/{peer_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"peer_id": "foo"})
|
||||
request.SetPathValue("peer_id", "foo")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -74,7 +73,7 @@ func TestGetPeer(t *testing.T) {
|
||||
|
||||
t.Run("Peer not found", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "http://example.com/eth/v1/node/peers/{peer_id}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"peer_id": "16Uiu2HAmQqFdEcHbSmQTQuLoAhnMUrgoWoraKK4cUJT6FuuqHqTU"})
|
||||
request.SetPathValue("peer_id", "16Uiu2HAmQqFdEcHbSmQTQuLoAhnMUrgoWoraKK4cUJT6FuuqHqTU")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ go_library(
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//network/httputil:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/sync"
|
||||
@@ -29,7 +28,7 @@ func UintFromQuery(w http.ResponseWriter, r *http.Request, name string, required
|
||||
}
|
||||
|
||||
func UintFromRoute(w http.ResponseWriter, r *http.Request, name string) (string, uint64, bool) {
|
||||
raw := mux.Vars(r)[name]
|
||||
raw := r.PathValue(name)
|
||||
v, valid := ValidateUint(w, name, raw)
|
||||
if !valid {
|
||||
return "", 0, false
|
||||
@@ -50,7 +49,7 @@ func HexFromQuery(w http.ResponseWriter, r *http.Request, name string, length in
|
||||
}
|
||||
|
||||
func HexFromRoute(w http.ResponseWriter, r *http.Request, name string, length int) (string, []byte, bool) {
|
||||
raw := mux.Vars(r)[name]
|
||||
raw := r.PathValue(name)
|
||||
v, valid := ValidateHex(w, name, raw, length)
|
||||
if !valid {
|
||||
return "", nil, false
|
||||
|
||||
@@ -92,7 +92,6 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
"@org_uber_go_mock//gomock:go_default_library",
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
mockChain "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
@@ -1464,7 +1463,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err = body.WriteString("[\"0\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1488,7 +1487,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err = body.WriteString("[\"0\",\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1500,7 +1499,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
})
|
||||
t.Run("no body", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodPost, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1516,7 +1515,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1532,7 +1531,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"foo\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1547,7 +1546,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err = body.WriteString("[\"0\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": strconv.FormatUint(uint64(slots.ToEpoch(bs.Slot())+1), 10)})
|
||||
request.SetPathValue("epoch", strconv.FormatUint(uint64(slots.ToEpoch(bs.Slot())+1), 10))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1572,7 +1571,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
currentEpoch := slots.ToEpoch(bs.Slot())
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": strconv.FormatUint(uint64(currentEpoch+2), 10)})
|
||||
request.SetPathValue("epoch", strconv.FormatUint(uint64(currentEpoch+2), 10))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1588,7 +1587,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err = body.WriteString(fmt.Sprintf("[\"%d\"]", len(pubKeys)))
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1604,7 +1603,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err = body.WriteString(fmt.Sprintf("[\"%d\"]", len(pubKeys)-1))
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1642,7 +1641,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
_, err = body.WriteString("[\"0\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1664,7 +1663,7 @@ func TestGetAttesterDuties(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/attester/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1721,7 +1720,7 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/proposer/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1763,7 +1762,7 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/proposer/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "1"})
|
||||
request.SetPathValue("epoch", "1")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1807,7 +1806,7 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
|
||||
currentEpoch := slots.ToEpoch(bs.Slot())
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/proposer/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": strconv.FormatUint(uint64(currentEpoch+2), 10)})
|
||||
request.SetPathValue("epoch", strconv.FormatUint(uint64(currentEpoch+2), 10))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1845,7 +1844,7 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/proposer/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1867,7 +1866,7 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/proposer/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1923,7 +1922,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1946,7 +1945,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"1\",\"2\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1958,7 +1957,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
})
|
||||
t.Run("no body", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodPost, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1974,7 +1973,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1990,7 +1989,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"foo\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2005,7 +2004,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"1\",\"10\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2021,7 +2020,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2038,7 +2037,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString(fmt.Sprintf("[\"%d\"]", numVals))
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2054,7 +2053,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"5\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": strconv.FormatUint(uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod), 10)})
|
||||
request.SetPathValue("epoch", strconv.FormatUint(uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod), 10))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2111,7 +2110,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"8\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": strconv.FormatUint(uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod), 10)})
|
||||
request.SetPathValue("epoch", strconv.FormatUint(uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod), 10))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2131,7 +2130,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "1"})
|
||||
request.SetPathValue("epoch", "1")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2151,7 +2150,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err := body.WriteString("[\"5\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": strconv.FormatUint(uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod*2), 10)})
|
||||
request.SetPathValue("epoch", strconv.FormatUint(uint64(params.BeaconConfig().EpochsPerSyncCommitteePeriod*2), 10))
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2207,7 +2206,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
_, err = body.WriteString("[\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "1"})
|
||||
request.SetPathValue("epoch", "1")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2229,7 +2228,7 @@ func TestGetSyncCommitteeDuties(t *testing.T) {
|
||||
}
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "http://www.example.com/eth/v1/validator/duties/sync/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "1"})
|
||||
request.SetPathValue("epoch", "1")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2453,7 +2452,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\",\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2472,7 +2471,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\",\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "1"})
|
||||
request.SetPathValue("epoch", "1")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2491,7 +2490,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\",\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "2"})
|
||||
request.SetPathValue("epoch", "2")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2510,7 +2509,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\",\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "3"})
|
||||
request.SetPathValue("epoch", "3")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2541,7 +2540,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\",\"1\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "foo"})
|
||||
request.SetPathValue("epoch", "foo")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2554,7 +2553,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
})
|
||||
t.Run("no body", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "3"})
|
||||
request.SetPathValue("epoch", "3")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2570,7 +2569,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "3"})
|
||||
request.SetPathValue("epoch", "3")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -2586,7 +2585,7 @@ func TestGetLiveness(t *testing.T) {
|
||||
_, err := body.WriteString("[\"0\",\"1\",\"2\"]")
|
||||
require.NoError(t, err)
|
||||
request := httptest.NewRequest(http.MethodPost, "http://example.com/eth/v1/validator/liveness/{epoch}", &body)
|
||||
request = mux.SetURLVars(request, map[string]string{"epoch": "0"})
|
||||
request.SetPathValue("epoch", "0")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ go_library(
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@io_opencensus_go//trace:go_default_library",
|
||||
],
|
||||
@@ -67,7 +66,6 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared"
|
||||
@@ -53,7 +52,7 @@ func (s *Server) GetValidatorCount(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "beacon.GetValidatorCount")
|
||||
defer span.End()
|
||||
|
||||
stateID := mux.Vars(r)["state_id"]
|
||||
stateID := r.PathValue("state_id")
|
||||
|
||||
isOptimistic, err := helpers.IsOptimistic(ctx, []byte(stateID), s.OptimisticModeFetcher, s.Stater, s.ChainInfoFetcher, s.BeaconDB)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
chainMock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/lookup"
|
||||
@@ -85,7 +84,7 @@ func TestGetValidatorCountInvalidRequest(t *testing.T) {
|
||||
Stater: test.stater,
|
||||
}
|
||||
|
||||
testRouter := mux.NewRouter()
|
||||
testRouter := http.NewServeMux()
|
||||
testRouter.HandleFunc("/eth/v1/beacon/states/{state_id}/validator_count", server.GetValidatorCount)
|
||||
s := httptest.NewServer(testRouter)
|
||||
defer s.Close()
|
||||
@@ -465,7 +464,7 @@ func TestGetValidatorCount(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
testRouter := mux.NewRouter()
|
||||
testRouter := http.NewServeMux()
|
||||
testRouter.HandleFunc("/eth/v1/beacon/states/{state_id}/validator_count", server.GetValidatorCount)
|
||||
s := httptest.NewServer(testRouter)
|
||||
defer s.Close()
|
||||
|
||||
@@ -21,7 +21,6 @@ go_library(
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@io_opencensus_go//trace:go_default_library",
|
||||
],
|
||||
@@ -64,7 +63,6 @@ go_test(
|
||||
"//time:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/core"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared"
|
||||
@@ -22,7 +21,7 @@ func (s *Server) GetParticipation(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.GetParticipation")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
@@ -67,7 +66,7 @@ func (s *Server) GetActiveSetChanges(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := trace.StartSpan(r.Context(), "validator.GetActiveSetChanges")
|
||||
defer span.End()
|
||||
|
||||
stateId := mux.Vars(r)["state_id"]
|
||||
stateId := r.PathValue("state_id")
|
||||
if stateId == "" {
|
||||
httputil.HandleError(w, "state_id is required in URL params", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
mock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
@@ -150,7 +149,7 @@ func TestServer_GetValidatorParticipation_CurrentAndPrevEpoch(t *testing.T) {
|
||||
|
||||
url := "http://example.com"
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -250,7 +249,7 @@ func TestServer_GetValidatorParticipation_OrphanedUntilGenesis(t *testing.T) {
|
||||
|
||||
url := "http://example.com"
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -380,7 +379,7 @@ func runGetValidatorParticipationCurrentEpoch(t *testing.T, genState state.Beaco
|
||||
|
||||
url := "http://example.com"
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "head"})
|
||||
request.SetPathValue("state_id", "head")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -430,7 +429,7 @@ func TestServer_GetValidatorActiveSetChanges_NoState(t *testing.T) {
|
||||
|
||||
url := "http://example.com" + fmt.Sprintf("%d", slots.ToEpoch(s.CoreService.GenesisTimeFetcher.CurrentSlot())+1)
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": ""})
|
||||
request.SetPathValue("state_id", "")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -507,7 +506,7 @@ func TestServer_GetValidatorActiveSetChanges(t *testing.T) {
|
||||
|
||||
url := "http://example.com"
|
||||
request := httptest.NewRequest(http.MethodGet, url, nil)
|
||||
request = mux.SetURLVars(request, map[string]string{"state_id": "genesis"})
|
||||
request.SetPathValue("state_id", "genesis")
|
||||
writer := httptest.NewRecorder()
|
||||
writer.Body = &bytes.Buffer{}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||
recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
||||
grpcopentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
|
||||
@@ -134,7 +135,7 @@ type Config struct {
|
||||
ExecutionEngineCaller execution.EngineCaller
|
||||
OptimisticModeFetcher blockchain.OptimisticModeFetcher
|
||||
BlockBuilder builder.BlockBuilder
|
||||
Router *mux.Router
|
||||
Router *http.ServeMux
|
||||
ClockWaiter startup.ClockWaiter
|
||||
BlobStorage *filesystem.BlobStorage
|
||||
TrackedValidatorsCache *cache.TrackedValidatorsCache
|
||||
@@ -309,10 +310,12 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
|
||||
endpoints := s.endpoints(s.cfg.EnableDebugRPCEndpoints, blocker, stater, rewardFetcher, validatorServer, coreService, ch)
|
||||
for _, e := range endpoints {
|
||||
for i := range e.methods {
|
||||
s.cfg.Router.HandleFunc(
|
||||
e.template,
|
||||
fmt.Sprintf("%s %s", e.methods[i], e.template),
|
||||
e.handlerWithMiddleware(),
|
||||
).Methods(e.methods...)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
ethpbv1alpha1.RegisterNodeServer(s.grpcServer, nodeServer)
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
mock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
mockExecution "github.com/prysmaticlabs/prysm/v5/beacon-chain/execution/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/startup"
|
||||
@@ -49,7 +49,7 @@ func TestLifecycle_OK(t *testing.T) {
|
||||
GenesisTimeFetcher: chainService,
|
||||
ExecutionChainService: &mockExecution.Chain{},
|
||||
StateNotifier: chainService.StateNotifier(),
|
||||
Router: mux.NewRouter(),
|
||||
Router: http.NewServeMux(),
|
||||
ClockWaiter: startup.NewClockSynchronizer(),
|
||||
})
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestRPC_InsecureEndpoint(t *testing.T) {
|
||||
HeadFetcher: chainService,
|
||||
ExecutionChainService: &mockExecution.Chain{},
|
||||
StateNotifier: chainService.StateNotifier(),
|
||||
Router: mux.NewRouter(),
|
||||
Router: http.NewServeMux(),
|
||||
ClockWaiter: startup.NewClockSynchronizer(),
|
||||
})
|
||||
|
||||
|
||||
6
deps.bzl
6
deps.bzl
@@ -1380,12 +1380,6 @@ def prysm_deps():
|
||||
sum = "h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_gorilla_mux",
|
||||
importpath = "github.com/gorilla/mux",
|
||||
sum = "h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=",
|
||||
version = "v1.8.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_gorilla_websocket",
|
||||
importpath = "github.com/gorilla/websocket",
|
||||
|
||||
1
go.mod
1
go.mod
@@ -30,7 +30,6 @@ require (
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/google/gofuzz v1.2.0
|
||||
github.com/google/uuid v1.4.0
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gostaticanalysis/comment v1.4.2
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||
|
||||
1
go.sum
1
go.sum
@@ -457,7 +457,6 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
|
||||
@@ -28,7 +28,6 @@ go_library(
|
||||
"@com_github_ethereum_go_ethereum//core/types:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//rpc:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//trie:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
gethTypes "github.com/ethereum/go-ethereum/core/types"
|
||||
gethRPC "github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
gMux "github.com/gorilla/mux"
|
||||
builderAPI "github.com/prysmaticlabs/prysm/v5/api/client/builder"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/signing"
|
||||
@@ -111,7 +110,7 @@ type Builder struct {
|
||||
prevBeaconRoot []byte
|
||||
currPayload interfaces.ExecutionData
|
||||
blobBundle *v1.BlobsBundle
|
||||
mux *gMux.Router
|
||||
mux *http.ServeMux
|
||||
validatorMap map[string]*eth.ValidatorRegistrationV1
|
||||
valLock sync.RWMutex
|
||||
srv *http.Server
|
||||
@@ -141,9 +140,8 @@ func New(opts ...Option) (*Builder, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/", p)
|
||||
router := gMux.NewRouter()
|
||||
router := http.NewServeMux()
|
||||
router.Handle("/", p)
|
||||
router.HandleFunc(statusPath, func(writer http.ResponseWriter, request *http.Request) {
|
||||
writer.WriteHeader(http.StatusOK)
|
||||
})
|
||||
@@ -152,7 +150,7 @@ func New(opts ...Option) (*Builder, error) {
|
||||
router.HandleFunc(blindedPath, p.handleBlindedBlock)
|
||||
addr := net.JoinHostPort(p.cfg.builderHost, strconv.Itoa(p.cfg.builderPort))
|
||||
srv := &http.Server{
|
||||
Handler: mux,
|
||||
Handler: router,
|
||||
Addr: addr,
|
||||
ReadHeaderTimeout: time.Second,
|
||||
}
|
||||
@@ -303,13 +301,12 @@ func (p *Builder) registerValidators(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
func (p *Builder) handleHeaderRequest(w http.ResponseWriter, req *http.Request) {
|
||||
urlParams := gMux.Vars(req)
|
||||
pHash := urlParams["parent_hash"]
|
||||
pHash := req.PathValue("parent_hash")
|
||||
if pHash == "" {
|
||||
http.Error(w, "no valid parent hash", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
reqSlot := urlParams["slot"]
|
||||
reqSlot := req.PathValue("slot")
|
||||
if reqSlot == "" {
|
||||
http.Error(w, "no valid slot provided", http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -60,7 +60,6 @@ go_library(
|
||||
"//validator/keymanager/local:go_default_library",
|
||||
"//validator/keymanager/remote-web3signer:go_default_library",
|
||||
"//validator/rpc:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
|
||||
@@ -6,6 +6,7 @@ package node
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -16,7 +17,6 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/middleware"
|
||||
@@ -112,7 +112,7 @@ func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) {
|
||||
}
|
||||
|
||||
// initialize router used for endpoints
|
||||
router := newRouter(cliCtx)
|
||||
router := http.NewServeMux()
|
||||
// If the --web flag is enabled to administer the validator
|
||||
// client via a web portal, we start the validator client in a different way.
|
||||
// Change Web flag name to enable keymanager API, look at merging initializeFromCLI and initializeForWeb maybe after WebUI DEPRECATED.
|
||||
@@ -134,19 +134,6 @@ func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) {
|
||||
return validatorClient, nil
|
||||
}
|
||||
|
||||
func newRouter(cliCtx *cli.Context) *mux.Router {
|
||||
var allowedOrigins []string
|
||||
if cliCtx.IsSet(flags.HTTPServerCorsDomain.Name) {
|
||||
allowedOrigins = strings.Split(cliCtx.String(flags.HTTPServerCorsDomain.Name), ",")
|
||||
} else {
|
||||
allowedOrigins = strings.Split(flags.HTTPServerCorsDomain.Value, ",")
|
||||
}
|
||||
r := mux.NewRouter()
|
||||
r.Use(middleware.NormalizeQueryValuesHandler)
|
||||
r.Use(middleware.CorsHandler(allowedOrigins))
|
||||
return r
|
||||
}
|
||||
|
||||
// Start every service in the validator client.
|
||||
func (c *ValidatorClient) Start() {
|
||||
c.lock.Lock()
|
||||
@@ -242,7 +229,7 @@ func (c *ValidatorClient) getLegacyDatabaseLocation(
|
||||
return dataDir, dataFile, nil
|
||||
}
|
||||
|
||||
func (c *ValidatorClient) initializeFromCLI(cliCtx *cli.Context, router *mux.Router) error {
|
||||
func (c *ValidatorClient) initializeFromCLI(cliCtx *cli.Context, router *http.ServeMux) error {
|
||||
isInteropNumValidatorsSet := cliCtx.IsSet(flags.InteropNumValidators.Name)
|
||||
isWeb3SignerURLFlagSet := cliCtx.IsSet(flags.Web3SignerURLFlag.Name)
|
||||
|
||||
@@ -286,7 +273,7 @@ func (c *ValidatorClient) initializeFromCLI(cliCtx *cli.Context, router *mux.Rou
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ValidatorClient) initializeForWeb(cliCtx *cli.Context, router *mux.Router) error {
|
||||
func (c *ValidatorClient) initializeForWeb(cliCtx *cli.Context, router *http.ServeMux) error {
|
||||
if cliCtx.IsSet(flags.Web3SignerURLFlag.Name) {
|
||||
// Custom Check For Web3Signer
|
||||
c.wallet = wallet.NewWalletForWeb3Signer(cliCtx)
|
||||
@@ -581,7 +568,7 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*proposer.Sett
|
||||
return l.Load(cliCtx)
|
||||
}
|
||||
|
||||
func (c *ValidatorClient) registerRPCService(router *mux.Router) error {
|
||||
func (c *ValidatorClient) registerRPCService(router *http.ServeMux) error {
|
||||
var vs *client.ValidatorService
|
||||
if err := c.services.FetchService(&vs); err != nil {
|
||||
return err
|
||||
@@ -604,7 +591,17 @@ func (c *ValidatorClient) registerRPCService(router *mux.Router) error {
|
||||
)
|
||||
}
|
||||
port := c.cliCtx.Int(flags.HTTPServerPort.Name)
|
||||
var allowedOrigins []string
|
||||
if c.cliCtx.IsSet(flags.HTTPServerCorsDomain.Name) {
|
||||
allowedOrigins = strings.Split(c.cliCtx.String(flags.HTTPServerCorsDomain.Name), ",")
|
||||
} else {
|
||||
allowedOrigins = strings.Split(flags.HTTPServerCorsDomain.Value, ",")
|
||||
}
|
||||
|
||||
middlewares := []middleware.Middleware{
|
||||
middleware.NormalizeQueryValuesHandler,
|
||||
middleware.CorsHandler(allowedOrigins),
|
||||
}
|
||||
s := rpc.NewServer(c.cliCtx.Context, &rpc.Config{
|
||||
HTTPHost: host,
|
||||
HTTPPort: port,
|
||||
@@ -622,6 +619,7 @@ func (c *ValidatorClient) registerRPCService(router *mux.Router) error {
|
||||
WalletInitializedFeed: c.walletInitializedFeed,
|
||||
ValidatorService: vs,
|
||||
AuthTokenPath: authTokenPath,
|
||||
Middlewares: middlewares,
|
||||
Router: router,
|
||||
})
|
||||
return c.services.RegisterService(s)
|
||||
|
||||
@@ -27,6 +27,7 @@ go_library(
|
||||
"//api/pagination:go_default_library",
|
||||
"//api/server:go_default_library",
|
||||
"//api/server/httprest:go_default_library",
|
||||
"//api/server/middleware:go_default_library",
|
||||
"//api/server/structs:go_default_library",
|
||||
"//async/event:go_default_library",
|
||||
"//beacon-chain/rpc/eth/shared:go_default_library",
|
||||
@@ -68,7 +69,6 @@ go_library(
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_fsnotify_fsnotify//:go_default_library",
|
||||
"@com_github_golang_jwt_jwt_v4//:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
|
||||
"@com_github_grpc_ecosystem_go_grpc_middleware//retry:go_default_library",
|
||||
"@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library",
|
||||
@@ -141,7 +141,6 @@ go_test(
|
||||
"@com_github_golang_jwt_jwt_v4//:go_default_library",
|
||||
"@com_github_golang_protobuf//ptypes/empty",
|
||||
"@com_github_google_uuid//:go_default_library",
|
||||
"@com_github_gorilla_mux//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
"@com_github_tyler_smith_go_bip39//:go_default_library",
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd/validator/flags"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
@@ -839,7 +838,7 @@ func TestServer_SetVoluntaryExit(t *testing.T) {
|
||||
require.NoError(t, tt.mockSetup(s))
|
||||
}
|
||||
req := httptest.NewRequest("POST", fmt.Sprintf("/eth/v1/validator/{pubkey}/voluntary_exit?epoch=%s", tt.epoch), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": tt.pubkey})
|
||||
req.SetPathValue("pubkey", tt.pubkey)
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -859,7 +858,7 @@ func TestServer_SetVoluntaryExit(t *testing.T) {
|
||||
tt.w.epoch, err = client.CurrentEpoch(genesisResponse.GenesisTime)
|
||||
require.NoError(t, err)
|
||||
req2 := httptest.NewRequest("POST", fmt.Sprintf("/eth/v1/validator/{pubkey}/voluntary_exit?epoch=%s", tt.epoch), nil)
|
||||
req2 = mux.SetURLVars(req2, map[string]string{"pubkey": hexutil.Encode(pubKeys[0][:])})
|
||||
req2.SetPathValue("pubkey", hexutil.Encode(pubKeys[0][:]))
|
||||
w2 := httptest.NewRecorder()
|
||||
w2.Body = &bytes.Buffer{}
|
||||
s.SetVoluntaryExit(w2, req2)
|
||||
@@ -952,7 +951,7 @@ func TestServer_GetGasLimit(t *testing.T) {
|
||||
validatorService: vs,
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/gas_limit"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": hexutil.Encode(tt.pubkey[:])})
|
||||
req.SetPathValue("pubkey", hexutil.Encode(tt.pubkey[:]))
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.GetGasLimit(w, req)
|
||||
@@ -1130,7 +1129,7 @@ func TestServer_SetGasLimit(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, fmt.Sprintf("/eth/v1/validator/{pubkey}/gas_limit"), &buf)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": hexutil.Encode(tt.pubkey)})
|
||||
req.SetPathValue("pubkey", hexutil.Encode(tt.pubkey))
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1166,7 +1165,7 @@ func TestServer_SetGasLimit_InvalidPubKey(t *testing.T) {
|
||||
validatorService: &client.ValidatorService{},
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/gas_limit"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0x00"})
|
||||
req.SetPathValue("pubkey", "0x00")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1304,7 +1303,7 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
params.BeaconConfig().DefaultBuilderGasLimit = uint64(globalDefaultGasLimit)
|
||||
|
||||
req := httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/gas_limit"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": hexutil.Encode(tt.pubkey)})
|
||||
req.SetPathValue("pubkey", hexutil.Encode(tt.pubkey))
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
|
||||
@@ -1557,7 +1556,7 @@ func TestServer_ListFeeRecipientByPubkey(t *testing.T) {
|
||||
validatorService: vs,
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.ListFeeRecipientByPubkey(w, req)
|
||||
@@ -1581,7 +1580,7 @@ func TestServer_ListFeeRecipientByPubKey_NoFeeRecipientSet(t *testing.T) {
|
||||
validatorService: vs,
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493"})
|
||||
req.SetPathValue("pubkey", "0xaf2e7ba294e03438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.ListFeeRecipientByPubkey(w, req)
|
||||
@@ -1592,7 +1591,7 @@ func TestServer_ListFeeRecipientByPubKey_NoFeeRecipientSet(t *testing.T) {
|
||||
func TestServer_ListFeeRecipientByPubkey_ValidatorServiceNil(t *testing.T) {
|
||||
s := &Server{}
|
||||
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0x00"})
|
||||
req.SetPathValue("pubkey", "0x00")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.SetFeeRecipientByPubkey(w, req)
|
||||
@@ -1606,7 +1605,7 @@ func TestServer_ListFeeRecipientByPubkey_InvalidPubKey(t *testing.T) {
|
||||
}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0x00"})
|
||||
req.SetPathValue("pubkey", "0x00")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.SetFeeRecipientByPubkey(w, req)
|
||||
@@ -1780,7 +1779,7 @@ func TestServer_FeeRecipientByPubkey(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), &buf)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.SetFeeRecipientByPubkey(w, req)
|
||||
@@ -1797,7 +1796,7 @@ func TestServer_SetFeeRecipientByPubkey_InvalidPubKey(t *testing.T) {
|
||||
validatorService: &client.ValidatorService{},
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodPost, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0x00"})
|
||||
req.SetPathValue("pubkey", "0x00")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.SetFeeRecipientByPubkey(w, req)
|
||||
@@ -1819,7 +1818,7 @@ func TestServer_SetFeeRecipientByPubkey_InvalidFeeRecipient(t *testing.T) {
|
||||
err := json.NewEncoder(&buf).Encode(request)
|
||||
require.NoError(t, err)
|
||||
req := httptest.NewRequest(http.MethodPost, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), &buf)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.SetFeeRecipientByPubkey(w, req)
|
||||
@@ -1881,7 +1880,7 @@ func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) {
|
||||
db: validatorDB,
|
||||
}
|
||||
req := httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.DeleteFeeRecipientByPubkey(w, req)
|
||||
@@ -1895,7 +1894,7 @@ func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) {
|
||||
func TestServer_DeleteFeeRecipientByPubkey_ValidatorServiceNil(t *testing.T) {
|
||||
s := &Server{}
|
||||
req := httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0x1234567878903438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493"})
|
||||
req.SetPathValue("pubkey", "0x1234567878903438ea819bd4033c6c1bf6b04320ee2075b77273c08d02f8a61bcc303c2c06bd3713cb442072ae591493")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.DeleteFeeRecipientByPubkey(w, req)
|
||||
@@ -1909,7 +1908,7 @@ func TestServer_DeleteFeeRecipientByPubkey_InvalidPubKey(t *testing.T) {
|
||||
}
|
||||
|
||||
req := httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/feerecipient"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": "0x123"})
|
||||
req.SetPathValue("pubkey", "0x123")
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.DeleteFeeRecipientByPubkey(w, req)
|
||||
@@ -1938,14 +1937,14 @@ func TestServer_Graffiti(t *testing.T) {
|
||||
err = json.NewEncoder(&buf).Encode(request)
|
||||
require.NoError(t, err)
|
||||
req := httptest.NewRequest(http.MethodPost, fmt.Sprintf("/eth/v1/validator/{pubkey}/graffiti"), &buf)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w := httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.SetGraffiti(w, req)
|
||||
require.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
req = httptest.NewRequest(http.MethodGet, fmt.Sprintf("/eth/v1/validator/{pubkey}/graffiti"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w = httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.GetGraffiti(w, req)
|
||||
@@ -1956,7 +1955,7 @@ func TestServer_Graffiti(t *testing.T) {
|
||||
assert.Equal(t, resp.Data.Pubkey, pubkey)
|
||||
|
||||
req = httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/eth/v1/validator/{pubkey}/graffiti"), nil)
|
||||
req = mux.SetURLVars(req, map[string]string{"pubkey": pubkey})
|
||||
req.SetPathValue("pubkey", pubkey)
|
||||
w = httptest.NewRecorder()
|
||||
w.Body = &bytes.Buffer{}
|
||||
s.DeleteGraffiti(w, req)
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/httprest"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/middleware"
|
||||
"github.com/prysmaticlabs/prysm/v5/async/event"
|
||||
"github.com/prysmaticlabs/prysm/v5/io/logs"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -41,7 +41,8 @@ type Config struct {
|
||||
WalletInitializedFeed *event.Feed
|
||||
ValidatorService *client.ValidatorService
|
||||
AuthTokenPath string
|
||||
Router *mux.Router
|
||||
Middlewares []middleware.Middleware
|
||||
Router *http.ServeMux
|
||||
}
|
||||
|
||||
// Server defining a HTTP server for the remote signer API and registering clients
|
||||
@@ -72,7 +73,7 @@ type Server struct {
|
||||
walletInitializedFeed *event.Feed
|
||||
walletInitialized bool
|
||||
validatorService *client.ValidatorService
|
||||
router *mux.Router
|
||||
router *http.ServeMux
|
||||
logStreamer logs.Streamer
|
||||
logStreamerBufferSize int
|
||||
startFailure error
|
||||
@@ -123,13 +124,16 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
||||
log.WithError(err).Fatal("Could not register beacon chain gRPC or HTTP client")
|
||||
}
|
||||
|
||||
if err := server.InitializeRoutesWithWebHandler(); err != nil {
|
||||
log.WithError(err).Fatal("Could not initialize routes with web handler")
|
||||
}
|
||||
|
||||
// Adding AuthTokenHandler to the list of middlewares
|
||||
cfg.Middlewares = append(cfg.Middlewares, server.AuthTokenHandler)
|
||||
opts := []httprest.Option{
|
||||
httprest.WithRouter(cfg.Router),
|
||||
httprest.WithHTTPAddr(net.JoinHostPort(server.httpHost, fmt.Sprintf("%d", server.httpPort))),
|
||||
httprest.WithMiddlewares(cfg.Middlewares),
|
||||
}
|
||||
|
||||
if err := server.InitializeRoutesWithWebHandler(); err != nil {
|
||||
log.WithError(err).Fatal("Could not initialize routes with web handler")
|
||||
}
|
||||
// create and set a new http server
|
||||
s, err := httprest.New(server.ctx, opts...)
|
||||
@@ -151,7 +155,7 @@ func (s *Server) InitializeRoutesWithWebHandler() error {
|
||||
if err := s.InitializeRoutes(); err != nil {
|
||||
return err
|
||||
}
|
||||
s.router.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
s.router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
if strings.HasPrefix(r.URL.Path, "/api") {
|
||||
r.URL.Path = strings.Replace(r.URL.Path, "/api", "", 1) // used to redirect apis to standard rest APIs
|
||||
s.router.ServeHTTP(w, r)
|
||||
@@ -169,51 +173,49 @@ func (s *Server) InitializeRoutes() error {
|
||||
if s.router == nil {
|
||||
return errors.New("no router found on server")
|
||||
}
|
||||
// Adding Auth Interceptor for the routes below
|
||||
s.router.Use(s.AuthTokenHandler)
|
||||
// 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)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/gas_limit", s.GetGasLimit).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/gas_limit", s.SetGasLimit).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/gas_limit", s.DeleteGasLimit).Methods(http.MethodDelete)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/feerecipient", s.ListFeeRecipientByPubkey).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/feerecipient", s.SetFeeRecipientByPubkey).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/feerecipient", s.DeleteFeeRecipientByPubkey).Methods(http.MethodDelete)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/voluntary_exit", s.SetVoluntaryExit).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/graffiti", s.GetGraffiti).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/graffiti", s.SetGraffiti).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("/eth/v1/validator/{pubkey}/graffiti", s.DeleteGraffiti).Methods(http.MethodDelete)
|
||||
s.router.HandleFunc("GET /eth/v1/keystores", s.ListKeystores)
|
||||
s.router.HandleFunc("POST /eth/v1/keystores", s.ImportKeystores)
|
||||
s.router.HandleFunc("DELETE /eth/v1/keystores", s.DeleteKeystores)
|
||||
s.router.HandleFunc("GET /eth/v1/remotekeys", s.ListRemoteKeys)
|
||||
s.router.HandleFunc("POST /eth/v1/remotekeys", s.ImportRemoteKeys)
|
||||
s.router.HandleFunc("DELETE /eth/v1/remotekeys", s.DeleteRemoteKeys)
|
||||
s.router.HandleFunc("GET /eth/v1/validator/{pubkey}/gas_limit", s.GetGasLimit)
|
||||
s.router.HandleFunc("POST /eth/v1/validator/{pubkey}/gas_limit", s.SetGasLimit)
|
||||
s.router.HandleFunc("DELETE /eth/v1/validator/{pubkey}/gas_limit", s.DeleteGasLimit)
|
||||
s.router.HandleFunc("GET /eth/v1/validator/{pubkey}/feerecipient", s.ListFeeRecipientByPubkey)
|
||||
s.router.HandleFunc("POST /eth/v1/validator/{pubkey}/feerecipient", s.SetFeeRecipientByPubkey)
|
||||
s.router.HandleFunc("DELETE /eth/v1/validator/{pubkey}/feerecipient", s.DeleteFeeRecipientByPubkey)
|
||||
s.router.HandleFunc("POST /eth/v1/validator/{pubkey}/voluntary_exit", s.SetVoluntaryExit)
|
||||
s.router.HandleFunc("GET /eth/v1/validator/{pubkey}/graffiti", s.GetGraffiti)
|
||||
s.router.HandleFunc("POST /eth/v1/validator/{pubkey}/graffiti", s.SetGraffiti)
|
||||
s.router.HandleFunc("DELETE /eth/v1/validator/{pubkey}/graffiti", s.DeleteGraffiti)
|
||||
|
||||
// auth endpoint
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"initialize", s.Initialize).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"initialize", s.Initialize)
|
||||
// accounts endpoints
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"accounts", s.ListAccounts).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"accounts/backup", s.BackupAccounts).Methods(http.MethodPost)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"accounts/voluntary-exit", s.VoluntaryExit).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"accounts", s.ListAccounts)
|
||||
s.router.HandleFunc("POST "+api.WebUrlPrefix+"accounts/backup", s.BackupAccounts)
|
||||
s.router.HandleFunc("POST "+api.WebUrlPrefix+"accounts/voluntary-exit", s.VoluntaryExit)
|
||||
// web health endpoints
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"health/version", s.GetVersion).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"health/logs/validator/stream", s.StreamValidatorLogs).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"health/logs/beacon/stream", s.StreamBeaconLogs).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"health/version", s.GetVersion)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"health/logs/validator/stream", s.StreamValidatorLogs)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"health/logs/beacon/stream", s.StreamBeaconLogs)
|
||||
// Beacon calls
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"beacon/status", s.GetBeaconStatus).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"beacon/summary", s.GetValidatorPerformance).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"beacon/validators", s.GetValidators).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"beacon/balances", s.GetValidatorBalances).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"beacon/peers", s.GetPeers).Methods(http.MethodGet)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"beacon/status", s.GetBeaconStatus)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"beacon/summary", s.GetValidatorPerformance)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"beacon/validators", s.GetValidators)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"beacon/balances", s.GetValidatorBalances)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"beacon/peers", s.GetPeers)
|
||||
// web wallet endpoints
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"wallet", s.WalletConfig).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"wallet/create", s.CreateWallet).Methods(http.MethodPost)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"wallet/keystores/validate", s.ValidateKeystores).Methods(http.MethodPost)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"wallet/recover", s.RecoverWallet).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"wallet", s.WalletConfig)
|
||||
s.router.HandleFunc("POST "+api.WebUrlPrefix+"wallet/create", s.CreateWallet)
|
||||
s.router.HandleFunc("POST "+api.WebUrlPrefix+"wallet/keystores/validate", s.ValidateKeystores)
|
||||
s.router.HandleFunc("POST "+api.WebUrlPrefix+"wallet/recover", s.RecoverWallet)
|
||||
// slashing protection endpoints
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"slashing-protection/export", s.ExportSlashingProtection).Methods(http.MethodGet)
|
||||
s.router.HandleFunc(api.WebUrlPrefix+"slashing-protection/import", s.ImportSlashingProtection).Methods(http.MethodPost)
|
||||
s.router.HandleFunc("GET "+api.WebUrlPrefix+"slashing-protection/export", s.ExportSlashingProtection)
|
||||
s.router.HandleFunc("POST "+api.WebUrlPrefix+"slashing-protection/import", s.ImportSlashingProtection)
|
||||
|
||||
log.Info("Initialized REST API routes")
|
||||
return nil
|
||||
|
||||
@@ -4,13 +4,12 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
)
|
||||
|
||||
func TestServer_InitializeRoutes(t *testing.T) {
|
||||
s := Server{
|
||||
router: mux.NewRouter(),
|
||||
router: http.NewServeMux(),
|
||||
}
|
||||
err := s.InitializeRoutes()
|
||||
require.NoError(t, err)
|
||||
@@ -41,20 +40,23 @@ func TestServer_InitializeRoutes(t *testing.T) {
|
||||
"/v2/validator/beacon/validators": {http.MethodGet},
|
||||
"/v2/validator/initialize": {http.MethodGet},
|
||||
}
|
||||
gotRouteList := make(map[string][]string)
|
||||
err = s.router.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
|
||||
tpl, err1 := route.GetPathTemplate()
|
||||
require.NoError(t, err1)
|
||||
met, err2 := route.GetMethods()
|
||||
require.NoError(t, err2)
|
||||
methods, ok := gotRouteList[tpl]
|
||||
if !ok {
|
||||
gotRouteList[tpl] = []string{met[0]}
|
||||
} else {
|
||||
gotRouteList[tpl] = append(methods, met[0])
|
||||
}
|
||||
return nil
|
||||
})
|
||||
for route, methods := range wantRouteList {
|
||||
for _, method := range methods {
|
||||
r, err := http.NewRequest(method, route, nil)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, wantRouteList, gotRouteList)
|
||||
if method == http.MethodGet {
|
||||
_, path := s.router.Handler(r)
|
||||
require.Equal(t, "GET "+route, path)
|
||||
} else if method == http.MethodPost {
|
||||
_, path := s.router.Handler(r)
|
||||
require.Equal(t, "POST "+route, path)
|
||||
} else if method == http.MethodDelete {
|
||||
_, path := s.router.Handler(r)
|
||||
require.Equal(t, "DELETE "+route, path)
|
||||
} else {
|
||||
t.Errorf("Unsupported method %v", method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user