Fail simulation if transaction contains duplicate accounts (#18304)

This commit is contained in:
Justin Starry 2021-06-30 13:50:55 -05:00 committed by GitHub
parent 78968d132f
commit b08f8bd1b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -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)]),
);