Nonce updates (#13799)

* runtime: Add `FeeCalculator` resolution method to `HashAgeKind`

* runtime: Plumb fee-collected accounts for failed nonce tx rollback

* runtime: Use fee-collected nonce/fee account for nonced TX error rollback

* runtime: Add test for failed nonced TX accounts rollback

* Fee payer test

* fixup: replace nonce account when it pays the fee

* fixup: nonce fee-payer collect test

* fixup: fixup: clippy/fmt for replace...

* runtime: Test for `HashAgeKind::fee_calculator()`

* Clippy

Co-authored-by: Trent Nelson <trent@solana.com>
This commit is contained in:
sakridge
2020-11-24 23:53:51 -08:00
committed by GitHub
parent 42421e77a9
commit b70abdc645
3 changed files with 446 additions and 57 deletions

View File

@ -1,11 +1,7 @@
use crossbeam_channel::{Receiver, RecvTimeoutError};
use itertools::izip;
use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusBatch};
use solana_runtime::{
bank::{Bank, HashAgeKind},
transaction_utils::OrderedIterator,
};
use solana_sdk::nonce_account;
use solana_runtime::{bank::Bank, transaction_utils::OrderedIterator};
use solana_transaction_status::{InnerInstructions, TransactionStatusMeta};
use std::{
sync::{
@ -76,13 +72,12 @@ impl TransactionStatusService {
transaction_logs
) {
if Bank::can_commit(&status) && !transaction.signatures.is_empty() {
let fee_calculator = match hash_age_kind {
Some(HashAgeKind::DurableNonce(_, account)) => {
nonce_account::fee_calculator_of(&account)
}
_ => bank.get_fee_calculator(&transaction.message().recent_blockhash),
}
.expect("FeeCalculator must exist");
let fee_calculator = hash_age_kind
.and_then(|hash_age_kind| hash_age_kind.fee_calculator())
.unwrap_or_else(|| {
bank.get_fee_calculator(&transaction.message().recent_blockhash)
})
.expect("FeeCalculator must exist");
let fee = fee_calculator.calculate_fee(transaction.message());
let (writable_keys, readonly_keys) =
transaction.message.get_account_keys_by_lock_type();