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

earlier fee payer validation #34666

Merged
merged 7 commits into from
Jan 12, 2024

Conversation

apfitzge
Copy link
Contributor

@apfitzge apfitzge commented Jan 5, 2024

Problem

  • Expired, already processed, and transactions that cannot pay fees can still take locks.

Summary of Changes

  • Check these conditions before taking locks
  • No significant affect on max or avg TPS in bench-tps
    • The account loading will bring the fee-paying account into cache (if not already there), which will typically make the subsequent load during actual processing faster

I made a patched bench-tps to spam 60% invalid fee-paying txs. Saw degraded perf on master, much better perf with this change:

master: max= 9744, avg=1714
thispr: max=20065, avg=9018

bench-tps patch/hack: invalid-transfer-generation.patch

Blocked by #34652

Fixes #

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (95f888a) 81.8% compared to head (c6c73d1) 81.8%.
Report is 26 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #34666   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         824      824           
  Lines      222717   222742   +25     
=======================================
+ Hits       182287   182380   +93     
+ Misses      40430    40362   -68     

@apfitzge apfitzge force-pushed the earlier_fee_payer_validation branch from daf0209 to 6aa6146 Compare January 9, 2024 17:05
@apfitzge apfitzge marked this pull request as ready for review January 9, 2024 17:07
@apfitzge apfitzge requested review from t-nelson and tao-stones and removed request for t-nelson and tao-stones January 9, 2024 23:02
@apfitzge apfitzge marked this pull request as draft January 10, 2024 17:06
@@ -684,6 +709,39 @@ impl Consumer {
}
}

pub fn check_fee_payer_unlocked(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

put this into a separate fn because I actually will be doing same operation in the new scheduler (#34699)

@@ -177,12 +180,31 @@ fn consume_scan_should_process_packet(
return ProcessingDecision::Never;
}

if !payload.account_locks.check_locks(message) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

did a separate check_locks, then take_locks so that we will not check fee-payers that we know can't even be in this batch.

@apfitzge apfitzge marked this pull request as ready for review January 10, 2024 18:39
@@ -177,6 +180,26 @@ fn consume_scan_should_process_packet(
return ProcessingDecision::Never;
}

// Only check fee-payer if we can actually take locks
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renewed hatred for all the edge-cases of MI 😭

Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

r+ @taozhu-chicago's review. ping me if he doesn't get to it before you're unavailable tomorrow and i'll approve

tao-stones
tao-stones previously approved these changes Jan 12, 2024
Copy link
Contributor

@tao-stones tao-stones left a comment

Choose a reason for hiding this comment

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

the functions make sense to me, my comments are mainly concerns of execution time, which can be monitored with additional metrics. Ok to merge it now, add metrics later.

let mut error_counters = TransactionErrorMetrics::default();
let pre_results = vec![Ok(()); txs.len()];
let check_results =
bank.check_transactions(txs, &pre_results, MAX_PROCESSING_AGE, &mut error_counters);
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd potentially submit more transactions to bank for checking, which read-locks status_cache. Might be useful to add elapse metrics for this call, perhaps in separate PR.


let check_results = check_results
.into_iter()
.zip(txs)
Copy link
Contributor

Choose a reason for hiding this comment

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

is zip(txs) needed?

process_compute_budget_instructions(message.program_instructions_iter())?.into();
let fee = bank.fee_structure.calculate_fee(
message,
bank.get_lamports_per_signature(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I noted early it should fetch lamports_per_signature for durable transactions from nonce account. Then @t-nelson just clarified that durable transaction's fee is calculated based on fee rate at execution. So this should be just fine.

@@ -684,6 +709,39 @@ impl Consumer {
}
}

pub fn check_fee_payer_unlocked(
Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of lifting in this function, the saving is remove bad transactions upfront, and warms up good transactions' payer accounts, the extra time spent here is still a concern, especially if a lot of transactions going through this check. Can we add another metrics to monitor it?

bank.transfer(5_000, &genesis_config_info.mint_keypair, &keypair.pubkey())
.unwrap();
bank.transfer(
100_000,
Copy link
Contributor

Choose a reason for hiding this comment

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

why change from 5_000 to 100_000?

@apfitzge
Copy link
Contributor Author

@taozhu-chicago pushed minor fix to undo unintended change on the funding, and remove .zip(txs).

Will add metrics in a follow-up PR.

Copy link
Contributor

@tao-stones tao-stones left a comment

Choose a reason for hiding this comment

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

lgtm

@apfitzge apfitzge merged commit be5337a into solana-labs:master Jan 12, 2024
35 checks passed
@apfitzge apfitzge deleted the earlier_fee_payer_validation branch January 12, 2024 16:22
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