Skip to content

feat(contract): Oracle freshness, multi-oracle medianization, VRF commit-reveal, keeper bonding (#1040-#1043) - #1111

Open
devdianax wants to merge 1 commit into
SoroLabs:mainfrom
devdianax:feat/contract-security-issues-1040-1043
Open

feat(contract): Oracle freshness, multi-oracle medianization, VRF commit-reveal, keeper bonding (#1040-#1043)#1111
devdianax wants to merge 1 commit into
SoroLabs:mainfrom
devdianax:feat/contract-security-issues-1040-1043

Conversation

@devdianax

Copy link
Copy Markdown

Summary

Implements four contract-level security improvements as specified in Issues #1040-#1043.

Issue #1040 - Oracle Heartbeat Freshness Verification & Staleness Circuit Breaker

  • Added MAX_ORACLE_DELAY_SECONDS = 300 (5 minutes) staleness threshold.
  • Implemented validate_oracle_freshness() helper that rejects oracle responses older than the threshold.
  • Integrated staleness check into execute_internal pipeline - stale oracle feeds cause execution to revert with Error::OracleStale.

Issue #1041 - Multi-Source Oracle Medianization & Flash Deviation Thresholds

  • Added OracleFeed struct for per-provider price feeds (Chainlink, Band).
  • Implemented compute_median_price() using insertion-sort median across all fresh feeds.
  • Implemented check_oracle_deviation() that panics with Error::OracleDeviationExceeded if any two feeds deviate by more than MAX_ORACLE_DEVIATION_BPS (2.5%).
  • Added public methods: set_oracle_feed(), get_oracle_feed(), get_medianized_oracle_price().
  • Oracle freshness and deviation checks run automatically during execute_internal.

Issue #1042 - Cryptographic VRF Commit-Reveal Scheme & Fulfillment Window Enforcement

  • Added VrfCommit type for the commit phase and commit_vrf_seed() method.
  • Added configurable timing via set_vrf_timing_config(delay_seconds, expiration_seconds).
  • fulfill_vrf_request() now enforces the fulfillment window - rejects early (VrfFulfillmentTooEarly) or expired (VrfFulfillmentExpired) fulfillments when delay > 0.
  • Added cancel_vrf_request() for requestors to reclaim after expiration.
  • Defaults to delay=0 (backward-compatible) - admin must explicitly enable via set_vrf_timing_config().

Issue #1043 - Keeper Economic Bonding & On-Chain Stake Slashing Protocol

  • Added KeeperBond type and MIN_KEEPER_STAKE = 500 token units requirement.
  • Implemented bond_keeper_stake() and unbond_keeper_stake() for keepers to lock/unlock collateral.
  • Enhanced slash_keeper() with 50/50 split: 50% to protocol treasury, 50% to whistleblower.
  • Slashed keepers are marked is_slashed and locked from participating until rebonded.
  • Added set_task_requires_bond(task_id, true) for per-task opt-in.
  • Bonding check runs in execute_internal only for tasks marked as restricted.

Acceptance Criteria

Closes #1040
Closes #1041
Closes #1042
Closes #1043

… freshness, multi-oracle medianization, VRF commit-reveal, keeper bonding

- Issue SoroLabs#1040: Oracle Heartbeat Freshness Verification & Staleness Circuit Breaker
  - Added MAX_ORACLE_DELAY_SECONDS (300s) constant
  - Added validate_oracle_freshness() and require_fresh_oracle_response() helpers
  - Integrated staleness check in execute_internal pipeline

- Issue SoroLabs#1041: Multi-Source Oracle Medianization & Flash Deviation Thresholds
  - Added OracleFeed type for per-provider price feeds
  - Added MAX_ORACLE_DEVIATION_BPS (250) threshold
  - Implemented compute_median_price() with insertion-sort median
  - Implemented check_oracle_deviation() to halt on >2.5% deviation
  - Added set_oracle_feed(), get_oracle_feed(), get_medianized_oracle_price()

- Issue SoroLabs#1042: Cryptographic VRF Commit-Reveal Scheme & Fulfillment Window Enforcement
  - Added VrfCommit type and commit_vrf_seed() method
  - Added configurable VRF delay/expiration via set_vrf_timing_config()
  - Enforces fulfillment window in fulfill_vrf_request()
  - Added cancel_vrf_request() for expired requests

- Issue SoroLabs#1043: Keeper Economic Bonding & On-Chain Stake Slashing Protocol
  - Added KeeperBond type and MIN_KEEPER_STAKE (500) constant
  - Implemented bond_keeper_stake() and unbond_keeper_stake()
  - Enhanced slash_keeper() with 50/50 treasury/whistleblower split
  - Added set_task_requires_bond() for per-task opt-in
  - Added bonding check in execute_internal for restricted tasks

Closes SoroLabs#1040
Closes SoroLabs#1041
Closes SoroLabs#1042
Closes SoroLabs#1043
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@devdianax 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

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Smartdevs17 is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment