Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit 9cf477e

Browse files
authored
feat: add max message size flag for gRPC server configuration (#32)
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.
1 parent 1d12dc9 commit 9cf477e

File tree

1 file changed

+6
-1
lines changed
  • cmd/evm-middleware/commands

1 file changed

+6
-1
lines changed

cmd/evm-middleware/commands/run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var (
2323
genesisHashHex string
2424
ethURL string
2525
engineURL string
26+
maxMsgSize int
2627
)
2728

2829
func init() {
@@ -35,6 +36,7 @@ func init() {
3536
runCmd.Flags().StringVar(&genesisHashHex, "genesis-hash", "0x8bf225d50da44f60dee1c4ee6f810fe5b44723c76ac765654b6692d50459f216", "Genesis hash of the EVM chain")
3637
runCmd.Flags().StringVar(&ethURL, "eth-url", "http://127.0.0.1:8545", "URL of the ETH API exposed by EVM node")
3738
runCmd.Flags().StringVar(&engineURL, "engine-url", "http://127.0.0.1:8551", "URL of the Engine API exposed by EVM node")
39+
runCmd.Flags().IntVar(&maxMsgSize, "max-msg-size", 4*1024*1024, "Maximum message size for gRPC connections (in bytes)") // New flag for maxMsgSize
3840

3941
// Attach the `runCmd` to the root command
4042
rootCmd.AddCommand(runCmd)
@@ -70,7 +72,10 @@ var runCmd = &cobra.Command{
7072

7173
log.Println("Starting GRPC server...")
7274
server := grpcproxy.NewServer(evmClient, grpcproxy.DefaultConfig())
73-
s := grpc.NewServer()
75+
s := grpc.NewServer(
76+
grpc.MaxRecvMsgSize(maxMsgSize), // Use the value from the flag
77+
grpc.MaxSendMsgSize(maxMsgSize), // Use the value from the flag
78+
)
7479
pb.RegisterExecutionServiceServer(s, server)
7580

7681
wg := sync.WaitGroup{}

0 commit comments

Comments
 (0)