Skip to content

fix: refresh mempool caches every block - #1245

Open
mmsqe wants to merge 4 commits into
cosmos:mainfrom
mmsqe:stalepin_main
Open

fix: refresh mempool caches every block#1245
mmsqe wants to merge 4 commits into
cosmos:mainfrom
mmsqe:stalepin_main

Conversation

@mmsqe

@mmsqe mmsqe commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Description

NotifyNewBlock refreshes mempool's cached context, but evmd/mempool.go only called it without an event bus — so with one, the SetEventBus goroutine was the sole driver, and it exits for good when CometBFT cancels a lagging subscriber, leaving the context stuck.

Drop !HasEventBus() gate so PrepareCheckState, which runs every block from Commit, always drives the refresh. NotifyNewBlock is made safe for two drivers: it refreshes before a per-height dedup and returns whether it emitted an event so the recheck reruns only when height advanced.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

call NotifyNewBlock unconditionally from EndBlock,
made idempotent per head so two drivers cannot emit duplicate chain head events

dedup chain head events per committed height
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.43%. Comparing base (0ae5e22) to head (b9d5ff7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mempool/blockchain.go 88.88% 1 Missing and 1 partial ⚠️
mempool/mempool.go 90.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1245      +/-   ##
==========================================
+ Coverage   67.41%   67.43%   +0.02%     
==========================================
  Files         320      320              
  Lines       23451    23473      +22     
==========================================
+ Hits        15810    15830      +20     
- Misses       6459     6461       +2     
  Partials     1182     1182              
Files with missing lines Coverage Δ
mempool/mempool.go 81.61% <90.00%> (-0.29%) ⬇️
mempool/blockchain.go 84.02% <88.88%> (+2.32%) ⬆️

... and 1 file 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.

@mmsqe
mmsqe marked this pull request as ready for review July 31, 2026 09:56
@mmsqe
mmsqe requested a review from a team as a code owner July 31, 2026 09:56
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

mmsqe added 2 commits August 7, 2026 10:51
* check the height hint before notifyMu (atomic), so a losing driver does not wait out the winner's feed delivery just to skip
* return the announced header (nil when nothing was sent), so recheck reuses it instead of rebuilding via CurrentBlock
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.

1 participant