Skip to content

Commit

Permalink
chore: replaced vec to slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Eagle941 committed Sep 3, 2024
1 parent 6730792 commit 7eb18d6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/src/state/cached_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl<S: StateReader, V: VisitedPcs> State for CachedState<S, V> {
Ok(())
}

fn add_visited_pcs(&mut self, class_hash: ClassHash, pcs: &Vec<usize>) {
fn add_visited_pcs(&mut self, class_hash: ClassHash, pcs: &[usize]) {
self.visited_pcs.insert(&class_hash, pcs);
}
}
Expand Down
13 changes: 1 addition & 12 deletions crates/blockifier/src/state/state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub trait State: StateReader {
/// Marks the given set of PC values as visited for the given class hash.
// TODO(lior): Once we have a BlockResources object, move this logic there. Make sure reverted
// entry points do not affect the final set of PCs.
fn add_visited_pcs(&mut self, class_hash: ClassHash, pcs: &Vec<usize>);
fn add_visited_pcs(&mut self, class_hash: ClassHash, pcs: &[usize]);
}

/// A class defining the API for updating a state with transactions writes.
Expand All @@ -119,14 +119,3 @@ pub trait UpdatableState: StateReader {
visited_pcs: &Self::T,
);
}

pub trait UpdatableStatetTest: StateReader {
type T;

fn apply_writes(
&mut self,
writes: &StateMaps,
class_hash_to_class: &ContractClassMapping,
visited_pcs: &Self::T,
);
}
6 changes: 3 additions & 3 deletions crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ fn test_simulate_validate_charge_fee_pre_validate(

// Fourth scenario: L1 gas price bound lower than the price on the block.
if !is_deprecated {
let account_tx = account_invoke_tx(invoke_tx_args! {
let result = account_invoke_tx(invoke_tx_args! {
resource_bounds: l1_resource_bounds(MAX_L1_GAS_AMOUNT, u128::from(gas_price) - 1),
nonce: nonce_manager.next(account_address),
..pre_validation_base_args
});
let result = account_tx.execute(&mut state, &block_context, charge_fee, validate);
})
.execute(&mut state, &block_context, charge_fee, validate);
if !charge_fee {
check_gas_and_fee(
&block_context,
Expand Down
3 changes: 1 addition & 2 deletions crates/blockifier/src/transaction/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ pub fn run_invoke_tx(
block_context: &BlockContext,
invoke_args: InvokeTxArgs,
) -> TransactionExecutionResult<TransactionExecutionInfo> {
let account_tx = account_invoke_tx(invoke_args);
account_tx.execute(state, block_context, true, true)
account_invoke_tx(invoke_args).execute(state, block_context, true, true)
}

/// Creates a `ResourceBoundsMapping` with the given `max_amount` and `max_price` for L1 gas limits.
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ fn assert_failure_if_resource_bounds_exceed_balance(
match block_context.to_tx_context(&invalid_tx).tx_info {
TransactionInfo::Deprecated(context) => {
assert_matches!(
invalid_tx.execute( state, block_context, true, true).unwrap_err(),
invalid_tx.execute(state, block_context, true, true).unwrap_err(),
TransactionExecutionError::TransactionPreValidationError(
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::MaxFeeExceedsBalance{ max_fee, .. }))
Expand All @@ -758,7 +758,7 @@ fn assert_failure_if_resource_bounds_exceed_balance(
TransactionInfo::Current(context) => {
let l1_bounds = context.l1_resource_bounds().unwrap();
assert_matches!(
invalid_tx.execute( state, block_context, true, true).unwrap_err(),
invalid_tx.execute(state, block_context, true, true).unwrap_err(),
TransactionExecutionError::TransactionPreValidationError(
TransactionPreValidationError::TransactionFeeError(
TransactionFeeError::L1GasBoundsExceedBalance{ max_amount, max_price, .. }))
Expand Down

0 comments on commit 7eb18d6

Please sign in to comment.