apollo_staking,apollo_consensus_manager: read mock epoch height from batcher first (#14698)#14761
Conversation
…batcher first (#14698) The mock staking contract derives the current epoch from the chain's latest block number. It read this solely from state sync, which is a downstream reader that can lag the commit tip significantly. Because committee resolution can only look ahead MIN_EPOCH_LENGTH (150) blocks past the epoch boundary implied by that height, a state-sync lag approaching ~150 blocks pushes the consensus height beyond the resolvable window: get_committee returns InvalidHeight, and consensus falls back to waiting for sync instead of producing blocks. Read the height from the batcher first (its storage marker tracks the commit tip), falling back to state sync on error, mirroring get_block_hash_with_fallback. The batcher get_height marker is the next-to-build height, so the latest committed block is one below it. Epoch math is unchanged; only the height source moves closer to the tip. This also aligns the mock with CairoStakingContract, which already reads epoch data via the batcher. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 6cfff03)
PR SummaryMedium Risk Overview
Tests were rewired to mock batcher height markers and add coverage for epoch-boundary markers and batcher-error fallback. The Reviewed by Cursor Bugbot for commit 163e4fc. Bugbot is set up for automated code reviews on this repo. Configure here. |
Backport of #14698 to
main-v0.14.3.Clean
git cherry-pick -xof163e4fc103. Nostarknet_versionchange (V0_14_3preserved).Stacked on
matanl/bp-14689-next-epoch-window— merge that first.