Skip to content

feat(autobahn): implement new lane ID for epoch (CON-358) - #3862

Open
wen-coding wants to merge 9 commits into
mainfrom
wen/lane_id_in_epoch
Open

feat(autobahn): implement new lane ID for epoch (CON-358)#3862
wen-coding wants to merge 9 commits into
mainfrom
wen/lane_id_in_epoch

Conversation

@wen-coding

@wen-coding wen-coding commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace LaneID = PublicKey with LaneID = (validator, e_join): stay keeps e_join, leave is terminal for that identity, rejoin allocates a new LaneID (tip from NextBlock, typically 0 for a fresh map).
  • ApplyEpoch seeds joiner lane maps; leavers stay in memory/WAL until tipEpoch (first retained CommitQC) omits them (staleLaneDisposable: e_join < tip and not in tip committee), then DeleteLane + map drop. Persist still flushes leave tips when proposals are non-empty before the first WAL open (allowCreate decided in avail, not persist).
  • Producer sessions: WaitProduce / WaitMustStop; leave clears mempool and rejects inserts (ErrNotProducing). SubscribeLaneProposals binds lane at subscribe and keeps serving until tipEpoch prune (ErrLanePruned); giga pauses and resubscribes without tearing down peer RPC.

Compatibility / ops

  • Hard break for autobahn persistent_state_dir: WAL dirs are hex(pubkey||e_join) (was hex(pubkey)), and BlockHeader / LaneRange wire the new LaneID message (field 5; old field 1 lane reserved). Pre-LaneID state does not migrate — wipe or coordinated reset before upgrade. Autobahn is opt-in / pre-launch; no mixed-version peers.
  • Invalid/legacy lane dirs are warn-and-skipped and leak until wipe (intentional for this PR).

Multi-epoch (#3736)

Production ApplyEpoch / ActivateEpoch wiring, neighbor VerifyInWindow, and accepting prior-epoch CommitQC while tip lags land in #3736. This PR ships LaneID + leave/rejoin scaffolding and unit coverage only; do not expect end-to-end multi-epoch production paths here.

Made with Cursor

Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go
Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
@wen-coding
wen-coding force-pushed the wen/lane_id_in_epoch branch from 8d254d4 to 4f52a00 Compare August 5, 2026 22:23
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 10, 2026, 9:50 PM

Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.73%. Comparing base (a115971) to head (dac0323).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3862      +/-   ##
==========================================
- Coverage   61.61%   60.73%   -0.88%     
==========================================
  Files        2348     2254      -94     
  Lines      200852   190212   -10640     
==========================================
- Hits       123755   115531    -8224     
+ Misses      66044    64480    -1564     
+ Partials    11053    10201     -852     
Flag Coverage Δ
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

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

Files with missing lines Coverage Δ
sei-db/ledger_db/block/blocksim/blocksim.go 7.14% <ø> (-1.89%) ⬇️
sei-tendermint/autobahn/types/block.go 83.06% <ø> (-0.27%) ⬇️
sei-tendermint/autobahn/types/committee.go 97.95% <ø> (-0.53%) ⬇️
sei-tendermint/autobahn/types/proposal.go 92.02% <ø> (-0.05%) ⬇️
sei-tendermint/autobahn/types/testonly.go 95.61% <ø> (-0.04%) ⬇️
sei-tendermint/internal/autobahn/avail/inner.go 98.64% <ø> (+1.11%) ⬆️
sei-tendermint/internal/autobahn/avail/state.go 79.08% <ø> (+0.65%) ⬆️
...endermint/internal/autobahn/avail/subscriptions.go 100.00% <ø> (ø)
sei-tendermint/internal/autobahn/avail/testonly.go 74.50% <ø> (-0.50%) ⬇️
...mint/internal/autobahn/consensus/persist/blocks.go 70.40% <ø> (+0.32%) ⬆️
... and 7 more

... and 94 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.

Comment thread sei-tendermint/internal/p2p/giga/avail.go Outdated
seidroid[bot]
seidroid Bot previously requested changes Aug 5, 2026

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The LaneID = (validator, e_join) refactor is coherent and well-tested at the type/proto layer, but the new lane-deletion path (pruneInactiveLanes + DeleteLane) breaks the "lanes are only added, never removed" invariant that three unguarded map reads in avail still rely on, and the leave/rejoin handling in SubscribeLaneProposals and ProduceLocalBlock has races that panic or permanently kill the producer. These are latent until epoch transitions are wired up (#3736), but they are defects in this PR's own feature and are not covered by the added tests.

Findings: 6 blocking | 13 non-blocking | 9 posted inline

Blockers

  • pruneInactiveLanes deletes entries from inner.blocks / inner.votes, but three call sites still index those maps without an ok check and will nil-deref once a leaver is pruned: avail/state.go:654 (headers: q := inner.votes[lr.Lane()] then q.first), avail/state.go:815 (PushQC loop: inner.blocks[lr.Lane()].q[n]), and avail/inner.go:189 (laneQC: i.votes[lane].q[n]). All three iterate the committee of the QC's epoch, which can be an older epoch that still contains the leaver. The comment removed from persist/blocks.go ("lanes are only added, never removed") was load-bearing for these too — every reader needs an ok-check (or lanes must be retained until the prune anchor passes them).
  • No test covers the interaction between tryPruneLeaveLanes and a lagging reader. TestApplyEpoch_AddsJoinerDefersLeaverUntilCommitQCWatermark verifies the leaver's maps/WAL disappear, but nothing exercises headers() / fullCommitQC / the s.data.PushQC loop against a previous-epoch CommitQC after the prune, which is exactly the crash path. Please add one.
  • Prune watermark choice needs justification: normal block retention is gated on the durable prune anchor (AppQC-derived, advancePersistedBlockStart), but a leaver's in-memory queues and WAL are dropped as soon as any durable CommitQC lands in the new epoch. Blocks that are committed but not yet executed/served can still be needed at that point. Either reuse the prune-anchor watermark or document why CommitQC-epoch is sufficient.
  • 3 blocking issue(s) flagged inline on specific lines.

Non-blocking

  • The Cursor review file (cursor-review.md) is empty — that pass produced no output, so this review merges only Claude's and Codex's findings.
  • Codex P1 #1 (legacy block WALs / wire format): the lane WAL directory name changes from hex(pubkey) (32B) to hex(pubkey||e_join) (40B), and BlockHeader.lane / LaneRange.lane change proto type from PublicKey to LaneID on the same field number. Both are hard breaks — existing WAL dirs are silently skipped on restart, and peers on the old binary cannot decode. Since ApplyEpoch/ActivateEpoch have no production callers yet, this is presumably pre-launch and acceptable; please confirm explicitly in the PR description rather than leaving it implicit.
  • ApplyEpoch never returns a non-nil error. Either drop the return value or note that it is reserved for the follow-up wiring.
  • tryPruneLeaveLanes re-Stores the identical latestCommitQC value after the disk delete purely to wake waiters. It is safe today only because markCommitQCsPersisted and tryPruneLeaveLanes are both on the runPersist goroutine — worth stating that in the comment, since a concurrent writer would make this a watermark regression. ctrl.Updated() alone may be enough.
  • markBlockPersisted writes inner.nextBlockToPersist[lane] = next unconditionally, so a pruned lane can be resurrected as a stale map entry (small leak, and it makes the map key sets diverge from blocks/votes).
  • LaneProposalsRecv.Recv allocates an errgroup and two goroutines per block received, plus a fresh LocalLaneUpdates() subscription per iteration. On the hot proposal path this is meaningful churn; consider hoisting the lane-change watcher out of the per-block loop.
  • alignMempoolForLane reads NextBlock(lane) before taking the mempool lock, so the tip can be stale by the time it is applied; and a rejoin silently discards all buffered evmTxs/evmNonces. Both are probably intended, but neither is documented.
  • 6 suggestion(s)/nit(s) flagged inline on specific lines.

Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/subscriptions.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/producer/state.go
Comment thread sei-tendermint/autobahn/types/committee.go
Comment thread sei-tendermint/autobahn/types/committee.go Outdated
Comment thread sei-tendermint/autobahn/types/lane_id.go Outdated
Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/producer/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/subscriptions.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
seidroid[bot]
seidroid Bot previously requested changes Aug 6, 2026

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid, well-documented reshaping of LaneID into (validator, e_join) with good test coverage of the stay/leave/rejoin state machine, but two correctness problems in the persistence/pruning paths are blocking: restored leave-lane queues are never positioned at the prune anchor (restart fails), and the leave-lane retention watermark is keyed on e_join rather than the leave epoch, so long-tenured leavers are dropped before their final tips are committed. Cursor's second-opinion pass produced no output; Codex's two findings are both confirmed and included.

Findings: 3 blocking | 12 non-blocking | 7 posted inline

Blockers

  • avail: no test covers the restart path that actually breaks — a persisted leave-lane WAL whose surviving blocks start above 0 (i.e. a prune anchor with a non-empty LaneRange for the leaver). TestApplyEpoch_AddsJoinerDefersLeaverUntilAppQCWatermark and TestTryPruneLeaveLanes_OrphanWALWithoutMaps both persist laneB at block 0 with no anchor, so they pass over the bug in newInner. Please add a restart test with an anchor whose leaver LaneRange.First() > 0.
  • 2 blocking issue(s) flagged inline on specific lines.

Non-blocking

  • Cursor's review file (cursor-review.md) is empty — that pass produced no output, so this review merges only Claude's and Codex's findings.
  • Epoch-boundary peer teardown for remote lanes is unhandled. Registry.VerifyInWindow still only checks the latest committee (existing TODO), and PushBlock/PushVote now return ErrBadLane when inner.blocks/inner.votes lacks the lane. A peer that applies epoch N+1 slightly before us and pushes a proposal on its new rejoin LaneID makes clientStreamLaneProposals return an error (giga/avail.go:194), tearing down that peer's RPC stream. The PR carefully protects the local lane via ErrLaneIdentityChanged; remote lanes need the equivalent soft-failure (or a widened verification window) before ApplyEpoch is wired up.
  • ApplyEpoch swaps inner.epoch wholesale, so inner.laneQC and PushVote immediately evaluate already-accumulated old-epoch votes against the new committee's LaneQuorum() and weights. Votes from departed validators are still in the queues and would be assembled into a LaneQC that fails verification against the new committee. The existing // TODO: filter votes per-epoch committee becomes load-bearing once ApplyEpoch is called in production — worth stating explicitly in the #3736 follow-up.
  • The BlockHeader.lane/LaneRange.lane proto type change (PublicKeyLaneID) alters block header hashes and makes previously persisted WAL entries undecodable, so any node with existing autobahn state needs a coordinated state reset. Autobahn is opt-in via autobahn-config-file, so this is likely fine, but the PR description doesn't mention it and there's no migration note.
  • producer.mempoolFirst() (producer/mempool.go:83) is now dead — alignMempoolForLane replaced its only caller. unused isn't enabled in .golangci.yml so it won't fail lint, but it should be removed.
  • types.GenCommittee (testonly.go) now bypasses the public constructors and calls normalizeWeights + finalizeCommittee directly to inject random e_join values. Randomizing e_join in tests is a genuine improvement (it catches code assuming e_join == 0), but duplicating the constructor body in test-only code means future changes to NewCommittee won't be reflected. Consider a newCommitteeWithEJoins(weights, func(PublicKey) EpochIndex) helper shared by all three.
  • State.ApplyEpoch always returns nil. The comment explains this is retained for #3736, which is reasonable, but every current caller has to handle an error that cannot occur.
  • 5 suggestion(s)/nit(s) flagged inline on specific lines.

Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go
Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/subscriptions.go Outdated
Comment thread sei-tendermint/internal/autobahn/producer/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/epoch/registry.go

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No new bugs found this run. The latest commit (b3a591f, "harden LaneID leave/rejoin lifecycle") appears to resolve the checkBound panic, nil-map-deref, orphan-WAL, and producer-race issues flagged in earlier reviews on this PR (cursor, seidroid, and my own prior comments). Given the size and consensus-critical scope of this change, I'd still like a human to take a look before merge rather than shadow-approving.

What was reviewed:

  • checkBound/Recv no longer panics on leave+rejoin coalescing - now returns ErrLaneIdentityChanged (avail/subscriptions.go)
  • headers(), the PushQC block-collection loop, and laneQC() now guard missing lane maps instead of nil-dereferencing after a leave prune (avail/state.go, avail/inner.go)
  • produceLocalBlock/streakOpErr now bind to an explicit LaneID per streak, so a stale rejoin race resolves to ErrBadLane/context.Canceled instead of killing producer.Run (producer/state.go)
  • Checked the ruled-out mempool-reset-on-rejoin candidate - alignMempoolForLane only resets state when the streak's LaneID actually changes, so a same-lane stay keeps its tip and txs
Extended reasoning...

This run's bug hunter found no new issues. Cross-referencing the current HEAD (b3a591f, ahead of the PR diff shown) against the earlier cursor-bot, seidroid-bot, and my own prior claude[bot] comments on this thread, the latest commit appears to specifically address nearly every previously flagged blocker: the LaneID-coalescing panic in checkBound (now returns ErrLaneIdentityChanged), the nil-map-dereference in headers()/PushQC/laneQC() after a leave-lane prune (now guarded with ok-checks), the orphan leave-WAL-survives-restart issue (inner.go now reattaches leave-lane WALs into maps so tryPruneLeaveLanes/DeleteLane can reap them), the 'leave tears down peer RPC' issue (giga/avail.go now retries/resubscribes instead of propagating a fatal error out of the multiplexed RunServer scope), the producer lane-rederivation race (produceLocalBlock now takes an explicit bound LaneID and checks HasLane against it), and the HasLane O(n) regression (committee.go now keeps a byValidator map for O(1) lookup). I did not find a case where these fixes are incomplete.

This is nonetheless a large (36-file), consensus-critical change to how lanes are identified across the availability plane, persistence layer, producer, and wire protocol (BlockHeader.lane and LaneRange.lane both change proto type), including a protobuf wire-format change and WAL directory-naming change. ApplyEpoch/ActivateEpoch have no production callers yet (explicitly deferred to #3736), which reduces blast radius today, but the design decisions here (e.g. epoch-scoped LaneID reuse, AppQC-floor-gated lane pruning, coalescing-safe subscription semantics) are exactly the kind of judgment calls that warrant a human's sign-off before the epoch-transition wiring lands on top of them.

No security-sensitive auth/crypto/permission logic is touched beyond the existing signature verification already in place; the main risk surface is correctness/liveness of consensus (panics, stuck goroutines, dropped blocks) rather than exploitable vulnerabilities. Test coverage is substantial (new tests for committee activation, lane WAL orphan pruning, coalesced leave/rejoin subscription behavior, and a producer lifecycle test), which supports confidence in the fixes but doesn't substitute for a maintainer familiar with the epoch-transition roadmap reviewing the design.

seidroid[bot]
seidroid Bot previously requested changes Aug 6, 2026

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid, well-tested refactor of LaneID from PublicKey to (validator, e_join) with careful prune/leave/rejoin bookkeeping. The blocking concern is that it silently breaks the on-disk autobahn WAL format (and the P2P wire format) with no migration or documented state-dir reset, so an in-place upgrade of an autobahn-enabled node fails to start; several smaller robustness/hot-path issues are noted below.

Findings: 2 blocking | 11 non-blocking | 7 posted inline

Blockers

  • On-disk WAL format break with no migration path. BlockHeader.lane and LaneRange.lane change from PublicKey to the new LaneID message. PublicKey{ed25519: <32 bytes>} and LaneID{validator, e_join} are not wire-compatible, so on an in-place upgrade of an autobahn-enabled node a persisted prune anchor decodes through PruneAnchorConv.Decode -> types.CommitQCConv.Decode -> LaneRangeConv.Decode and fails on the embedded LaneRange. loadPersistedState (sei-tendermint/internal/autobahn/avail/state.go:267) treats that as fatal, so NewState errors and the node will not start until <persistent_state_dir> is wiped. Same for the peer wire format: old and new binaries cannot exchange BlockHeader/LaneRange, and BlockHeader.Hash() changes. Autobahn is opt-in and off by default, so this is likely acceptable in substance -- but it needs to be explicit: either handle/skip the old encoding, or state the required state-dir reset and the no-mixed-version constraint in the PR description / release notes. Right now the only breakage signal is the non-app-hash-breaking label, which reads as the opposite.
  • 1 blocking issue(s) flagged inline on specific lines.

Non-blocking

  • Cursor's second-opinion pass produced no output (cursor-review.md is empty), so this review merges only Claude's and Codex's findings.
  • Codex's point, confirmed but downgraded: avail.State.ApplyEpoch, epoch.Registry.ActivateEpoch, and types.ActivateCommittee have no non-test callers, so the entire leave/rejoin/prune path this PR adds is unreachable in production until the advanceEpoch/onAdvance wiring in #3736 lands. That is consistent with the PR being explicitly incremental (the ApplyEpoch doc comment says so), so it is not a defect -- but it does mean the new gates get no production coverage in this PR, and the correctness of tryPruneLeaveLanes rests entirely on unit tests plus a chain of non-local invariants (see the inline notes on state.go:122 and blocks.go:347). Worth an integration test that drives a real epoch transition through producer.Run + runPersist before the wiring PR flips it on.
  • Registry.ActivateEpoch changing RWMutex[registryState] to RWMutex[*registryState] is the right fix (s.latest = next on a value copy would have been lost) -- good catch. Unrelated nit: ActivateEpoch doesn't touch prev's RoadRange, so callers passing OpenRoadRange() for every epoch (as all the new tests do) end up with overlapping open ranges. The doc comment acknowledges this; consider rejecting a roads that overlaps prev so the invalid state is unrepresentable rather than a caller contract.
  • The PR description says leavers are pruned at the "AppQC prune floor (lane.EJoin() < appQC.EpochIndex())", but the implemented gate is tipcut-committee membership (!current.HasLane(lane) && !tipcut.HasLane(lane)), with no EJoin() comparison anywhere. The code is fine; the description should match it so future readers don't go looking for the EJoin check.
  • serverStreamLaneProposals can now silently switch the stream to a different LaneID mid-connection (rejoin resets first = 0). clientStreamLaneProposals happens to tolerate this because PushBlock resolves the lane from the header, but the commented-out sanity check at giga/avail.go:191 (proposal lane == peer key) can no longer be a simple equality once it's uncommented -- it has to compare Lane().Validator(). Worth updating that comment now while the context is fresh.
  • 6 suggestion(s)/nit(s) flagged inline on specific lines.

Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/subscriptions.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/producer/state.go
Comment thread sei-tendermint/internal/autobahn/producer/mempool.go
Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
seidroid[bot]
seidroid Bot previously requested changes Aug 6, 2026

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid, well-documented refactor of LaneID from a bare pubkey to (validator, e_join), with good test coverage for the stay/leave/rejoin state machine and correctly regenerated wireguard/proto size tables. Two blocking issues remain: existing autobahn persistent state becomes unreadable with no migration or version gate (commitQC WAL hard-fails, block WAL dirs are silently orphaned), and a restart inside a leave window can make the local PushQC loop permanently skip road indices whose retained CommitQCs still reference the departed lane.

Findings: 5 blocking | 13 non-blocking | 9 posted inline

Blockers

  • Upgrade path for an existing autobahn persistent_state_dir is undefined and handled inconsistently: the commitQC WAL / prune anchor hard-fail to decode (startup abort), while legacy block WAL dirs are warn-and-skipped (silent data loss + orphaned dirs that tryPruneLeaveLanes can never reach, since they are not in bp.lanes). Pick one policy — a state-dir version marker that fails fast with an actionable message, or an explicit migration/cleanup — and state it in the PR description. See the two inline comments on blocks.go:234 and autobahn.proto:131.
  • No test covers the upgrade path at all: there is no case that opens a BlockPersister over a 32-byte-hex lane dir, and none that feeds a pre-change (field-1 lane) LaneRange/CommitQC WAL entry through loadAllCommitQCs. Whatever policy is chosen for the item above should be pinned by a test, since this is exactly the failure that only shows up on a real operator's disk.
  • 3 blocking issue(s) flagged inline on specific lines.

Non-blocking

  • The Cursor pass (cursor-review.md) produced no output — the file is empty. Only Codex's three findings were available to merge; all three are reflected above (its P1 #1 as a blocker, P1 #2 as a blocker, P2 #3 as an inline suggestion).
  • PR description drift: it states the prune floor is the "in-memory AppQC prune floor (lane.EJoin() < appQC.EpochIndex())", but the implemented gate in tryPruneLeaveLanes is "the first retained CommitQC's committee no longer names the lane". The code comments are accurate; the description is not. Worth fixing since this is the subtlest invariant in the change.
  • producer.mempoolFirst() (producer/mempool.go:83) is now dead — Run was its only caller and it went through alignMempoolForLane. unused is not in .golangci.yml, so lint will not catch it.
  • tryPruneLeaveLanes allocates a full KnownLanes() snapshot and re-scans it after every persist batch, even when nothing has left the committee. Cheap fix: skip the whole body unless the epoch changed since the last check or len(inner.blocks) > current.Lanes().Len() (the guard already used for the in-memory half).
  • LaneID.Bytes() calls l.validator.Bytes() twice (once for the capacity, once for the append). Hoist it into a local.
  • epoch.GenRegistry still builds its genesis committee via NewCommittee (all e_join = 0), so the avail/producer/giga tests only ever exercise e_join = 0 lanes end-to-end; the random-e_join GenCommittee change is confined to the types package. An ActivateEpoch-based fixture with a non-zero e_join stayer would give the new WAL naming and map keying real coverage.
  • ApplyEpoch returns an error that is documented as always nil. Fine as a forward-compat hook for #3736, but every current caller has to require.NoError on something that cannot fail.
  • 6 suggestion(s)/nit(s) flagged inline on specific lines.

Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go
Comment thread sei-tendermint/internal/autobahn/autobahn.proto Outdated
Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/subscriptions.go Outdated
Comment thread sei-tendermint/internal/autobahn/producer/state.go
Comment thread sei-tendermint/autobahn/types/committee.go Outdated
Comment thread sei-tendermint/internal/autobahn/epoch/registry.go
Comment thread sei-tendermint/internal/autobahn/avail/inner.go
Comment thread sei-tendermint/internal/autobahn/avail/state.go
Comment thread sei-tendermint/autobahn/types/testonly.go Outdated
@wen-coding wen-coding changed the title feat(autobahn): identify lanes as (validator, e_join) (CON-358) feat(autobahn): implement new lane ID for epoch (CON-358) Aug 6, 2026
@wen-coding wen-coding added the ai: skip-review Skips Seidroid AI review triggered via Unified CI. label Aug 6, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is a large, consensus-critical refactor (LaneID now (validator, e_join) instead of a bare pubkey, touching committee membership, avail WAL persistence, producer lifecycle, and the wire format) — well outside the scope for auto-approval regardless of this run's findings.

No new bugs were found this run. Beyond the reported findings, I also checked three additional candidates and ruled them out: a hang in Block/PushBlock/WaitForLocalCapacity if a lane is deleted mid-wait (the deployment model in this repo means ApplyEpoch/epoch transitions have no production callers yet, so this is dormant); tryPruneLeaveLanes turning a missing registry epoch into a NewState startup-abort (registry only holds genesis today, so unreachable until epoch persistence lands); and unbounded epoch registry growth (bounded in practice since nothing currently activates new epochs).

Extended reasoning...

Given the volume of prior findings on this thread (several genuine correctness gaps around leave-lane pruning windows, restart handling of in-flight leave WALs, and WAL/wire format compatibility flagged by other reviewers) and the fact that this changes core consensus lane-identity semantics, a human should review this rather than relying on automated approval.

Comment thread sei-tendermint/internal/autobahn/avail/inner.go Outdated
@wen-coding
wen-coding force-pushed the wen/lane_id_in_epoch branch from 3c335fa to fcee025 Compare August 8, 2026 00:30
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/subscriptions.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
LaneID pairs validator with join epoch so leave/rejoin does not collide
with a recycled validator slot. TipEpoch leave prunes maps on the same
tick as DeleteLane; Subscribe fails with ErrLanePruned after drop.

Co-authored-by: Cursor <cursoragent@cursor.com>
@wen-coding
wen-coding force-pushed the wen/lane_id_in_epoch branch from 26a7c0b to d37679b Compare August 9, 2026 04:53
@wen-coding wen-coding removed the ai: skip-review Skips Seidroid AI review triggered via Unified CI. label Aug 9, 2026
Comment thread sei-tendermint/internal/autobahn/avail/state.go
seidroid[bot]
seidroid Bot previously requested changes Aug 9, 2026

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid, well-documented reworking of LaneID into (validator, e_join) with good coverage on the persist/DeleteLane paths, but two blocking issues remain: PushBlock/PushVote don't re-check lane presence after waiting (the exact hazard the rest of the PR carefully fixes elsewhere), and four unrelated QC-verification tests were deleted with no replacement, leaving PrepareQC.Verify and AppQC.Verify weight/epoch-binding coverage at zero.

Findings: 4 blocking | 11 non-blocking | 8 posted inline

Blockers

  • Unexplained test deletions in sei-tendermint/autobahn/types/committee_test.go: TestPrepareQCVerifyChecksWeight, TestPrepareQCVerifyChecksEpochBinding, TestAppQCVerifyChecksWeight, and TestNewCommittee_RejectsEmptyWeights are removed with no replacement. TestCommitQCVerifyChecksWeight was not added — the old one was deleted and the PrepareQC test renamed into its place. After this PR there is no test anywhere in autobahn/types exercising PrepareQC.Verify, and none exercising AppQC.Verify weight thresholds. None of these depend on LaneID, so nothing in this change requires dropping them. Please restore them (mechanically updating to committee.Lane(...) where needed).
  • 3 blocking issue(s) flagged inline on specific lines.

Non-blocking

  • cursor-review.md is empty — the Cursor pass produced no output, so this review reflects only Claude + Codex findings.
  • inner.prune(c *types.Committee, ...) (inner.go:228) never references c — its body iterates i.votes. This PR now threads a carefully computed anchorCommittee into that ignored parameter, which reads as if the anchor committee scopes the prune when it does not. Either use it or drop the parameter.
  • Stale-leave pruning only runs when collectPersistBatch's WaitUntil predicate fires (new blocks / new commitQC / new appQC). A tip-stale leave lane with nothing pending and an otherwise idle chain lingers in inner.blocks and on disk until unrelated activity wakes the loop. Consider adding staleLaneDisposable to the wake predicate.
  • PushCommitQC still hard-rejects QCs whose EpochIndex differs from the applied epoch (state.go:435). Once ApplyEpoch has production callers, in-flight prior-epoch QCs will surface as stream errors to peers during a transition. The PR body defers this to #3736 — worth a TODO(#3736) at that comparison so it isn't lost.
  • NewBlockPersister logs and skips lane dirs whose names don't parse as the new 80-hex LaneID (old 64-hex pubkey dirs). Those directories are then never reclaimed. Given the PR requires a state wipe this is acceptable, but the skip path should say the entry leaks rather than implying it's handled.
  • LaneVotesRecv.next (subscriptions.go:55) is keyed by LaneID and never has entries removed when dropLanes fires, so it accumulates one entry per historical lane over the node's lifetime. Negligible in size, but easy to clean up alongside dropLanes.
  • 5 suggestion(s)/nit(s) flagged inline on specific lines.

Comment thread sei-tendermint/internal/autobahn/avail/state.go
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/autobahn/types/committee_test.go Outdated
Comment thread sei-tendermint/internal/autobahn/producer/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/consensus/persist/blocks.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/inner.go
Comment thread sei-tendermint/internal/autobahn/avail/state.go
Comment thread sei-tendermint/autobahn/types/testonly.go
}

// finalizeCommittee sorts lanes and rejects duplicate validators (multiple e_join).
func finalizeCommittee(lanes []LaneID, weights map[PublicKey]uint64, totalWeight uint64) (*Committee, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

newCommittee? It is effectively just a constructor.

rng := utils.TestRng()
ep, keys := makeEpoch(rng)
vote := NewLaneVote(NewBlock(keys[0].Public(), 0, GenBlockHeaderHash(rng), GenPayload(rng)).Header())
vote := NewLaneVote(NewBlock(NewLaneID(keys[0].Public(), 0), 0, GenBlockHeaderHash(rng), GenPayload(rng)).Header())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't it be a laneID from ep.Committee() instead? Check other tests as well.

type LaneID struct {
utils.ReadOnly
validator PublicKey
eJoin EpochIndex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since LaneID's purpose is to be passed by value, make it a plain struct with public fields.

type LaneID struct {
utils.ReadOnly
validator PublicKey
eJoin EpochIndex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: imo "eJoin" doesn't feel very informative. How about calling it sth like "Start"/"Begin"/"First"? I.e. epoch at which the lane started? The fact that this is an epoch index is implied by the type, so "e" prefix is redundant. Or perhaps simply "Joined"?


// Compare orders by validator, then e_join.
func (l LaneID) Compare(other LaneID) int {
if c := l.validator.Compare(other.validator); c != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: cmp.Or(...)


func newInner(epoch *types.Epoch, loaded utils.Option[*loadedAvailState]) (*inner, error) {
func newInner(registry *epoch.Registry, loaded utils.Option[*loadedAvailState]) (*inner, error) {
ep := registry.LatestEpoch()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

epoch of Inner is not "Latest". It is the epoch of the next CommitQC.

}

// WaitProduce waits until LocalLane is Some (produce session start).
func (s *State) WaitProduce(ctx context.Context) (types.LaneID, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WaitForLocalLane? We are simply waiting for local lane to be available here.

// is separate; production wiring is #3736.
func (s *State) ApplyEpoch(ep *types.Epoch) {
for inner, ctrl := range s.inner.Lock() {
inner.addCommitteeLanes(ep.Committee())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not pruning lanes here as well?

@pompon0 pompon0 Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

persister can catch up based on the diff

}

// tipEpochOf is the registry epoch of the first retained CommitQC.
func tipEpochOf(inner *inner, registry *epoch.Registry) (utils.Option[*types.Epoch], error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

epochOfFirst?


// staleLaneDisposable: tipEpoch omits lane and e_join < tip (joiners at/after tip stay).
// None tipEpoch → false.
func staleLaneDisposable(lane types.LaneID, tipEpoch utils.Option[*types.Epoch]) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Epoch.IsClosed(lane) bool"? Also move it to types. You can add IsClosedOpt function if you want it to work on Option[Epoch], although I don't understand what are the conditions under which you don't have epoch available. It doesn't make sense to evaluate IsClosed without epoch.


// deleteStaleLaneWAL Deletes WALs for tip-stale leave maps.
// DeleteLane no-ops if a lane never opened a WAL (empty leave).
func (s *State) deleteStaleLaneWAL(lanes []types.LaneID) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should be method of blocks. Or just inline it, since this is a trivial loop over existing method.


// pruneStaleLeave Deletes WALs then drops maps for tip-stale leave LaneIDs
// (same tick as runPersist after Parallel).
func (s *State) pruneStaleLeave(staleLeave []types.LaneID) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dropLanes/pruneLanes? "pruneStaleLeave" doesn't tell me what we are pruning, what is stale, and whether "prune" or "leave" is the verb here.

// Block returns block n of the given lane.
// Waits until the block is available.
// Returns ErrPruned if the block has been already pruned.
// Returns ErrBadLane if the lane map is gone (tipEpoch leave prune).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what does it mean?

func (s *State) Block(ctx context.Context, lane types.LaneID, n types.BlockNumber) (*types.Signed[*types.LaneProposal], error) {
for inner, ctrl := range s.inner.Lock() {
if err := ctrl.WaitUntil(ctx, func() bool {
q, ok := inner.blocks[lane]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it might be missing, because it is from the future though. Use Epoch.IsClosed(lane).

}
if err := ctrl.WaitUntil(ctx, func() bool {
return h.BlockNumber() <= min(q.next, inner.persistedBlockStart[h.Lane()]+BlocksPerLane-1)
q, ok := inner.blocks[lane]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto, you should use IsClosed() here to distinguish future lanes from closed lanes.


// headers collects headers for the given range.
// Missing vote queue (leave map dropped past AppQC floor) → ErrPruned so PushQC can skip;
// ErrBadLane would kill avail.Run.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we really need to distinguish BadLane from Pruned in general? We technically can distinguish pruned lanes from bad lanes in case eJoin == current epoch, but this is a special case.
Again, this should be blocking in case LaneRange.ID is from the future.

// ErrBadLane if the lane left committee or its map was tipEpoch-pruned while waiting.
// Presence is keyed off blocks (always set for live lanes); persistedBlockStart may
// be absent on a fresh start (zero start), which is not a prune.
func (s *State) WaitForLocalCapacity(ctx context.Context, lane types.LaneID, toProduce types.BlockNumber) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just "WaitForCapacity", if you are providing the LaneID anyway

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

again, block if LaneID is from the future.

blocksByLane[lane] = append(blocksByLane[lane], proposal)
}

active := s.epoch.Load().Committee()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"committee"/"activeCommittee"?

// TODO: when epoch transitions land, also union in lanes from all
// epochs that appear in batch.commitQCs so new-epoch lanes are
// never skipped in a cross-epoch batch.
// TODO(#3736): only lanes of the latest CommitQC's epoch are

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not in this PR?

pruneAnchor utils.Option[*PruneAnchor]
// staleLeave: tipEpoch-disposable map keys skipped for append this tick.
// WAL deleted then maps dropped after Parallel (same iteration).
staleLeave []types.LaneID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO this should be derived from blocks and persister state within runPersist

// runPersist's Parallel batch returns for tip-stale leave maps.
//
// No-op if the lane WAL is not open (never created, or already deleted).
func (bp *BlockPersister) DeleteLane(lane types.LaneID) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: IMO it would be a cleaner API to have a separate idempotent (so that most of the time it is a fast noop) method BlockPersister.UpdateLanes(epoch) which would prune old/add new WALs. And only then do persisting of the lanes. One quirk will be that the CommitQCs of the previous epoch need to be persisted BEFORE old lanes are pruned.


type mempool struct {
capacity uint64
lane utils.Option[types.LaneID]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wouldn't it be better for the whole mempool to be optional instead of the lane inside? Closed lane invalidates the mempool anyway.

}

// clearMempool wipes pending txs and session lane so InsertTx rejects until alignMempool.
func (s *State) clearMempool() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's what I'm talking about. Mempool should just not exist in epochs without local lane.

// sessionOpErr maps leave ErrBadLane → Canceled so Run can WaitProduce again.
func (s *State) sessionOpErr(lane types.LaneID, op string, err error) error {
if errors.Is(err, avail.ErrBadLane) {
if got, ok := s.consensus.Avail().LocalLane().Get(); !ok || got != lane {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

imo you can just do Avail().epoch.Iter(func() { produceSession() }) here

return ctx.Err()
}

func (s *State) produceSession(ctx context.Context, availState *avail.State, lane types.LaneID) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: runMempool?

option (hashable.hashable) = true;
option (wireguard.sized) = true;
optional PublicKey lane = 1; // required
// Field 1 was PublicKey "lane"; LaneID is additive on a new number/name so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's an obvious comment

optional uint64 first = 2; // required
optional uint64 next = 3; // required
optional bytes last_hash = 4 [(wireguard.max_size) = 32]; // required
optional LaneID lane_id = 5; // required

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lane is it the top level selector, despite it having highest tag. I'd put it on top (where "lane" used to be)

sub := x.validatorState().Avail().SubscribeLaneProposals(req.FirstBlockNumber)
// ErrLanePruned ends the stream; leave alone keeps serving. Do not bubble —
// wait and resubscribe (rejoin tip is 0; back-leash prunes before rejoin).
first := req.FirstBlockNumber

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

make request include full LaneID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

then there won't be no need for specifically waiting for SOME local lane: first verify that LaneID is actually local (by comparing the key), then avail.Block() will take care of distinguishing closed lanes from future lanes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

RPC should gracefully terminate (without error) in case the lane has been closed. Client should wait for a new lane of this producer in this case (i.e. observe its avail.epoch)

wen-coding and others added 2 commits August 10, 2026 13:27
Document replica vs lane order on Committee. Use Option.Or and cmp.Or,
document normalizeWeights, take test lanes from the committee, and put
lane_id first in proto source (tag unchanged).

Co-authored-by: Cursor <cursoragent@cursor.com>
CI lint regenerates protos and diffs; field declaration order in
autobahn.proto changed the generated Go descriptors.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai: skip-review Skips Seidroid AI review triggered via Unified CI. non-app-hash-breaking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants