Skip to content

v3.0: CostTracker: Add a getter to expose cost by writable accounts (backport of #7920)#8174

Merged
apfitzge merged 1 commit intov3.0from
mergify/bp/v3.0/pr-7920
Sep 29, 2025
Merged

v3.0: CostTracker: Add a getter to expose cost by writable accounts (backport of #7920)#8174
apfitzge merged 1 commit intov3.0from
mergify/bp/v3.0/pr-7920

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify Bot commented Sep 24, 2025

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).

* 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)
@mergify mergify Bot requested a review from a team as a code owner September 24, 2025 16:54
@tao-stones tao-stones requested a review from apfitzge September 24, 2025 16:56
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.4%. Comparing base (9c181a4) to head (dee4f24).
⚠️ Report is 56 commits behind head on v3.0.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@apfitzge
Copy link
Copy Markdown

What's justification for this to be backported, it doesn't fix any bug or behavior for our 3.0 version?

@ebin-mathews
Copy link
Copy Markdown

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

@tao-stones
Copy link
Copy Markdown

Checking - does this still need to be merged into 3.0? @ebin-mathews @apfitzge

@ebin-mathews
Copy link
Copy Markdown

Checking - does this still need to be merged into 3.0? @ebin-mathews @apfitzge

If possible, yes please 🙏

@apfitzge apfitzge merged commit 20a4683 into v3.0 Sep 29, 2025
42 checks passed
@apfitzge apfitzge deleted the mergify/bp/v3.0/pr-7920 branch September 29, 2025 20:43
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.

5 participants