Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
refactor: remove underscore prefix from functions (#1962)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware authored Jun 6, 2024
1 parent 0048d03 commit 27635f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
30 changes: 15 additions & 15 deletions crates/blockifier/src/bouncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S: StateReader>(
&mut self,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/bouncer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions crates/native_blockifier/src/state_readers/papyrus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContractClass> {
fn get_compiled_contract_class_inner(
&self,
class_hash: ClassHash,
) -> StateResult<ContractClass> {
let state_number = StateNumber(self.latest_block);
let class_declaration_block_number = self
.reader()?
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 27635f2

Please sign in to comment.