State too large to be viewed

Viewed 101

I am trying to debug the gas usage of the following transaction: https://explorer.near.org/transactions/HLCCBGUQLE1jUPJ7cSeaH9VPt4AAGhBLehB2F6zrx58H by requesting the state from the archival node with intention to patch it on the sandbox, however, RPC is returning the following error:

{
  code: -32000,
  message: "Server error",
  data: "State of contract jerry.zest.near is too large to be viewed",
}

I was not able to find the option of paginating the state. Is there a suggestion on what should be done?

2 Answers

Querying the state with too many keys is slow and resource-heavy. The public RPCs are configured to prevent excessive resource consumption.

Currently, the only option is to run your own node with the bumped limits in config.json: https://github.com/near/nearcore/pull/4199 (or reach out to providers who can run the node for you)

I do not believe it can be done with existing RPC nodes.

Moreover, to the best of my knowledge the limit for the state request is not configurable. So the solution is to patch nearcore:

@@ -318,7 +318,7 @@ fn default_view_client_throttle_period() -> Duration {
 }
 
 fn default_trie_viewer_state_size_limit() -> Option<u64> {
-    Some(50_000)
+    Some(50_000_000)
 }

And run your own RPC node compiled with such a patch.

Related