diff --git a/rpc-client-api/src/config.rs b/rpc-client-api/src/config.rs index 05e97b9594..dbefc95137 100644 --- a/rpc-client-api/src/config.rs +++ b/rpc-client-api/src/config.rs @@ -49,8 +49,14 @@ pub struct RpcSimulateTransactionConfig { #[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] #[serde(rename_all = "camelCase")] pub enum SimulationSlotConfig { + /// Simulate on top of bank with the provided commitment. Commitment(CommitmentConfig), + + /// Simulate on the provided slot's bank. Slot(Slot), + + /// Simulates on top of the RPC's highest slot's bank i.e. the working bank. + Tip, } impl Default for SimulationSlotConfig { diff --git a/rpc-client/src/nonblocking/rpc_client.rs b/rpc-client/src/nonblocking/rpc_client.rs index f8201e4215..bb1c7fa21e 100644 --- a/rpc-client/src/nonblocking/rpc_client.rs +++ b/rpc-client/src/nonblocking/rpc_client.rs @@ -5446,6 +5446,7 @@ impl RpcClient { T: serde::de::DeserializeOwned, { let response = self.sender.send_batch(requests_and_params).await?; + debug!("response: {:?}", response); serde_json::from_value(response).map_err(|err| ClientError { request: None, diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 605240a572..63a8e2afe5 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -4036,6 +4036,7 @@ pub mod rpc_full { SimulationSlotConfig::Slot(slot) => meta.bank_from_slot(slot).ok_or_else(|| { Error::invalid_params(format!("bank not found for the provided slot: {}", slot)) }), + SimulationSlotConfig::Tip => Ok(meta.bank_forks.read().unwrap().working_bank()), }?; // TODO: Come back to this and allow unfrozen bank as long as the parent is frozen. diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 22e016a1e0..2742b3f1cc 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3851,24 +3851,9 @@ impl Bank { pre_execution_accounts_requested: Vec>>, post_execution_accounts_requested: Vec>>, ) -> result::Result> { - assert!(self.is_frozen(), "simulation bank must be frozen"); assert_eq!(pre_execution_accounts_requested.len(), bundle.len()); assert_eq!(post_execution_accounts_requested.len(), bundle.len()); - self.simulate_bundle_unchecked( - bundle, - pre_execution_accounts_requested, - post_execution_accounts_requested, - ) - } - - /// Run transactions against a bank without committing the results; does not check if the bank is frozen. - fn simulate_bundle_unchecked( - &self, - bundle: Vec, - pre_execution_accounts_requested: Vec>>, - post_execution_accounts_requested: Vec>>, - ) -> result::Result> { // Used to cache account data in between batch execution iterations let mut account_overrides = AccountOverrides::default(); @@ -9020,14 +9005,6 @@ pub(crate) mod tests { assert_eq!(account, bank.get_account(&pubkey).unwrap()); } - #[test] - #[should_panic] - fn test_simulate_bundle_unfrozen_bank() { - let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000); - let bank = Bank::new_for_tests(&genesis_config); - let _ = bank.simulate_bundle(vec![], vec![], vec![]); - } - #[test] #[should_panic] fn test_simulate_bundle_mismatched_lengths() {