Skip to content

Conversation

@rafaelcr
Copy link
Collaborator

@rafaelcr rafaelcr commented May 2, 2025

This PR performs multiple checks to make sure we trace transactions that are replaced by fee correctly:

  1. Adds a replaced_by_tx_id key to dropped mempool transaction responses that will include another transaction ID if this represents an RBF operation.
  2. Takes the new_tx_id field from Stacks core when included on dropped mempool messages
  3. On mempool inserts, block confirmations and re-orgs, check for duplicate nonces for the same sender/sponsor and calculate the correct RBF setting. In other words, find the same nonce transaction that got confirmed or has the highest fee and mark all others as replaced.

Replaces #2141
Fixes #1813

@github-actions
Copy link

github-actions bot commented May 2, 2025

Vercel deployment URL: https://stacks-blockchain-1ht0fcc46-hirosystems.vercel.app 🚀

@codecov
Copy link

codecov bot commented May 2, 2025

Codecov Report

❌ Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/datastore/pg-write-store.ts 90.00% 2 Missing ⚠️
src/event-stream/event-server.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@rafaelcr rafaelcr marked this pull request as ready for review May 2, 2025 19:32
@rafaelcr rafaelcr changed the title feat: specify transaction id being replaced in mempool results feat: add replaced_by_tx_id to replaced mempool transactions May 2, 2025

test('prunes transactions with nonces that were already confirmed', async () => {
// Initial block
test('prunes and restores replaced-by-fee transactions', async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zone117x this is the main test of the new functionality

Copy link
Contributor

@zone117x zone117x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks great, nice tests 💯

The new sql query is in the block ingestion path -- have we tested its performance?

Copy link
Contributor

@janniks janniks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test 👍

@rafaelcr
Copy link
Collaborator Author

@zone117x thanks, I've tested locally but the next step will be to deploy this PR to dev and then staging to perform some load tests

@rafaelcr rafaelcr merged commit a70c3d1 into develop Jun 2, 2025
26 checks passed
@rafaelcr rafaelcr deleted the feat/rbf branch June 2, 2025 15:12
hirosystems-release-bot bot added a commit that referenced this pull request Aug 6, 2025
## [8.12.0](v8.11.6...v8.12.0) (2025-08-06)

### Features

* Add exclude_function_args parameter to reduce transaction response sizes ([#2312](#2312)) ([852a60e](852a60e))
* add replaced_by_tx_id to replaced mempool transactions ([#2271](#2271)) ([a70c3d1](a70c3d1))
* **prometheus:** add chain tip metrics ([#2333](#2333)) ([bde1037](bde1037))
* SNP integration ([#2291](#2291)) ([9a159e1](9a159e1))

### Bug Fixes

* drop redundant db indexes ([#2329](#2329)) ([0ddd6a6](0ddd6a6))
* ensure some ops only run when SNP is not enabled ([fd4717b](fd4717b))
* only ingest snp chain events to avoid db bloat ([287f572](287f572))
* optimize queries to prune and restore mempool rbf txs ([#2327](#2327)) ([0b196f0](0b196f0))
* optimize replace-by-fee mempool calculations ([#2326](#2326)) ([01998bc](01998bc))
* parallelize mempool rbf updates ([#2328](#2328)) ([e7347e5](e7347e5))
* update snp image in tests ([c7c0dbb](c7c0dbb))
@hirosystems-release-bot
Copy link
Contributor

🎉 This PR is included in version 8.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

specify which transaction replaced another via RBF

4 participants