diff --git a/rpc-client/src/nonblocking/rpc_client.rs b/rpc-client/src/nonblocking/rpc_client.rs index bb1c7fa21e..1ea8d7dd59 100644 --- a/rpc-client/src/nonblocking/rpc_client.rs +++ b/rpc-client/src/nonblocking/rpc_client.rs @@ -1473,6 +1473,8 @@ impl RpcClient { bundle, RpcSimulateBundleConfig { simulation_bank: Some(SimulationSlotConfig::Commitment(self.commitment())), + pre_execution_accounts_configs: vec![None; bundle.transactions.len()], + post_execution_accounts_configs: vec![None; bundle.transactions.len()], ..RpcSimulateBundleConfig::default() }, ) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 2e7918fcba..085cf79b06 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -3441,6 +3441,7 @@ pub mod rpc_full { super::*, crate::rpc::utils::{build_simulate_bundle_params, rpc_bundle_result_from_bank_result}, itertools::izip, + solana_runtime::bank::SimulateBundleError, solana_sdk::message::{SanitizedVersionedMessage, VersionedMessage}, }; @@ -3606,6 +3607,14 @@ pub mod rpc_full { ) -> Result>; } + fn jsonrpc_error_from_simulate_bundle_error(e: SimulateBundleError) -> Error { + match e { + SimulateBundleError::AccountNotFoundInBank(pubkey) => { + Error::invalid_params(format!("account {:?} not found in bank", pubkey)) + } + } + } + pub struct FullImpl; impl Full for FullImpl { type Metadata = JsonRpcRequestProcessor; @@ -4084,10 +4093,7 @@ pub mod rpc_full { let bank_result = bank .simulate_bundle(sanitized_txs, pre_execution_pks, post_execution_pks) - .map_err(|e| { - error!("bank error {}", e); - Error::internal_error() - })?; + .map_err(jsonrpc_error_from_simulate_bundle_error)?; let rpc_bundle_result = rpc_bundle_result_from_bank_result(bank_result, config)?; diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 2742b3f1cc..b91132272c 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -158,7 +158,6 @@ use { cmp::min, collections::{HashMap, HashSet}, convert::{TryFrom, TryInto}, - error::Error, fmt, mem, ops::{Deref, RangeInclusive}, path::PathBuf, @@ -174,6 +173,7 @@ use { thread::Builder, time::{Duration, Instant}, }, + thiserror::Error, }; /// params to `verify_bank_hash` @@ -523,6 +523,12 @@ pub struct BundleSimulationResult { pub transaction_results: Vec, } +#[derive(Error, Debug)] +pub enum SimulateBundleError { + #[error("account missing from bank: {0}")] + AccountNotFoundInBank(Pubkey), +} + #[derive(Clone)] pub struct BundleTransactionSimulationResult { pub result: Result<()>, @@ -3850,7 +3856,7 @@ impl Bank { bundle: Vec, pre_execution_accounts_requested: Vec>>, post_execution_accounts_requested: Vec>>, - ) -> result::Result> { + ) -> result::Result { assert_eq!(pre_execution_accounts_requested.len(), bundle.len()); assert_eq!(post_execution_accounts_requested.len(), bundle.len()); @@ -3920,8 +3926,7 @@ impl Bank { Ok(data) } else { self.get_account(pubkey) - // TODO(seg): let's use a concrete error type - .ok_or(format!("pubkey {} does not exist", pubkey)) + .ok_or(SimulateBundleError::AccountNotFoundInBank(*pubkey)) }?; pre_accounts.push(AccountData { pubkey: *pubkey,