v3.0: CostTracker: Add a getter to expose cost by writable accounts (backport of #7920)#8174
Merged
v3.0: CostTracker: Add a getter to expose cost by writable accounts (backport of #7920)#8174
Conversation
* Summary
This change adds a new method to the CostTracker that provides a breakdown of compute unit costs for each writable account during block processing.
Problem
Currently, CostTracker aggregates compute unit costs but doesn't expose a detailed breakdown of costs per account. This makes it difficult to analyze resource consumption patterns and identify which accounts are the biggest resource consumers within a block.
Solution
A new method, get_cost_by_writable_accounts(), has been added to the CostTracker to address this issue. This method returns a mapping of each writable account to its specific compute unit costs, providing a granular view of resource usage.
Testing
✅ The new method was tested to ensure it correctly tracks and returns per-account costs.
✅ Existing CostTracker functionality remains unchanged and unaffected by this addition.
✅ The change was validated to confirm it correctly captures the cost distribution among writable accounts.
Type of Change
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] Documentation update
Checklist
[x] Code compiles without errors
[x] New tests have been added and pass
[x] No breaking changes
[x] Follows existing code style
* Use a trait to expose the heavy method
* gate behind a feature
* Revert "gate behind a feature"
This reverts commit b927337.
(cherry picked from commit f4598b1)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.0 #8174 +/- ##
=======================================
Coverage 83.4% 83.4%
=======================================
Files 810 810
Lines 365773 365790 +17
=======================================
+ Hits 305395 305432 +37
+ Misses 60378 60358 -20 🚀 New features to boost your workflow:
|
|
What's justification for this to be backported, it doesn't fix any bug or behavior for our 3.0 version? |
@apfitzge Mainly to be able to pull in the changes from 3.0.x crate https://crates.io/crates/solana-cost-model |
t-nelson
approved these changes
Sep 25, 2025
|
Checking - does this still need to be merged into 3.0? @ebin-mathews @apfitzge |
If possible, yes please 🙏 |
apfitzge
approved these changes
Sep 29, 2025
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
This change adds a new method to the CostTracker that provides a breakdown of compute unit costs for each writable account during block processing.
Problem
Currently, CostTracker aggregates compute unit costs but doesn't expose a detailed breakdown of costs per account. This makes it difficult to analyze resource consumption patterns and identify which accounts are the biggest resource consumers within a block during post-analysis.
Proposed Changes
A new method, get_cost_by_writable_accounts(), has been added to the CostTracker which exposes a reference to the map that holds the detailed breakdown of costs per account.
This is an automatic backport of pull request #7920 done by [Mergify](https://mergify.com).