Add runtime event schema validation and cross checks for Issue 312 - #324
Merged
MaryammAli merged 2 commits intoJul 21, 2026
Merged
Conversation
Contributor
|
@dotmantissa |
Contributor
Author
|
@MaryammAli |
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.
Add runtime event schema validation and cross-checks for emitted events (#312)
Closes #312
Summary
I have implemented full runtime schema validation for
EVENT_SCHEMASand added cross-checking for events emitted by theFoldercontract against theEVENT_SCHEMAScatalog.Implemented Fixes
Schema Catalog Enforcement (
events.rs):validate_event_schemas()andvalidate_event_schema_entry()to enforce schema uniqueness (names and numericevent_type_id), topic namespace rules, strictly sorted payload keys, and mandatory deterministic replay fields (EVENT_REPLAY_FIELDS).validate_emitted_event()to cross-validate emitted Soroban contract event topics and payload keys againstEVENT_SCHEMAS.Event Payload Alignment (
events.rs):event_type_idandledger_sequencefields on emitted event structs (DisputeAutoResolvedEvent,DisputeExpiryActionSetEvent,DisputeTimeoutConfigSetEvent,FeeCollectorRotatedEvent,PerAssetFeeSetEvent,HookRegisteredEvent,HookUnregisteredEvent,UpgradeWindowSetEvent,PauseFlagsChangedEvent,EscrowCleanupEvent).EVENT_SCHEMASentries forEscrowWithdrawn,PerAssetFeeSet, andEscrowCleanupso defined payload keys match emitted payload data.Contract Entry Point (
lib.rs):validate_event_schemas()read-only entry point toRustAcademyContractfor indexer and deployment integrity checks.Tests & Documentation (
events_test.rs,metadata_test.rs,test.rs,README.md):events_test.rsto test catalog integrity, negative validation rules, and cross-checking emitted contract events across contract state transitions.metadata_test.rsandtest.rsforvalidate_event_schemas()coverage.validate_event_schemas()inapp/contract/README.md.Verification
cargo build --all-targetscompleted cleanly.cargo testpassed with 324 passing tests.cargo clippy --all-targets --all-features -- -D warningspassed without warnings.