Skip to content

feat: add deterministic event identity and cross-chunk deduplication - #230

Open
code3ks wants to merge 14 commits into
wraith-protocol:developfrom
code3ks:feat/deterministic-event-identity
Open

code3ks wants to merge 14 commits into
wraith-protocol:developfrom
code3ks:feat/deterministic-event-identity

Conversation

@code3ks

@code3ks code3ks commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Issue

Overview

This PR implements deterministic event identity and cross-chunk deduplication for Stellar announcement scanning, addressing the issue where parallel scans and different providers could produce duplicate events.

Changes Made

Core Implementation

  • Added EventIdentity interface: SHA-256-based deterministic event identities
  • Added computeEventIdentity() function: Computes stable identity from chain, transaction, ledger, contract, and topic data
  • Added seenEventIds option: Enables cross-chunk deduplication by persisting state
  • Updated fetchAnnouncementsStream(): Uses deterministic event identity instead of provider-dependent IDs

Testing

  • 15 unit tests in test/chains/stellar/event-identity.test.ts
  • 7 integration tests added to test/chains/stellar/announcements.test.ts
  • All tests passing ✅

Documentation

  • Comprehensive guide in docs/event-identity-deduplication.md
  • Updated CHANGELOG.md for v2.0.0

API Changes

New Exports

export interface EventIdentity {
  id: string;
  txHash: string;
  ledger: number;
  contractId: string;
  topicsHash: string;
}

export function computeEventIdentity(event: Record<string, unknown>): EventIdentity | null;

Closes #211

- Add EventIdentity interface and computeEventIdentity() function
- Implement SHA-256-based deterministic event identity computation
- Add seenEventIds option to FetchAnnouncementsOptions
- Update fetchAnnouncementsStream() to use deterministic deduplication
- Add comprehensive test suite with 15 unit tests and 7 integration tests
- Add detailed documentation in docs/event-identity-deduplication.md
- Update CHANGELOG.md for v2.0.0

Fixes wraith-protocol#211
@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

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

These symbols were added in the develop branch (wraith-protocol#153) but weren't
re-exported from src/chains/stellar/index.ts, causing sdk-react builds
to fail when importing them.

Exports added:
- deriveStealthKeysFromSigner (function)
- StellarStealthSigner (interface)
- FreighterStealthSigner (class)
- WebAuthnPasskeyStealthSigner (class)
- FreighterLikeWallet (interface)
- WebAuthnPasskeyStealthSignerOptions (interface)
- KeyDerivationOptions (type)

Fixes merge artifact from commit 1be708b
The merge from develop added extra blank lines that don't match
the canonical format generated by scripts/compat/check.mjs
Fixes CI format check by running prettier --write on:
- CONTRIBUTING.md
- examples/react-native-stellar/polyfills.ts
- examples/stellar-chrome-extension/src/lib/types.ts
- examples/stellar-vue-receive/src/App.vue
- packages/sdk-vue/src/composables/useScanner.ts
- packages/sdk-vue/src/composables/useStealthKeys.ts
- src/chains/stellar/index.ts
- examples/stellar-nextjs-app-router/next-env.d.ts

Also updated pnpm-lock.yaml from previous dependency updates.
Updates etc/sdk.api.md and etc/sdk-stellar.api.md to reflect
the new exports added in src/chains/stellar/index.ts:
- deriveStealthKeysFromSigner
- StellarStealthSigner
- FreighterStealthSigner
- WebAuthnPasskeyStealthSigner
- KeyDerivationOptions

Also updates internal file hash references from develop branch merge.
@code3ks

code3ks commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Note that all checks pass except for the pre-existing memory issue

@truthixify

Copy link
Copy Markdown
Contributor

The identity omits the event index, so two announcements from the same transaction, contract, ledger, and topics collapse into one. Please include the stable event index, add a same-transaction collision test, and preserve the existing scan regression tests.

@truthixify

Copy link
Copy Markdown
Contributor

The event index fix is good, but this branch removes the current parallel scan path and strict RPC validation. Existing malformed-payload tests now fail. Please rebase on develop and add identity deduplication without removing those paths.

@code3ks
code3ks force-pushed the feat/deterministic-event-identity branch from 5a9ff12 to 50d6ff5 Compare September 29, 2026 06:37
@truthixify

Copy link
Copy Markdown
Contributor

The scan paths and identity fix look good. CI was rerun after a Node 20 out-of-memory failure. Also close the API code fence and move Closes #211 outside it so the Wave issue is linked.

@truthixify

Copy link
Copy Markdown
Contributor

The rerun hit the same Node 20 heap exhaustion after the identity tests passed. Please isolate the hanging or leaking test path and make the full Node 20 suite complete before merge.

@truthixify

Copy link
Copy Markdown
Contributor

CI is green because the latest commit replaced the stream deduplication tests with Set-only checks. Those tests no longer exercise fetchAnnouncementsStream or seenEventIds. Restore finite mocked-page tests for cross-page, cross-filter, parallel, and persisted deduplication.

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.

2 participants