0

I have some pallet that provide storage SomeValue, and this storage was exposed through #[pallet::getter(fn some_value)]. Having removed this getter in favour of a paged RPC API, I was thinking that this would allow avoiding a malicious client to query repeatedly the entire storage, that potentially could contain a lot of data.

I may have missed the point here, since in the Runtime storage documentation is stated:

The optional getter extension only impact the way that a storage item can be accessed from within Substrate code—you will always be able to query the storage of your runtime to get the value of a storage item.

Therefore,

  • is the continued and complete availability of the storage a wanted behaviour of a blockchain?
  • Is limiting the amount of data on chain the only strategy preventing an attacker that queries continuously a storage to introduce instability in the system?
  • is there a possibility to define some weights in retrieving the chain state?

1 Answer 1

1

#[pallet::getter(fn some_value)] does not affect the ability for storage to be queried. It's purpose is only to provide an internal Rust function which can be used in pallet development.

From the node side, the RPC getStorage and the other state RPCs are always available.

So yes, technically it is possible to waste the resources of a node by continually querying lots of storage, but this is true for basically any RPC the node exposes, since they all take some computation to execute.

To protect against these kinds of attacks here are some suggestions

  • Do not expose your node to the public internet, at least not without some kind of network traffic controller in front of it like cloudflare.
  • Adjust your RPC limits with CLI flags:
--rpc-max-request-size <RPC_MAX_REQUEST_SIZE>
    Set the the maximum RPC request payload size for both HTTP and WS in megabytes. Default
    is 15MiB

--rpc-max-response-size <RPC_MAX_RESPONSE_SIZE>
    Set the the maximum RPC response payload size for both HTTP and WS in megabytes. Default
    is 15MiB

--rpc-max-subscriptions-per-connection <RPC_MAX_SUBSCRIPTIONS_PER_CONNECTION>
    Set the the maximum concurrent subscriptions per connection. Default is 1024

More suggestions for running a node safely can be found here:

https://wiki.polkadot.network/docs/build-node-management

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.