feat: time-lock fee-config updates#695
Merged
greatest0fallt1me merged 1 commit intoJun 27, 2026
Merged
Conversation
- Add FeeConfigManager::queue_update(env, admin, new_config, eta) to stage updates - Add FeeConfigManager::apply_update(env, admin) to apply when env.ledger().timestamp() >= eta - Add FeeConfigManager::cancel_queued_update(env, admin) to cancel before ETA - Add FeeConfigManager::get_queued_fee_config(env) for transparency - Emit FeeConfigQueuedEvent, FeeConfigAppliedEvent, FeeConfigCancelledEvent - Update FeeManager::update_fee_config to use time-locked queue - Add FeeManager::apply_fee_update and FeeManager::cancel_fee_update wrappers - Update AdminFunctions to accept eta parameter and expose apply/cancel methods - Add 5 tests: queue stores pending, apply before ETA rejected, apply at ETA succeeds, cancel removes pending, past ETA rejected
|
@anupam7984 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
closes #630
Summary
Wraps fee-config updates in a governance time-lock to prevent surprise changes. Follows a proposal → queue → apply cycle with a mandatory delay.
Changes
contracts/predictify-hybrid/src/fees.rsFeeConfigManager::queue_update(env, admin, new_config, eta)— stages a new config with a future ETA. Rejects past ETAs withError::InvalidInput.FeeConfigManager::apply_update(env, admin)— activates the queued config only whenenv.ledger().timestamp() >= eta. Clears pending storage after application.FeeConfigManager::cancel_queued_update(env, admin)— admin-only cancel before ETA. Requires bothrequire_auth()andvalidate_admin_permissions.FeeConfigManager::get_queued_fee_config(env)— returnsOption<(FeeConfig, u64)>for transparency.FeeManager::update_fee_configsignature to accepteta: u64and delegate toqueue_update.FeeManager::apply_fee_updateandFeeManager::cancel_fee_updatepublic wrappers.unwrap()introduced — allOptiontypes handled withok_or.Tests (5):
test_queue_update_stores_pending_config— verifies queued config is storedtest_apply_update_before_eta_fails— apply rejected withError::InvalidInputtest_apply_update_at_eta_succeeds— sets timestamp, applies, verifies active config matchestest_cancel_queued_update_removes_pending— cancel clears pending, confirmed viaget_queued_fee_configtest_queue_update_with_past_eta_fails— past ETA rejectedcontracts/predictify-hybrid/src/events.rsAdded 3 event types and emit methods:
FeeConfigQueuedEventFeeConfigAppliedEventFeeConfigCancelledEventcontracts/predictify-hybrid/src/admin.rsUpdated
AdminFunctions::update_fee_configto accepteta: u64and delegate toFeeManager::update_fee_config. Addedapply_fee_updateandcancel_fee_updatepublic admin functions.Files Changed
contracts/predictify-hybrid/src/fees.rscontracts/predictify-hybrid/src/events.rscontracts/predictify-hybrid/src/admin.rsAcceptance Criteria
Error::InvalidInput)require_auth+validate_admin_permissions)FeeConfigQueuedEventunwrap()introduced — all Option types handled withok_orenv.ledger().timestamp()used for ETA comparisons