mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
rpc: add --rpc.http-body-limit flag for HTTP request body size (#35224)
The HTTP JSON-RPC server caps request bodies at a hardcoded 5 MB (`defaultBodyLimit`), with no way to raise it. EEST bloatnet depth benchmarks post worst-case batch requests larger than that during fill-stateful, which the server rejects with `413 Request Entity Too Large`. This adds `node.Config.HTTPBodyLimit` (default 5 MB), wired through to the HTTP/WS server config, and exposes it via `--rpc.http-body-limit` (value in **megabytes**, default 5). Default behaviour is unchanged.
This commit is contained in:
parent
3620a947ee
commit
7c1959b306
5 changed files with 16 additions and 0 deletions
|
|
@ -177,6 +177,7 @@ var (
|
||||||
utils.AllowUnprotectedTxs,
|
utils.AllowUnprotectedTxs,
|
||||||
utils.BatchRequestLimit,
|
utils.BatchRequestLimit,
|
||||||
utils.BatchResponseMaxSize,
|
utils.BatchResponseMaxSize,
|
||||||
|
utils.HTTPBodyLimitFlag,
|
||||||
utils.RPCTxSyncDefaultTimeoutFlag,
|
utils.RPCTxSyncDefaultTimeoutFlag,
|
||||||
utils.RPCTxSyncMaxTimeoutFlag,
|
utils.RPCTxSyncMaxTimeoutFlag,
|
||||||
utils.RPCGlobalRangeLimitFlag,
|
utils.RPCGlobalRangeLimitFlag,
|
||||||
|
|
|
||||||
|
|
@ -861,6 +861,12 @@ var (
|
||||||
Value: node.DefaultConfig.BatchResponseMaxSize,
|
Value: node.DefaultConfig.BatchResponseMaxSize,
|
||||||
Category: flags.APICategory,
|
Category: flags.APICategory,
|
||||||
}
|
}
|
||||||
|
HTTPBodyLimitFlag = &cli.IntFlag{
|
||||||
|
Name: "rpc.http-body-limit",
|
||||||
|
Usage: "Maximum size (in megabytes) of an HTTP request body",
|
||||||
|
Value: node.DefaultConfig.HTTPBodyLimit / (1024 * 1024),
|
||||||
|
Category: flags.APICategory,
|
||||||
|
}
|
||||||
|
|
||||||
// Network Settings
|
// Network Settings
|
||||||
MaxPeersFlag = &cli.IntFlag{
|
MaxPeersFlag = &cli.IntFlag{
|
||||||
|
|
@ -1361,6 +1367,10 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
|
||||||
if ctx.IsSet(BatchResponseMaxSize.Name) {
|
if ctx.IsSet(BatchResponseMaxSize.Name) {
|
||||||
cfg.BatchResponseMaxSize = ctx.Int(BatchResponseMaxSize.Name)
|
cfg.BatchResponseMaxSize = ctx.Int(BatchResponseMaxSize.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.IsSet(HTTPBodyLimitFlag.Name) {
|
||||||
|
cfg.HTTPBodyLimit = ctx.Int(HTTPBodyLimitFlag.Name) * 1024 * 1024
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setGraphQL creates the GraphQL listener interface string from the set
|
// setGraphQL creates the GraphQL listener interface string from the set
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,9 @@ type Config struct {
|
||||||
// BatchResponseMaxSize is the maximum number of bytes returned from a batched rpc call.
|
// BatchResponseMaxSize is the maximum number of bytes returned from a batched rpc call.
|
||||||
BatchResponseMaxSize int `toml:",omitempty"`
|
BatchResponseMaxSize int `toml:",omitempty"`
|
||||||
|
|
||||||
|
// HTTPBodyLimit is the maximum size (in bytes) of an HTTP request body.
|
||||||
|
HTTPBodyLimit int `toml:",omitempty"`
|
||||||
|
|
||||||
// JWTSecret is the path to the hex-encoded jwt secret.
|
// JWTSecret is the path to the hex-encoded jwt secret.
|
||||||
JWTSecret string `toml:",omitempty"`
|
JWTSecret string `toml:",omitempty"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ var DefaultConfig = Config{
|
||||||
WSModules: []string{"net", "web3"},
|
WSModules: []string{"net", "web3"},
|
||||||
BatchRequestLimit: 1000,
|
BatchRequestLimit: 1000,
|
||||||
BatchResponseMaxSize: 25 * 1000 * 1000,
|
BatchResponseMaxSize: 25 * 1000 * 1000,
|
||||||
|
HTTPBodyLimit: 5 * 1024 * 1024,
|
||||||
GraphQLVirtualHosts: []string{"localhost"},
|
GraphQLVirtualHosts: []string{"localhost"},
|
||||||
P2P: p2p.Config{
|
P2P: p2p.Config{
|
||||||
ListenAddr: ":30303",
|
ListenAddr: ":30303",
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,7 @@ func (n *Node) startRPC() error {
|
||||||
rpcConfig := rpcEndpointConfig{
|
rpcConfig := rpcEndpointConfig{
|
||||||
batchItemLimit: n.config.BatchRequestLimit,
|
batchItemLimit: n.config.BatchRequestLimit,
|
||||||
batchResponseSizeLimit: n.config.BatchResponseMaxSize,
|
batchResponseSizeLimit: n.config.BatchResponseMaxSize,
|
||||||
|
httpBodyLimit: n.config.HTTPBodyLimit,
|
||||||
}
|
}
|
||||||
|
|
||||||
initHttp := func(server *httpServer, port int) error {
|
initHttp := func(server *httpServer, port int) error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue