From 9419e8f0a511426fc04cf20107e7454558143a3b Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:59:31 -0400 Subject: [PATCH 1/2] update buffer size --- cmd/soroban-rpc/internal/jsonrpc.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-rpc/internal/jsonrpc.go b/cmd/soroban-rpc/internal/jsonrpc.go index b56c255c2..43e31dd9d 100644 --- a/cmd/soroban-rpc/internal/jsonrpc.go +++ b/cmd/soroban-rpc/internal/jsonrpc.go @@ -25,6 +25,11 @@ import ( "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/transactions" ) +// maxHTTPRequestSize defines the largest request that the http +// would be willing to accept. The implementation uses the default +// MaxBytesHandler to limit the request size. +const maxHTTPRequestSize = 512 * 1024 // half a megabyte + // Handler is the HTTP handler which serves the Soroban JSON RPC responses type Handler struct { bridge jhttp.Bridge @@ -275,8 +280,7 @@ func NewJSONRPCHandler(cfg *config.Config, params HandlerParams) Handler { globalQueueRequestExecutionDurationLimitCounter, params.Logger) - // Limit request sizes to 10MB - handler = http.MaxBytesHandler(handler, 1024*1024*10) + handler = http.MaxBytesHandler(handler, maxHTTPRequestSize) corsMiddleware := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, From 5c27de5c23a23e9d3cfc0da3c658e8eaae965530 Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:31:02 -0400 Subject: [PATCH 2/2] address review comment. --- cmd/soroban-rpc/internal/jsonrpc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/internal/jsonrpc.go b/cmd/soroban-rpc/internal/jsonrpc.go index 43e31dd9d..436c1f264 100644 --- a/cmd/soroban-rpc/internal/jsonrpc.go +++ b/cmd/soroban-rpc/internal/jsonrpc.go @@ -25,9 +25,9 @@ import ( "github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/transactions" ) -// maxHTTPRequestSize defines the largest request that the http -// would be willing to accept. The implementation uses the default -// MaxBytesHandler to limit the request size. +// maxHTTPRequestSize defines the largest request size that the http handler +// would be willing to accept before dropping the request. The implementation +// uses the default MaxBytesHandler to limit the request size. const maxHTTPRequestSize = 512 * 1024 // half a megabyte // Handler is the HTTP handler which serves the Soroban JSON RPC responses