Skip to content

feat(autobahn): Add epoch.Registry to maintain committee/stake (CON-358)#3632

Open
wen-coding wants to merge 3 commits into
mainfrom
wen/autobahn_epoch_registry
Open

feat(autobahn): Add epoch.Registry to maintain committee/stake (CON-358)#3632
wen-coding wants to merge 3 commits into
mainfrom
wen/autobahn_epoch_registry

Conversation

@wen-coding

@wen-coding wen-coding commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduces epoch.Registry which consolidates firstBlock and genesisTimestamp — genesis config that doesn't change across epochs — alongside the committee
  • Bakes firstBlock into Proposal so GlobalRange() returns absolute block numbers directly, removing it as a call-site parameter throughout the stack. The proto message is now self-contained on the wire, making it much easier to interpret during emergency debugging. Also fixes a reproposal bug where TimeoutQC.reproposal() was double-counting firstBlock
  • All consumers (consensus, avail, data) now route committee lookups through registry.CommitteeFor(roadIndex). The registry currently returns the genesis committee for all RoadIndexes — we wire the read side first so that any bug introduced when implementing dynamic epochs in follow-up PRs is immediately visible at the call sites rather than requiring a cascading refactor to find it

🤖 Generated with Claude Code

@cursor

cursor Bot commented Jun 24, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Wide refactor of consensus verification, global numbering, and wire decoding (required global_first), plus avail quorum logic—behavior should match genesis-fixed committee today but mistakes would affect safety and sync.

Overview
Adds epoch.Registry as the shared source for firstBlock, genesis timestamp, and committee lookup by road index (CommitteeFor, EpochWindow, VerifyInWindow), replacing a bare *types.Committee in data, consensus, and avail (including tests and block DB sim helpers).

Committee is slimmed to validator weights only; firstBlock / genesis time move to ViewSpec.FirstBlock, NewProposal, and FullProposal.Verify(..., genesisTimestamp). CommitQC / Proposal.GlobalRange() no longer take a committee—the absolute range is stored on the proposal and on the wire as required global_first in autobahn.proto.

Avail initializes lanes across the epoch window, resolves lane QCs per epoch (votes weighted per committee in blockVotes), and WaitForLaneQCs takes an epoch index. Prune/load paths use the anchor’s committee and registry.FirstBlock().

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

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 25, 2026, 12:47 AM

