Skip to content

Implement NIP-62 Request to Vanish support#180

Open
alltheseas wants to merge 3 commits intohoytech:masterfrom
alltheseas:nip-62-request-to-vanish
Open

Implement NIP-62 Request to Vanish support#180
alltheseas wants to merge 3 commits intohoytech:masterfrom
alltheseas:nip-62-request-to-vanish

Conversation

@alltheseas
Copy link
Contributor

@alltheseas alltheseas commented Mar 19, 2026

Summary

  • Implement NIP-62 (Request to Vanish): Two-phase approach — writer thread sets a VanishPubkey marker instantly (blocking re-storage), cron thread sweeps and deletes events in batches every 30s to avoid long write locks. Deletes all authored events up to the vanish timestamp plus kind 1059 gift wraps addressed via p-tag. Kind 62 events are preserved for bookkeeping and protected from kind 5 deletion.
  • Harden NIP-62: Add cfg().relay__nip62__enabled guard in writeEvents() so non-websocket paths (import, sync, router) respect the feature flag. Skip deletion index (tombstone) check for kind 62 events per spec: "Kind 5 deletion of a kind 62 event has no effect."
  • Add writeTest cases: 6 tests covering vanish marker blocking, cross-pubkey isolation, kind 5 protection of kind 62, max-timestamp semantics, and boundary conditions.
  • Add NIP-62 E2E websocket tests: 39 tests against a live strfry relay covering the full NIP-62 lifecycle — event submission, cron-based deletion sweep, re-broadcast prevention, relay tag validation, kind 5 protection (both orderings), deletion tombstone bypass via import path, gift wrap cleanup/blocking (ALL_RELAYS and specific serviceUrl), NIP-09 deletion event sweep, cross-pubkey isolation, timestamp boundaries, persistence across restart, NIP-11 advertisement, and feature flag behavior.

NIP-62 spec coverage

Spec requirement Level Test
Kind 62 deletes everything from .pubkey until .created_at MUST E2E: test_vanish_all_relays
Tag list MUST include at least one relay value MUST E2E: test_vanish_no_relay_tag_rejected
Relay MUST delete if its service URL is tagged MUST E2E: test_vanish_specific_relay
Relay SHOULD delete NIP-59 gift wraps p-tagged to pubkey SHOULD E2E: test_gift_wrap_deletion
Relay MUST prevent re-broadcast MUST E2E: test_vanish_all_relays, test_vanish_persists_after_restart
Relay MAY store the vanish event for bookkeeping MAY E2E: kind 62 preserved in all cron tests
Kind 5 against kind 62 has no effect MUST E2E: test_kind5_cannot_delete_kind62, test_kind5_tombstone_does_not_block_kind62
Global vanish via ["relay", "ALL_RELAYS"] MUST E2E: multiple tests
Delete everything including NIP-09 deletion events MUST E2E: test_nip09_deletion_events_swept

Test plan

  • make test-subid — unit tests pass
  • perl test/writeTest.pl — 36 tests pass (30 existing + 6 NIP-62)
  • python3 test/nip62_e2e_test.py — 39 E2E tests pass (requires pip install secp256k1 websockets)
  • Sync tests with generated test data pass

Closes #179

🤖 Generated with Claude Code

alltheseas and others added 3 commits March 19, 2026 12:26
Two-phase approach: writer thread sets a VanishPubkey marker instantly
(blocking re-storage), cron thread sweeps and deletes events in batches
every 30s to avoid long write locks. Deletes all authored events up to
the vanish timestamp plus kind 1059 gift wraps addressed via p-tag.
Kind 62 events are preserved for bookkeeping and protected from kind 5
deletion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests vanish marker blocking, cross-pubkey isolation, kind 5
protection of kind 62, max-timestamp semantics, and boundary
conditions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 tests covering the full NIP-62 Request to Vanish lifecycle over
websocket against a live strfry relay: event submission, cron-based
deletion sweep (polled), re-broadcast prevention, relay tag validation
(matching, non-matching, missing), kind 5 protection of kind 62 in
both orderings, deletion tombstone bypass via import path, gift wrap
cleanup and blocking (ALL_RELAYS and specific serviceUrl), NIP-09
deletion event sweep, cross-pubkey isolation, timestamp boundary
semantics, persistence across restart, NIP-11 advertisement, and
feature flag behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alltheseas
Copy link
Contributor Author

cc @jb55 @danieldaquino @kernelkind

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.

nip-62 request to vanish

1 participant