mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Register v1alpha2
endpoints in the gateway (#9768)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
7a825a79ae
commit
280dc4ecf0
@ -11,26 +11,26 @@ import (
|
||||
|
||||
// MuxConfig contains configuration that should be used when registering the beacon node in the gateway.
|
||||
type MuxConfig struct {
|
||||
Handler gateway.MuxHandler
|
||||
EthPbMux *gateway.PbMux
|
||||
V1Alpha1PbMux *gateway.PbMux
|
||||
Handler gateway.MuxHandler
|
||||
EthPbMux *gateway.PbMux
|
||||
V1AlphaPbMux *gateway.PbMux
|
||||
}
|
||||
|
||||
// DefaultConfig returns a fully configured MuxConfig with standard gateway behavior.
|
||||
func DefaultConfig(enableDebugRPCEndpoints bool, httpModules string) MuxConfig {
|
||||
var v1Alpha1PbHandler, ethPbHandler *gateway.PbMux
|
||||
var v1AlphaPbHandler, ethPbHandler *gateway.PbMux
|
||||
if flags.EnableHTTPPrysmAPI(httpModules) {
|
||||
v1Alpha1Registrations := []gateway.PbHandlerRegistration{
|
||||
v1AlphaRegistrations := []gateway.PbHandlerRegistration{
|
||||
ethpbalpha.RegisterNodeHandler,
|
||||
ethpbalpha.RegisterBeaconChainHandler,
|
||||
ethpbalpha.RegisterBeaconNodeValidatorHandler,
|
||||
ethpbalpha.RegisterHealthHandler,
|
||||
}
|
||||
if enableDebugRPCEndpoints {
|
||||
v1Alpha1Registrations = append(v1Alpha1Registrations, ethpbalpha.RegisterDebugHandler)
|
||||
v1AlphaRegistrations = append(v1AlphaRegistrations, ethpbalpha.RegisterDebugHandler)
|
||||
|
||||
}
|
||||
v1Alpha1Mux := gwruntime.NewServeMux(
|
||||
v1AlphaMux := gwruntime.NewServeMux(
|
||||
gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.HTTPBodyMarshaler{
|
||||
Marshaler: &gwruntime.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
@ -45,10 +45,10 @@ func DefaultConfig(enableDebugRPCEndpoints bool, httpModules string) MuxConfig {
|
||||
"text/event-stream", &gwruntime.EventSourceJSONPb{},
|
||||
),
|
||||
)
|
||||
v1Alpha1PbHandler = &gateway.PbMux{
|
||||
Registrations: v1Alpha1Registrations,
|
||||
Patterns: []string{"/eth/v1alpha1/"},
|
||||
Mux: v1Alpha1Mux,
|
||||
v1AlphaPbHandler = &gateway.PbMux{
|
||||
Registrations: v1AlphaRegistrations,
|
||||
Patterns: []string{"/eth/v1alpha1/", "/eth/v1alpha2/"},
|
||||
Mux: v1AlphaMux,
|
||||
}
|
||||
}
|
||||
if flags.EnableHTTPEthAPI(httpModules) {
|
||||
@ -83,7 +83,7 @@ func DefaultConfig(enableDebugRPCEndpoints bool, httpModules string) MuxConfig {
|
||||
}
|
||||
|
||||
return MuxConfig{
|
||||
EthPbMux: ethPbHandler,
|
||||
V1Alpha1PbMux: v1Alpha1PbHandler,
|
||||
EthPbMux: ethPbHandler,
|
||||
V1AlphaPbMux: v1AlphaPbHandler,
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,11 @@ func TestDefaultConfig(t *testing.T) {
|
||||
assert.Equal(t, "/internal/eth/v1/", cfg.EthPbMux.Patterns[0])
|
||||
assert.Equal(t, "/internal/eth/v2/", cfg.EthPbMux.Patterns[1])
|
||||
assert.Equal(t, 4, len(cfg.EthPbMux.Registrations))
|
||||
assert.NotNil(t, cfg.V1Alpha1PbMux.Mux)
|
||||
require.Equal(t, 1, len(cfg.V1Alpha1PbMux.Patterns))
|
||||
assert.Equal(t, "/eth/v1alpha1/", cfg.V1Alpha1PbMux.Patterns[0])
|
||||
assert.Equal(t, 4, len(cfg.V1Alpha1PbMux.Registrations))
|
||||
assert.NotNil(t, cfg.V1AlphaPbMux.Mux)
|
||||
require.Equal(t, 2, len(cfg.V1AlphaPbMux.Patterns))
|
||||
assert.Equal(t, "/eth/v1alpha1/", cfg.V1AlphaPbMux.Patterns[0])
|
||||
assert.Equal(t, "/eth/v1alpha2/", cfg.V1AlphaPbMux.Patterns[1])
|
||||
assert.Equal(t, 4, len(cfg.V1AlphaPbMux.Registrations))
|
||||
})
|
||||
|
||||
t.Run("With debug endpoints", func(t *testing.T) {
|
||||
@ -29,10 +30,11 @@ func TestDefaultConfig(t *testing.T) {
|
||||
assert.Equal(t, "/internal/eth/v1/", cfg.EthPbMux.Patterns[0])
|
||||
assert.Equal(t, "/internal/eth/v2/", cfg.EthPbMux.Patterns[1])
|
||||
assert.Equal(t, 5, len(cfg.EthPbMux.Registrations))
|
||||
assert.NotNil(t, cfg.V1Alpha1PbMux.Mux)
|
||||
require.Equal(t, 1, len(cfg.V1Alpha1PbMux.Patterns))
|
||||
assert.Equal(t, "/eth/v1alpha1/", cfg.V1Alpha1PbMux.Patterns[0])
|
||||
assert.Equal(t, 5, len(cfg.V1Alpha1PbMux.Registrations))
|
||||
assert.NotNil(t, cfg.V1AlphaPbMux.Mux)
|
||||
require.Equal(t, 2, len(cfg.V1AlphaPbMux.Patterns))
|
||||
assert.Equal(t, "/eth/v1alpha1/", cfg.V1AlphaPbMux.Patterns[0])
|
||||
assert.Equal(t, "/eth/v1alpha2/", cfg.V1AlphaPbMux.Patterns[1])
|
||||
assert.Equal(t, 5, len(cfg.V1AlphaPbMux.Registrations))
|
||||
})
|
||||
t.Run("Without Prysm API", func(t *testing.T) {
|
||||
cfg := DefaultConfig(true, "eth")
|
||||
@ -40,14 +42,15 @@ func TestDefaultConfig(t *testing.T) {
|
||||
require.Equal(t, 2, len(cfg.EthPbMux.Patterns))
|
||||
assert.Equal(t, "/internal/eth/v1/", cfg.EthPbMux.Patterns[0])
|
||||
assert.Equal(t, 5, len(cfg.EthPbMux.Registrations))
|
||||
assert.Equal(t, (*gateway.PbMux)(nil), cfg.V1Alpha1PbMux)
|
||||
assert.Equal(t, (*gateway.PbMux)(nil), cfg.V1AlphaPbMux)
|
||||
})
|
||||
t.Run("Without Eth API", func(t *testing.T) {
|
||||
cfg := DefaultConfig(true, "prysm")
|
||||
assert.Equal(t, (*gateway.PbMux)(nil), cfg.EthPbMux)
|
||||
assert.NotNil(t, cfg.V1Alpha1PbMux.Mux)
|
||||
require.Equal(t, 1, len(cfg.V1Alpha1PbMux.Patterns))
|
||||
assert.Equal(t, "/eth/v1alpha1/", cfg.V1Alpha1PbMux.Patterns[0])
|
||||
assert.Equal(t, 5, len(cfg.V1Alpha1PbMux.Registrations))
|
||||
assert.NotNil(t, cfg.V1AlphaPbMux.Mux)
|
||||
require.Equal(t, 2, len(cfg.V1AlphaPbMux.Patterns))
|
||||
assert.Equal(t, "/eth/v1alpha1/", cfg.V1AlphaPbMux.Patterns[0])
|
||||
assert.Equal(t, "/eth/v1alpha2/", cfg.V1AlphaPbMux.Patterns[1])
|
||||
assert.Equal(t, 5, len(cfg.V1AlphaPbMux.Registrations))
|
||||
})
|
||||
}
|
||||
|
@ -778,8 +778,8 @@ func (b *BeaconNode) registerGRPCGateway() error {
|
||||
|
||||
gatewayConfig := gateway.DefaultConfig(enableDebugRPCEndpoints, httpModules)
|
||||
muxs := make([]*apigateway.PbMux, 0)
|
||||
if gatewayConfig.V1Alpha1PbMux != nil {
|
||||
muxs = append(muxs, gatewayConfig.V1Alpha1PbMux)
|
||||
if gatewayConfig.V1AlphaPbMux != nil {
|
||||
muxs = append(muxs, gatewayConfig.V1AlphaPbMux)
|
||||
}
|
||||
if gatewayConfig.EthPbMux != nil {
|
||||
muxs = append(muxs, gatewayConfig.EthPbMux)
|
||||
|
@ -46,8 +46,8 @@ func main() {
|
||||
|
||||
gatewayConfig := beaconGateway.DefaultConfig(*enableDebugRPCEndpoints, *httpModules)
|
||||
muxs := make([]*gateway.PbMux, 0)
|
||||
if gatewayConfig.V1Alpha1PbMux != nil {
|
||||
muxs = append(muxs, gatewayConfig.V1Alpha1PbMux)
|
||||
if gatewayConfig.V1AlphaPbMux != nil {
|
||||
muxs = append(muxs, gatewayConfig.V1AlphaPbMux)
|
||||
}
|
||||
if gatewayConfig.EthPbMux != nil {
|
||||
muxs = append(muxs, gatewayConfig.EthPbMux)
|
||||
|
Loading…
Reference in New Issue
Block a user