SCORU/Node: readonly durable RPC
Background
Currently the only way to inspect the state of a running wasm kernel is through the /global/block/<block_id>/state?key=<key> RPC endpoint, which returns the hex-encoded data of the value in the context at the given key.
While it is possible to build a simple view of the kernel state from this, it has some restrictions w.r.t. durable storage:
- Constructing the actual-value from the RPC endpoint requires
- knowledge of the internals of
Chunked_byte_vectorand durable's use of the special@subkey - either knowing statically the length of a value, or multiple calls to the endpoint to retrieve both the length of the value, and all its chunks
- knowledge of the internals of
- There is no means for discovering other values (one can only lookup values that you expect to be there)
- The keys for the context are subtely different compared to the keys for durable storage (e.g. no
/prefix) which leads to further confusion
Goal
A new RPC endpoint could be added to give a readonly view of durable storage, e.g. /global/block/<block_id>/durable/<operation>?key=<durable_key> where <operation> could be one of:
-
valuereturns the value stored at<durable_key>, if it exists -
lengthreturns the size of the value stored at<durable_key>if it exists -
subkeysreturns the subkeys of<durable_key>if they exist
e.g. once a kernel is running on the rollup, then a request to /global/block/head/durable/value?key=/kernel/boot.wasm would return the hex-encoded WASM of the currently running kernel.
Motivation
Such an RPC would cover a significant number of use-cases for 'kernel-specific' views over durable storage, and allow a kernel-client to produce a reasonable view/interpretation of what the kernel is doing.
e.g. for the prototype tx-client such an endpoint would allow discoverability of other accounts within the TX-kernel rollup, or list tickets which have been recieved into an account - even where the contents of the ticket are not necessarily known.