feat: optional zstd compression for event payloads at ingest#173
Draft
imp0stor wants to merge 3 commits intohoytech:masterfrom
Draft
feat: optional zstd compression for event payloads at ingest#173imp0stor wants to merge 3 commits intohoytech:masterfrom
imp0stor wants to merge 3 commits intohoytech:masterfrom
Conversation
added 3 commits
February 28, 2026 18:29
When enabled, strfry keeps ALL versions of replaceable events (kinds 0, 3, 10000-19999, 30000-39999) instead of deleting old versions when newer ones arrive. This is useful for: - Audit trails - Historical analysis - Compliance requirements Enable with env var: STRFRY_RETAIN_REPLACED_EVENTS=true
The previous implementation could cause index corruption by storing older incoming events. This fix: 1. When NEWER event arrives: keep old event in storage (audit) but still update replace index to point to new event. NIP-01 queries return only latest; old events queryable by ID. 2. When OLDER event arrives: reject it (even in audit mode) to prevent index corruption. Use external JSONL audit log to capture these. This preserves NIP-01 compliance while enabling audit trail for events that were superseded by newer versions.
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
This PR adds an optional ingest-time event-payload compression path that keeps default behavior unchanged.
0x02for zstd-compressed payloads without dictionary metadata.0x00uncompressed payload0x01zstd + dictionary id0x02indecodeEventPayload(...).writeEvents(...)gated by env var:STRFRY_EVENT_PAYLOAD_ZSTD_LEVEL=1..220=> current behavior (no ingest compression)golpe.yamland operator note instrfry.conf.Why
For installations prioritizing storage and bandwidth efficiency, immutable signed event JSON is a strong candidate for compress-once semantics. This provides a low-risk, opt-in path while preserving current defaults.
Compatibility
0x00,0x01) remain readable.0x02records decode transparently for reads.Notes
I could not run a full local build here because this environment is missing strfry's
golpebuild include (golpe/rules.mk). The change is intentionally scoped to payload encode/decode logic to simplify review and testing.