Skip to content

unable to call debug_traceBlockByHash on large blocks #984

Closed
@saurik

Description

@saurik

Blocks have been getting larger, and thereby so has the result of debug_traceBlockByHash. I'm trying to trace block #8942019, hash 0x112b4b6bf1097fa43a8f7406310184040a3a63716091fa3c3322d434617840d6, and I just don't get any result at all. I've managed to determine that it has no issue generating the answer, but writeJSONSkipDeadline is returning an error that is being eaten by handleMsg. I modified coreth to output the error and was able to determine it was weirdly due to a grpc client in avalanchego that refused to receive all of the data.

rpc error: code = ResourceExhausted desc = grpc: received message larger than max (60044844 vs. 4194304)

I've determined the following patch--which notably affects the second block of repeated, similar code: the gresponsewriter--allows me to get the full response. Note that math.MaxInt32 is what grpc uses internally as the default for some other similar limits and is what the go-plugin project also uses to disable all such limits in its client, so I believe it is more correct than merely setting a larger arbitrary limit, assuming I am understanding correctly that this is for responses from APIs (and a user can't connect and send an infinite amount of data to this server).

diff --git a/vms/rpcchainvm/ghttp/http_client.go b/vms/rpcchainvm/ghttp/http_client.go
index fb53d74b4..14a944ff3 100644
--- a/vms/rpcchainvm/ghttp/http_client.go
+++ b/vms/rpcchainvm/ghttp/http_client.go
@@ -4,6 +4,7 @@
 package ghttp

 import (
+       "math"
        "net/http"

        "google.golang.org/grpc"
@@ -49,6 +50,7 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
        })
        writerID := c.broker.NextId()
        go c.broker.AcceptAndServe(writerID, func(opts []grpc.ServerOption) *grpc.Server {
+               opts = append(opts, grpc.MaxRecvMsgSize(math.MaxInt32))
                writer := grpc.NewServer(opts...)
                closer.Add(writer)
                gresponsewriterproto.RegisterWriterServer(writer, gresponsewriter.NewServer(w, c.broker))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions