From 7fbe3894c71895e97aae8bb014e54b50c8d10582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Sat, 22 Feb 2025 20:44:57 +0100 Subject: [PATCH] feat: add max message size flag for gRPC server configuration Introduce a `--max-msg-size` flag to configure the maximum gRPC message size for both receiving and sending. This enhances flexibility and prevents runtime issues with oversized messages by allowing customization through the command line. Defaults to 4MB if unspecified. --- cmd/evm-middleware/commands/run.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/evm-middleware/commands/run.go b/cmd/evm-middleware/commands/run.go index fcf6e54..c1b565b 100644 --- a/cmd/evm-middleware/commands/run.go +++ b/cmd/evm-middleware/commands/run.go @@ -23,6 +23,7 @@ var ( genesisHashHex string ethURL string engineURL string + maxMsgSize int ) func init() { @@ -35,6 +36,7 @@ func init() { runCmd.Flags().StringVar(&genesisHashHex, "genesis-hash", "0x8bf225d50da44f60dee1c4ee6f810fe5b44723c76ac765654b6692d50459f216", "Genesis hash of the EVM chain") runCmd.Flags().StringVar(ðURL, "eth-url", "http://127.0.0.1:8545", "URL of the ETH API exposed by EVM node") runCmd.Flags().StringVar(&engineURL, "engine-url", "http://127.0.0.1:8551", "URL of the Engine API exposed by EVM node") + runCmd.Flags().IntVar(&maxMsgSize, "max-msg-size", 4*1024*1024, "Maximum message size for gRPC connections (in bytes)") // New flag for maxMsgSize // Attach the `runCmd` to the root command rootCmd.AddCommand(runCmd) @@ -70,7 +72,10 @@ var runCmd = &cobra.Command{ log.Println("Starting GRPC server...") server := grpcproxy.NewServer(evmClient, grpcproxy.DefaultConfig()) - s := grpc.NewServer() + s := grpc.NewServer( + grpc.MaxRecvMsgSize(maxMsgSize), // Use the value from the flag + grpc.MaxSendMsgSize(maxMsgSize), // Use the value from the flag + ) pb.RegisterExecutionServiceServer(s, server) wg := sync.WaitGroup{}