Skip to content

fix(relay): dedupe and cap a deletion request's e ids (#1090) - #1164

Merged
cameri merged 1 commit into
rewrite/mainfrom
fix/1090-cap-delete-e-ids
Nov 17, 2026
Merged

cameri merged 1 commit into
rewrite/mainfrom
fix/1090-cap-delete-e-ids

Conversation

@chappie-daemon

Copy link
Copy Markdown
Collaborator

Opened on @AgrimTawani's behalf so the change is not re-authored: the commit is his, cherry-picked with -x from AgrimTawani:fix/1090-cap-delete-e-ids.

Closes #1090.

What it does

A kind-5 request's e arm handed every parseable id to delete_by_pubkey_and_ids, unbounded and undeduplicated — ~7 180 ids at the shipped maxPayloadSize, repeats included. The ids now go through event_ids(), which keeps first-seen order, collapses repeats and stops at the (cap + 1)th distinct id, and a request naming more than MAX_EVENT_IDS_PER_REQUEST (100) is refused with OK false before anything is deleted or stored — the same shape as the address arm's refusal, because a partial delete answered true would claim deletions that did not happen.

The cap is derived from its own measurement rather than copied from MAX_ADDRESSES_PER_REQUEST: 100 hits cost 3.95 ms in one LMDB write transaction (~0.008 ms per id at the margin, against ~0.010 ms per address), so kind-5's 30/min per free key stays at ~120 ms of single-writer time per minute, the same 0.2 % the address cap allows. docs/rewrite/nip-parity.md §9 item 12 records the divergence from the TypeScript target.

Verified before opening

  • The cherry-pick applied cleanly onto rewrite/main (f971d6f3) with no conflicts; 4 files — the strategy, its tests, the parity note, one changeset.
  • No workflow, package.json, lockfile or script is touched. No hidden or bidirectional characters in the added lines.
  • Tests: 134 added lines in tests/strategies.rs covering the cap, cap + 1 and repeats, per the commit.

A kind-5 request's `e` arm handed every parseable id to
`delete_by_pubkey_and_ids` unbounded and undeduplicated: ~7 180 ids at
the shipped `maxPayloadSize`, repeats included. Collect them through
`event_ids()`, which keeps first-seen order, collapses repeats and stops
at the (cap + 1)th distinct id, and refuse a request naming more than
`MAX_EVENT_IDS_PER_REQUEST` (100) with `OK false` before anything is
deleted or stored, the same shape as the address arm's refusal.

The number is derived from a measured per-id cost (LMDB, release: 3.95 ms
per 100 hits, ~0.008 ms per id at the margin, against ~0.010 ms per
address), so 100 ids cost what 100 addresses cost: ~120 ms of writer time
per minute per free key. nip-parity.md §9 item 12 records the cap as a
deliberate divergence from the TypeScript target.

Closes #1090

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3dfe4e6)
@changeset-bot

changeset-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9c6b058

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 279a6807-143a-43a8-bebc-ac5336f8a837

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chappie-daemon chappie-daemon changed the title relay: dedupe and cap a deletion request's e ids (#1090) fix(relay): dedupe and cap a deletion request's e ids (#1090) Nov 17, 2026
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Kind-5 requests now remove repeated e ids and reject requests naming more than 100 distinct valid ids.

  • Kind-5 deletion requests accept up to 100 unique event ids.

No actionable issues were found. Tests were inspected, not run.

Reviews (1) · Last reviewed commit: "fix(relay): dedupe and cap a deletion re..." · Reviewed by Greptile

@cameri
cameri merged commit 239bee0 into rewrite/main Nov 17, 2026
19 of 20 checks passed
@cameri
cameri deleted the fix/1090-cap-delete-e-ids branch November 17, 2026 20:37
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.

3 participants