Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC: pending extrinsics entering mempool #3473

Closed
2 tasks done
zees-dev opened this issue Feb 25, 2024 · 2 comments
Closed
2 tasks done

RPC: pending extrinsics entering mempool #3473

zees-dev opened this issue Feb 25, 2024 · 2 comments
Labels
I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@zees-dev
Copy link

zees-dev commented Feb 25, 2024

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

Was looking for a subscription (websocket pubsub) to monitor the live mempool/txpool for incoming extrinsics.
There is the author_pendingExtrinsics RPC; but this gives a snapshot view of the mempool 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 mempool.
	#[subscription(
		name = "author_watchMempool" => "author_mempoolUpdate",
		unsubscribe = "author_unwatchMempool",
		item = sp_runtime::OpaqueExtrinsic, // Transaction
	)]
	fn watch_mempool(&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_mempoolUpdate","params":{"subscription":"GcJD5bwBSSzLMNIK","result":"0x8d018425451a4de12dccc2d166922fa938e900fcc4ed244f7826dbd9e7984784cd33ea3c23f24509fa4f77bf56c509692c4d1e20c7541d62677cf055d32e078d2b38a30cd2ab244cbde87b3ab88fcc8997da043e770a760186010031110001147375702032"}}

Potential concerns

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

Are you willing to help with this request?

Yes!

@zees-dev zees-dev added the I5-enhancement An additional feature request. label Feb 25, 2024
@github-actions github-actions bot added the I10-unconfirmed Issue might be valid, but it's not yet known. label Feb 25, 2024
@bkchr
Copy link
Member

bkchr commented Feb 25, 2024

Hey, thank you for the issue!

Can you please reopen the issue here for discussion: https://github.com/paritytech/json-rpc-interface-spec

@zees-dev
Copy link
Author

Hey, thank you for the issue!

Can you please reopen the issue here for discussion: https://github.com/paritytech/json-rpc-interface-spec

Raised here: paritytech/json-rpc-interface-spec#138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

2 participants