feat(consensus): SIP-5 speculative apply — block hash commits state root (Bug B, #751)#814
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…SIP-5 Bug B, #751) Adds the block-executor side of SIP-5 (speculative apply at propose so the block hash commits the post-execution state_root): - SPECULATIVE_APPLY_HEIGHT fork gate (default u64::MAX, env-activated; SIP-5) - Blockchain::speculative_apply_for_state_root: computes the state_root a candidate block would produce on a throwaway clone, for the proposer to stamp at propose time and validators to verify before prevoting - commit-gate: post-fork a self-produced block with state_root=None is rejected instead of stamp+recompute (the Bug B H1->H2 divergence) Fork-gated off on both nets; inert until a height is set. Propose-side stamp + verify-before-vote wiring (main.rs) and the full regression test land separately. Not for deploy without fresh-brain review + testnet bake.
f650702 to
b7b1ef0
Compare
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR implements SIP-5 / "Bug B" by adding a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Draft / WIP — not for merge. Block-executor core for SIP-5 (Bug B, #751): speculative apply at propose so the block hash commits the post-execution
state_root, closing theblock.hash != justification.block_hashinconsistency.Design: SIP-5 (B1).
In this PR (block-executor side)
SPECULATIVE_APPLY_HEIGHTfork gate (defaultu64::MAXboth nets — inert until activated by env)Blockchain::speculative_apply_for_state_root— computes thestate_roota candidate block would produce on a throwaway clone (justification gate is peer-only, so a propose-time block with no justification still applies)Blockchain::is_speculative_apply_heightwrapperstate_root = Noneis rejected instead of stamp+recompute (the Bug B H1→H2 divergence)Builds clean (
-p sentrix-fork-heights,-p sentrix-core).Remaining (separate commits)
bin/sentrix/src/main.rs(refactorbuild_or_reuse_proposal→ single point that stampsstate_root+ recomputes hash before signing)block.hash == justification.block_hashpost-fork)Activation
Fork-gated off. Activation = halt-all + state-root-alignment pre-flight + simul-start, testnet first, then mainnet at a coordinated height. Requires fresh-brain review + testnet bake before activation.
Summary by CodeRabbit
New Features
Bug Fixes