Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support committing fee-only transactions #2425

Merged
merged 7 commits into from
Aug 22, 2024

Conversation

jstarry
Copy link

@jstarry jstarry commented Aug 3, 2024

Problem

In order to implement solana-foundation/solana-improvement-documents#82, the transaction pipeline needs to support committing validated transactions that are not executable to a block.

Summary of Changes

  • Add new ProcessedTransaction enum to represent transactions processed by the runtime but not necessarily executed
  • Added feature gate to enable committing fee-only transactions to blocks

Fixes #

@jstarry
Copy link
Author

jstarry commented Aug 3, 2024

@apfitzge do you mind browsing through this PR to see if the direction looks reasonable? If it looks ok, I will break up the changes into smaller PRs and add testing.

runtime/src/bank.rs Outdated Show resolved Hide resolved
svm/src/account_loader.rs Outdated Show resolved Hide resolved
Ok(loaded_transaction) => {
TransactionLoadResult::NotLoaded(err) => Err(err),
TransactionLoadResult::FeesOnly(fees_only_tx) => {
if enable_transaction_failure_fees {
Copy link
Author

Choose a reason for hiding this comment

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

This is where we opt in to the new behavior of committing fees-only transactions

sdk/src/feature_set.rs Outdated Show resolved Hide resolved
@apfitzge
Copy link

apfitzge commented Aug 4, 2024

@apfitzge do you mind browsing through this PR to see if the direction looks reasonable? If it looks ok, I will break up the changes into smaller PRs and add testing.

Overall approach seems very solid, didn't dig into details yet but the separateion during acct loading and then again during committing makes sense to me.

@jstarry jstarry force-pushed the feat/tx-fees-only branch 3 times, most recently from 16314bb to 3eb5127 Compare August 5, 2024 12:51
@jstarry jstarry force-pushed the feat/tx-fees-only branch 6 times, most recently from a420bd8 to 0ebc876 Compare August 13, 2024 14:07
@jstarry jstarry force-pushed the feat/tx-fees-only branch from 0ebc876 to 29f2058 Compare August 14, 2024 05:44
@jstarry jstarry marked this pull request as ready for review August 14, 2024 05:45
@jstarry jstarry requested review from dmakarov and pgarg66 August 14, 2024 05:45
@jstarry
Copy link
Author

jstarry commented Aug 14, 2024

This is now ready for review. I put the implementation changes in the first commit and test changes in the second commit to help with review.

@jstarry jstarry requested a review from apfitzge August 14, 2024 05:52
ledger/src/blockstore_processor.rs Show resolved Hide resolved
programs/sbf/tests/programs.rs Outdated Show resolved Hide resolved
sdk/src/feature_set.rs Outdated Show resolved Hide resolved
runtime/src/bank.rs Show resolved Hide resolved
runtime/src/bank.rs Show resolved Hide resolved
Comment on lines +22 to +29
pub enum ProcessedTransaction {
/// Transaction was executed, but if execution failed, all account state changes
/// will be rolled back except deducted fees and any advanced nonces
Executed(Box<ExecutedTransaction>),
/// Transaction was not able to be executed but fees are able to be
/// collected and any nonces are advanceable
FeesOnly(Box<FeesOnlyTransaction>),
}

Choose a reason for hiding this comment

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

Outside the scope of this PR, but we may want to re-evaluate this at some later point.
Doing a box-allocation per transaction is likely bad for performance - though I'm sure there are many such sins in our current pipeline.

Copy link

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

code changes are looking good to me. I still need to take another pass on the new/changed tests.

Copy link

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

few minor comments are request for clarification on a test change.

];
let initial_balance = bank.get_balance(&leader);

bank.filter_program_errors_and_collect_fee(&processing_results);
bank.freeze();
assert_eq!(
bank.get_balance(&leader),
initial_balance + bank.fee_rate_governor.burn(tx_fee * 2).0
initial_balance + bank.fee_rate_governor.burn(tx_fee * 3).0

Choose a reason for hiding this comment

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

Note for myself.
Change to 3 is because there are 2 added results:

  1. Err => no fees
  2. FeesOnly => fees

runtime/src/bank/tests.rs Outdated Show resolved Hide resolved
runtime/src/bank/tests.rs Outdated Show resolved Hide resolved
runtime/src/bank/tests.rs Outdated Show resolved Hide resolved
@jstarry jstarry merged commit 530e9c3 into anza-xyz:master Aug 22, 2024
52 checks passed
@jstarry jstarry deleted the feat/tx-fees-only branch August 22, 2024 13:33
ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
* feat: support committing fee-only transactions

* update and add new tests

* fix sbf test

* feedback

* fix new test

* test cleanup
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