@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✅ passedJun 24, 2026, 2:30 AM

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

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.38558% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.16%. Comparing base (c528303) to head (09e677e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-tendermint/internal/autobahn/avail/state.go 72.72% 6 Missing and 6 partials ⚠️
sei-tendermint/internal/autobahn/data/state.go 72.97% 1 Missing and 9 partials ⚠️
...dermint/internal/autobahn/pb/autobahn.wireguard.go 40.00% 6 Missing ⚠️
sei-tendermint/internal/autobahn/epoch/registry.go 83.87% 4 Missing and 1 partial ⚠️
...ei-tendermint/internal/autobahn/consensus/inner.go 33.33% 0 Missing and 4 partials ⚠️
...-tendermint/internal/autobahn/avail/block_votes.go 85.71% 2 Missing and 1 partial ⚠️
sei-tendermint/internal/autobahn/avail/inner.go 89.65% 1 Missing and 2 partials ⚠️
...ei-tendermint/internal/autobahn/consensus/state.go 81.25% 0 Missing and 3 partials ⚠️
sei-tendermint/autobahn/types/commit_qc.go 50.00% 0 Missing and 2 partials ⚠️
sei-db/ledger_db/block/blocksim/blocksim.go 50.00% 1 Missing ⚠️
... and 4 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3632      +/-   ##
==========================================
- Coverage   59.12%   58.16%   -0.96%     
==========================================
  Files        2259     2178      -81     
  Lines      186489   176961    -9528     
==========================================
- Hits       110255   102931    -7324     
+ Misses      66353    64936    -1417     
+ Partials     9881     9094     -787     
Flag Coverage Δ
sei-chain-pr 75.53% <83.38%> (?)
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/block_generator.go 81.25% <100.00%> (+0.60%) ⬆️
sei-tendermint/autobahn/types/committee.go 98.48% <100.00%> (-0.09%) ⬇️
sei-tendermint/autobahn/types/opt.go 100.00% <ø> (ø)
sei-tendermint/autobahn/types/testonly.go 94.52% <100.00%> (+0.53%) ⬆️
sei-tendermint/autobahn/types/timeout.go 82.31% <100.00%> (-0.59%) ⬇️
...ternal/autobahn/consensus/persist/fullcommitqcs.go 78.75% <100.00%> (ø)
...nternal/autobahn/consensus/persist/globalblocks.go 77.77% <100.00%> (ø)
sei-tendermint/internal/autobahn/data/testonly.go 50.00% <100.00%> (-11.33%) ⬇️
sei-tendermint/internal/autobahn/epoch/testonly.go 100.00% <100.00%> (ø)
...i-tendermint/internal/p2p/giga/pb/api.wireguard.go 100.00% <100.00%> (ø)
... and 15 more

... and 83 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/autobahn/data/state.go
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
Comment thread sei-tendermint/internal/autobahn/avail/state.go Outdated
@wen-coding wen-coding changed the title feat(autobahn): introduce epoch.Registry as single source of truth for committee/stake feat(autobahn): Add epoch.Registry to maintain committee/stake (CON-358) Jun 24, 2026
Comment thread sei-tendermint/internal/autobahn/avail/state_test.go Outdated
Comment thread sei-tendermint/internal/autobahn/epoch/registry.go Outdated
@wen-coding wen-coding force-pushed the wen/autobahn_epoch_registry branch from d764443 to 705d8c9 Compare June 24, 2026 03:59
Comment thread sei-tendermint/internal/autobahn/avail/inner.go
@wen-coding wen-coding force-pushed the wen/autobahn_epoch_registry branch from 130227a to ab4c67c Compare June 24, 2026 17:04
…r committee/stake

- Add epoch.Registry holding the genesis committee, firstBlock, and genesisTimestamp
- Wire Registry into data.State, avail.State, and consensus.State, replacing the
  ad-hoc committee/election fields
- Drop EpochWindowCommittee in favour of direct EpochWindow() usage
- Drop Activate and the committees map; Registry holds a single genesis committee
  for now — dynamic committee support deferred until execution layer is ready
- Add EpochFor(RoadIndex) and VerifyInWindow for epoch-transition message acceptance
- Per-epoch vote accumulation in avail: laneQCs returns one QC per epoch in window;
  WaitForLaneQCs takes an epoch.Index so consensus always gets the matching QC
- Fix sei-db blocksim and block_db_test to match updated autobahn type signatures
  (GlobalRange, NewProposal, NewRoundRobinElection) introduced by concurrent main commits

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wen-coding wen-coding force-pushed the wen/autobahn_epoch_registry branch from ab4c67c to 9cce5d2 Compare June 24, 2026 17:32
…olute everywhere

- Remove firstBlock parameter from GlobalRange(), BlockTimestamp(), and
  related Verify() methods; store it in Proposal at construction time
- Add global_first (optional uint64, field 6) to pb.Proposal so the
  epoch offset survives encode/decode round-trips; regenerate pb files
- Add ViewSpec.FirstBlock and NextGlobalBlock() so callers no longer
  pass firstBlock at every call site — oncall reads absolute numbers
- Remove GlobalRangeOpt (footgun: returned 0 when CommitQC absent,
  wrong for non-genesis epochs); replace call sites with explicit .Get()
- Add types.BuildCommitQC test helper; remove BuildFullCommitQC (each
  caller owns its own block generation)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6b591bc. Configure here.

Comment thread sei-tendermint/autobahn/types/proposal.go
@wen-coding wen-coding force-pushed the wen/autobahn_epoch_registry branch 2 times, most recently from 4b08607 to f1f1d55 Compare June 25, 2026 00:12
…).First

GlobalRange().First is sum(lane.First)+firstBlock. Passing it as the
firstBlock argument to newProposal would add it on top of the lane sum
again, doubling the offset. Use p.firstBlock (the raw epoch offset) instead.

Reproposals happen when the chain is recovering after a halt — the path
exercised by TestAutobahn/Recovery — so a wrong GlobalRange caused
FullProposal.Verify to reject every reproposal, preventing recovery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wen-coding wen-coding force-pushed the wen/autobahn_epoch_registry branch from f1f1d55 to 09e677e Compare June 25, 2026 00:46
@wen-coding wen-coding requested a review from pompon0 June 25, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant