Skip to content

docs(contract): sync TYPES_SYSTEM with types.rs#474

Merged
greatest0fallt1me merged 1 commit intoPredictify-org:masterfrom
Tola-byte:feature/types-doc-sync
Mar 25, 2026
Merged

docs(contract): sync TYPES_SYSTEM with types.rs#474
greatest0fallt1me merged 1 commit intoPredictify-org:masterfrom
Tola-byte:feature/types-doc-sync

Conversation

@Tola-byte
Copy link
Copy Markdown
Contributor

Pull Request Description

📋 Basic Information

Type of Change

Please select the type of change this PR introduces:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧪 Test addition/update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🎨 UI/UX improvement
  • 🚀 Deployment/Infrastructure change

Related Issues

Closes #437
Fixes #437
Related to #437

Priority Level

  • 🔴 Critical (blocking other development)
  • 🟡 High (significant impact)
  • 🟢 Medium (moderate impact)
  • 🔵 Low (minor improvement)

📝 Detailed Description

What does this PR do?

  • Syncs docs/contracts/TYPES_SYSTEM.md with the actual #[contracttype] definitions in contracts/predictify-hybrid/src/types.rs.
  • Fixes a validation gap in Market::validate by validating fallback_oracle_config whenever has_fallback == true.
  • Adds regression tests to enforce the fallback validation behavior.

Why is this change needed?

  • The documentation had drifted from code, making integration/audit review harder.
  • A malformed fallback oracle config could pass Market::validate previously, creating a correctness/security risk at resolution time.
  • This PR restores type-documentation parity and enforces stronger upfront validation invariants.

How was this tested?

  • Added unit tests in types.rs:
    • market_validate_rejects_invalid_fallback_when_enabled
    • market_validate_allows_no_fallback_sentinel_path
  • Ran full crate tests locally.

Alternative Solutions Considered

  • Leaving fallback validation to downstream oracle/resolution flows only.
    Rejected because early validation is safer, simpler, and easier to reason about.

🏗️ Smart Contract Specific

Contract Changes

Please check all that apply:

  • Core contract logic modified
  • Oracle integration changes (Pyth/Reflector)
  • 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

  • Pyth oracle integration affected
  • Reflector oracle integration affected
  • Oracle configuration changes
  • Price feed handling modified
  • Oracle fallback mechanisms
  • Price 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
  • Reentrancy protection
  • Input validation
  • Overflow/underflow protection
  • Oracle manipulation protection

🧪 Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests passing locally
  • Manual testing completed
  • Oracle integration tested
  • Edge cases covered
  • Error conditions tested
  • Gas usage optimized
  • Cross-contract interactions tested

Test Results

cargo +stable test -p predictify-hybrid

test result: ok. 272 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Manual Testing Steps

  1. Created a market with valid primary oracle and invalid fallback oracle while has_fallback=true; confirmed Market::validate returns Error::InvalidOracleConfig.
  2. Created a market with fallback_oracle_config=None; confirmed sentinel path still validates.
  3. Ran full crate test suite and confirmed all tests pass.

📚 Documentation

Documentation Updates

  • README updated
  • Code comments added/updated
  • API documentation updated
  • Examples updated
  • Deployment instructions updated
  • Contributing guidelines updated
  • Architecture documentation updated

Breaking Changes

Breaking Changes:

  • None

Migration Guide:

  • No migration required.

🔍 Code Quality

Code Review Checklist

  • Code follows Rust/Soroban best practices
  • Self-review completed
  • No unnecessary code duplication
  • Error handling is appropriate
  • Logging/monitoring added where needed
  • Security considerations addressed
  • Performance implications considered
  • Code is readable and well-commented
  • Variable names are descriptive
  • Functions are focused and small

Performance Impact

  • Gas Usage: Negligible; one extra fallback config validation branch in Market::validate.
  • Storage Impact: None.
  • Computational Complexity: Constant-time additional validation when fallback is enabled.

Security Review

  • No obvious security vulnerabilities
  • Access controls properly implemented
  • Input validation in place
  • Oracle data properly validated
  • No sensitive data exposed

🚀 Deployment & Integration

Deployment Notes

  • Network: N/A (contract source update)
  • Contract Address: N/A
  • Migration Required: No
  • Special Instructions: None

Integration Points

  • Frontend integration considered
  • API changes documented
  • Backward compatibility maintained
  • Third-party integrations updated

📊 Impact Assessment

User Impact

  • End Users: Reduced risk of markets created with invalid fallback oracle config.
  • Developers: Accurate TYPES_SYSTEM.md now matches code 1:1 for integrator use.
  • Admins: Earlier failure on invalid fallback config improves operational safety.

Business Impact

  • Revenue: Neutral.
  • User Experience: Positive for reliability and predictability.
  • Technical Debt: Reduced documentation drift and validation ambiguity.

✅ Final Checklist

Pre-Submission

  • Code follows Rust/Soroban best practices
  • All CI checks passing
  • No breaking changes (or breaking changes are documented)
  • Ready for review
  • PR description is complete and accurate
  • All required sections filled out
  • Test results included
  • Documentation updated

Review Readiness

  • Self-review completed
  • Code is clean and well-formatted
  • Commit messages are clear and descriptive
  • Branch is up to date with main
  • No merge conflicts

📸 Screenshots (if applicable)

N/A

🔗 Additional Resources

  • Design Document: N/A
  • Technical Spec: docs/contracts/TYPES_SYSTEM.md
  • Related Discussion: Issue Types documentation sync #437
  • External Documentation: N/A

💬 Notes for Reviewers

Please pay special attention to:

  • Market::validate fallback validation branch correctness and expected error behavior.
  • Documentation parity between docs/contracts/TYPES_SYSTEM.md and types.rs contract types.

Questions for reviewers:

  • Should we additionally validate non-empty feed_id in OracleConfig::validate in a follow-up PR?

Thank you for your contribution to Predictify! 🚀

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 24, 2026

@Tola-byte 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 3e033fc into Predictify-org:master Mar 25, 2026
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.

Types documentation sync

2 participants