feat: event emission audit for material state changes (#426)#483
Closed
jabir-dev788 wants to merge 1 commit intoPredictify-org:masterfrom
Closed
feat: event emission audit for material state changes (#426)#483jabir-dev788 wants to merge 1 commit intoPredictify-org:masterfrom
jabir-dev788 wants to merge 1 commit intoPredictify-org:masterfrom
Conversation
- Fix store_event to publish to Soroban event stream - Add bet resolution and cancellation emit helpers - Fix resolve_market_bets and resolve_dispute to emit events - Add event_management_tests.rs regression tests - Update SECURITY_TESTING_GUIDE.md and docs
|
@jabir-dev788 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! 🚀 |
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
Please select the type of change this PR introduces:
Related Issues
Closes #426
Fixes #426
Priority Level
📝 Detailed Description
What does this PR do?
This PR completes the Event Emission Audit for the Predictify Hybrid smart contracts to ensure all financially material state changes emit indexer-friendly events. Specifically, it:
store_eventinevents.rsto publish directly to the Soroban event stream (env.events().publish) along with persistent storage.emit_bet_resolved), bet cancellation (emit_bet_cancelled), and market cancellation (emit_market_cancelled).resolve_market_betsinbets.rsto emit per-bet status events (removing the old implicit skip).disputes.rs(emit_dispute_resolved) to ensure dispute finalization is indexable.event_management_tests.rswith 9 new regression tests to verify that every material transition publishes an event.SECURITY_TESTING_GUIDE.mdcontaining the threat model, invariant proofs, and full event tables, and updates the mainREADME.md.Why is this change needed?
Prior to this change, key state transitions (like bet resolutions, dispute finalization, and market cancellations) were only written to persistent contract storage. Off-chain indexers (like Horizon), analytics tools, and downstream DApps cannot effectively listen to state changes purely through storage modifications. This PR ensures a robust, auditable event stream is emitted for every financially material action.
How was this tested?
Tested by writing 9 new property/regression tests in
event_management_tests.rs. Each test simulates a full contract action (e.g.,place_bet,resolve_market_manual,dispute_market,claim_winnings) and asserts thatenv.events().all()is not empty and captures the correct state transition event.Alternative Solutions Considered
Instead of fundamentally changing
store_eventto dual-write to the Soroban event stream, we considered writing a separatepublish_eventutility. However, updatingstore_eventnatively ensures all existing 15+ event-emitting call sites immediately become indexer-visible without requiring invasive caller-side refactoring.🏗️ Smart Contract Specific
Contract Changes
Please check all that apply:
Oracle Integration
Market Resolution Logic
Security Considerations
🧪 Testing
Test Coverage
Test Results