Skip to content

fix(nano): clean up mempool after reorg#1409

Merged
glevco merged 1 commit intomasterfrom
fix/nano/clean-up-mempool
Sep 12, 2025
Merged

fix(nano): clean up mempool after reorg#1409
glevco merged 1 commit intomasterfrom
fix/nano/clean-up-mempool

Conversation

@glevco
Copy link
Contributor

@glevco glevco commented Sep 11, 2025

Motivation

Clean up NC txs that became invalid after a reorg, removing them from the mempool.

Acceptance Criteria

  • Move compute_vertices_that_became_invalid from TransactionStorage to the consensus and change its algorithm:
    • Before, it iterated over all mempool txs with a BFS, executing the reward lock verification for each of them, and marking them to removal if they're invalid.
    • Now, it does a BFS from right to left looking for the rightmost confirmed txs, and starting from those it does a BFS from left to right to find the lefmost invalid txs. Finally, all txs that are right to those are marked for removal. This makes sure blocks are included, at the cost of one extra BFS over the mempool. It also prevents having to run verifications for all txs (since now it marks reverse dependencies for removal, too) which is good because we'll be adding more verifications to this, such as from Nano.
  • Refactor consensus, moving invalidation of NC txs to inside compute_vertices_that_became_invalid. Also, that function was called only when the best height decreased, but now it's called for every reorg.

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@glevco glevco self-assigned this Sep 11, 2025
@glevco glevco moved this from Todo to In Progress (Done) in Hathor Network Sep 11, 2025
@github-actions
Copy link

github-actions bot commented Sep 11, 2025

🐰 Bencher Report

Branchfix/nano/clean-up-mempool
Testbedubuntu-22.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
minutes (m)
(Result Δ%)
Lower Boundary
minutes (m)
(Limit %)
Upper Boundary
minutes (m)
(Limit %)
sync-v2 (up to 20000 blocks)📈 view plot
🚷 view threshold
1.87 m
(+10.88%)Baseline: 1.69 m
1.52 m
(81.17%)
2.02 m
(92.40%)
🐰 View full continuous benchmarking report in Bencher

@glevco glevco moved this from In Progress (Done) to In Review (WIP) in Hathor Network Sep 11, 2025
@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 98.41270% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.88%. Comparing base (d866f0c) to head (b234b33).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
hathor/consensus/consensus.py 98.41% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1409      +/-   ##
==========================================
+ Coverage   85.86%   85.88%   +0.01%     
==========================================
  Files         432      432              
  Lines       32760    32791      +31     
  Branches     5102     5112      +10     
==========================================
+ Hits        28129    28162      +33     
+ Misses       3610     3609       -1     
+ Partials     1021     1020       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glevco glevco moved this from In Review (WIP) to In Review (Done) in Hathor Network Sep 11, 2025
@glevco glevco force-pushed the fix/nano/clean-up-mempool branch from f361221 to b234b33 Compare September 12, 2025 16:00
@github-project-automation github-project-automation bot moved this from In Review (Done) to In Review (WIP) in Hathor Network Sep 12, 2025
@glevco glevco moved this from In Review (WIP) to In Review (Done) in Hathor Network Sep 12, 2025
@glevco glevco merged commit 57f9bdc into master Sep 12, 2025
8 checks passed
@glevco glevco deleted the fix/nano/clean-up-mempool branch September 12, 2025 16:41
@github-project-automation github-project-automation bot moved this from In Review (Done) to Waiting to be deployed in Hathor Network Sep 12, 2025
@jansegre jansegre mentioned this pull request Sep 17, 2025
2 tasks
@jansegre jansegre moved this from Waiting to be deployed to Done in Hathor Network Sep 18, 2025
@jansegre jansegre mentioned this pull request Sep 24, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants