diff --git a/crates/blockifier/src/bouncer.rs b/crates/blockifier/src/bouncer.rs index c1195b63eb..e5bc4f1879 100644 --- a/crates/blockifier/src/bouncer.rs +++ b/crates/blockifier/src/bouncer.rs @@ -194,20 +194,6 @@ impl Bouncer { &self.accumulated_weights } - fn _update( - &mut self, - tx_weights: BouncerWeights, - tx_execution_summary: &ExecutionSummary, - state_changes_keys: &StateChangesKeys, - ) { - self.accumulated_weights += tx_weights; - self.visited_storage_entries.extend(&tx_execution_summary.visited_storage_entries); - self.executed_class_hashes.extend(&tx_execution_summary.executed_class_hashes); - // Note: cancelling writes (0 -> 1 -> 0) will not be removed, but it's fine since fee was - // charged for them. - self.state_changes_keys.extend(state_changes_keys); - } - /// Updates the bouncer with a new transaction. pub fn try_update( &mut self, @@ -252,11 +238,25 @@ impl Bouncer { Err(TransactionExecutorError::BlockFull)? } - self._update(tx_weights, tx_execution_summary, &marginal_state_changes_keys); + self.update(tx_weights, tx_execution_summary, &marginal_state_changes_keys); Ok(()) } + fn update( + &mut self, + tx_weights: BouncerWeights, + tx_execution_summary: &ExecutionSummary, + state_changes_keys: &StateChangesKeys, + ) { + self.accumulated_weights += tx_weights; + self.visited_storage_entries.extend(&tx_execution_summary.visited_storage_entries); + self.executed_class_hashes.extend(&tx_execution_summary.executed_class_hashes); + // Note: cancelling writes (0 -> 1 -> 0) will not be removed, but it's fine since fee was + // charged for them. + self.state_changes_keys.extend(state_changes_keys); + } + #[cfg(test)] pub fn set_accumulated_weights(&mut self, weights: BouncerWeights) { self.accumulated_weights = weights; diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index 2338289f33..ea03e49e6c 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -136,7 +136,7 @@ fn test_bouncer_update(#[case] initial_bouncer: Bouncer) { StateChangesKeys::create_for_testing(HashSet::from([ContractAddress::from(1_u128)])); let mut updated_bouncer = initial_bouncer.clone(); - updated_bouncer._update( + updated_bouncer.update( weights_to_update, &execution_summary_to_update, &state_changes_keys_to_update, diff --git a/crates/native_blockifier/src/state_readers/papyrus_state.rs b/crates/native_blockifier/src/state_readers/papyrus_state.rs index 33d700c278..c80e5d7af8 100644 --- a/crates/native_blockifier/src/state_readers/papyrus_state.rs +++ b/crates/native_blockifier/src/state_readers/papyrus_state.rs @@ -40,7 +40,10 @@ impl PapyrusReader { /// Returns a V1 contract if found, or a V0 contract if a V1 contract is not /// found, or an `Error` otherwise. - fn _get_compiled_contract_class(&self, class_hash: ClassHash) -> StateResult { + fn get_compiled_contract_class_inner( + &self, + class_hash: ClassHash, + ) -> StateResult { let state_number = StateNumber(self.latest_block); let class_declaration_block_number = self .reader()? @@ -125,7 +128,7 @@ impl StateReader for PapyrusReader { match contract_class { Some(contract_class) => Ok(contract_class), None => { - let contract_class_from_db = self._get_compiled_contract_class(class_hash)?; + let contract_class_from_db = self.get_compiled_contract_class_inner(class_hash)?; // The class was declared in a previous (finalized) state; update the global cache. self.global_class_hash_to_class.set(class_hash, contract_class_from_db.clone()); Ok(contract_class_from_db)