Repository navigation
fix(consensus): reset future fork stats during maintenance - #7131
halibobo1205 wants to merge 1 commit into
Conversation
Scan stored fork-version records during maintenance. Clear records for known or future versions that have not passed, preserving historical versions omitted from the enum.
| // Preserve records for historical gaps below the highest known version. | ||
| for (int version : store.getForkStatsVersions()) { | ||
| boolean futureVersion = version > MAX_KNOWN_VERSION; | ||
| if ((futureVersion || ForkBlockVersionEnum.getForkBlockVersionEnum(version) != null) |
There was a problem hiding this comment.
[SHOULD] Redundant pass() call for future versions repeats a warn log every maintenance period
When version > MAX_KNOWN_VERSION, ForkBlockVersionEnum.getForkBlockVersionEnum(version) is always null, so passNew logs logger.warn("Not exist block version: {}.") and returns false. That means !pass(version) is always true for future versions and the pass() call has no decision value. Since reset() zeroes the stats without deleting the key, each future-version key persists indefinitely and triggers one warn log per maintenance period (~every 6 hours) on the consensus path.
Evidence clarity: Confirmed
Suggestion: Short-circuit future versions, e.g. if (futureVersion || (ForkBlockVersionEnum.getForkBlockVersionEnum(version) != null && !pass(version))), so future versions are cleared directly without calling pass().
What does this PR do?
Scan stored
FORK_VERSION_keys during maintenance and reset records for known or future fork versions that have yet to pass. Preserve records for historical versions omitted from the enum.Why are these changes required?
The previous reset only checked versions in the local enum, leaving future-version support records in place across maintenance periods.
Testing
ForkControllerTestpassed, including the new regression test for future-version records.