Skip to content

feat: time-lock fee-config updates#695

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
anupam7984:feat/fee-config-timelock
Jun 27, 2026
Merged

feat: time-lock fee-config updates#695
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
anupam7984:feat/fee-config-timelock

Conversation

@anupam7984

Copy link
Copy Markdown

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.rs

  • Added FeeConfigManager::queue_update(env, admin, new_config, eta) — stages a new config with a future ETA. Rejects past ETAs with Error::InvalidInput.
  • Added FeeConfigManager::apply_update(env, admin) — activates the queued config only when env.ledger().timestamp() >= eta. Clears pending storage after application.
  • Added FeeConfigManager::cancel_queued_update(env, admin) — admin-only cancel before ETA. Requires both require_auth() and validate_admin_permissions.
  • Added FeeConfigManager::get_queued_fee_config(env) — returns Option<(FeeConfig, u64)> for transparency.
  • Updated FeeManager::update_fee_config signature to accept eta: u64 and delegate to queue_update.
  • Added FeeManager::apply_fee_update and FeeManager::cancel_fee_update public wrappers.
  • No unwrap() introduced — all Option types handled with ok_or.

Tests (5):

  • test_queue_update_stores_pending_config — verifies queued config is stored
  • test_apply_update_before_eta_fails — apply rejected with Error::InvalidInput
  • test_apply_update_at_eta_succeeds — sets timestamp, applies, verifies active config matches
  • test_cancel_queued_update_removes_pending — cancel clears pending, confirmed via get_queued_fee_config
  • test_queue_update_with_past_eta_fails — past ETA rejected

contracts/predictify-hybrid/src/events.rs

Added 3 event types and emit methods:

Event Fields
FeeConfigQueuedEvent admin, eta, all 6 FeeConfig fields, timestamp
FeeConfigAppliedEvent admin, all 6 FeeConfig fields, timestamp
FeeConfigCancelledEvent admin, timestamp

contracts/predictify-hybrid/src/admin.rs

Updated AdminFunctions::update_fee_config to accept eta: u64 and delegate to FeeManager::update_fee_config. Added apply_fee_update and cancel_fee_update public admin functions.


Files Changed

File Additions Deletions
contracts/predictify-hybrid/src/fees.rs +192 -17
contracts/predictify-hybrid/src/events.rs +89 -0
contracts/predictify-hybrid/src/admin.rs +23 -3

Acceptance Criteria

  • Apply before ETA rejected with typed error (Error::InvalidInput)
  • Cancel path requires admin auth (require_auth + validate_admin_permissions)
  • ETA stored and surfaced in FeeConfigQueuedEvent
  • No unwrap() introduced — all Option types handled with ok_or
  • env.ledger().timestamp() used for ETA comparisons

- 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
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit 8bf67f5 into Predictify-org:master Jun 27, 2026
1 check failed
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.

Add governance time-lock for fee-config updates via FeeConfigManager

2 participants