fix: guard ThrottleMultiplier against congestion tier-count changes - #26760
Open
AlexKehayov wants to merge 2 commits into
Open
fix: guard ThrottleMultiplier against congestion tier-count changes#26760AlexKehayov wants to merge 2 commits into
AlexKehayov wants to merge 2 commits into
Conversation
…on state restore Signed-off-by: Alex Kehayov <aleks.kehayov@limechain.tech>
|
Merging to
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 |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report❌ Patch coverage is
@@ 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
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: 24bc7f7 Learn more about TestLens at testlens.app. |
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.
Description
ThrottleMultiplier.resetCongestionLevelStartscloned the state-restoredcongestionLevelStartsarray without checking its length against the active congestion config.updateMultiplierthen indexes that array overactiveConfig.multipliers().lengthtiers. 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 deterministicfee/handle path throws
ArrayIndexOutOfBoundsExceptionon the nextupdateMultiplierafter a restart/reconnect, crashing the node.(The init ordering makes this reachable:
resetExpectations()sizes the array to the current tier count viarebuildState(), thensyncFromCongestionLevelStarts()overwrites it with the saved array, andensureConfigUpToDate()returns false sorebuildState()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
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.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
ThrottleMultiplierTest.testResetCongestionLevelStartsIgnoresTierCountMismatch: with a 3-tier active config, restoring a 2-elementcongestionLevelStartsarray is ignored (the array stays sized to the active tier count) and the nextupdateMultiplierdoes not throw. The test fails against the previous code (expected: <3> but was: <2>, then anArrayIndexOutOfBoundsExceptionon update) and passes with this change.