Skip to content

Add runtime event schema validation and cross checks for Issue 312 - #324

Merged
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
dotmantissa:fix/issue-312-event-schema-validation
Jul 21, 2026
Merged

Add runtime event schema validation and cross checks for Issue 312#324
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
dotmantissa:fix/issue-312-event-schema-validation

Conversation

@dotmantissa

Copy link
Copy Markdown
Contributor

Add runtime event schema validation and cross-checks for emitted events (#312)

Closes #312

Summary

I have implemented full runtime schema validation for EVENT_SCHEMAS and added cross-checking for events emitted by the Folder contract against the EVENT_SCHEMAS catalog.

Implemented Fixes

  1. Schema Catalog Enforcement (events.rs):

    • Added validate_event_schemas() and validate_event_schema_entry() to enforce schema uniqueness (names and numeric event_type_id), topic namespace rules, strictly sorted payload keys, and mandatory deterministic replay fields (EVENT_REPLAY_FIELDS).
    • Added validate_emitted_event() to cross-validate emitted Soroban contract event topics and payload keys against EVENT_SCHEMAS.
  2. Event Payload Alignment (events.rs):

    • Fixed missing event_type_id and ledger_sequence fields on emitted event structs (DisputeAutoResolvedEvent, DisputeExpiryActionSetEvent, DisputeTimeoutConfigSetEvent, FeeCollectorRotatedEvent, PerAssetFeeSetEvent, HookRegisteredEvent, HookUnregisteredEvent, UpgradeWindowSetEvent, PauseFlagsChangedEvent, EscrowCleanupEvent).
    • Updated EVENT_SCHEMAS entries for EscrowWithdrawn, PerAssetFeeSet, and EscrowCleanup so defined payload keys match emitted payload data.
  3. Contract Entry Point (lib.rs):

    • Added validate_event_schemas() read-only entry point to RustAcademyContract for indexer and deployment integrity checks.
  4. Tests & Documentation (events_test.rs, metadata_test.rs, test.rs, README.md):

    • Created events_test.rs to test catalog integrity, negative validation rules, and cross-checking emitted contract events across contract state transitions.
    • Updated metadata_test.rs and test.rs for validate_event_schemas() coverage.
    • Documented event schema enforcement and validate_event_schemas() in app/contract/README.md.

Verification

  • cargo build --all-targets completed cleanly.
  • cargo test passed with 324 passing tests.
  • cargo clippy --all-targets --all-features -- -D warnings passed without warnings.

@MaryammAli

Copy link
Copy Markdown
Contributor

@dotmantissa
run cargo build and cargo test to fix errors please

@dotmantissa

Copy link
Copy Markdown
Contributor Author

@MaryammAli
Fixed, kindly approve workflow.

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
a job welldone

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
a job welldone

@MaryammAli
MaryammAli merged commit 31ee177 into BlockDash-Studios:main Jul 21, 2026
2 checks 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.

event schema compatibility is only documented, not enforced in code or tests

2 participants