Skip to content

Conversation

simzzz
Copy link
Contributor

@simzzz simzzz commented Sep 24, 2025

Description

This PR adds implementation for LocalPendingTransactionStorage following the PendingTransactionStorage + relevant tests

Related issue(s)

Closes #4391

Testing Guide

  1. Verify class matches interface and logic is correct
  2. Verify tests pass

Changes from original design (optional)

The interface has been slightly modified to pass the txHash to addToList

Additional work needed (optional)

N/A

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

…tests

Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
@simzzz simzzz added this to the 0.72.0 milestone Sep 24, 2025
@simzzz simzzz self-assigned this Sep 24, 2025
@simzzz simzzz added the enhancement New feature or request label Sep 24, 2025
@simzzz simzzz changed the base branch from main to feat/transaction-pool September 24, 2025 12:55
@simzzz simzzz changed the title Implement LocalPendingTransactionStorage feat: adds LocalPendingTransactionStorage implementation Sep 24, 2025
Copy link

github-actions bot commented Sep 24, 2025

Test Results

 20 files  ±0  265 suites  ±0   18m 43s ⏱️ -18s
726 tests ±0  721 ✅ ±0  5 💤 ±0  0 ❌ ±0 
742 runs  ±0  737 ✅ ±0  5 💤 ±0  0 ❌ ±0 

Results for commit 4924857. ± Comparison against base commit c5c5433.

♻️ This comment has been updated with latest results.

@simzzz simzzz marked this pull request as ready for review September 24, 2025 13:09
@simzzz simzzz requested review from a team as code owners September 24, 2025 13:09
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 96.15385% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/relay/src/lib/types/transactionPool.ts 0.00% 4 Missing ⚠️
@@                   Coverage Diff                    @@
##             feat/transaction-pool    #4408   +/-   ##
========================================================
  Coverage                         ?   95.70%           
========================================================
  Files                            ?      123           
  Lines                            ?    20107           
  Branches                         ?     1756           
========================================================
  Hits                             ?    19244           
  Misses                           ?      838           
  Partials                         ?       25           
Flag Coverage Δ
config-service 98.80% <ø> (?)
relay 90.36% <96.15%> (?)
server 88.82% <ø> (?)
ws-server 98.27% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/relay/src/lib/services/index.ts 100.00% <100.00%> (ø)
.../nonceManagement/LocalPendingTransactionStorage.ts 100.00% <100.00%> (ø)
packages/relay/src/lib/types/transactionPool.ts 0.00% <0.00%> (ø)
🚀 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.

Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

LGTM just a couple of feedback

}

// Also remove from transaction data map
this.transactionData.delete(txHash);
Copy link
Contributor

Choose a reason for hiding this comment

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

When does this.transactionData have a record of txHash? I don't see the txHash got added to this.transactionData at any point, right?

* @param addr - The account address to query
* @returns Promise resolving to the number of pending transactions
*/
async getList(addr: string): Promise<number> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kinda misleading in a sense. getList() sounds like it's getting a list of the actual values, while this method is returning the size of the list. Should we rename it to some else more descriptive? Not a big deal and no need to address in this PR.

async addToList(addr: string, txHash: string, expectedPending: number): Promise<AddToListResult> {
const currentCount = await this.getList(addr);

// Check if the current count matches expectations (optimistic concurrency control)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the purpose of optimistic concurrency control to prevent race conditioning? If so I think we should add more context for this. Can address in upcoming PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement LocalPendingTransctionStorage
4 participants