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

feat(l1): implement transaction requests tracker #1801

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

avilagaston9
Copy link
Contributor

@avilagaston9 avilagaston9 commented Jan 24, 2025

Motivation

Currently, we don't have a registry of transaction requests made to other peers using the GetPooledTransactions message. As a result, we don't have a way to validate the peers' responses. We may also be requesting the same transaction from multiple peers, consuming more bandwidth.

Description

  • Creates a PendingRequests structure to keep track of requests made.
  • On a NewPooledTransactionHashes message, checks if the transactions have not been requested yet.
  • On a PooledTransactions response, validates the response against the stored request.
  • If the response is valid, removes the request from PendingRequests.
  • Every 5 secs, removes the stale requests from the registry.
  • On a peer_conn_failed event, removes the pending requests of the remote_node from the registry.
  • Fixes eth/BlobViolations Hive test: This test sends a PooledTransactions message with invalid types and sizes. The test was previously passing because the transactions used in the test were also dummy.

Additionally, this PR changes how we handle errors when validating the transactions against our mempool before adding them:

  • Stops disconnecting from peers on validation errors, as we may be one block behind the current head and invalidating transactions for insufficient balance. L1 P2P: penalize peers on invalid transactions #1806 was created.
  • On receiving a Transactions message, filters and propagates only the valid transactions. This change brakes the Hive test eth/InvalidTxs since we are incorrectly considering valid two transactions in the test. InvalidTxs #1139 was created to fix this.

Closes #1415
Closes #1781
Closes #1416

@avilagaston9 avilagaston9 self-assigned this Jan 24, 2025
Copy link

github-actions bot commented Jan 24, 2025

| File                                                                           | Lines | Diff |
+--------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/common/types/transaction.rs             | 2440  | +17  |
+--------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/p2p/rlpx/connection.rs       | 580   | +29  |
+--------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/p2p/rlpx/eth/transactions.rs | 435   | +155 |
+--------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/pending_requests.rs       | 176   | +176 |
+--------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/storage/store/storage.rs                | 1229  | +69  |
+--------------------------------------------------------------------------------+-------+------+

Total lines added: +446
Total lines removed: 0
Total lines changed: 446

@avilagaston9 avilagaston9 mentioned this pull request Jan 25, 2025
@avilagaston9 avilagaston9 marked this pull request as ready for review January 25, 2025 19:28
@avilagaston9 avilagaston9 requested a review from a team as a code owner January 25, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant