Skip to content

fix: guard ThrottleMultiplier against congestion tier-count changes - #26760

Open
AlexKehayov wants to merge 2 commits into
mainfrom
issue-243
Open

fix: guard ThrottleMultiplier against congestion tier-count changes#26760
AlexKehayov wants to merge 2 commits into
mainfrom
issue-243

Conversation

@AlexKehayov

Copy link
Copy Markdown
Contributor

Description

ThrottleMultiplier.resetCongestionLevelStarts cloned the state-restored congestionLevelStarts array without checking its length against the active congestion config. updateMultiplier then indexes that array over activeConfig.multipliers().length tiers. If the number of congestion tiers (fees.percentCongestionMultipliers) changed between when the array was saved and when it is restored — and the restored array is shorter — the deterministic
fee/handle path throws ArrayIndexOutOfBoundsException on the next updateMultiplier after a restart/reconnect, crashing the node.

(The init ordering makes this reachable: resetExpectations() sizes the array to the current tier count via rebuildState(), then syncFromCongestionLevelStarts() overwrites it with the saved array, and ensureConfigUpToDate() returns false so rebuildState() is skipped before the out-of-bounds read.)

This reconciles the restored array against the active tier count: on a mismatch it logs a warning and skips the restore (discarding stale warm-up history) so the multiplier re-warms from a correctly-sized array instead of indexing out of bounds.

Behavior

  • No change in the normal case. When the number of tiers is unchanged, the restored array length matches the active tier count and it is cloned exactly as before.
  • The guard runs only when the restored array length differs from the active tier count — the case that crashes today. It then drops the stale start times and lets the multiplier re-accumulate from the default (1x) over minCongestionPeriod. Both inputs (the saved array length and the configured tier count) are identical on every node, so the guard behaves the same across the network and stays deterministic.
  • Not externally triggerable, and not a consensus/funds change. The tier count comes only from fees.percentCongestionMultipliers — node-local startup config, not a @NetworkProperty, and not writable by any transaction. The only way to change the number of tiers is an operator/local-config or shipped-default change that takes effect on the next restart. Without this check, adding a tier to the shipped default would crash the handle path on every node at the next restart.

Testing

  • Added ThrottleMultiplierTest.testResetCongestionLevelStartsIgnoresTierCountMismatch: with a 3-tier active config, restoring a 2-element congestionLevelStarts array is ignored (the array stays sized to the active tier count) and the next updateMultiplier does not throw. The test fails against the previous code (expected: <3> but was: <2>, then an ArrayIndexOutOfBoundsException on update) and passes with this change.

…on state restore

Signed-off-by: Alex Kehayov <aleks.kehayov@limechain.tech>
@AlexKehayov AlexKehayov self-assigned this Aug 10, 2026
@AlexKehayov
AlexKehayov requested a review from a team as a code owner August 10, 2026 12:36
@trunk-io

trunk-io Bot commented Aug 10, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@lfdt-bot

lfdt-bot commented Aug 10, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...a/node/app/fees/congestion/ThrottleMultiplier.java 80.00% 0 Missing and 1 partial ⚠️

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #26760      +/-   ##
============================================
- Coverage     70.47%   70.47%   -0.01%     
+ Complexity    11673    11672       -1     
============================================
  Files          2579     2579              
  Lines        108277   108282       +5     
  Branches      12100    12100              
============================================
- Hits          76313    76308       -5     
- Misses        27986    27993       +7     
- Partials       3978     3981       +3     
Files with missing lines Coverage Δ Complexity Δ
...a/node/app/fees/congestion/ThrottleMultiplier.java 92.92% <80.00%> (-0.60%) 0.00 <0.00> (ø)

... and 3 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Aug 10, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 24bc7f7
▶️ Tests: 21769 executed
⚪️ Checks: 48/48 completed


Learn more about TestLens at testlens.app.

@AlexKehayov AlexKehayov added this to the v0.79 milestone Aug 11, 2026
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