From 4ca4038d540d66ab8f6ddd9082626028fc01cc69 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Wed, 13 Mar 2019 13:58:44 -0600 Subject: [PATCH] Rename BankError to TransactionError --- book/src/testing-programs.md | 2 +- core/src/banking_stage.rs | 10 +++---- core/src/blocktree_processor.rs | 28 +++++++++--------- core/src/result.rs | 8 +++--- core/src/rpc.rs | 10 ++++--- core/src/rpc_subscriptions.rs | 8 ++++-- programs/failure/tests/failure.rs | 4 +-- programs/vote/tests/vote.rs | 4 +-- runtime/src/accounts.rs | 46 ++++++++++++++++------------- runtime/src/bank.rs | 48 +++++++++++++++---------------- runtime/src/runtime.rs | 6 ++-- runtime/src/status_cache.rs | 12 ++++---- runtime/tests/system.rs | 4 +-- 13 files changed, 100 insertions(+), 90 deletions(-) diff --git a/book/src/testing-programs.md b/book/src/testing-programs.md index 398f761dfe..2485bdb3c3 100644 --- a/book/src/testing-programs.md +++ b/book/src/testing-programs.md @@ -25,7 +25,7 @@ When Futures 0.3.0 is released, the Transact trait may look like this: ```rust,ignore trait Transact { - async fn send_transactions(txs: &[Transaction]) -> Vec>; + async fn send_transactions(txs: &[Transaction]) -> Vec>; } ``` diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 3fc2038e7a..3005c98eb9 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -16,7 +16,7 @@ use crate::service::Service; use crate::sigverify_stage::VerifiedPackets; use bincode::deserialize; use solana_metrics::counter::Counter; -use solana_runtime::bank::{self, Bank, BankError}; +use solana_runtime::bank::{self, Bank, TransactionError}; use solana_sdk::timing::{self, duration_as_us, MAX_RECENT_BLOCKHASHES}; use solana_sdk::transaction::Transaction; use std::net::UdpSocket; @@ -208,7 +208,7 @@ impl BankingStage { .zip(txs.iter()) .filter_map(|(r, x)| match r { Ok(_) => Some(x.clone()), - Err(BankError::InstructionError(index, err)) => { + Err(TransactionError::InstructionError(index, err)) => { info!("instruction error {:?}, {:?}", index, err); Some(x.clone()) } @@ -682,7 +682,7 @@ mod tests { assert_eq!(entries[0].0.transactions.len(), transactions.len()); // ProgramErrors should still be recorded - results[0] = Err(BankError::InstructionError( + results[0] = Err(TransactionError::InstructionError( 1, InstructionError::new_result_with_negative_lamports(), )); @@ -690,8 +690,8 @@ mod tests { let (_, entries) = entry_receiver.recv().unwrap(); assert_eq!(entries[0].0.transactions.len(), transactions.len()); - // Other BankErrors should not be recorded - results[0] = Err(BankError::AccountNotFound); + // Other TransactionErrors should not be recorded + results[0] = Err(TransactionError::AccountNotFound); BankingStage::record_transactions(&transactions, &results, &poh_recorder).unwrap(); let (_, entries) = entry_receiver.recv().unwrap(); assert_eq!(entries[0].0.transactions.len(), transactions.len() - 1); diff --git a/core/src/blocktree_processor.rs b/core/src/blocktree_processor.rs index 460a2ad96c..73009d4a51 100644 --- a/core/src/blocktree_processor.rs +++ b/core/src/blocktree_processor.rs @@ -229,7 +229,7 @@ mod tests { use crate::blocktree::create_new_tmp_ledger; use crate::blocktree::tests::entries_to_blobs; use crate::entry::{create_ticks, next_entry, Entry}; - use solana_runtime::bank::BankError; + use solana_runtime::bank::TransactionError; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::hash::Hash; use solana_sdk::signature::{Keypair, KeypairUtil}; @@ -383,32 +383,32 @@ mod tests { fn test_first_err() { assert_eq!(first_err(&[Ok(())]), Ok(())); assert_eq!( - first_err(&[Ok(()), Err(BankError::DuplicateSignature)]), - Err(BankError::DuplicateSignature) + first_err(&[Ok(()), Err(TransactionError::DuplicateSignature)]), + Err(TransactionError::DuplicateSignature) ); assert_eq!( first_err(&[ Ok(()), - Err(BankError::DuplicateSignature), - Err(BankError::AccountInUse) + Err(TransactionError::DuplicateSignature), + Err(TransactionError::AccountInUse) ]), - Err(BankError::DuplicateSignature) + Err(TransactionError::DuplicateSignature) ); assert_eq!( first_err(&[ Ok(()), - Err(BankError::AccountInUse), - Err(BankError::DuplicateSignature) + Err(TransactionError::AccountInUse), + Err(TransactionError::DuplicateSignature) ]), - Err(BankError::AccountInUse) + Err(TransactionError::AccountInUse) ); assert_eq!( first_err(&[ - Err(BankError::AccountInUse), + Err(TransactionError::AccountInUse), Ok(()), - Err(BankError::DuplicateSignature) + Err(TransactionError::DuplicateSignature) ]), - Err(BankError::AccountInUse) + Err(TransactionError::AccountInUse) ); } @@ -431,7 +431,7 @@ mod tests { // First, ensure the TX is rejected because of the unregistered last ID assert_eq!( bank.process_transaction(&tx), - Err(BankError::BlockhashNotFound) + Err(TransactionError::BlockhashNotFound) ); // Now ensure the TX is accepted despite pointing to the ID of an empty entry. @@ -733,7 +733,7 @@ mod tests { let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]); assert_eq!( process_entries(&bank, &[entry_3]), - Err(BankError::AccountNotFound) + Err(TransactionError::AccountNotFound) ); } } diff --git a/core/src/result.rs b/core/src/result.rs index 4e817a3836..f007f87f45 100644 --- a/core/src/result.rs +++ b/core/src/result.rs @@ -22,7 +22,7 @@ pub enum Error { RecvTimeoutError(std::sync::mpsc::RecvTimeoutError), TryRecvError(std::sync::mpsc::TryRecvError), Serialize(std::boxed::Box), - BankError(bank::BankError), + TransactionError(bank::TransactionError), ClusterInfoError(cluster_info::ClusterInfoError), BlobError(packet::BlobError), #[cfg(feature = "erasure")] @@ -57,9 +57,9 @@ impl std::convert::From for Error { Error::RecvTimeoutError(e) } } -impl std::convert::From for Error { - fn from(e: bank::BankError) -> Error { - Error::BankError(e) +impl std::convert::From for Error { + fn from(e: bank::TransactionError) -> Error { + Error::TransactionError(e) } } impl std::convert::From for Error { diff --git a/core/src/rpc.rs b/core/src/rpc.rs index ed2da0b506..0769194ba0 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -9,7 +9,7 @@ use bs58; use jsonrpc_core::{Error, ErrorCode, Metadata, Result}; use jsonrpc_derive::rpc; use solana_drone::drone::request_airdrop_transaction; -use solana_runtime::bank::{self, Bank, BankError}; +use solana_runtime::bank::{self, Bank, TransactionError}; use solana_sdk::account::Account; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::Signature; @@ -261,9 +261,11 @@ impl RpcSol for RpcSolImpl { } else { match res.unwrap() { Ok(_) => RpcSignatureStatus::Confirmed, - Err(BankError::AccountInUse) => RpcSignatureStatus::AccountInUse, - Err(BankError::AccountLoadedTwice) => RpcSignatureStatus::AccountLoadedTwice, - Err(BankError::InstructionError(_, _)) => { + Err(TransactionError::AccountInUse) => RpcSignatureStatus::AccountInUse, + Err(TransactionError::AccountLoadedTwice) => { + RpcSignatureStatus::AccountLoadedTwice + } + Err(TransactionError::InstructionError(_, _)) => { RpcSignatureStatus::ProgramRuntimeError } Err(err) => { diff --git a/core/src/rpc_subscriptions.rs b/core/src/rpc_subscriptions.rs index 9b5835c7d3..c287121ef6 100644 --- a/core/src/rpc_subscriptions.rs +++ b/core/src/rpc_subscriptions.rs @@ -6,7 +6,7 @@ use core::hash::Hash; use jsonrpc_core::futures::Future; use jsonrpc_pubsub::typed::Sink; use jsonrpc_pubsub::SubscriptionId; -use solana_runtime::bank::{self, Bank, BankError}; +use solana_runtime::bank::{self, Bank, TransactionError}; use solana_sdk::account::Account; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::Signature; @@ -98,8 +98,10 @@ impl RpcSubscriptions { pub fn check_signature(&self, signature: &Signature, bank_error: &bank::Result<()>) { let status = match bank_error { Ok(_) => RpcSignatureStatus::Confirmed, - Err(BankError::AccountInUse) => RpcSignatureStatus::AccountInUse, - Err(BankError::InstructionError(_, _)) => RpcSignatureStatus::ProgramRuntimeError, + Err(TransactionError::AccountInUse) => RpcSignatureStatus::AccountInUse, + Err(TransactionError::InstructionError(_, _)) => { + RpcSignatureStatus::ProgramRuntimeError + } Err(_) => RpcSignatureStatus::GenericFailure, }; diff --git a/programs/failure/tests/failure.rs b/programs/failure/tests/failure.rs index a8f6a3eee4..27998b477e 100644 --- a/programs/failure/tests/failure.rs +++ b/programs/failure/tests/failure.rs @@ -1,5 +1,5 @@ use solana_runtime::bank::Bank; -use solana_runtime::bank::BankError; +use solana_runtime::bank::TransactionError; use solana_runtime::loader_utils::load_program; use solana_runtime::runtime::InstructionError; use solana_sdk::genesis_block::GenesisBlock; @@ -26,7 +26,7 @@ fn test_program_native_failure() { ); assert_eq!( bank.process_transaction(&tx), - Err(BankError::InstructionError( + Err(TransactionError::InstructionError( 0, InstructionError::ProgramError(ProgramError::GenericError) )) diff --git a/programs/vote/tests/vote.rs b/programs/vote/tests/vote.rs index b19db9050b..05eb63847b 100644 --- a/programs/vote/tests/vote.rs +++ b/programs/vote/tests/vote.rs @@ -1,4 +1,4 @@ -use solana_runtime::bank::BankError; +use solana_runtime::bank::TransactionError; use solana_runtime::bank::{Bank, Result}; use solana_runtime::runtime::InstructionError; use solana_sdk::genesis_block::GenesisBlock; @@ -135,7 +135,7 @@ fn test_vote_via_bank_with_no_signature() { assert_eq!( result, - Err(BankError::InstructionError( + Err(TransactionError::InstructionError( 1, InstructionError::ProgramError(ProgramError::InvalidArgument) )) diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 8a728e9c83..79eaf74517 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -1,5 +1,5 @@ use crate::append_vec::AppendVec; -use crate::bank::{BankError, Result}; +use crate::bank::{Result, TransactionError}; use crate::runtime::has_duplicates; use bincode::serialize; use hashbrown::{HashMap, HashSet}; @@ -608,12 +608,12 @@ impl AccountsDB { ) -> Result> { // Copy all the accounts if tx.signatures.is_empty() && tx.fee != 0 { - Err(BankError::MissingSignatureForFee) + Err(TransactionError::MissingSignatureForFee) } else { // Check for unique account keys if has_duplicates(&tx.account_keys) { error_counters.account_loaded_twice += 1; - return Err(BankError::AccountLoadedTwice); + return Err(TransactionError::AccountLoadedTwice); } // There is no way to predict what program will execute without an error @@ -624,10 +624,10 @@ impl AccountsDB { } if called_accounts.is_empty() || called_accounts[0].lamports == 0 { error_counters.account_not_found += 1; - Err(BankError::AccountNotFound) + Err(TransactionError::AccountNotFound) } else if called_accounts[0].lamports < tx.fee { error_counters.insufficient_funds += 1; - Err(BankError::InsufficientFundsForFee) + Err(TransactionError::InsufficientFundsForFee) } else { called_accounts[0].lamports -= tx.fee; Ok(called_accounts) @@ -652,7 +652,7 @@ impl AccountsDB { if depth >= 5 { error_counters.call_chain_too_deep += 1; - return Err(BankError::CallChainTooDeep); + return Err(TransactionError::CallChainTooDeep); } depth += 1; @@ -660,12 +660,12 @@ impl AccountsDB { Some(program) => program, None => { error_counters.account_not_found += 1; - return Err(BankError::AccountNotFound); + return Err(TransactionError::AccountNotFound); } }; if !program.executable || program.owner == Pubkey::default() { error_counters.account_not_found += 1; - return Err(BankError::AccountNotFound); + return Err(TransactionError::AccountNotFound); } // add loader to chain @@ -688,7 +688,7 @@ impl AccountsDB { .map(|ix| { if tx.program_ids.len() <= ix.program_ids_index as usize { error_counters.account_not_found += 1; - return Err(BankError::AccountNotFound); + return Err(TransactionError::AccountNotFound); } let program_id = tx.program_ids[ix.program_ids_index as usize]; self.load_executable_accounts(fork, &program_id, error_counters) @@ -889,7 +889,7 @@ impl Accounts { for k in keys { if locks.contains(k) { error_counters.account_in_use += 1; - return Err(BankError::AccountInUse); + return Err(TransactionError::AccountInUse); } } for k in keys { @@ -905,7 +905,7 @@ impl Accounts { account_locks: &mut HashMap>, ) { match result { - Err(BankError::AccountInUse) => (), + Err(TransactionError::AccountInUse) => (), _ => { if let Some(locks) = account_locks.get_mut(&fork) { for k in &tx.account_keys { @@ -1060,7 +1060,7 @@ mod tests { assert_eq!(error_counters.account_not_found, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::AccountNotFound)); + assert_eq!(loaded_accounts[0], Err(TransactionError::AccountNotFound)); } #[test] @@ -1084,7 +1084,7 @@ mod tests { assert_eq!(error_counters.account_not_found, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::AccountNotFound)); + assert_eq!(loaded_accounts[0], Err(TransactionError::AccountNotFound)); } #[test] @@ -1116,7 +1116,7 @@ mod tests { assert_eq!(error_counters.account_not_found, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::AccountNotFound)); + assert_eq!(loaded_accounts[0], Err(TransactionError::AccountNotFound)); } #[test] @@ -1144,7 +1144,10 @@ mod tests { assert_eq!(error_counters.insufficient_funds, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::InsufficientFundsForFee)); + assert_eq!( + loaded_accounts[0], + Err(TransactionError::InsufficientFundsForFee) + ); } #[test] @@ -1248,7 +1251,7 @@ mod tests { assert_eq!(error_counters.call_chain_too_deep, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::CallChainTooDeep)); + assert_eq!(loaded_accounts[0], Err(TransactionError::CallChainTooDeep)); } #[test] @@ -1282,7 +1285,7 @@ mod tests { assert_eq!(error_counters.account_not_found, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::AccountNotFound)); + assert_eq!(loaded_accounts[0], Err(TransactionError::AccountNotFound)); } #[test] @@ -1315,7 +1318,7 @@ mod tests { assert_eq!(error_counters.account_not_found, 1); assert_eq!(loaded_accounts.len(), 1); - assert_eq!(loaded_accounts[0], Err(BankError::AccountNotFound)); + assert_eq!(loaded_accounts[0], Err(TransactionError::AccountNotFound)); } #[test] @@ -1408,7 +1411,10 @@ mod tests { assert_eq!(error_counters.account_loaded_twice, 1); assert_eq!(loaded_accounts.len(), 1); loaded_accounts[0].clone().unwrap_err(); - assert_eq!(loaded_accounts[0], Err(BankError::AccountLoadedTwice)); + assert_eq!( + loaded_accounts[0], + Err(TransactionError::AccountLoadedTwice) + ); } #[macro_export] @@ -1867,7 +1873,7 @@ mod tests { let mut error_counters = ErrorCounters::default(); assert_eq!( accounts.load_executable_accounts(0, &Keypair::new().pubkey(), &mut error_counters), - Err(BankError::AccountNotFound) + Err(TransactionError::AccountNotFound) ); assert_eq!(error_counters.account_not_found, 1); } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index f27aed831c..3c49e51c6e 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -106,7 +106,7 @@ impl EpochSchedule { /// Reasons a transaction might be rejected. #[derive(Debug, PartialEq, Eq, Clone)] -pub enum BankError { +pub enum TransactionError { /// This Pubkey is being processed in another transaction AccountInUse, @@ -139,9 +139,9 @@ pub enum BankError { MissingSignatureForFee, } -pub type Result = result::Result; +pub type Result = result::Result; -type BankStatusCache = StatusCache; +type BankStatusCache = StatusCache; /// Manager for the state of all accounts and programs after processing its entries. #[derive(Default)] @@ -395,9 +395,9 @@ impl Bank { status_cache.add(&tx.signatures[0]); } } - Err(BankError::BlockhashNotFound) => (), - Err(BankError::DuplicateSignature) => (), - Err(BankError::AccountNotFound) => (), + Err(TransactionError::BlockhashNotFound) => (), + Err(TransactionError::DuplicateSignature) => (), + Err(TransactionError::AccountNotFound) => (), Err(e) => { if !tx.signatures.is_empty() { status_cache.add(&tx.signatures[0]); @@ -512,7 +512,7 @@ impl Bank { .map(|(tx, lock_res)| { if lock_res.is_ok() && !hash_queue.check_entry_age(tx.recent_blockhash, max_age) { error_counters.reserve_blockhash += 1; - Err(BankError::BlockhashNotFound) + Err(TransactionError::BlockhashNotFound) } else { lock_res } @@ -536,7 +536,7 @@ impl Bank { } if lock_res.is_ok() && StatusCache::has_signature_all(&caches, &tx.signatures[0]) { error_counters.duplicate_signature += 1; - Err(BankError::DuplicateSignature) + Err(TransactionError::DuplicateSignature) } else { lock_res } @@ -650,7 +650,7 @@ impl Bank { .iter() .zip(executed.iter()) .map(|(tx, res)| match *res { - Err(BankError::InstructionError(_, _)) => { + Err(TransactionError::InstructionError(_, _)) => { // Charge the transaction fee even in case of InstructionError self.withdraw(&tx.account_keys[0], tx.fee)?; fees += tx.fee; @@ -759,14 +759,14 @@ impl Bank { match self.get_account(pubkey) { Some(mut account) => { if lamports > account.lamports { - return Err(BankError::InsufficientFundsForFee); + return Err(TransactionError::InsufficientFundsForFee); } account.lamports -= lamports; self.accounts.store_slow(self.accounts_id, pubkey, &account); Ok(()) } - None => Err(BankError::AccountNotFound), + None => Err(TransactionError::AccountNotFound), } } @@ -942,7 +942,7 @@ mod tests { let res = bank.process_transactions(&vec![t1.clone(), t2.clone()]); assert_eq!(res.len(), 2); assert_eq!(res[0], Ok(())); - assert_eq!(res[1], Err(BankError::AccountInUse)); + assert_eq!(res[1], Err(TransactionError::AccountInUse)); assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 0); assert_eq!(bank.get_balance(&key1), 1); assert_eq!(bank.get_balance(&key2), 0); @@ -950,7 +950,7 @@ mod tests { // TODO: Transactions that fail to pay a fee could be dropped silently assert_eq!( bank.get_signature_status(&t2.signatures[0]), - Some(Err(BankError::AccountInUse)) + Some(Err(TransactionError::AccountInUse)) ); } @@ -989,7 +989,7 @@ mod tests { assert_eq!(bank.get_balance(&key2), 0); assert_eq!( bank.get_signature_status(&t1.signatures[0]), - Some(Err(BankError::InstructionError( + Some(Err(TransactionError::InstructionError( 1, InstructionError::new_result_with_negative_lamports(), ))) @@ -1037,7 +1037,7 @@ mod tests { assert_eq!( bank.process_transaction(&tx), - Err(BankError::InstructionError( + Err(TransactionError::InstructionError( 0, InstructionError::new_result_with_negative_lamports(), )) @@ -1057,7 +1057,7 @@ mod tests { let keypair = Keypair::new(); assert_eq!( bank.transfer(1, &keypair, &mint_keypair.pubkey(), genesis_block.hash()), - Err(BankError::AccountNotFound) + Err(TransactionError::AccountNotFound) ); assert_eq!(bank.transaction_count(), 0); } @@ -1073,7 +1073,7 @@ mod tests { assert_eq!(bank.get_balance(&pubkey), 1_000); assert_eq!( bank.transfer(10_001, &mint_keypair, &pubkey, genesis_block.hash()), - Err(BankError::InstructionError( + Err(TransactionError::InstructionError( 0, InstructionError::new_result_with_negative_lamports(), )) @@ -1119,7 +1119,7 @@ mod tests { let key = Keypair::new(); assert_eq!( bank.withdraw(&key.pubkey(), 10), - Err(BankError::AccountNotFound) + Err(TransactionError::AccountNotFound) ); bank.deposit(&key.pubkey(), 3); @@ -1128,7 +1128,7 @@ mod tests { // Low balance assert_eq!( bank.withdraw(&key.pubkey(), 10), - Err(BankError::InsufficientFundsForFee) + Err(TransactionError::InsufficientFundsForFee) ); // Enough balance @@ -1174,7 +1174,7 @@ mod tests { let results = vec![ Ok(()), - Err(BankError::InstructionError( + Err(TransactionError::InstructionError( 1, InstructionError::new_result_with_negative_lamports(), )), @@ -1252,13 +1252,13 @@ mod tests { // try executing an interleaved transfer twice assert_eq!( bank.transfer(1, &mint_keypair, &bob.pubkey(), genesis_block.hash()), - Err(BankError::AccountInUse) + Err(TransactionError::AccountInUse) ); // the second time should fail as well // this verifies that `unlock_accounts` doesn't unlock `AccountInUse` accounts assert_eq!( bank.transfer(1, &mint_keypair, &bob.pubkey(), genesis_block.hash()), - Err(BankError::AccountInUse) + Err(TransactionError::AccountInUse) ); bank.unlock_accounts(&pay_alice, &results_alice); @@ -1311,7 +1311,7 @@ mod tests { let bank = new_from_parent(&parent); assert_eq!( bank.process_transaction(&tx), - Err(BankError::DuplicateSignature) + Err(TransactionError::DuplicateSignature) ); } @@ -1524,7 +1524,7 @@ mod tests { assert_eq!( bank.process_transaction(&tx), - Err(BankError::MissingSignatureForFee) + Err(TransactionError::MissingSignatureForFee) ); // Set the fee to 0, this should give an InstructionError diff --git a/runtime/src/runtime.rs b/runtime/src/runtime.rs index 6ca138a619..4a89eed7aa 100644 --- a/runtime/src/runtime.rs +++ b/runtime/src/runtime.rs @@ -1,4 +1,4 @@ -use crate::bank::BankError; +use crate::bank::TransactionError; use crate::native_loader; use crate::system_program::SystemError; use solana_sdk::account::{create_keyed_accounts, Account, KeyedAccount}; @@ -196,7 +196,7 @@ pub fn execute_transaction( loaders: &mut [Vec<(Pubkey, Account)>], tx_accounts: &mut [Account], tick_height: u64, -) -> Result<(), BankError> { +) -> Result<(), TransactionError> { for (instruction_index, instruction) in tx.instructions.iter().enumerate() { let executable_accounts = &mut (&mut loaders[instruction.program_ids_index as usize]); let mut program_accounts = get_subset_unchecked_mut(tx_accounts, &instruction.accounts); @@ -207,7 +207,7 @@ pub fn execute_transaction( &mut program_accounts, tick_height, ) - .map_err(|err| BankError::InstructionError(instruction_index as u8, err))?; + .map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?; } Ok(()) } diff --git a/runtime/src/status_cache.rs b/runtime/src/status_cache.rs index 186a4a07b9..2cd1cd5d71 100644 --- a/runtime/src/status_cache.rs +++ b/runtime/src/status_cache.rs @@ -167,10 +167,10 @@ impl StatusCache { #[cfg(test)] mod tests { use super::*; - use crate::bank::BankError; + use crate::bank::TransactionError; use solana_sdk::hash::hash; - type BankStatusCache = StatusCache; + type BankStatusCache = StatusCache; #[test] fn test_has_signature() { @@ -293,11 +293,11 @@ mod tests { let blockhash = hash(Hash::default().as_ref()); let mut first = StatusCache::new(&blockhash); first.add(&sig); - first.save_failure_status(&sig, BankError::DuplicateSignature); + first.save_failure_status(&sig, TransactionError::DuplicateSignature); assert_eq!(first.has_signature(&sig), true); assert_eq!( first.get_signature_status(&sig), - Some(Err(BankError::DuplicateSignature)), + Some(Err(TransactionError::DuplicateSignature)), ); } @@ -308,10 +308,10 @@ mod tests { let mut first = StatusCache::new(&blockhash); first.add(&sig); assert_eq!(first.has_signature(&sig), true); - first.save_failure_status(&sig, BankError::DuplicateSignature); + first.save_failure_status(&sig, TransactionError::DuplicateSignature); assert_eq!( first.get_signature_status(&sig), - Some(Err(BankError::DuplicateSignature)), + Some(Err(TransactionError::DuplicateSignature)), ); first.clear(); assert_eq!(first.has_signature(&sig), false); diff --git a/runtime/tests/system.rs b/runtime/tests/system.rs index 72b45e81a2..1ee7941b22 100644 --- a/runtime/tests/system.rs +++ b/runtime/tests/system.rs @@ -1,4 +1,4 @@ -use solana_runtime::bank::{Bank, BankError}; +use solana_runtime::bank::{Bank, TransactionError}; use solana_runtime::runtime::InstructionError; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::native_program::ProgramError; @@ -47,7 +47,7 @@ fn test_system_unsigned_transaction() { .sign(&[&to_keypair], blockhash); assert_eq!( system_bank.bank.process_transaction(&tx), - Err(BankError::InstructionError( + Err(TransactionError::InstructionError( 0, InstructionError::ProgramError(ProgramError::MissingRequiredSignature) ))