Skip to content

refactor(bft): extract state, vote_collector, timeouts into submodules#420

Merged
satyakwok merged 4 commits intomainfrom
refactor/bft-engine-extract-state-vote-timeouts
Apr 29, 2026
Merged

refactor(bft): extract state, vote_collector, timeouts into submodules#420
satyakwok merged 4 commits intomainfrom
refactor/bft-engine-extract-state-vote-timeouts

Conversation

@satyakwok
Copy link
Copy Markdown
Member

Summary

Phase 3 (consensus-touching) of the workspace audit. bft/engine.rs was 2166 LOC mixing five concerns:

  • timeout constants (PROPOSE_TIMEOUT_MS / PREVOTE_TIMEOUT_MS / PRECOMMIT_TIMEOUT_MS / etc.) + helpers (propose_timeout / prevote_timeout / precommit_timeout)
  • BftPhase enum
  • BftRoundState struct + impl (per-(height, round) bookkeeping with locked-block / staging-block fields)
  • VoteCollector struct + impl (stake-weighted prevote + precommit tally with supermajority detection)
  • the BftEngine itself + tests

Moved the first three into engine/{timeouts,state,vote_collector}.rs and re-exported from engine.rs so the public API at sentrix_bft::engine::* (and the lib.rs re-exports) is unchanged. engine.rs drops to 1944 LOC, focused on BftEngine itself.

No behaviour change. Pure mechanical extraction.

Test plan

  • cargo clippy --workspace --tests -- -D warnings clean
  • cargo test --workspace passes (700+ tests, 0 failures)
  • Live mainnet 7119: halt-all + simul-start, all 4 validators advancing 4-of-4 lockstep at ~1 block/sec (verified ~896221 → 896431 in 64s)
  • Live testnet 7120: 4-docker stack restart, advancing healthy (verified 1150711 → 1150997 in 64s)

Satya Kwok and others added 4 commits April 29, 2026 01:16
…chain.com

scan.sentrixchain.com remains the primary explorer with full
native-op coverage. Blockscout sidecar adds EVM-standard UX
(ERC-20 holders, source verification, EIP-3091 URLs) for listing
platforms + EVM tooling that expects that shape.
engine.rs was 2166 LOC mixing five concerns:
- timeout constants + propose/prevote/precommit_timeout helpers
- BftPhase enum
- BftRoundState struct + impl (per-(height,round) bookkeeping)
- VoteCollector struct + impl (stake-weighted tally + supermajority)
- the BftEngine itself + tests

Moved the first three into engine/{timeouts,state,vote_collector}.rs
and re-export from engine.rs so the public API at sentrix_bft::engine::*
is unchanged. engine.rs drops to 1944 LOC, focused on BftEngine.

No behaviour change. cargo clippy --workspace --tests -- -D warnings
clean; cargo test --workspace passes; live verified on mainnet 7119
(halt-all + simul-start, all 4 validators advancing 4-of-4 lockstep)
+ testnet 7120 (4 docker validators advancing).

Phase 3 of the workspace audit.
@satyakwok satyakwok merged commit f7ccd65 into main Apr 29, 2026
5 checks passed
@satyakwok satyakwok deleted the refactor/bft-engine-extract-state-vote-timeouts branch April 29, 2026 07:23
satyakwok added a commit that referenced this pull request Apr 29, 2026
* docs: dual-explorer note for Blockscout sidecar at blockscout.sentrixchain.com

scan.sentrixchain.com remains the primary explorer with full
native-op coverage. Blockscout sidecar adds EVM-standard UX
(ERC-20 holders, source verification, EIP-3091 URLs) for listing
platforms + EVM tooling that expects that shape.

* chore: humanize the just-extracted submodule headers

The recent batch of refactor PRs (#419 explorer, #420 bft engine, #421
slashing) shipped with header comments that read a bit like a release-
notes generator wrote them — "X.rs — short description. Pulled out
of Y for Z. No behaviour change." That's not the voice the rest of
this codebase carries. Comments here usually tell stories, reference
incidents, drop dates and PR numbers. This pass rewrites the seven
new file headers + the two re-export blocks so they sound like the
operator wrote them late at night, which is closer to the truth.

No code change.

---------

Co-authored-by: Satya Kwok <satyakwik@gmail.com>
Co-authored-by: satyakwok <satyakwok@users.noreply.github.com>
Co-authored-by: Satya Kwok <satyakwik@users.noreply.github.com>
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