Skip to content

fix(consensus): reset future fork stats during maintenance - #7131

Closed
halibobo1205 wants to merge 1 commit into
tronprotocol:release_v4.8.3from
halibobo1205:feat/reset-future-fork-stats
Closed

halibobo1205 wants to merge 1 commit into
tronprotocol:release_v4.8.3from
halibobo1205:feat/reset-future-fork-stats

Conversation

@halibobo1205

Copy link
Copy Markdown
Collaborator

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

  • ForkControllerTest passed, including the new regression test for future-version records.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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().

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.

2 participants