fix(transport)(sphere-sdk#559): opt out HMCP + ACP sendDM self-wraps#51
Merged
Merged
Conversation
F3 from sphere-sdk#559. Wires `{ selfWrap: false }` into the two
short-lived RPC paths the F1 soak identified as the biggest
contributors to §3/§4 relay-index pollution:
- src/transport/dm-transport.ts (HMCP — CLI → host manager)
- src/trader/acp-transport.ts (ACP — CLI → trader tenant)
Both are short-lived RPC: the `sphere host …` / `sphere trader …`
process publishes a single request and exits as soon as the reply
correlates. The default NIP-17 self-wrap publishes a SECOND
gift-wrap targeting the SENDER's own pubkey so a returning client
can replay outbound history — useless work for one-shot CLI, and
exactly the noise the F1 soak measured at ~7 new events per spawn
process in §3 of `manual-test-trader-roundtrip.sh`.
Both files also widen their local `SphereComms.sendDM` interface
to forward an optional `SendMessageOptions` to the SDK call.
`sphere message send` in src/legacy/legacy-cli.ts:3961 is NOT
touched — that command is user-initiated and the user likely
wants their sent DM in their own outbound history. Default
behavior preserved.
## Validation
- npx tsc --noEmit → no new errors (3 pre-existing in legacy-cli
unrelated to F3, confirmed by stashing F3
and re-running)
- npx vitest run → 187/187 pass
## Related
- sphere-sdk#555 — original M8 mitigation framing
- sphere-sdk#559 — fresh-wallet backlog + F1 soak verdict
- sphere-sdk PR #558 — selfWrap: false SDK API (merged into uxf)
- sphere-sdk PR #582 — F1 instrumentation (open, awaiting follow-up soak)
- sphere-sdk PR #614 — re-export SendMessageOptions from index.ts (merged)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
F3 from the #559 verdict comment. Wires
{ selfWrap: false }(new SDK API from sphere-sdk PR #558) into the two short-lived RPC paths the F1 soak identified as the biggest contributors to §3/§4 relay-index pollution:src/transport/dm-transport.ts(HMCP — CLI → host manager)src/trader/acp-transport.ts(ACP — CLI → trader tenant)src/legacy/legacy-cli.ts:3961(sphere message send) is not touched — that command is user-initiated and the user likely wants their sent DM in their own outbound history. Default behavior preserved.Why
Both files implement short-lived RPC: the
sphere host …/sphere trader …process publishes a single request, awaits the correlated reply, and exits. The default NIP-17 self-wrap publishes a SECOND gift-wrap targeting the SENDER's own pubkey so a returning client can replay outbound history — useless work for one-shot CLI, and exactly the noise the F1 soak measured at ~7 new events per spawn process in §3 ofmanual-test-trader-roundtrip.sh. Cutting the self-wrap halves the per-process publish count and removes the corresponding entries from the relay's#p:controllerindex for the next short-lived CLI process to pull down on subscribe.The fix is a strict subset of what sphere-sdk PR #558 was designed for — see #558's own description: "For short-lived senders (one-shot CLI RPC like
sphere trader portfolio) the process exits before it could ever read its own self-wrap, making the second publish pure relay-index pollution."What changed
Both
dm-transport.tsandacp-transport.ts:SphereComms.sendDMinterface to forward an optionalSendMessageOptionsto the SDK call.{ selfWrap: false }at the only outgoingsendDMcall site.Net diff: 2 files changed, 24 insertions(+), 6 deletions(-).
Test plan
npx tsc --noEmit→ no new errors (3 pre-existing errors inlegacy-cli.tsconfirmed by stashing F3 and re-running)npx vitest run --reporter=basic→ 187/187 pass (incl. 14 dm-transport, 19 spawn, 44 trader-commands)Related
selfWrap: falseSDK API (merged into uxf)SendMessageOptionsfrom index.ts (merged, prereq for this PR's typecheck)