|
2 | 2 |
|
3 | 3 | use crate::util::{create_execution_context, BatchToExecute, BlockExecutionContext, ExecutionStats}; |
4 | 4 | use anyhow::Context; |
5 | | -use blockifier::{blockifier::transaction_executor::TransactionExecutor, state::state_api::State}; |
| 5 | +use blockifier::blockifier::transaction_executor::TransactionExecutor; |
6 | 6 | use futures::future::OptionFuture; |
7 | 7 | use mc_db::MadaraBackend; |
8 | | -use mc_exec::{execution::TxInfo, LayeredStateAdapter, MadaraBackendExecutionExt}; |
| 8 | +use mc_exec::{execution::TxInfo, LayeredStateAdapter}; |
9 | 9 | use mp_convert::{Felt, ToFelt}; |
10 | 10 | use starknet_api::contract_class::ContractClass; |
11 | 11 | use starknet_api::core::ClassHash; |
@@ -220,29 +220,14 @@ impl ExecutorThread { |
220 | 220 | previous_l2_gas_used, |
221 | 221 | )?; |
222 | 222 |
|
223 | | - // Create the TransactionExecution, but reuse the layered_state_adapter. |
224 | | - let mut executor = |
225 | | - self.backend.new_executor_for_block_production(state.state_adaptor, exec_ctx.to_blockifier()?)?; |
226 | | - |
227 | | - // Prepare the block_n-10 state diff entry on the 0x1 contract. |
228 | | - if let Some((block_n_min_10, block_hash_n_min_10)) = |
229 | | - self.wait_for_hash_of_block_min_10(exec_ctx.block_number)? |
230 | | - { |
231 | | - let contract_address = 1u64.into(); |
232 | | - let key = block_n_min_10.into(); |
233 | | - executor |
234 | | - .block_state |
235 | | - .as_mut() |
236 | | - .expect("Blockifier block context has been taken") |
237 | | - .set_storage_at(contract_address, key, block_hash_n_min_10) |
238 | | - .context("Cannot set storage value in cache")?; |
| 223 | + // Create the TransactionExecutor with block_n-10 handling, reusing the layered_state_adapter. |
| 224 | + let executor = crate::util::create_executor_with_block_n_min_10( |
| 225 | + &self.backend, |
| 226 | + &exec_ctx, |
| 227 | + state.state_adaptor, |
| 228 | + |block_n| self.wait_for_hash_of_block_min_10(block_n), |
| 229 | + )?; |
239 | 230 |
|
240 | | - tracing::debug!( |
241 | | - "State diff inserted {:#x} {:#x} => {block_hash_n_min_10:#x}", |
242 | | - contract_address.to_felt(), |
243 | | - key.to_felt() |
244 | | - ); |
245 | | - } |
246 | 231 | Ok(ExecutorStateExecuting { |
247 | 232 | exec_ctx, |
248 | 233 | executor, |
@@ -433,7 +418,11 @@ impl ExecutorThread { |
433 | 418 | ); |
434 | 419 | let block_exec_summary = execution_state.executor.finalize()?; |
435 | 420 |
|
436 | | - if self.replies_sender.blocking_send(super::ExecutorMessage::EndBlock(Box::new(block_exec_summary))).is_err() { |
| 421 | + if self |
| 422 | + .replies_sender |
| 423 | + .blocking_send(super::ExecutorMessage::EndBlock(Box::new(block_exec_summary))) |
| 424 | + .is_err() |
| 425 | + { |
437 | 426 | // Receiver closed |
438 | 427 | break Ok(()); |
439 | 428 | } |
|
0 commit comments