Skip to content

Return transaction status from all bank process tx methods#6561

Merged
jstarry merged 1 commit intoanza-xyz:masterfrom
jstarry:refactor/bank-process-tx
Jun 17, 2025
Merged

Return transaction status from all bank process tx methods#6561
jstarry merged 1 commit intoanza-xyz:masterfrom
jstarry:refactor/bank-process-tx

Conversation

@jstarry
Copy link
Copy Markdown

@jstarry jstarry commented Jun 13, 2025

Problem

The transaction status isn't returned consistently from bank process transaction methods.

Summary of Changes

  • Remove unnecessary status lookup in Bank::process_transaction
  • Return transaction status through bank process transaction methods
  • Fix tests which weren't properly processing transactions successfully

Fixes #

@jstarry jstarry force-pushed the refactor/bank-process-tx branch from 2b2fa7b to 6aacc73 Compare June 13, 2025 16:31
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.8%. Comparing base (69e749e) to head (934c270).
Report is 17 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #6561    +/-   ##
========================================
  Coverage    82.8%    82.8%            
========================================
  Files         849      849            
  Lines      379196   379205     +9     
========================================
+ Hits       314029   314140   +111     
+ Misses      65167    65065   -102     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jstarry jstarry force-pushed the refactor/bank-process-tx branch 4 times, most recently from 412b9ff to a90fed1 Compare June 14, 2025 02:06
@jstarry jstarry changed the title refactor: rm status lookup in bank process tx remove status lookup in bank process tx Jun 14, 2025
@jstarry jstarry force-pushed the refactor/bank-process-tx branch from a90fed1 to 934c270 Compare June 14, 2025 02:19
@jstarry jstarry changed the title remove status lookup in bank process tx Return transaction status from all bank process tx methods Jun 14, 2025
Comment thread core/src/banking_stage.rs
Comment thread runtime/src/bank.rs
.0
.into_iter()
.map(|commit_result| commit_result.map(|_| ()))
.map(|commit_result| commit_result.and_then(|committed_tx| committed_tx.status))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changing this revealed a few tests that were processing transactions unsuccessfully. I think it makes sense to always bubble up the execution status.

Comment thread runtime/src/bank/tests.rs
vote_state::create_account(&vote_pubkey1, &authorized_voter.pubkey(), 0, 100);
let vote_account2 =
vote_state::create_account(&vote_pubkey2, &authorized_voter.pubkey(), 0, 100);
let vote_account0 = vote_state::create_account_with_authorized(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This test doesn't technically require all of the vote transactions to succeed, but I thought it was worth cleaning up all the issues causing them to fail. One issue with this test was that vote_state::create_account sets the authorized voter as the vote account itself. So I updated to create_account_with_authorized to set the authorized voter to authorized_voter as I assume was intended by the original author.

Comment thread runtime/src/bank/tests.rs
@jstarry jstarry marked this pull request as ready for review June 14, 2025 02:23
@jstarry jstarry requested a review from steviez June 14, 2025 02:27
Copy link
Copy Markdown

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Cleanup generally looks good, just a couple questions to confirm my understanding

Comment thread runtime/src/bank.rs
/// Process a Transaction. This is used for unit tests and simply calls the vector
/// Bank::process_transactions method.
pub fn process_transaction(&self, tx: &Transaction) -> Result<()> {
self.try_process_transactions(std::iter::once(tx))?[0].clone()?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Out of scope for this PR, but given the "This is used for unit tests and ..." comment, this should seemingly be DCOU

Comment thread runtime/src/bank.rs
Comment thread core/src/banking_stage.rs
Comment thread runtime/src/bank/tests.rs
@jstarry jstarry requested a review from steviez June 16, 2025 18:55
Copy link
Copy Markdown

@steviez steviez left a comment

Choose a reason for hiding this comment

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

LGTM

@jstarry jstarry merged commit 3281f61 into anza-xyz:master Jun 17, 2025
28 checks passed
@jstarry jstarry deleted the refactor/bank-process-tx branch June 18, 2025 03:23
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