mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Update gateway max resv size to 16MB (#5756)
* Update max resv size to 16MB * Merge refs/heads/master into 5752 * Use GrpcMaxCallRecvMsgSizeFlag for beacon node * Merge branch '5752' of github.com:prysmaticlabs/prysm into 5752 * Typo * Fix server * Merge refs/heads/master into 5752 * Merge refs/heads/master into 5752 * Merge refs/heads/master into 5752 * Merge refs/heads/master into 5752 * Update beacon-chain/gateway/server/main.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * Merge refs/heads/master into 5752
This commit is contained in:
@@ -32,6 +32,7 @@ type Gateway struct {
|
||||
allowedOrigins []string
|
||||
startFailure error
|
||||
enableDebugRPCEndpoints bool
|
||||
maxCallRecvMsgSize uint64
|
||||
}
|
||||
|
||||
// Start the gateway service. This serves the HTTP JSON traffic on the specified
|
||||
@@ -42,7 +43,7 @@ func (g *Gateway) Start() {
|
||||
|
||||
log.WithField("address", g.gatewayAddr).Info("Starting gRPC gateway.")
|
||||
|
||||
conn, err := dial(ctx, "tcp", g.remoteAddr)
|
||||
conn, err := g.dial(ctx, "tcp", g.remoteAddr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to connect to gRPC server")
|
||||
g.startFailure = err
|
||||
@@ -125,6 +126,7 @@ func New(
|
||||
mux *http.ServeMux,
|
||||
allowedOrigins []string,
|
||||
enableDebugRPCEndpoints bool,
|
||||
maxCallRecvMsgSize uint64,
|
||||
) *Gateway {
|
||||
if mux == nil {
|
||||
mux = http.NewServeMux()
|
||||
@@ -137,14 +139,15 @@ func New(
|
||||
mux: mux,
|
||||
allowedOrigins: allowedOrigins,
|
||||
enableDebugRPCEndpoints: enableDebugRPCEndpoints,
|
||||
maxCallRecvMsgSize: maxCallRecvMsgSize,
|
||||
}
|
||||
}
|
||||
|
||||
// dial the gRPC server.
|
||||
func dial(ctx context.Context, network, addr string) (*grpc.ClientConn, error) {
|
||||
func (g *Gateway) dial(ctx context.Context, network, addr string) (*grpc.ClientConn, error) {
|
||||
switch network {
|
||||
case "tcp":
|
||||
return dialTCP(ctx, addr)
|
||||
return g.dialTCP(ctx, addr)
|
||||
case "unix":
|
||||
return dialUnix(ctx, addr)
|
||||
default:
|
||||
@@ -154,8 +157,18 @@ func dial(ctx context.Context, network, addr string) (*grpc.ClientConn, error) {
|
||||
|
||||
// dialTCP creates a client connection via TCP.
|
||||
// "addr" must be a valid TCP address with a port number.
|
||||
func dialTCP(ctx context.Context, addr string) (*grpc.ClientConn, error) {
|
||||
return grpc.DialContext(ctx, addr, grpc.WithInsecure())
|
||||
func (g *Gateway) dialTCP(ctx context.Context, addr string) (*grpc.ClientConn, error) {
|
||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
|
||||
if g.enableDebugRPCEndpoints {
|
||||
opts = append(opts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(int(g.maxCallRecvMsgSize))))
|
||||
}
|
||||
|
||||
return grpc.DialContext(
|
||||
ctx,
|
||||
addr,
|
||||
opts...,
|
||||
)
|
||||
}
|
||||
|
||||
// dialUnix creates a client connection via a unix domain socket.
|
||||
|
||||
@@ -21,6 +21,7 @@ var (
|
||||
debug = flag.Bool("debug", false, "Enable debug logging")
|
||||
allowedOrigins = flag.String("corsdomain", "", "A comma separated list of CORS domains to allow")
|
||||
enableDebugRPCEndpoints = flag.Bool("enable-debug-rpc-endpoints", false, "Enable debug rpc endpoints such as /eth/v1alpha1/beacon/state")
|
||||
grpcMaxMsgSize = flag.Int("grpc-max-msg-size", 1<<22, "Integer to define max recieve message call size")
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -43,6 +44,7 @@ func main() {
|
||||
mux,
|
||||
strings.Split(*allowedOrigins, ","),
|
||||
*enableDebugRPCEndpoints,
|
||||
uint64(*grpcMaxMsgSize),
|
||||
)
|
||||
mux.HandleFunc("/swagger/", gateway.SwaggerServer())
|
||||
mux.HandleFunc("/healthz", healthzServer(gw))
|
||||
|
||||
@@ -88,6 +88,7 @@ var appFlags = []cli.Flag{
|
||||
cmd.EnableUPnPFlag,
|
||||
cmd.ConfigFileFlag,
|
||||
cmd.ChainConfigFileFlag,
|
||||
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -594,6 +594,7 @@ func (b *BeaconNode) registerGRPCGateway() error {
|
||||
nil, /*optional mux*/
|
||||
allowedOrigins,
|
||||
enableDebugRPCEndpoints,
|
||||
b.cliCtx.Uint64(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ var appHelpFlagGroups = []flagGroup{
|
||||
cmd.ClearDB,
|
||||
cmd.ConfigFileFlag,
|
||||
cmd.ChainConfigFileFlag,
|
||||
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -179,4 +179,10 @@ var (
|
||||
Name: "chain-config-file",
|
||||
Usage: "The path to a YAML file with chain config values",
|
||||
}
|
||||
// GrpcMaxCallRecvMsgSizeFlag defines the max call message size for GRPC
|
||||
GrpcMaxCallRecvMsgSizeFlag = &cli.IntFlag{
|
||||
Name: "grpc-max-msg-size",
|
||||
Usage: "Integer to define max recieve message call size (default: 4194304 (for 40MB))",
|
||||
Value: 1 << 22,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -33,11 +33,6 @@ var (
|
||||
Name: "graffiti",
|
||||
Usage: "String to include in proposed blocks",
|
||||
}
|
||||
// GrpcMaxCallRecvMsgSizeFlag defines the max call message size for GRPC
|
||||
GrpcMaxCallRecvMsgSizeFlag = &cli.IntFlag{
|
||||
Name: "grpc-max-msg-size",
|
||||
Usage: "Integer to define max recieve message call size (default: 52428800 (for 50Mb)).",
|
||||
}
|
||||
// GrpcRetriesFlag defines the number of times to retry a failed gRPC request.
|
||||
GrpcRetriesFlag = &cli.UintFlag{
|
||||
Name: "grpc-retries",
|
||||
|
||||
@@ -47,7 +47,6 @@ var appFlags = []cli.Flag{
|
||||
flags.UnencryptedKeysFlag,
|
||||
flags.InteropStartIndex,
|
||||
flags.InteropNumValidators,
|
||||
flags.GrpcMaxCallRecvMsgSizeFlag,
|
||||
flags.GrpcRetriesFlag,
|
||||
flags.GrpcHeadersFlag,
|
||||
flags.KeyManager,
|
||||
@@ -72,6 +71,7 @@ var appFlags = []cli.Flag{
|
||||
cmd.LogFileName,
|
||||
cmd.ConfigFileFlag,
|
||||
cmd.ChainConfigFileFlag,
|
||||
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -183,7 +183,7 @@ func (s *ValidatorClient) registerClientService(ctx *cli.Context, keyManager key
|
||||
emitAccountMetrics := ctx.Bool(flags.AccountMetricsFlag.Name)
|
||||
cert := ctx.String(flags.CertFlag.Name)
|
||||
graffiti := ctx.String(flags.GraffitiFlag.Name)
|
||||
maxCallRecvMsgSize := ctx.Int(flags.GrpcMaxCallRecvMsgSizeFlag.Name)
|
||||
maxCallRecvMsgSize := ctx.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name)
|
||||
grpcRetries := ctx.Uint(flags.GrpcRetriesFlag.Name)
|
||||
v, err := client.NewValidatorService(context.Background(), &client.Config{
|
||||
Endpoint: endpoint,
|
||||
|
||||
@@ -57,6 +57,7 @@ var appHelpFlagGroups = []flagGroup{
|
||||
cmd.LogFileName,
|
||||
cmd.ConfigFileFlag,
|
||||
cmd.ChainConfigFileFlag,
|
||||
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -82,7 +83,6 @@ var appHelpFlagGroups = []flagGroup{
|
||||
flags.DisablePenaltyRewardLogFlag,
|
||||
flags.UnencryptedKeysFlag,
|
||||
flags.GraffitiFlag,
|
||||
flags.GrpcMaxCallRecvMsgSizeFlag,
|
||||
flags.GrpcRetriesFlag,
|
||||
flags.GrpcHeadersFlag,
|
||||
flags.AccountMetricsFlag,
|
||||
|
||||
Reference in New Issue
Block a user