Skip to content

Conversation

natanasow
Copy link
Contributor

Description

Currently, we cache getTransactionCount("latest") with ttl 500ms, however, we may still return an old value that is not relevant, if e.g we cache the getTransactionCount("latest") for 500ms, but after 300ms a new block is mined, the value needs to be updated, but we will still return the older value.

Motivation

Avoid returning an old value on request to eth_getTransctionCount with block tag = latest

Related issue(s)

Fixes #4389

Testing Guide

Changes from original design (optional)

N/A

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.)

@natanasow natanasow added the enhancement New feature or request label Sep 19, 2025
@natanasow natanasow added this to the 0.73.0 milestone Sep 19, 2025
@natanasow natanasow self-assigned this Sep 19, 2025
Copy link

github-actions bot commented Sep 19, 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 7b38629. ± Comparison against base commit c5c5433.

♻️ This comment has been updated with latest results.

@natanasow natanasow marked this pull request as ready for review September 22, 2025 07:53
@natanasow natanasow requested review from a team as code owners September 22, 2025 07:53
@natanasow natanasow changed the base branch from main to feat/transaction-pool September 23, 2025 10:12
return await this.getAccountNonceForHistoricBlock(address, blockNumOrTag, requestDetails);
}

const cacheTtl =
Copy link
Contributor

Choose a reason for hiding this comment

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

@natanasow shouldnt we keep the cache for the earliest block and specific block numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

great, thanks

@natanasow natanasow merged commit c96d94a into feat/transaction-pool Sep 23, 2025
67 of 71 checks passed
@natanasow natanasow deleted the 4389-remove-cache-for-latest-on-get-transaction-count branch September 23, 2025 13:41
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                    Coverage Diff                    @@
##           feat/transaction-pool    #4398      +/-   ##
=========================================================
- Coverage                  96.10%   96.10%   -0.01%     
=========================================================
  Files                        121      121              
  Lines                      19940    19920      -20     
  Branches                    1755     1748       -7     
=========================================================
- Hits                       19164    19144      -20     
  Misses                       751      751              
  Partials                      25       25              
Flag Coverage Δ
config-service 98.80% <ø> (ø)
relay 90.80% <100.00%> (+0.02%) ⬆️
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 Δ
...rvices/ethService/accountService/AccountService.ts 96.40% <100.00%> (-0.14%) ⬇️
🚀 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

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove getTransactionCount with latest tag caching

3 participants