Skip to content

fix: don't keep the startup finalized block pinned forever - #2266

Open
marian-radu wants to merge 2 commits into
masterfrom
mr/fix-startup-best-block-pin
Open

fix: don't keep the startup finalized block pinned forever#2266
marian-radu wants to merge 2 commits into
masterfrom
mr/fix-startup-best-block-pin

Conversation

@marian-radu

@marian-radu marian-radu commented Jul 31, 2026

Copy link
Copy Markdown

Problem

FollowStreamDriver's replay buffer holds BlockRefs and entries only leave it when a later Finalized event reports the block.
At subscription start the node unconditionally reports the current best block. When best == finalized, always on instant-seal, a connect-time race otherwise, that block was finalized before we started watching, so no Finalized event we receive ever reports it and the pin lasts for the life of the subscription, so the node can't prune state past that block.

Fix

Keep only the latest BestBlockChanged in the buffer. This behavior matches the node rather than diverging from it.
Subscribers joining mid-stream now receive only the latest best-block event. Existing subscribers are unaffected.

Testing

startup_best_block_event_is_not_kept_alive_forever asserts the replay buffer no longer references block 0 and that an unpin was issued for it.

@marian-radu marian-radu added the bug Something isn't working label Jul 31, 2026
@marian-radu
marian-radu requested a review from lexnv July 31, 2026 15:55
Comment thread subxt/src/backend/chain_head/follow_stream_driver.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant