Skip to content

Add events.rs replay protection nonce in EventEmitter to dedup retried emissions #674

Description

@greatest0fallt1me

Description

Cross-contract retries or batch fallbacks can cause EventEmitter to emit the same logical event twice. Add a monotonic per-(emitter, topic) nonce so consumers can dedupe at-most-once even if upstream retries fire repeatedly.

Requirements and Context

  • Nonce stored under DataKey::EventNonce(topic)
  • Embedded in the event payload as nonce: u64
  • Reset only on contract upgrade (documented)
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feature/event-emitter-replay-nonce
  2. Implement changes
    • contracts/predictify-hybrid/src/events.rs
    • New test file under tests/
  3. Test and commit
    • cargo test -p predictify-hybrid event_replay_nonce
    • Cover edge cases
    • Include test output and notes in the PR

Example commit message

feat: add per-topic replay nonce to EventEmitter

Acceptance Criteria

  • Two consecutive emissions on the same topic increment nonce monotonically
  • Topic isolation: nonce of topic A does not affect topic B
  • Documented behaviour on upgrade

Guidelines

  • Clear documentation and inline comments
  • Real Soroban SDK idioms in any new helper code
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions