Skip to content

Fix dBFT invalid transaction cache capacity and lifecycle - #1127

Merged
shargon merged 19 commits into
master-n3from
dbft-invalid-transactions-cache
Nov 27, 2026
Merged

shargon merged 19 commits into
master-n3from
dbft-invalid-transactions-cache

Conversation

@shargon

@shargon shargon commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Increase the invalid transaction cache capacity by 65,535 entries to accommodate a full ChangeView message alongside existing mempool rejection entries.

Keep rejected transactions cached across blocks and view changes. Process mempool removals through the consensus actor to avoid concurrent cache mutations, and unsubscribe from mempool events when the actor stops.

The existing ChangeView message format and hash limit remain unchanged. The additional capacity mitigates single-message eviction but does not prevent saturation by repeated messages.

@github-actions github-actions Bot added the N3 label Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.26%. Comparing base (3f32585) to head (09feb34).

Files with missing lines Patch % Lines
plugins/DBFTPlugin/Consensus/ConsensusService.cs 37.50% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           master-n3    #1127      +/-   ##
=============================================
+ Coverage      54.23%   54.26%   +0.03%     
=============================================
  Files            299      299              
  Lines          17999    18005       +6     
  Branches        2366     2366              
=============================================
+ Hits            9762     9771       +9     
+ Misses          7607     7602       -5     
- Partials         630      632       +2     

☔ View full report in Codecov by Harness.
📢 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.

ajara87
ajara87 previously approved these changes Nov 8, 2026
@shargon
shargon requested a review from superboyiii November 20, 2026 09:00
@shargon

shargon commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

@superboyiii could you review it please?

@superboyiii

superboyiii commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

@shargon

This needs to be solved. It brings a new issue. InvalidTransactions.Clear() in Reset(0) drops the cache at the start of every block. A transaction rejected by more than F nodes used to stay cached until it left the mempool, so later blocks did not propose it again. It is now proposed again on every block while it remains in the mempool, causing another view change each time.

The other two changes are correct. Mempool removals are now posted to the consensus actor, so the cache and its inner HashSet are updated only on the actor thread. PostStop unsubscribes from NewTransaction and TransactionRemoved, so a restarted actor does not stack duplicate handlers.

shargon commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

@superboyiii Thanks for catching this. I removed InvalidTransactions.Clear() from Reset(0) in bc38ed1, so rejected transactions remain cached across blocks and are still removed when they leave the mempool via the consensus actor. I updated the regression test to cover a transaction rejected by more than F validators across view changes and consecutive blocks. All 53 DBFTPlugin tests pass.

@superboyiii

Copy link
Copy Markdown
Member

Need update neo to v3.11.3

@ajara87 ajara87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@shargon
shargon merged commit c989dd8 into master-n3 Nov 27, 2026
6 of 7 checks passed
@shargon
shargon deleted the dbft-invalid-transactions-cache branch November 27, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants