fix: harden istanbul_status RPC against resource exhaustion and data integrity issues#86
Open
eomti-wm wants to merge 6 commits into
Open
fix: harden istanbul_status RPC against resource exhaustion and data integrity issues#86eomti-wm wants to merge 6 commits into
eomti-wm wants to merge 6 commits into
Conversation
Remove duplicated code and fix range boundary inconsistency.
Introduce maxStatusBlockRange constant in calculateBlockRange to reject requests exceeding the limit, preventing CPU/DB I/O exhaustion from unbounded range scans.
Handle LatestBlockNumber as current block and reject unsupported negative block numbers with an explicit error in calculateBlockRange.
Return explicit errors on block fetch, WBFT extra extraction, and validator resolution failures to prevent partial counter updates and round distribution pollution.
Round-change weighted sum semantics were ambiguous and misleading.
Cache validator sets per epoch instead of fetching every block to avoid redundant DB lookups, and initialize zero baseline entries on each epoch transition so validators with no activity are included in the result.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR hardens the
istanbul_statusRPC API in the WBFT consensus module by introducing block range limits and epoch-based validator set caching, resolving several reliability issues and resource exhaustion risks.Problem
LatestBlockNumber) directly touint64caused underflow (wrapping), leading to incorrect parsing.Solution
maxStatusBlockRange) incalculateBlockRangeto restrict scan ranges, and correctly mappedLatestBlockNumberwhile rejecting other unsupported negative constants.analyzeBlockto return errors explicitly and deferred counter increments until all data fetches succeed.Changes
rpc.BlockNumberconstants incalculateBlockRangeanalyzeBlockto return(uint64, error)and defer counter updates to prevent partial state corruptionStatusloopTotalRoundsfield fromRoundStatsstruct