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

Commit

Permalink
refactor(execution, native_blockifier): move pre_process_block to PyB…
Browse files Browse the repository at this point in the history
…lockExecutor
  • Loading branch information
barak-b-starkware committed Feb 5, 2024
1 parent 1ba0733 commit d8abfd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
9 changes: 7 additions & 2 deletions crates/native_blockifier/src/py_block_executor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::sync::Arc;

use blockifier::block::{BlockInfo, GasPrices};
use blockifier::block::{pre_process_block, BlockInfo, BlockNumberHashPair, GasPrices};
use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses};
use blockifier::state::cached_state::{GlobalContractCache, GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST};
use blockifier::transaction::objects::TransactionExecutionInfo;
Expand Down Expand Up @@ -139,7 +139,12 @@ impl PyBlockExecutor {
&mut self,
old_block_number_and_hash: Option<(u64, PyFelt)>,
) -> NativeBlockifierResult<()> {
self.tx_executor().pre_process_block(old_block_number_and_hash)
let old_block_number_and_hash = old_block_number_and_hash
.map(|(block_number, block_hash)| BlockNumberHashPair::new(block_number, block_hash.0));
let state = &mut self.tx_executor().state;
pre_process_block(state, old_block_number_and_hash)?;

Ok(())
}

pub fn commit_tx(&mut self) {
Expand Down
15 changes: 0 additions & 15 deletions crates/native_blockifier/src/transaction_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use std::vec::IntoIter;

use blockifier::block::{pre_process_block, BlockNumberHashPair};
use blockifier::context::BlockContext;
use blockifier::execution::call_info::{CallInfo, MessageL1CostInfo};
use blockifier::execution::entry_point::ExecutionResources;
Expand All @@ -26,7 +25,6 @@ use crate::errors::{NativeBlockifierError, NativeBlockifierResult};
use crate::py_block_executor::{into_block_context, PyGeneralConfig};
use crate::py_state_diff::PyBlockInfo;
use crate::py_transaction_execution_info::PyBouncerInfo;
use crate::py_utils::PyFelt;

pub(crate) type RawTransactionExecutionInfo = Vec<u8>;

Expand Down Expand Up @@ -203,19 +201,6 @@ impl<S: StateReader> TransactionExecutor<S> {
(self.state.to_state_diff(), visited_pcs)
}

// Block pre-processing; see `block::pre_process_block` documentation.
pub fn pre_process_block(
&mut self,
old_block_number_and_hash: Option<(u64, PyFelt)>,
) -> NativeBlockifierResult<()> {
let old_block_number_and_hash = old_block_number_and_hash
.map(|(block_number, block_hash)| BlockNumberHashPair::new(block_number, block_hash.0));

pre_process_block(&mut self.state, old_block_number_and_hash)?;

Ok(())
}

pub fn commit(&mut self) {
let Some(finalized_transactional_state) = self.staged_for_commit_state.take() else {
panic!("commit called without a transactional state")
Expand Down

0 comments on commit d8abfd0

Please sign in to comment.