Skip to content

Event-filter analysis tool + 15-term v2-spec getEvents filter corpus#749

Closed
chowbao wants to merge 3 commits into
stellar:rpc-hackfrom
chowbao:chowbao/event-filter-15term-corpus
Closed

Event-filter analysis tool + 15-term v2-spec getEvents filter corpus#749
chowbao wants to merge 3 commits into
stellar:rpc-hackfrom
chowbao:chowbao/event-filter-15term-corpus

Conversation

@chowbao
Copy link
Copy Markdown
Contributor

@chowbao chowbao commented May 21, 2026

Summary

  • Adds cmd/stellar-rpc/scripts/event-filter-analysis: a one-shot scanner over a cold ledger pack that derives a v2-spec getEvents filter sized to a 15-unique-term budget (3 contractIds + 4 topic positions × 3 values per position, per the proposal in stellar discussion #1872).
  • When a topic position has fewer than 3 distinct real values across the picked contracts, the picker spends the remaining budget on additional contractIds instead of padding with synthetic/empty slots — keeps every term real and observable.
  • Ships the corpus output for chunk 5999 (ledgers 59,990,002–60,000,001, 9.9M events): bench-out/filter-15terms-5999.json (v2 layout, single filter) and bench-out/filter-15terms-5999-v1.json (cartesian-product expansion to 216 v1-style per-tuple filters, same 15-term universe).

What the 15 terms exercise

Slot Count Description
contractIds 4 native XLM SAC (6.29M events) + 3 other SAC-style contracts
topic[0] 2 Symbol(transfer) (3M hits) + Symbol(approve)
topic[1] 3 3 hot "from" addresses (~231k transfers each)
topic[2] 3 3 hot "to" addresses (~37–49k transfers each)
topic[3] 3 asset id Bytes: native, USDC, VLR

Per-query bitmap work: union 4 contract bitmaps + union 2/3/3/3 topic bitmaps at the 4 positions, then AND all 5 unions — the heaviest real shape that fits in the proposed v2 caps.

Test plan

  • Run go build ./cmd/stellar-rpc/scripts/event-filter-analysis — clean on rpc-hack base
  • Re-run scanner on a different pack: ./event-filter-analysis -pack <path> -out /tmp/fc.json -filter15-out /tmp/f15.json and confirm unique_terms == 15
  • Replay the v2 filter against a working getEvents endpoint and verify the result set is non-empty

🤖 Generated with Claude Code

Adds cmd/stellar-rpc/scripts/event-filter-analysis: scans a cold ledger
pack, counts per-contract topic-prefix and per-position topic-value
distributions over events with 4 topics, and emits a v2-spec getEvents
filter sized to a 15-unique-term budget (3 contractIds + 4 positions × 3
values per position). When a topic position has fewer than 3 distinct
real values across the picked contracts, the picker grows the contractId
set to spend the remaining term budget on additional contracts rather
than padding with empty/synthetic values.

Output for chunk 5999 (ledgers 59,990,002–60,000,001, 9.9M events) is
checked in at bench-out/filter-15terms-5999.json (v2 layout) and
bench-out/filter-15terms-5999-v1.json (cartesian-product expansion into
v1 per-tuple filters, 216 entries, same 15-term universe).

The resulting filter exercises 4 contractIds + [2,3,3,3] topic values
across positions — 5-way bitmap union/AND per query — and targets the
hottest real Stellar Asset Contract activity (transfer/approve verbs,
hot wallet transfer pairs, native + USDC + VLR asset identifiers).
@chowbao chowbao force-pushed the chowbao/event-filter-15term-corpus branch from 5c87362 to 0a50b00 Compare May 21, 2026 18:49
Simon Chow added 2 commits May 21, 2026 19:14
700 ready-to-fire JSON-RPC envelopes sampled from the 216-entry v1
filter pool, stratified across K (filters per request) ∈ {1, 2, 3, 5,
8, 12, 15} with 100 requests per bucket. Filters are drawn without
replacement; all use the chunk-5999 ledger range (59,990,002–60,000,001,
the v2-proposal-max 10K-ledger window) and pagination.limit=100.

Sampling is deterministic (seed 20260521) so repeated bench runs hit
the same workload. Sidecar -meta.json records the seed, bucket plan,
and pool size for the bench harness to read back.

Layout:
- bench-out/filter-15terms-5999-requests.jsonl       — JSONL, 700 requests
- bench-out/filter-15terms-5999-requests-meta.json   — generation metadata
@tamirms
Copy link
Copy Markdown
Contributor

tamirms commented May 22, 2026

these changes were integrated into #751 so now this can be closed

@tamirms tamirms closed this May 22, 2026
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.

2 participants