Repository navigation
feat(stellar): emit the v2 scheme id from announcement builders - #259
Conversation
|
@aratass 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! 🚀 |
truthixify
left a comment
There was a problem hiding this comment.
The v2 scheme activation preserves v1 scanning compatibility; 67 conformance, batch, and transaction builder tests pass. Approved.
The deployed v2 announcer accepts only scheme_id 2, but the builders sent 1. ACTIVE_SCHEME_ID (= SCHEME_ID_V2) is now the single source of truth for buildStealthAnnouncement(), buildPathStealthPayment(), buildStellarSwapAndStealth(), buildAnnouncementData() and encodeAnnouncementData(). The legacy shared-secret scanner accepts v2 announcements like the other scanners, and SCHEME_ID is deprecated. A conformance test checks every builder against the announcer ABI vendored from wraith-protocol/contracts. Refs wraith-protocol#234
c7a59ae to
b8ddc9b
Compare
truthixify
left a comment
There was a problem hiding this comment.
The builder changes correctly emit scheme 2, but scanAnnouncementsLegacySharedSecretTag now claims to accept scheme 2 while still comparing metadata with computeViewTag(sharedSecret), the legacy v1 algorithm. V2 announcements use computeAnnouncementViewTag(ephemeralPubKey, viewingPubKey), so this exported scanner silently misses roughly 255/256 valid v2 announcements. Keep the legacy scanner v1-only or branch to the v2 tag algorithm, and add a non-vacuous v2 regression test that requires one generated v2 announcement to match.
scanAnnouncementsLegacySharedSecretTag() compares the metadata tag with computeViewTag(sharedSecret), the v1 algorithm. Scheme 2 announcements carry the public tag from computeAnnouncementViewTag(), so accepting them there missed about 255 of 256 valid v2 announcements. It reads scheme 1 only again, as before this branch, and says so in its docs. Tests: a v2 announcement from buildAnnouncementData() must match in scanAnnouncements() and scanAnnouncementsStream(), and the legacy scanner must not claim a scheme 2 announcement, including one that carries the legacy tag. CHANGELOG, MIGRATING and the ACTIVE_SCHEME_ID docs say which scanners read which schemes.
|
@truthixify Thanks, fixed in de8c1e8.
Locally: format:check, build, 1,576 tests plus the Svelte suite, test:types, size-limit and api:check pass. The API reports are unchanged. |
truthixify
left a comment
There was a problem hiding this comment.
The legacy shared-secret scanner is now explicitly v1-only, while the primary and streaming scanners retain scheme-2 support with regression coverage. Local verification passed 91 focused Stellar tests, the package build, and public type tests.
Closes #234.
Summary
#231 found that
buildStealthAnnouncement()sends scheme1, while the deployed v2 announcer assertsscheme_id == 2(STELLAR_V2_SCHEME_IDin wraith-protocol/contracts). The same default was inbuildPathStealthPayment(),buildStellarSwapAndStealth(),buildAnnouncementData()andencodeAnnouncementData().ACTIVE_SCHEME_ID(= SCHEME_ID_V2) inconstants.ts, exported from@wraith-protocol/sdk/chains/stellar. All five builders read it.test/chains/stellar/fixtures/stealth-announcer-v2.jsonvendorsstellar/abi/stealth_announcer.jsonfrom contracts at66273f2, plus the two rulesannounce()enforces in code: scheme id2, and the view tag inmetadata[0].announcer-conformance.test.tsdecodes theannouncecall each builder produces and checks the function name, argument count and Soroban types against the ABI, then the scheme id, stealth address, 32-byte ephemeral key and view tag. WithACTIVE_SCHEME_IDset back to1, 6 of its 10 tests fail.MIGRATING.md, the CHANGELOG andEVENT_FETCHING.md.Compatibility
announce()has no check), so the same calls keep working against a v1 deployment. Its events keep the 3-topic layout, now with scheme2.fetchAnnouncements()already reads v1 events with("announce", *, *), and the parser picks v1 or v2 by topic count, so historical v1 events are never reinterpreted as v2, as the contract's migration note asks.scanAnnouncements()and the stream and pool scanners already accept1and2.scanAnnouncementsLegacySharedSecretTag()accepted only1; it now accepts both, so conformance invariant 23 (it matchesscanAnnouncements()) stays true for new announcements.SCHEME_IDkeeps its value1and is marked@deprecated, pointing toSCHEME_ID_V1andACTIVE_SCHEME_ID. No export is removed.Semver
Behaviour change for code that compares a built announcement's scheme to
1, so the entry is under Changed in Upcoming: 2.0.0. Otherwise additive (ACTIVE_SCHEME_ID).Checks run locally
pnpm format:check,pnpm build,pnpm test(1,551 SDK tests and the Svelte package),pnpm test:types,pnpm test:exports,pnpm size(Stellar ESM 30.82 kB of 31 kB),pnpm api:check(report updated inetc/sdk-stellar.api.md) andpnpm pack:check.