Skip to content

[Feat]:: Implemented Oracle Contract Validation and Approved Oracle W…#186

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
ryzen-xp:Oracle-Contract-Validation-and-Approved
Oct 5, 2025
Merged

[Feat]:: Implemented Oracle Contract Validation and Approved Oracle W…#186
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
ryzen-xp:Oracle-Contract-Validation-and-Approved

Conversation

@ryzen-xp

@ryzen-xp ryzen-xp commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

Pull Request Description

Close #53

📋 Basic Information

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🧪 Test addition/update
  • 🔧 Refactoring
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🎨 UI/UX improvement
  • 🚀 Deployment/Infrastructure change

Related Issues

Closes #53

Priority Level

  • 🔴 Critical
  • 🟡 High
  • 🟢 Medium
  • 🔵 Low

📝 Detailed Description

What does this PR do?

This PR implements the Oracle Whitelist and Validation system for the Predictify Hybrid contracts.
Key additions include:

  • OracleWhitelist struct for centralized oracle management.
  • Functions for adding/removing oracles with admin-only access.
  • Validation of oracle contract signatures and function compatibility.
  • Oracle health check and metadata storage.
  • get_approved_oracles() for fetching the active whitelist.
  • Events for oracle addition/removal for audit trail.

Why is this change needed?

Previously, any address could be passed as an oracle, creating security risks (malicious or invalid oracle contracts).
This PR ensures that:

  • Only verified oracles are used.
  • Oracles pass signature validation, health checks, and version checks.
  • Administrators maintain a single authoritative whitelist.

How was this tested?

  • Added unit tests for:

    • Adding/removing oracles.
    • Rejecting duplicate entries.
    • Validation of whitelisted vs non-whitelisted oracles.
    • Edge cases such as removing non-existent oracles.
  • Manual testing on local testnet.

  • Verified events (oracle_whitelisted, oracle_removed) are emitted correctly.

Alternative Solutions Considered

  • Iterating directly over storage for oracles (rejected due to Soroban’s lack of iteration APIs).
  • Using only metadata flags without a list (rejected since it made retrieval inefficient).
  • Final approach uses a Vec<Address> stored under OracleList for efficient lookup and retrieval.

🏗️ Smart Contract Specific

Contract Changes

  • Core contract logic modified
  • Oracle integration changes
  • New functions added
  • Existing functions modified
  • Storage structure changes
  • Events added/modified
  • Error handling improved
  • Gas optimization
  • Access control changes
  • Admin functions modified
  • Fee structure changes

Oracle Integration

  • Oracle configuration changes
  • Pyth oracle integration affected
  • Reflector oracle integration affected
  • Oracle fallback mechanisms
  • Oracle validation logic

Market Resolution Logic

  • Hybrid resolution algorithm changed
  • Dispute mechanism modified
  • Fee structure updated
  • Voting mechanism changes
  • Community weight calculation
  • Oracle weight calculation

Security Considerations

  • Access control reviewed
  • Input validation
  • Oracle manipulation protection
  • Reentrancy protection
  • Overflow/underflow protection

🧪 Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests updated
  • All tests passing locally
  • Manual testing completed
  • Gas usage optimized

Test Results

cargo test
# Output: All 27 tests passed

Manual Testing Steps

  1. Deploy contract on local testnet.
  2. Call add_oracle_to_whitelist with admin → succeeds.
  3. Call get_approved_oracles → returns correct list.
  4. Attempt invalid oracle → rejected.
  5. Remove oracle → validated and removed.

📚 Documentation

Documentation Updates

  • Code comments updated
  • Architecture documentation updated
  • README updated
  • API documentation updated
  • Deployment instructions updated

Breaking Changes

Breaking Changes:

  • None (only adds new functionality).

Migration Guide:

  • Existing deployments unaffected.

🔍 Code Quality

  • Code follows Rust/Soroban best practices
  • No unnecessary duplication
  • Error handling improved
  • Events for auditing added
  • Self-review completed

Performance Impact:

  • Gas Usage: Minimal increase due to validation logic.
  • Storage Impact: Additional vector of approved oracle addresses.

🚀 Deployment & Integration

Deployment Notes

  • Network: Testnet deployment planned.
  • Migration Required: No.
  • Special Instructions: None.

Integration Points

  • Backward compatibility maintained
  • Frontend can now fetch approved oracles via get_approved_oracles.

📊 Impact Assessment

User Impact

  • End Users: More secure oracle feeds.
  • Developers: Cleaner API for oracle validation.
  • Admins: Centralized control over oracle approval.

Business Impact

  • Security: Stronger protection from malicious contracts.
  • Reliability: Validated oracle feeds ensure correct market outcomes.

✅ Final Checklist

  • All CI checks passing
  • Tests included and passing
  • Documentation updated
  • PR description complete

💬 Notes for Reviewers

Please focus on:

  • Correctness of get_approved_oracles logic.
  • Efficiency of whitelist storage.
  • Event emissions for monitoring and auditing.

⚡ This PR secures the oracle pipeline by introducing a robust validation and whitelist system, closing #53.

@ryzen-xp

ryzen-xp commented Oct 5, 2025

Copy link
Copy Markdown
Contributor Author
Screenshot from 2025-10-05 15-26-00

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

LGTM! @ryzen-xp

@greatest0fallt1me greatest0fallt1me merged commit 9d08b93 into Predictify-org:master Oct 5, 2025
1 check passed
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.

Implement Oracle Contract Validation and Approved Oracle Whitelist

2 participants