Skip to content

Conversation

@PhilWindle
Copy link
Collaborator

@PhilWindle PhilWindle commented Feb 6, 2026

Summary

Implements soft deletion for transactions from pruned blocks in TxPoolV2:

  • Transactions from pruned blocks are soft-deleted - kept in DB for later re-execution
  • Transactions NOT from pruned blocks are hard-deleted - removed from DB immediately as before
  • Soft-deleted txs are retrievable via getTxByHash and hasTxs, with status 'deleted' from getTxStatus
  • Hard deletion on finalization - soft-deleted txs are permanently removed when their original mined block is finalized

Key Design Decisions

  1. Track mined block, not prune point: When a tx is un-mined due to a reorg, we track the block it was mined in, not the block we pruned to. This ensures the tx is kept until that block is finalized on the new chain.

  2. Handle re-mining: If a tx is mined at block 4, pruned, re-mined at block 5, then pruned again, we track block 5 (the higher value). The tx is only hard-deleted when block 5 is finalized.

  3. Single source of truth: DeletedPool is responsible for ALL deletion decisions. It determines whether to soft-delete or hard-delete based on whether the tx is from a pruned block.

Example Scenario

1. Tx mined at block 10
2. Chain prunes to block 5 (tx un-mined, tracked as minedAtBlock=10)
3. Tx fails validation and is soft-deleted
4. Block 9 finalized → tx still in DB
5. Block 10 finalized → tx hard-deleted

Test plan

  • 177 tx_pool_v2 tests pass
  • 17 deleted_pool tests pass
  • Test: tx mined, pruned, soft-deleted, finalized at correct block
  • Test: tx re-mined at higher block, tracked correctly
  • Test: multiple txs with different mined blocks finalize at correct times
  • Test: persistence across restarts

🤖 Generated with Claude Code

Copy link
Contributor

@alexghr alexghr left a comment

Choose a reason for hiding this comment

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

We agreed to remove txs from the DeletePool once they re-mine in order to keep tracking consisten.

@PhilWindle PhilWindle changed the base branch from next to merge-train/spartan February 10, 2026 21:30
@PhilWindle PhilWindle enabled auto-merge February 10, 2026 22:14
## Summary

Implements soft deletion for transactions from pruned blocks in TxPoolV2:

- **Transactions from pruned blocks are soft-deleted** - kept in DB for later re-execution
- **Transactions NOT from pruned blocks are hard-deleted** - removed from DB immediately as before
- **Soft-deleted txs are retrievable** via `getTxByHash` and `hasTxs`, with status `'deleted'` from `getTxStatus`
- **Hard deletion on finalization** - soft-deleted txs are permanently removed when their original mined block is finalized

### Key Design Decisions

1. **Track mined block, not prune point**: When a tx is un-mined due to a reorg, we track the block it was *mined* in, not the block we pruned to. This ensures the tx is kept until that block is finalized on the new chain.

2. **Handle re-mining**: If a tx is mined at block 4, pruned, re-mined at block 5, then pruned again, we track block 5 (the higher value). The tx is only hard-deleted when block 5 is finalized.

3. **Single source of truth**: `DeletedPool` is responsible for ALL deletion decisions. It determines whether to soft-delete or hard-delete based on whether the tx is from a pruned block.

### Example Scenario

```
1. Tx mined at block 10
2. Chain prunes to block 5 (tx un-mined, tracked as minedAtBlock=10)
3. Tx fails validation and is soft-deleted
4. Block 9 finalized → tx still in DB
5. Block 10 finalized → tx hard-deleted
```

## Test plan

- 177 tx_pool_v2 tests pass
- 17 deleted_pool tests pass
- Test: tx mined, pruned, soft-deleted, finalized at correct block
- Test: tx re-mined at higher block, tracked correctly
- Test: multiple txs with different mined blocks finalize at correct times
- Test: persistence across restarts

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@PhilWindle PhilWindle merged commit f75d98b into merge-train/spartan Feb 10, 2026
11 checks passed
@PhilWindle PhilWindle deleted the pw/soft-delete branch February 10, 2026 22:36
github-merge-queue bot pushed a commit that referenced this pull request Feb 11, 2026
BEGIN_COMMIT_OVERRIDE
chore(ci3): add optional local cache for bootstrap artifacts (#20305)
fix: Fix p2p integration test (#20331)
chore: reduce fee log severity (#20336)
feat: restrict response sizes to expected sizes (#20287)
feat: retry web3signer connection (#20342)
feat(p2p): Integrate TxPoolV2 across codebase (#20172)
feat: review and optimize Claude configuration, agents, and skills
(#20270)
fix(prover): handle cross-chain messages when proving mbps (#20354)
chore: retry flakes. if retry pass, is a flake as we know it now. fail
both is hard fail (#19322)
chore(p2p): add mock reqresp layer for tests (#20370)
fix: (A-370) don't propagate on tx mempool add failure (#20374)
chore: Skip the HA test (#20376)
feat: Retain pruned transactions until pruned block is finalised
(#20237)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants