-
Notifications
You must be signed in to change notification settings - Fork 3
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 txpool #138
Comments
What's your use case for such a feature?
How do you define "incoming extrinsics"? Do you also include in that the transactions that were received from other nodes on the peer-to-peer network? |
Yes this is correct; transactions which are in the ready state (ready pool), but not yet finalized to be included in the block. |
This would need to be a
This information really shouldn't be displayed in an explorer. If you're thinking of work-arounds for these two issues, for example querying multiple nodes, is kind of counter-productive. The entire reason why blockchains exist in the first place is precisely to solve these two issues. |
Im assuming the same issues exist in geth (not to say this is an architecture one should look upto); and yes teams/searchers participating in MEV do subscribe to the mempool of multiple nodes to get an accurate picture of the live state of the mempool. Another use-case: If you for example wanted to create bots which stabilized the price after an AMM swap - to provide best price for users, or building some other service which acts on the unfinalized data (which is normal in other chains) - then currently this isn't possible for substrate based chains (out of the box atleast). The current WRT to MEV, this RPC just levels the playing field a bit since advanced players can make code changes to their nodes to achieve this functionality (which I'm planning to do); thought it would be a better option if this just came out of the box with the substrate based chains. |
I would also be interested in this feature. The use case is to provide a real-time and interactive view of what's going on on-chain. In the UI, you can display "pending" extrinsics, and then mark them as included once they are in a block, for example. You can already do that by querying the current API frequently, but having a subscribe API would be nicer. Some example use-cases: https://txcity.io/v/eth-btc - A visualization of txs as people and blocks as cars. |
Previously raised here: paritytech/polkadot-sdk#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 theReady
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:
This should be fairly simple to implement (already have a local implementation building/streaming out to WS connection).
Example response (scale encoded extrinsic):
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!
The text was updated successfully, but these errors were encountered: