Repository navigation
fix(#265): bound prune_expired_parameter_proposals per-call work - #326
Open
Stickernote145 wants to merge 1 commit into
Open
Stickernote145 wants to merge 1 commit into
Stickernote145 wants to merge 1 commit into
Conversation
Add prune_expired_parameter_proposals_bounded(env, max_prune) to storage.rs that caps the number of expired proposals processed in a single call. The existing prune_expired_parameter_proposals now delegates to the bounded variant with MAX_PENDING_PARAMETER_PROPOSALS (10) as its cap, and the propose_parameter_change call site in lib.rs is updated to call the bounded version directly so the limit is visible at the call site. This prevents resource-budget exhaustion when many proposals accumulate without a timely prune and the next propose_parameter_change call triggers cleanup (Soroban resource limits apply per-transaction). Tests added to test_parameter_governance.rs: - test_prune_bounded_max_zero_is_noop - test_prune_bounded_cap_limits_work_per_call - test_prune_bounded_prunes_all_when_cap_exceeds_pending_count - test_prune_bounded_skips_non_expired_proposals Closes hartz0#265
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.
Summary
closes #265.
closes #262
closes #263
closes #264
prune_expired_parameter_proposalsiterated the entire pending-proposals vector in a single unbounded loop. If a long period elapsed without pruning and dozens of proposals accumulated, executing this function inside onepropose_parameter_changetransaction could exhaust the Soroban resource budget and abort the transaction.Changes
storage.rsprune_expired_parameter_proposals_bounded(env, max_prune) -> u32: iterates the pending IDs vector but breaks as soon asmax_pruneexpired proposals have been marked and removed. Returns the count pruned.prune_expired_parameter_proposalsnow delegates to the bounded variant withMAX_PENDING_PARAMETER_PROPOSALS(10) as the cap, so the function signature and all existing callers stay unchanged.lib.rspropose_parameter_changecall site now callsprune_expired_parameter_proposals_boundeddirectly withMAX_PENDING_PARAMETER_PROPOSALS, making the budget bound visible at the call site rather than hidden inside the helper.Tests added (
test_parameter_governance.rs)test_prune_bounded_max_zero_is_noopmax_prune = 0leaves all pending proposals untouchedtest_prune_bounded_cap_limits_work_per_callmax_prune = 1prunes only the first expired proposal, leaving the rest pendingtest_prune_bounded_prunes_all_when_cap_exceeds_pending_countmax_prune >= lenprunes everything (same as old behaviour for the normal case)test_prune_bounded_skips_non_expired_proposalsBackward compatibility
prune_expired_parameter_proposalskeeps its existing signature and behaviour for all callers that already use it (includingcleanup_expired_parameter_proposals). The change is purely additive.