Skip to content

Backport giga-1: Retain Autobahn lane last block across prune - #4210

Merged
wen-coding merged 1 commit into
giga-1from
backport-4199-to-giga-1
Sep 16, 2026
Merged

wen-coding merged 1 commit into
giga-1from
backport-4199-to-giga-1

Conversation

@seidroid

@seidroid seidroid Bot commented Sep 16, 2026

Copy link
Copy Markdown

Backport of #4199 to giga-1.

## Summary
- After a CommitQC drains `[first, next)`, keep the last local lane
proposal so the next produced/pushed block still names a real parent
instead of the zero hash (which stalled the lane).
- Persist that last block when it has left the active range and has not
been flushed, restore it from the WAL on restart, and never rewind
`nextBlockToPersist`.
- Jump-prune (Anchor `Next` past the local tip / empty-range zero
`LastHash`) is left as a TODO; this change only covers last-seen local
production.

## Test plan
- [x] `GOWORK=off go test ./sei-tendermint/internal/autobahn/avail/
-count=1`

Made with [Cursor](https://cursor.com)

(cherry picked from commit 36bcce7)
@cursor

cursor Bot commented Sep 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes consensus availability pruning, WAL retention, and local block production parent linking; regressions could stall lanes or lose chain continuity after prune/restart.

Overview
Autobahn availability now keeps each lane’s last locally pushed proposal after anchor/QC pruning, so validators can still extend the chain and flush pruned-but-unpersisted blocks to the WAL.

Per-lane block storage is a new blockQueue with a last pointer, retentionFloor, and unpersistedLast. Prune clears last only when the certified range moves past the active queue; inner.prune bumps nextBlockToPersist to the retention floor (not only the QC’s LaneRange.Next()). ProduceLocalBlock and peer test helpers take the parent hash from last, not the in-memory queue tail. collectPersistBatch prunes WAL batches from the retention floor and appends any unpersisted last; setNextBlockToPersist no longer rewinds the cursor after a concurrent prune.

restoreBlocks rebuilds last from the block at first-1 on restart and limits parent-hash validation to blocks still in [first, next). PushBlock keeps the same rule so post-prune blocks can be accepted when the predecessor is only in last. Tests cover prune, persistence, restart, and batch collection.

Reviewed by Cursor Bugbot for commit 1cdaf8e. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedSep 16, 2026, 3:34 PM

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.51%. Comparing base (7e3ca24) to head (1cdaf8e).
⚠️ Report is 17 commits behind head on giga-1.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           giga-1    #4210      +/-   ##
==========================================
- Coverage   65.55%   65.51%   -0.04%     
==========================================
  Files        2081     2076       -5     
  Lines      157460   156930     -530     
==========================================
- Hits       103222   102813     -409     
+ Misses      54097    53976     -121     
  Partials      141      141              
Flag Coverage Δ
sei-chain-pr 88.52% <100.00%> (?)
sei-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-tendermint/internal/autobahn/avail/inner.go 96.99% <100.00%> (+1.30%) ⬆️
sei-tendermint/internal/autobahn/avail/state.go 86.49% <100.00%> (+0.41%) ⬆️

... and 5 files 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.

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Faithful backport of merged PR #4199 (identical per-file stats); the retained-last logic, WAL retention floor, and persistence-cursor changes all hold up under tracing, including the persistBlock sequence check and RecvBatch cursor monotonicity. One non-blocking comment issue: the rewritten comment in PushBlock deletes the invariant that justified skipping the parent-hash check after prune.

Findings: 0 blocking | 1 non-blocking | 1 posted inline

Blockers

  • None at the file/PR level.

Non-blocking

  • None at the file/PR level.
  • 1 suggestion(s)/nit(s) flagged inline on specific lines.

Inline comments (could not post inline; listed here)

  • sei-tendermint/internal/autobahn/avail/state.go:470 (RIGHT) -- [suggestion] The replacement comment restates the condition (first < next) but drops the invariant that makes skipping the check safe: the old NOTE recorded that headers() never follows the first block's parentHash within a LaneRange. That is still true (headers() at state.go:536 seeds want from lr.LastHash() and walks back only to lr.First()), and it is the reason an unverifiable parent below the anchor cannot deadlock header reconstruction. AGENTS.md is explicit that relocating a load-bearing invariant is the move, never deleting it to tidy up — please keep that sentence here (or move it to the headers() godoc and point at it).

The same applies to the comment replaced in restoreBlocks (inner.go:146): the dropped rationale that the WAL prunes lazily on disk, so blocks below the anchor are expected on startup, is exactly what the new b.Number < q.next branch depends on.

@wen-coding
wen-coding self-requested a review September 16, 2026 19:49
@wen-coding
wen-coding added this pull request to the merge queue Sep 16, 2026
Merged via the queue into giga-1 with commit b12043a Sep 16, 2026
65 of 66 checks passed
@wen-coding
wen-coding deleted the backport-4199-to-giga-1 branch September 16, 2026 20:02
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.

1 participant