Skip to content

fix(#478): replace emitter self-declaration with caller provenance va… - #493

Merged
Oluwaseyi89 merged 1 commit into
CarbonScribe:mainfrom
chinecherem58:fix/478-audit-trail-caller-provenance
Aug 3, 2026
Merged

fix(#478): replace emitter self-declaration with caller provenance va…#493
Oluwaseyi89 merged 1 commit into
CarbonScribe:mainfrom
chinecherem58:fix/478-audit-trail-caller-provenance

Conversation

@chinecherem58

Copy link
Copy Markdown
Contributor

…lidation

  • Add storage.rs module: extracted DataKey enum from lib.rs into its own module with comprehensive documentation for each storage key.

  • Add events.rs module: created PruningEvent (moved from lib.rs) and new ProvenanceValidationFailed event that captures the actual caller address, attempted event type, and timestamp when an unauthorized recording attempt is detected.

  • Refactor lib.rs:

    • Renamed record_event_auth() → record_event() to reflect the new model
    • record_event() now accepts 'caller: Address' instead of the old 'emitter'
    • Authorization order: allowlist check first (emits ProvenanceValidationFailed and panics on failure), then caller.require_auth() to enforce host-level identity verification via the Soroban auth framework
    • emitting_contract is now always the auth-verified caller — the host guarantees no contract can satisfy require_auth() for a foreign address
    • Replaced inline PruningEvent emission with emit_pruning_event() helper
    • Imports DataKey from storage module, events from events module
  • Update test.rs:

    • All existing tests updated to use new record_event(caller, ...) signature
    • 5 new provenance/spoofing-prevention tests added:
      • test_emitting_contract_reflects_actual_caller
      • test_spoofing_unauthorized_address_is_rejected
      • test_revoked_emitter_cannot_record_events
      • test_two_authorized_callers_produce_independent_records
      • test_cannot_record_events_using_another_contracts_identity

All 13 tests pass (8 existing + 5 new).
closes #478

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@chinecherem58 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

@Oluwaseyi89

Copy link
Copy Markdown
Contributor

@chinecherem58 please, fix the errors causing the CI failure.

@chinecherem58

Copy link
Copy Markdown
Contributor Author

@Oluwaseyi89 please boss ejoor

…rovenance validation

- Add storage.rs module: extracted DataKey enum from lib.rs into its own
  module with comprehensive documentation for each storage key.

- Add events.rs module: created PruningEvent (moved from lib.rs) and new
  ProvenanceValidationFailed event that captures the actual caller address,
  attempted event type, and timestamp when an unauthorized recording attempt
  is detected.

- Refactor lib.rs:
  - Renamed record_event_auth() → record_event() to reflect the new model
  - record_event() now accepts 'caller: Address' instead of the old 'emitter'
  - Authorization order: allowlist check first (emits ProvenanceValidationFailed
    and panics on failure), then caller.require_auth() to enforce host-level
    identity verification via the Soroban auth framework
  - emitting_contract is now always the auth-verified caller — the host
    guarantees no contract can satisfy require_auth() for a foreign address
  - Replaced inline PruningEvent emission with emit_pruning_event() helper
  - Imports DataKey from storage module, events from events module

- Update test.rs:
  - All existing tests updated to use new record_event(caller, ...) signature
  - 5 new provenance/spoofing-prevention tests added:
    * test_emitting_contract_reflects_actual_caller
    * test_spoofing_unauthorized_address_is_rejected
    * test_revoked_emitter_cannot_record_events
    * test_two_authorized_callers_produce_independent_records
    * test_cannot_record_events_using_another_contracts_identity

All 13 tests pass (8 existing + 5 new).
@chinecherem58
chinecherem58 force-pushed the fix/478-audit-trail-caller-provenance branch from 38d113a to 182b15c Compare August 3, 2026 09:08
@chinecherem58

Copy link
Copy Markdown
Contributor Author

@Oluwaseyi89 gm gm boss im done fixing all the errors causing the ci check to fail
looking forward to you merging my pr and also working with you in the next wave
thank you

@Oluwaseyi89
Oluwaseyi89 merged commit 08f513f into CarbonScribe:main Aug 3, 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.

Replace emitter self-declaration model with stronger caller provenance validation

2 participants