feat: vanish optimization - #446
Conversation
cameri
commented
Apr 10, 2026
Are we missing the code refactor to use the new flag on the users table? |
There was a problem hiding this comment.
Pull request overview
Adds a database-level optimization for NIP-62 “request-to-vanish” checks by introducing a persisted users.is_vanished flag and backfilling it from existing kind-62 events, reducing reliance on repeated events table lookups.
Changes:
- Add
is_vanishedboolean column to theuserstable (defaultfalse, not nullable). - Backfill
is_vanished = truefor users with non-deleted kind-62 events and insert missingusersrows for pubkeys that have active kind-62 events.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
vikashsiwach
commented
Apr 11, 2026
Hey @cameri ! I made migration reversible (removed user inserts from events) and optimized backfill query using EXISTS. Also missing users issue is solved by adding lazy hydration for |
cameri
commented
Apr 18, 2026
@vikashsiwach Please address conflicts that have surfaced |
5b93ceb to
5436848CompareResolve IUserRepository conflict by retaining both vanish-state methods and new admit-user API, and keep branch passing build/lint/unit tests. Made-with: Cursor
Resolve worker factory merge conflict by keeping vanish-aware UserRepository wiring and upstream NIP-05 repository wiring so vanish and gift-wrap flows remain compatible. Made-with: Cursor
This PR introduces a new
is_vanishedcolumn on theuserstable to support a more efficient way of handling NIP-62 (request-to-vanish) checks.Related Issue
Currently NIP-62 query the
eventstable for active kind-62 records on every check.Fixes issue #436
Motivation and Context
The relay have to check every pubkey for an active request-to-vanish by querying events.As events volume grows ,this becomes less efficient. So we introduced a
is_vanishedflag in users table for faster checks.How Has This Been Tested?
npm run build:checknpm run test:unit(504 passing)Types of changes
Checklist: