Closes #919#1012
Merged
greatest0fallt1me merged 2 commits intoJul 26, 2026
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@aburex12345 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! 🚀 |
Contributor
|
Merged via direct push to master (admin) |
greatest0fallt1me
merged commit Jul 26, 2026
794e641
into
Predictify-org:master
0 of 2 checks passed
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.
Pull Request Description
Basic Information
Type of Change
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 #919
Priority Level
Critical (blocking other development)
High (significant impact)
Medium (moderate impact)
Low (minor improvement)
Detailed Description
What does this PR do?
Adds a focused markets package with a v7 per-entrypoint gas snapshot suite. It measures Soroban host CPU and memory for the core market lifecycle calls (initialize, create_market, vote, resolve_market, claim_winnings, plus read-only helpers) and asserts each stays under documented ceilings so we have a regression baseline for CI/PR review.
Also documents how to run the suite and what the [gas_snap:v7] output means.
Why is this change needed?
Issue #919 asks for a markets gas snapshot baseline. Long-term we need stable CPU/mem numbers per call so performance regressions are caught early. predictify-hybrid is currently hard to compile in isolation for this work, so this PR lands a small, reviewable markets harness at the requested path (contracts/markets/tests/gas_snap.rs) instead of blocking on the hybrid package.
How was this tested?
Ran the dedicated snapshot suite locally with --nocapture so the measured numbers print for the PR:
cargo test -p markets --test gas_snap -- --nocapture
All 11 gas snapshot tests passed. Also ran cargo test -p markets for the package as a whole.
Alternative Solutions Considered
Hooking snapshots directly into predictify-hybrid was the first idea, but that package currently fails to compile with a large error set. A standalone markets crate keeps the GrantFox deliverable reviewable and matches the issue’s file path, while still using the same Soroban budget APIs (cost_estimate().budget()).
Smart Contract Specific
Contract Changes
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
(Note: voting/resolution here is the focused markets harness, not a change to PredictifyHybrid’s hybrid resolver.)
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 test -p markets --test gas_snap -- --nocapture
Result: 11 passed; 0 failed
[gas_snap:v7] initialize cpu=60380 mem=22763
[gas_snap:v7] create_market cpu=120018 mem=49789
[gas_snap:v7] vote cpu=171976 mem=78263
[gas_snap:v7] get_market cpu=68760 mem=37468
[gas_snap:v7] get_stake cpu=49151 mem=27097
[gas_snap:v7] resolve_market cpu=122722 mem=50246
[gas_snap:v7] claim_winnings cpu=140396 mem=61671
[gas_snap:v7] gas_snap_version cpu=15863 mem=5755
[gas_snap:v7] vote_invalid_stake cpu=55028 mem=21329
[gas_snap:v7] create_market_invalid_outcomes cpu=56789 mem=20465
Manual Testing Steps
Checked out task/markets-gas-v7
Ran cargo test -p markets --test gas_snap -- --nocapture
Confirmed all entrypoints print v7 snapshot lines and stay under the documented ceilings
Spot-checked edge paths (zero stake, single outcome) reject cheaply
Documentation
Documentation Updates
README updated
Code comments added/updated
API documentation updated
Examples updated
Deployment instructions updated
Contributing guidelines updated
Architecture documentation updated
(Added contracts/markets/README.md and a Markets gas snapshot section in docs/gas/GAS_BENCHMARKING.md.)
Breaking Changes
Breaking Changes:
None. This adds a new workspace package; existing contracts are unchanged.
Migration Guide:
N/A
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: Snapshot suite records CPU/mem per entrypoint; no production hot-path regression intended
Storage Impact: New markets harness uses instance + persistent keys for market/stake/vote data only within this package
Computational Complexity: Lifecycle ops are O(outcomes) for outcome checks; outcomes capped at 8
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: Testnet first (when/if this harness is deployed separately)
Contract Address: N/A for this PR (test/harness focused)
Migration Required: No
Special Instructions: Treat markets as the gas baseline harness; hybrid production logic remains in predictify-hybrid
Integration Points
Frontend integration considered
API changes documented
Backward compatibility maintained
Third-party integrations updated
Impact Assessment
User Impact
End Users: No direct UX change
Developers: Can run a fast, focused gas baseline for market entrypoints
Admins: No operational change required
Business Impact
Revenue: None
User Experience: Indirect — helps catch cost regressions before they hit users
Technical Debt: Slightly reduced around missing markets gas baselines; hybrid compile issues remain a separate track
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
Additional Resources
Design Document:
Technical Spec: contracts/markets/README.md, docs/gas/GAS_BENCHMARKING.md
Related Discussion: #919
External Documentation:
💬 Notes for Reviewers
Please pay special attention to:
Questions for reviewers:
Thank you for your contribution to Predictify! 🚀