Skip to content

eth: improve private tx purging and error reporting in relay#2198

Open
manav2401 wants to merge 4 commits intodevelopfrom
improve-private-tx-purge
Open

eth: improve private tx purging and error reporting in relay#2198
manav2401 wants to merge 4 commits intodevelopfrom
improve-private-tx-purge

Conversation

@manav2401
Copy link
Copy Markdown
Member

Description

This PR does 2 main things

Private tx purging changes

  • Earlier the in memory map tracking the private transaction hashes used to grow without any bound as it used a very naive purging mechanism.
  • This mechanism is optimised for cases where transactions are rejected from BPs but aren't purged from the store.
  • Also adds a 10 min strict time for removing private transactions. This is important for clients using the service as post the 10 min timeout, the tx can be gossiped to the public p2p network.

Error reporting improvements

  • Adds a better error tracking logic for all RPC errors occurring while submitting a preconf / private tx to block producers.
  • Aggregates all error types and logs every minute.
  • Also adds more nuanced metrics.

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Nodes audience

In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply
  • Created a task in Jira and informed the team for implementation in Erigon client (if applicable)
  • Includes RPC methods changes, and the Notion documentation has been updated

Cross repository changes

  • This PR requires changes to heimdall
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on amoy
  • I have created new e2e tests into express-cli

Manual tests

Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

Copilot AI review requested due to automatic review settings April 24, 2026 12:08
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the relay’s handling of private transactions by adding bounded, deterministic cleanup behavior, and enhances observability by aggregating and periodically reporting block-producer RPC submission errors.

Changes:

  • Add a txpool-aware + hard-TTL sweep mechanism to prevent unbounded growth of the private-tx hash store.
  • Introduce a rejection/error aggregation tracker with periodic summary logging and new metrics for preconf/private submission failures.
  • Wire the txpool presence checker from the ETH backend into the relay’s private-tx store.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
eth/relay/relay.go Exposes SetTxPoolChecker on RelayService; expands documentation around private-tx purge behavior.
eth/relay/rejection_tracker.go Adds in-memory aggregation + formatting for grouped RPC error reporting.
eth/relay/private_tx_store.go Implements sweep-based eviction (grace-period txpool check + 10m hard TTL) and adds an “expired” metric.
eth/relay/private_tx_store_test.go Adds unit tests for TTL sweep, txpool-aware sweep, and checker setter behavior.
eth/relay/multiclient.go Records per-submission errors into the tracker, adds new meters, runs periodic summary reporter, improves close idempotence.
eth/relay/multiclient_test.go Adds unit + integration tests for tracker behavior, formatting, and wiring through submit paths.
eth/backend.go Wires eth.txPool.Has into the relay private-tx store for txpool-aware cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread eth/relay/relay.go Outdated
Comment thread eth/relay/relay.go Outdated
Comment thread eth/relay/private_tx_store.go
Comment thread eth/relay/multiclient.go
Comment thread eth/relay/rejection_tracker.go Outdated
@claude
Copy link
Copy Markdown

claude Bot commented Apr 24, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 88.61789% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.29%. Comparing base (1a5510f) to head (978f92f).

Files with missing lines Patch % Lines
eth/relay/multiclient.go 81.81% 6 Missing ⚠️
eth/relay/private_tx_store.go 88.88% 4 Missing ⚠️
eth/relay/relay.go 0.00% 4 Missing ⚠️

❌ Your patch check has failed because the patch coverage (88.61%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2198      +/-   ##
===========================================
+ Coverage    52.24%   52.29%   +0.05%     
===========================================
  Files          884      885       +1     
  Lines       155551   155667     +116     
===========================================
+ Hits         81262    81413     +151     
+ Misses       69055    69019      -36     
- Partials      5234     5235       +1     
Files with missing lines Coverage Δ
eth/backend.go 52.73% <100.00%> (+0.19%) ⬆️
eth/relay/rejection_tracker.go 100.00% <100.00%> (ø)
eth/relay/private_tx_store.go 83.33% <88.88%> (+3.33%) ⬆️
eth/relay/relay.go 89.01% <0.00%> (-4.10%) ⬇️
eth/relay/multiclient.go 90.55% <81.81%> (-1.34%) ⬇️

... and 19 files with indirect coverage changes

Files with missing lines Coverage Δ
eth/backend.go 52.73% <100.00%> (+0.19%) ⬆️
eth/relay/rejection_tracker.go 100.00% <100.00%> (ø)
eth/relay/private_tx_store.go 83.33% <88.88%> (+3.33%) ⬆️
eth/relay/relay.go 89.01% <0.00%> (-4.10%) ⬇️
eth/relay/multiclient.go 90.55% <81.81%> (-1.34%) ⬇️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants