Repository navigation
feat: add mempool_tx_confirmation_seconds metric by tx type - #2711
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Confirmation observations can omit known transactions or use unreliable receipt timestamps.
3 open findings
What changed in this PR
Adds a transaction-type confirmation-time histogram to existing mempool monitoring, using SNP receipt timestamps to improve catch-up accuracy.
Changes:
- Preserves SNP timestamps during event ingestion.
- Emits mined-transaction metadata after commit and records confirmation durations.
- Adds timestamp, filtering, lag-cutoff, and replay tests.
| File | Description |
|---|---|
| tests/snp/snp-ingestion.test.ts | Checks original receipt times after replay. |
| tests/api/mempool/mempool-confirmation-metric.test.ts | Tests timing helpers and ingestion behavior. |
| src/event-stream/snp-event-stream.ts | Forwards SNP timestamps. |
| src/event-stream/event-server.ts | Resolves and passes receipt times. |
| src/env.ts | Configures the observation lag cutoff. |
| src/datastore/pg-write-store.ts | Collects and emits mined-transaction metadata. |
| src/datastore/pg-store-event-emitter.ts | Defines the confirmation event. |
| src/datastore/helpers.ts | Calculates durations and registers the histogram. |
| src/datastore/common.ts | Defines confirmation metadata. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
rafa-stacks
marked this pull request as ready for review
October 8, 2026 18:15
bgridley-stacks
approved these changes
Oct 8, 2026
This branch was successfully deployed
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.

Adds a
mempool_tx_confirmation_secondsPrometheus histogram that measures how long each tx waits between first being received into the mempool and being mined, labeled by txtypeso it can be split per type in Grafana.block_time - receipt_timein seconds, clamped to ≥ 0 to absorb clock differences between the miner and the mempool observer.getTxTypeString, the same values as the existingmempool_tx_count{type}.1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 45, 60, 120, 300, 600, 1800, 3600, 7200, 21600. Dense below a minute, where most Nakamoto confirmations land.