Conflux-Chain / conflux-rust

The official Rust implementation of Conflux protocol. https://doc.confluxnetwork.org
https://doc.confluxnetwork.org
GNU General Public License v3.0
645 stars 196 forks source link

Implement missing newPendingTransactions functionality for EVM space #2672

Open waelsy123 opened 1 year ago

waelsy123 commented 1 year ago

Currently, the Conflux Rust implementation is missing the newPendingTransactions functionality for the EVM (Ethereum Virtual Machine) space. This feature is crucial for developers and users who rely on pending transactions for various applications and use cases. This issue aims to discuss and implement the newPendingTransactions functionality for EVM-compatible transactions in Conflux.

Motivation Adding the newPendingTransactions feature for EVM space will provide the following benefits:

  1. Improve compatibility with Ethereum tooling and infrastructure.
  2. Enable developers to monitor and manage pending transactions effectively.
  3. Facilitate various applications and use cases that rely on pending transactions, such as DEXs, DeFi projects, and NFT marketplaces.

Requirements

To implement the newPendingTransactions feature, the following tasks need to be accomplished:

  1. Define the newPendingTransactions JSON-RPC method for the EVM space, including parameters, return types, and any required error codes.
  2. Implement the logic to track, store, and manage EVM-compatible pending transactions within the Conflux Rust codebase.
  3. Add tests for the new functionality to ensure correctness and reliability.
  4. Update the documentation to include the newPendingTransactions feature and provide examples of its usage.

Acceptance Criteria

The newPendingTransactions functionality is considered complete when:

  1. The JSON-RPC method is defined and implemented according to the specified requirements.
  2. The feature correctly tracks, stores, and manages pending EVM-compatible transactions within the Conflux Rust implementation.
  3. The new functionality is covered by adequate test cases.
  4. The documentation is updated to include the newPendingTransactions feature and its usage.

Notes

Please discuss any questions, concerns, or suggestions related to this issue in the comments below. Let's collaborate to implement this important feature for the Conflux EVM space. I can assign this task to me personally I just need technical guidance what's the best approach to achieve that.

CRossel87a commented 1 year ago

Hi,

Please consider prioritizing support for "newPendingTransactionsWithBody" instead of just "newPendingTransactions". With the ladder you only get the hash, which requires the user to do unnecessary calling of get_transaction to obtain the transaction struct (this burdens the node and adds lag). Primary users of this will be searchers

peilun-conflux commented 1 year ago

Thanks for the interest!

newPendingTransactions has already been implemented in filter RPCs for eSpace (you can check new_pending_transaction_filter and filter_changes in rpc/impls/eth_filter.rs), so I guess we can use a similar method for the eth_pubsub. This implementation is a little bit inefficient though, because we keep an copy of all the transaction hashes in the transaction pool for each filter to find the differences.

Another thing worth noting is that this does not notify pending "phantom transactions" in eSpace, which are created by cross-space calls from core space transactions. I guess this is not an issue in most use cases here.

waelsy123 commented 1 year ago

thanks @peilun-conflux for the tip 🔥 , that's very helpful. You can assign this task to me, I will be working on it and will keep you in the loop