Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Add txpool methods to RPC #763

Open
1 of 4 tasks
davidmurdoch opened this issue Feb 2, 2021 · 7 comments · May be fixed by #3719
Open
1 of 4 tasks

Add txpool methods to RPC #763

davidmurdoch opened this issue Feb 2, 2021 · 7 comments · May be fixed by #3719

Comments

@davidmurdoch
Copy link
Member

davidmurdoch commented Feb 2, 2021

https://geth.ethereum.org/docs/rpc/ns-txpool

  • txpool_content
  • txpool_contentFrom
  • txpool_inspect
  • txpool_status
@domob1812
Copy link
Contributor

This is something I ran into with my own project (I need txpool_content to be precise). Is there any particular issue holding this up, or it is just blocked on missing time? Is this something that will come any time soon, or are many other things higher priority?

@davidmurdoch
Copy link
Member Author

davidmurdoch commented Nov 5, 2021

No one else has asked for it, as far as I know. So it hasn't been prioritized.

There are other issues ahead of this, like getting Ganache v7 to a stable release. After that we can evaluate adding these methods.

Please feel free to work this issue if you don't want to wait for us. Here is where our tx pool transactions are held:

public readonly executables: Executables = {
inProgress: new Set(),
pending: new Map()
};
readonly #origins: Map<string, Heap<TypedTransaction>>;
#origins would need to be changed to readonly public origins.

You just need to add the RPC methods you need to api.ts and that would make it available over RPC.

You'd build the tx pool content by accessing the transaction pool like this:

const { transactions, common } = this.#blockchain;
const { transactionPool } = transactions;

transactionPool.origins // contains queued txs (see https://github.com/trufflesuite/ganache/blob/434d971f7305c66dabe7b65173d6f5583d930025/src/chains/ethereum/ethereum/src/transaction-pool.ts#L400-L409 for how to loop over this object!)
transactionPool.executables // contains pending txs

You can get the json RPC representation of each transaction by calling transaction.toJSON(common).

@domob1812
Copy link
Contributor

Thanks for the pointers, they seem very helpful!

@amandesai01
Copy link

Adding below methods would be straight forward now that we have txpool_content present.
txpool_contentFrom
txpool_inspect
txpool_status

Should I start working on this (if anyone isn't)? Also, if yes, single PR for all or one for each?

@amandesai01
Copy link

Also, #1539 (comment)

@davidmurdoch
Copy link
Member Author

@amandesai01 Go for it! Regarding that comment about the processMap function. Maybe you could move it to a new helper function exported from transaction-pool.ts. Maybe name it something like mapToJSON (I'm bad at naming things... other ideas welcome!)

@MicaiahReid
Copy link
Contributor

@amandesai01

single PR for all or one for each?

It's your call, whatever you prefer!

@amandesai01 amandesai01 linked a pull request Sep 27, 2022 that will close this issue
6 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

5 participants