Skip to content

Add functions to collect executed transactions fee in details;#178

Merged
mergify[bot] merged 7 commits intomasterfrom
simd0096-collect-fee-details
Mar 21, 2024
Merged

Add functions to collect executed transactions fee in details;#178
mergify[bot] merged 7 commits intomasterfrom
simd0096-collect-fee-details

Conversation

@tao-stones
Copy link
Copy Markdown

Problem

Working bank should be able to collect executed transactions's fee in detail, separating transaction_fee (half burnt) and prio fee (100% rewarded).

Summary of Changes

  • Add CollectorFeeDetails to bank, which is NOT (de)serialized
  • Add dead_code filter_program_errors_and_collect_fee_details() implements collecting fee_details. This function is not called yet, next PR will invoke it behind a feature gate.

Fixes #

Comment thread runtime/src/bank.rs
Copy link
Copy Markdown

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

Could you explain the motivation for why the bank should be aware of the details of collection at all?
It seems all we need from the bank variable is to accumulate reward into a u64 so it can be distributed at the end of slot. In that case, why not simply use a (atomic)u64 for the accumulation?

Comment thread runtime/src/bank.rs
Comment thread runtime/src/bank.rs Outdated
Comment thread runtime/src/bank.rs Outdated
Comment thread runtime/src/bank.rs
@tao-stones
Copy link
Copy Markdown
Author

Could you explain the motivation for why the bank should be aware of the details of collection at all? It seems all we need from the bank variable is to accumulate reward into a u64 so it can be distributed at the end of slot. In that case, why not simply use a (atomic)u64 for the accumulation?

For SIMD-0096, how fee is distributed at the end of bank is different based on fee "type". Transaction Fee will be 50% rewarded 50% burnt, and Priority Fee will be 100% rewarded. For that, bank has to keep collected fees in different buckets. struct CollectorFeeDetails for this purpose. In the future, in case there is another type of fee that requires different distribution, say 100% burn, it can be simply added to CollectorFeeDetails.

Fee distribution changes are in next PR (preview).

@apfitzge
Copy link
Copy Markdown

apfitzge commented Mar 11, 2024

Could you explain the motivation for why the bank should be aware of the details of collection at all? It seems all we need from the bank variable is to accumulate reward into a u64 so it can be distributed at the end of slot. In that case, why not simply use a (atomic)u64 for the accumulation?

For SIMD-0096, how fee is distributed at the end of bank is different based on fee "type". Transaction Fee will be 50% rewarded 50% burnt, and Priority Fee will be 100% rewarded. For that, bank has to keep collected fees in different buckets. struct CollectorFeeDetails for this purpose. In the future, in case there is another type of fee that requires different distribution, say 100% burn, it can be simply added to CollectorFeeDetails.

Fee distribution changes are in next PR (preview).

I understand we have to distribute them differently based on type. But that can be done at transaction level, the bank only needs to be aware of the reward at the end of the slot.

Basically my question is why does the bank need to be aware of the details and not just the result, i.e. reward.

edit: I see now - it's because we do not update total capitalization changes until end of slot. Change to capitalization will depend on the burn rate, so we need the details unless we moved capitalization update by fee into transaction committing.

@t-nelson
Copy link
Copy Markdown

planning on adding tests?

@tao-stones
Copy link
Copy Markdown
Author

planning on adding tests?

Yes 💪🏼, one last thing to address from Andrew's last review.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 97.88732% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 81.9%. Comparing base (ade9035) to head (f59c93d).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master     #178    +/-   ##
========================================
  Coverage    81.9%    81.9%            
========================================
  Files         838      838            
  Lines      226927   227067   +140     
========================================
+ Hits       185918   186049   +131     
- Misses      41009    41018     +9     

@tao-stones tao-stones requested a review from apfitzge March 13, 2024 18:31
@tao-stones tao-stones force-pushed the simd0096-collect-fee-details branch from 7aa681a to ca0ae44 Compare March 13, 2024 18:48
@tao-stones tao-stones requested a review from lheeger-jump March 14, 2024 17:06
Copy link
Copy Markdown

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

Think we need to discuss the rounding; it seems to be a blocker for this style of accumulation.

I previously expressed my thought on accumulating only reward instead of fee, which I pointed out will not work due to the capitalization update.

Alternatively we could still accumulate 2 variables: reward, burn.
This would let us update capitalization correctly at the end of the slot using burn.
I think that would also let us move forward with this change without blocking on the rounding feature.
wdyt?

Comment thread runtime/src/bank.rs
Comment thread runtime/src/bank.rs Outdated
@tao-stones tao-stones requested a review from apfitzge March 15, 2024 19:11
Comment thread runtime/src/bank.rs
@tao-stones tao-stones requested a review from apfitzge March 18, 2024 16:47
apfitzge
apfitzge previously approved these changes Mar 18, 2024
Copy link
Copy Markdown

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

lgtm

@tao-stones
Copy link
Copy Markdown
Author

@lheeger-jump Do you have time to check this one out? I'd like to merge this so can put next one out, which distributes collected collector_fee_details by fee type (50/50 for transaction fee, 100% for prio fee).

Copy link
Copy Markdown

@lheeger-jump lheeger-jump left a comment

Choose a reason for hiding this comment

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

LGTM

@tao-stones tao-stones force-pushed the simd0096-collect-fee-details branch from 43b8180 to f59c93d Compare March 20, 2024 23:38
@tao-stones tao-stones added the automerge automerge Merge this Pull Request automatically once CI passes label Mar 20, 2024
@mergify mergify Bot merged commit 1e08e90 into master Mar 21, 2024
@mergify mergify Bot deleted the simd0096-collect-fee-details branch March 21, 2024 04:33
OliverNChalk pushed a commit to OliverNChalk/agave that referenced this pull request Nov 11, 2025
Originally written by Andrew Fitzgerald <apfitzge@gmail.com> on Wed Aug
9 14:57:55 2023 -0700.

Previous version:

    commit 86a2b8f8aa19e606bd6396dfdbc6f35950b23ee9
    Author: Andrew Fitzgerald <apfitzge@gmail.com>
    Date:   Wed Aug 9 14:57:55 2023 -0700

        Spawn adversarial and normal banking stages (anza-xyz#113)

Rewritten to match the upstream scheduler code as of anza-xyz#5467 by Illia
Bobyr <illia.bobyr@anza.xyz>.

This change includes all of the following changes:

---

Author: Illia Bobyr <illia.bobyr@solana.com>
Date:   Mon Oct 2 14:03:46 2023 -0700

    adversary: test_scheduler => attack_scheduler (anza-xyz#175)

    We mostly talk about attacks, when we discuss the functionality this
    code supports.  Considering that we have a lot of other kinds of tests,
    it seems a bit clearer to call use "attack" in this part of the code.

Author: Illia Bobyr <illia.bobyr@solana.com>
Date:   Tue Oct 3 15:21:33 2023 -0700

    adversary: test_generators => transaction_generators (anza-xyz#178)

    We mostly talk about "attacks" rather than "tests" in this part of the
    code.  And even the main type in the `test_generators` module is called
    `TransactionGenerator`.

Author: kirill lykov <kirill.lykov@solana.com>
Date:   Thu Feb 8 10:52:48 2024 +0100

    replay: atomicbool instead of singleton for dropping packets (anza-xyz#224)

    * use atomicbool instead of singleton to drop packets

    * add use for Ordering

    Co-authored-by: Illia Bobyr <ilya.bobyr@gmail.com>
    Signed-off-by: kirill lykov <lykov.kirill@gmail.com>

    * rename drop_packets

    ---------

    Signed-off-by: kirill lykov <lykov.kirill@gmail.com>
    Co-authored-by: Illia Bobyr <ilya.bobyr@gmail.com>

Author: Brennan <brennan.watt@anza.xyz>
Date:   Fri Mar 22 06:45:29 2024 -0700

    remove dead code (anza-xyz#298)

Author: Andrew Fitzgerald <apfitzge@gmail.com>
Date:   Tue Jul 16 14:49:59 2024 -0500

    AdversarialBankingStage: Remove warning (anza-xyz#370)

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

Labels

automerge automerge Merge this Pull Request automatically once CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants