Skip to content

Commit a87d4f8

Browse files
authored
add http body limit flag (#1327)
1 parent 2cec242 commit a87d4f8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

plugin/evm/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ type Config struct {
222222
// Note: only supports AddressedCall payloads as defined here:
223223
// https://github.com/ava-labs/avalanchego/tree/7623ffd4be915a5185c9ed5e11fa9be15a6e1f00/vms/platformvm/warp/payload#addressedcall
224224
WarpOffChainMessages []hexutil.Bytes `json:"warp-off-chain-messages"`
225+
226+
// RPC settings
227+
HttpBodyLimit uint64 `json:"http-body-limit"`
225228
}
226229

227230
// EthAPIs returns an array of strings representing the Eth APIs that should be enabled

plugin/evm/vm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,10 @@ func newHandler(name string, service interface{}) (http.Handler, error) {
994994
// CreateHandlers makes new http handlers that can handle API calls
995995
func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
996996
handler := rpc.NewServer(vm.config.APIMaxDuration.Duration)
997+
if vm.config.HttpBodyLimit > 0 {
998+
handler.SetHTTPBodyLimit(int(vm.config.HttpBodyLimit))
999+
}
1000+
9971001
enabledAPIs := vm.config.EthAPIs()
9981002
if err := attachEthService(handler, vm.eth.APIs(), enabledAPIs); err != nil {
9991003
return nil, err
@@ -1042,6 +1046,9 @@ func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
10421046
// CreateStaticHandlers makes new http handlers that can handle API calls
10431047
func (vm *VM) CreateStaticHandlers(context.Context) (map[string]http.Handler, error) {
10441048
handler := rpc.NewServer(0)
1049+
if vm.config.HttpBodyLimit > 0 {
1050+
handler.SetHTTPBodyLimit(int(vm.config.HttpBodyLimit))
1051+
}
10451052
if err := handler.RegisterName("static", &StaticService{}); err != nil {
10461053
return nil, err
10471054
}

0 commit comments

Comments
 (0)