4

Does any of these methods make a call to state_getRuntimeVersion internally?

api.rpc.chain.getHeader api.rpc.chain.getBlockHash api.rpc.chain.getBlock api.rpc.state.getStorage

because, I see double the number of calls to state_getRuntimeVersion than what i'm actually making through polkadot.js (api.rpc.state.getRuntimeVersion). And i'm not making any other rpc calls other than to the methods listed above.

XXXX stats {
  chain_getBlockHash: 115,
  state_getRuntimeVersion: 211,
  system_chain: 1,
  system_properties: 1,
  rpc_methods: 1,
  state_getMetadata: 2,
  state_subscribeRuntimeVersion: 1,
  chain_getFinalizedHead: 7,
  chain_getHeader: 210,
  chain_getBlock: 100,
  state_getStorage: 100,
  system_health: 2
}

1 Answer 1

6

From what I understand RPC calls don't have any underlying or additional calls made when on their own (with the exception of system_health pinging the node with an open websocket connection). It's different when using api.at() for storage queries, there are underlying caching mechanisms that will make certain checks that might require making rpc calls.

That being said, if you would like more detailed logging in order to see what exactly is being called per rpc call, you can set the following env variable for websocket connections:

export DEBUG=api-ws - This can be seen in the following code inside of rpc-provider for websockets.

More details on how logging works can be seen inside of the common package.

Edit: Rpc calls do make underlying calls for registry caching: See answer here: RuntimeVersion in SignedBlock - polkadot.js

Your Answer

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

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