block / block/buzz

NIP-IA archive snapshot can lose rapid same-second updates

Open
#3,848 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

## Problem

Rapid NIP-IA archive operations can emit multiple relay-signed `kind:13535` replaceable snapshots with the same second-resolution `created_at`. NIP-01 resolves same-second replaceable events by the lowest event ID, so an intermediate snapshot may remain authoritative even though every `kind:8002` delta and canonical `archived_identities` row was accepted.

Observed behavior: six rapid archive requests produced six valid archive deltas, while the latest authoritative snapshot exposed only three archived identities.

## Expected behavior

Every accepted archive or unarchive mutation should publish a snapshot that supersedes the previous snapshot deterministically, including multiple mutations within one wall-clock second.

## Proposed fix

Before signing `kind:13535`, query the existing relay-authored snapshot and assign `created_at = max(now, previous_created_at + 1)`, matching the monotonic timestamp guards already used for Buzz discovery and DM visibility snapshots.

## Regression coverage

Add a test that simulates six snapshot updates during one wall-clock second and verifies strictly increasing timestamps from `T` through `T+5`.

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.