Skip to content

Commit

Permalink
add http body limit flag (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur authored Sep 2, 2024
1 parent 2cec242 commit a87d4f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugin/evm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ type Config struct {
// Note: only supports AddressedCall payloads as defined here:
// https://github.com/ava-labs/avalanchego/tree/7623ffd4be915a5185c9ed5e11fa9be15a6e1f00/vms/platformvm/warp/payload#addressedcall
WarpOffChainMessages []hexutil.Bytes `json:"warp-off-chain-messages"`

// RPC settings
HttpBodyLimit uint64 `json:"http-body-limit"`
}

// EthAPIs returns an array of strings representing the Eth APIs that should be enabled
Expand Down
7 changes: 7 additions & 0 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,10 @@ func newHandler(name string, service interface{}) (http.Handler, error) {
// CreateHandlers makes new http handlers that can handle API calls
func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
handler := rpc.NewServer(vm.config.APIMaxDuration.Duration)
if vm.config.HttpBodyLimit > 0 {
handler.SetHTTPBodyLimit(int(vm.config.HttpBodyLimit))
}

enabledAPIs := vm.config.EthAPIs()
if err := attachEthService(handler, vm.eth.APIs(), enabledAPIs); err != nil {
return nil, err
Expand Down Expand Up @@ -1042,6 +1046,9 @@ func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
// CreateStaticHandlers makes new http handlers that can handle API calls
func (vm *VM) CreateStaticHandlers(context.Context) (map[string]http.Handler, error) {
handler := rpc.NewServer(0)
if vm.config.HttpBodyLimit > 0 {
handler.SetHTTPBodyLimit(int(vm.config.HttpBodyLimit))
}
if err := handler.RegisterName("static", &StaticService{}); err != nil {
return nil, err
}
Expand Down

0 comments on commit a87d4f8

Please sign in to comment.