From 150cd31ec0ea19b93821f98f94d95def2b43250f Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Wed, 13 Mar 2019 13:51:40 -0600 Subject: [PATCH] Blur the line between Bank and Runtime --- runtime/src/bank.rs | 8 ++------ runtime/src/runtime.rs | 12 +++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 52add6813..f27aed831 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -5,7 +5,7 @@ use crate::accounts::{Accounts, ErrorCounters, InstructionAccounts, InstructionLoaders}; use crate::hash_queue::HashQueue; -use crate::runtime::{self, InstructionError, TransactionError}; +use crate::runtime::{self, InstructionError}; use crate::status_cache::StatusCache; use bincode::serialize; use hashbrown::HashMap; @@ -569,11 +569,7 @@ impl Bank { .map(|(accs, tx)| match accs { Err(e) => Err(e.clone()), Ok((ref mut accounts, ref mut loaders)) => { - runtime::execute_transaction(tx, loaders, accounts, tick_height).map_err( - |TransactionError::InstructionError(index, err)| { - BankError::InstructionError(index, err) - }, - ) + runtime::execute_transaction(tx, loaders, accounts, tick_height) } }) .collect(); diff --git a/runtime/src/runtime.rs b/runtime/src/runtime.rs index db2962e45..6ca138a61 100644 --- a/runtime/src/runtime.rs +++ b/runtime/src/runtime.rs @@ -1,3 +1,4 @@ +use crate::bank::BankError; use crate::native_loader; use crate::system_program::SystemError; use solana_sdk::account::{create_keyed_accounts, Account, KeyedAccount}; @@ -33,13 +34,6 @@ impl InstructionError { } } -/// Reasons the runtime might have rejected a transaction. -#[derive(Debug, PartialEq, Eq, Clone)] -pub enum TransactionError { - /// Executing the instruction at the given index produced an error. - InstructionError(u8, InstructionError), -} - /// Process an instruction /// This method calls the instruction's program entrypoint method fn process_instruction( @@ -202,7 +196,7 @@ pub fn execute_transaction( loaders: &mut [Vec<(Pubkey, Account)>], tx_accounts: &mut [Account], tick_height: u64, -) -> Result<(), TransactionError> { +) -> Result<(), BankError> { 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); @@ -213,7 +207,7 @@ pub fn execute_transaction( &mut program_accounts, tick_height, ) - .map_err(|err| TransactionError::InstructionError(instruction_index as u8, err))?; + .map_err(|err| BankError::InstructionError(instruction_index as u8, err))?; } Ok(()) }