Skip to content

Lock-in RPC api #1977

@Mirko-von-Leipzig

Description

@Mirko-von-Leipzig

Our RPC api is mostly complete. This issue serves to discuss any remaining changes or outstanding functionality that we may want.

We're only looking to finalize the RPC public facing method definitions. This excludes the actual input/output message definitions as we still want to separately decide on the schema/codec.

In other words, this issue is only about finalizing the method signatures and intents.


Account syncing

SyncAccountVault and SyncAccountStorageMaps currently paginate by returning all changes within a block range, even ones which overwrite each other. This lets us delimit pages at block boundaries, and since blocks are limited in capacity, this means we have a manageable response size.

The downside of this is that the client throws most of this away, retaining only the aggregated information i.e. the latest value for each slot/key. It would therefore be more efficient for both server and client if we only send the final value.

The original intention was to let the client sync to any block desired, but that roles has been filled by SyncMmr iiuc. So a client will

  1. use SyncMmr to determine which exact block to sync to
  2. use the account methods to end at that block
  3. drop all intermediate values

Instead, we could only do (1) + send final values. The open questions are:

  • Are there any use cases which are served by the current API?
  • How do we paginate, if not at block boundaries?
    • We could simply paginate by key i.e. index
    • If clients don't trust server, we could also send the merkle proof for the page

Block and proof streams

#1960 and #1961 touch on this, but it might be nicer to have the store push new blocks and proofs, instead of having clients poll for them.

#1960 might also introduce a dedicated GetProof endpoint.

The benefit would be lower latency between store instances, and no unnecessary polls (though the latter is probably a minor issue). Downside is slightly more complexity, and potentially a DoS vector if many open stream connections. This may be better as an internal method only - though it would be nice to have this be public so anyone can create a personal RPC+store using these (instead we would have to have either both polling and streaming, or only polling).

The idea would be to have separate subscriptions for blocks and proofs, starting at some block height forwards. This enables syncing from any block height onward, maybe in combination with SyncMmr for security.


Mempool transaction status

We may want an endpoint for clients to know the status of a transaction within the mempool.

This is useful so that a client can know if the transaction(s) are still pending, or have been reverted for some reason. While the client can detect an expired transaction, it cannot do this if the transaction builds on some other expired state, or if the node resets, or just decides to evict the transaction for whatever reason.

The current client implementation marks a transaction as failed after some configurable number of blocks have passed. Which is of course not a perfect solution.

We could have a dedicated block-producer endpoint for this (re-exposed via RPC ofc). Where the mempool would retain information about transactions still in the mempool, as well as recently reverted transactions (kept for some configurable amount of time/blocks).

ito I think we can make this efficient by having a dedicated task connected to the mempool via a channel. The mempool sends transaction events to this task, which aggregates and manages them. The RPC endpoint then interacts with the state from this task. Given sufficient channel capacity, I don't think this endpoint would be an overload.

Open question: what states would we be interested in?

  • submitted aka in-mempool aka in-queue aka pending
  • reverted (kept for e.g. 5minutes)
  • committed(BlockNumber) (kept for e.g. 5minutes)
  • in batch? in pending block? probably not needed..

Metadata

Metadata

Labels

rpcRelated to the RPC component

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions