Extend getConfirmedBlock rpc to return account pre- and post-balances (#7543)
automerge
This commit is contained in:
@ -22,7 +22,7 @@ use solana_metrics::{inc_new_counter_debug, inc_new_counter_info, inc_new_counte
|
||||
use solana_perf::{cuda_runtime::PinnedVec, perf_libs};
|
||||
use solana_runtime::{
|
||||
accounts_db::ErrorCounters,
|
||||
bank::{Bank, TransactionProcessResult},
|
||||
bank::{Bank, TransactionBalancesSet, TransactionProcessResult},
|
||||
transaction_batch::TransactionBatch,
|
||||
};
|
||||
use solana_sdk::{
|
||||
@ -511,6 +511,11 @@ impl BankingStage {
|
||||
// TODO: Banking stage threads should be prioritized to complete faster then this queue
|
||||
// expires.
|
||||
let txs = batch.transactions();
|
||||
let pre_balances = if transaction_status_sender.is_some() {
|
||||
bank.collect_balances(txs)
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let (mut loaded_accounts, results, mut retryable_txs, tx_count, signature_count) =
|
||||
bank.load_and_execute_transactions(batch, MAX_PROCESSING_AGE);
|
||||
load_execute_time.stop();
|
||||
@ -541,11 +546,14 @@ impl BankingStage {
|
||||
signature_count,
|
||||
)
|
||||
.processing_results;
|
||||
|
||||
if let Some(sender) = transaction_status_sender {
|
||||
let post_balances = bank.collect_balances(txs);
|
||||
send_transaction_status_batch(
|
||||
bank.clone(),
|
||||
batch.transactions(),
|
||||
transaction_statuses,
|
||||
TransactionBalancesSet::new(pre_balances, post_balances),
|
||||
sender,
|
||||
);
|
||||
}
|
||||
|
@ -53,10 +53,16 @@ impl TransactionStatusService {
|
||||
bank,
|
||||
transactions,
|
||||
statuses,
|
||||
balances,
|
||||
} = write_transaction_status_receiver.recv_timeout(Duration::from_secs(1))?;
|
||||
|
||||
let slot = bank.slot();
|
||||
for (transaction, (status, hash_age_kind)) in transactions.iter().zip(statuses) {
|
||||
for (((transaction, (status, hash_age_kind)), pre_balances), post_balances) in transactions
|
||||
.iter()
|
||||
.zip(statuses)
|
||||
.zip(balances.pre_balances)
|
||||
.zip(balances.post_balances)
|
||||
{
|
||||
if Bank::can_commit(&status) && !transaction.signatures.is_empty() {
|
||||
let fee_hash = if let Some(HashAgeKind::DurableNonce) = hash_age_kind {
|
||||
bank.last_blockhash()
|
||||
@ -70,7 +76,12 @@ impl TransactionStatusService {
|
||||
blocktree
|
||||
.write_transaction_status(
|
||||
(slot, transaction.signatures[0]),
|
||||
&RpcTransactionStatus { status, fee },
|
||||
&RpcTransactionStatus {
|
||||
status,
|
||||
fee,
|
||||
pre_balances,
|
||||
post_balances,
|
||||
},
|
||||
)
|
||||
.expect("Expect database write to succeed");
|
||||
}
|
||||
|
Reference in New Issue
Block a user