From 153c261ab80ffe979d1cc751927a7dbc5b29163e Mon Sep 17 00:00:00 2001
From: Boming Zhang <bomingzh@sjtu.edu.cn>
Date: Wed, 6 Nov 2024 07:46:44 -0500
Subject: [PATCH] feat(executor): default 2 GiB grpc msg size

---
 internal/executor/sandbox/grpc.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/internal/executor/sandbox/grpc.go b/internal/executor/sandbox/grpc.go
index 09ac7ef..2582f9c 100644
--- a/internal/executor/sandbox/grpc.go
+++ b/internal/executor/sandbox/grpc.go
@@ -3,6 +3,7 @@ package sandbox
 import (
 	"context"
 	"log/slog"
+	"math"
 
 	"github.com/criyle/go-judge/pb"
 	"google.golang.org/grpc"
@@ -21,10 +22,11 @@ func createExecClient(execServer, token string) (pb.ExecutorClient, error) {
 }
 
 func createGRPCConnection(addr, token string) (*grpc.ClientConn, error) {
+	// max size according to https://protobuf.dev/programming-guides/encoding/#size-limit
 	opts := []grpc.DialOption{
 		grpc.WithTransportCredentials(insecure.NewCredentials()),
 		grpc.WithDefaultCallOptions(
-			grpc.MaxCallRecvMsgSize(512 * 1024 * 1024), // 512 MB
+			grpc.MaxCallRecvMsgSize(math.MaxInt32), // 2 GB
 		),
 	}
 	if token != "" {