paritytech / paritytech/json-rpc-interface-spec

RPC: pending extrinsics entering txpool

Open
#138 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
37
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Previously raised here: https://github.com/paritytech/polkadot-sdk/issues/3473

Motivation

Was looking for a subscription (websocket pubsub) to monitor the live txpool/mempool for incoming extrinsics.
There is the author_pendingExtrinsics RPC; but this gives a snapshot view of the txpool upon request.

Request

A new RPC endpoint which should simply allow a caller to subscribe to all incoming pending extrinsics.

Once a user subscribes, the RPC endpoint will stream out live incoming transactions (type Extrinsic) in the Ready state.
The transactions do not need to be finalized - as that defeats the purpose since the state has already been set.

Solution

A new subscription in the client/rpc-api/src/author/mod.rs file.
Something like so:

	/// Watch transaction txpool.
	#[subscription(
		name = "author_watchTxpool" => "author_txpoolUpdate",
		unsubscribe = "author_unwatchTxpool",
		item = sp_runtime::OpaqueExtrinsic, // Transaction (scale-encoded-extrinsic)
	)]
	fn watch_txpool(&self);

This should be fairly simple to implement (already have a local implementation building/streaming out to WS connection).

Example response (scale encoded extrinsic):

{"jsonrpc":"2.0","method":"author_txpoolUpdate","params":{"subscription":"GcJD5bwBSSzLMNIK","result":"0x8d018425451a4de12dccc2d166922fa938e900fcc4ed244f7826dbd9e7984784cd33ea3c23f24509fa4f77bf56c509692c4d1e20c7541d62677cf055d32e078d2b38a30cd2ab244cbde87b3ab88fcc8997da043e770a760186010031110001147375702032"}}
Potential concerns

If there are issues (DoS, etc.); maybe this could be put behind feature flags - similar to what's done in frontier for the ethereum txpool subscriptions.

Are you willing to help with this request?

Yes!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with client/rpc-api/src/author/mod.rs and compare the requested subscription with author_pendingExtrinsics. Review the existing local implementation and websocket behavior described in the issue. Done means an author_watchTxpool subscription can stream incoming Ready-state extrinsics and supports author_unwatchTxpool.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.