Repository navigation
fix: invalidate principal ETag on matured miner rewards and their re-orgs - #2704
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation correctly invalidates principal ETags for miner reward changes and includes focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Adds miner rewards to principal ETag calculation, preventing stale cached STX balances after reward maturation or reorganization.
Changes:
- Includes the latest canonical matured miner reward in principal ETags.
- Adds a partial index supporting efficient reward lookup.
- Adds coverage for reward maturation, rollback, and reward-only principals.
| File | Description |
|---|---|
src/datastore/pg-store.ts |
Retrieves the latest canonical reward for ETag generation. |
src/api/controllers/cache-controller.ts |
Incorporates reward state into principal ETags. |
migrations/1779800000027_miner-rewards-recipient-maturity-index.ts |
Adds the supporting partial index. |
tests/api/cache/cache-control.test.ts |
Tests reward-driven cache invalidation and reward-only principals. |
💡 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 6, 2026 14:32
bgridley-stacks
approved these changes
Oct 6, 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.
Principal ETags ignored miner rewards, so cached STX balances went stale whenever a reward matured or a re-org orphaned one.
getPrincipalLastActivityTxIdsnow also returns the latest canonical matured reward for the recipient asmature_block_height:index_block_hash.ETAG_EMPTY.miner_rewards (recipient, mature_block_height DESC) WHERE canonical = true.