From b08f8bd1b042c0a9c49f34694885365f4372c345 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Wed, 30 Jun 2021 13:50:55 -0500 Subject: [PATCH] Fail simulation if transaction contains duplicate accounts (#18304) --- runtime/src/bank.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index d80525c785..cd9087816a 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -2616,8 +2616,17 @@ impl Bank { &'a self, tx: &'b Transaction, ) -> TransactionBatch<'a, 'b> { + let check_transaction = |tx: &Transaction| -> Result<()> { + tx.sanitize().map_err(TransactionError::from)?; + if Accounts::has_duplicates(&tx.message.account_keys) { + Err(TransactionError::AccountLoadedTwice) + } else { + Ok(()) + } + }; + let mut batch = TransactionBatch::new( - vec![tx.sanitize().map_err(|e| e.into())], + vec![check_transaction(tx)], self, Cow::Owned(vec![HashedTransaction::from(tx)]), );