telemetry: add timestamp index for latency sample gap correction#3237
Open
telemetry: add timestamp index for latency sample gap correction#3237
Conversation
eea0f20 to
4b0384c
Compare
Contributor
|
In both submitters, when |
Contributor
|
will approve, not sure if nik or karl want to take a looks since they were involved in the initial convo in #877 |
martinsander00
approved these changes
Mar 23, 2026
cbc657b to
32569cd
Compare
karl-dz
reviewed
Mar 30, 2026
karl-dz
reviewed
Mar 30, 2026
karl-dz
reviewed
Mar 30, 2026
karl-dz
reviewed
Mar 30, 2026
karl-dz
reviewed
Mar 30, 2026
cc8e5f1 to
1c6f316
Compare
karl-dz
approved these changes
Apr 10, 2026
1c6f316 to
3a930d3
Compare
Add a TimestampIndex account that tracks sample index → timestamp mappings as a companion to device and internet latency sample accounts. - New onchain account type (AccountTypeTimestampIndex = 5) with PDA derived from samples account PK - InitializeTimestampIndex and WriteLatencySamples instructions updated to optionally append index entries - Read-only deserialization in Go, Python, and TypeScript SDKs with fixture generation and cross-language compat tests - Timestamp reconstruction helpers using binary search and single-pass for efficient sample timestamp lookups - Timestamp index full condition is non-fatal in write path
3a930d3 to
7f2746d
Compare
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 of Changes
RFC:
rfcs/rfc18-telemetry-write-timestamp-index.mdCloses #877
Diff Breakdown
~70% core logic, ~17% tests, ~12% RFC/docs. Note: this PR exceeds the ~500-line guideline due to cross-language SDK parity (Go + Python + TypeScript) and the onchain program changes — splitting further would leave incomplete functionality.
Key files (click to expand)
smartcontract/programs/doublezero-telemetry/src/state/timestamp_index.rs— New TimestampIndex account type: header struct, serialization, and 10K-entry ring buffersmartcontract/programs/doublezero-telemetry/src/processors/telemetry/initialize_timestamp_index.rs— New instruction: creates the companion PDA derived from the samples accountsmartcontract/programs/doublezero-telemetry/src/processors/telemetry/write_timestamp_index.rs— Appends a (sample_index, timestamp) entry on each write batchsmartcontract/programs/doublezero-telemetry/src/processors/telemetry/write_device_latency_samples.rs— Optionally accepts 4th account (timestamp index) for backward compatsdk/telemetry/go/state.go— Go read-only SDK: DeserializeTimestampIndex + ReconstructTimestamp(s)sdk/telemetry/python/telemetry/state.py— Python read-only SDK: TimestampIndex.from_bytes + reconstruct helperssdk/telemetry/typescript/telemetry/state.ts— TypeScript read-only SDK: deserializeTimestampIndex + reconstruct helperscontrolplane/telemetry/internal/telemetry/submitter.go— Device telemetry submitter: derives timestamp index PDA, passes on writes, initializes after new account creationTesting Verification
.bin/.jsonfixtures, Go/Python/TypeScript deserialize and assert field values match