Skip to content

Commit

Permalink
fix regression in transact
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Jul 12, 2024
1 parent 3c97a7c commit 238f330
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
6 changes: 3 additions & 3 deletions crates/zksync/core/src/vm/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
let mut aggregated_result: Option<ZKVMExecutionResult> = None;

for (idx, tx) in txns.into_iter().enumerate() {
info!("executing batched tx ({}/{})", idx, total_txns);
info!("executing batched tx ({}/{})", idx + 1, total_txns);
let mut result = inspect(tx, ecx, ccx, call_ctx.clone())?;

match (&mut aggregated_result, result.execution_result) {
Expand Down Expand Up @@ -512,7 +512,7 @@ pub fn batch_factory_dependencies(mut factory_deps: Vec<Vec<u8>>) -> Vec<Vec<Vec
let factory_deps_count = factory_deps.len();
let factory_deps_sizes = factory_deps.iter().map(|dep| dep.len()).collect_vec();
let factory_deps_total_size = factory_deps_sizes.iter().sum::<usize>();
tracing::debug!(count=factory_deps_count, total=factory_deps_total_size, sizes=?factory_deps_sizes, "optimizing factory_deps");
tracing::info!(count=factory_deps_count, total=factory_deps_total_size, sizes=?factory_deps_sizes, "optimizing factory_deps");

let mut batches = vec![];
let mut current_batch = vec![];
Expand Down Expand Up @@ -542,7 +542,7 @@ pub fn batch_factory_dependencies(mut factory_deps: Vec<Vec<u8>>) -> Vec<Vec<Vec
let batch_cumulative_sizes =
batches.iter().map(|deps| deps.iter().map(|dep| dep.len()).sum::<usize>()).collect_vec();
let batch_total_size = batch_cumulative_sizes.iter().sum::<usize>();
tracing::debug!(count=batch_count, total=batch_total_size, sizes=?batch_cumulative_sizes, batched_sizes=?batch_individual_sizes, "optimized factory_deps into batches");
tracing::info!(count=batch_count, total=batch_total_size, sizes=?batch_cumulative_sizes, batched_sizes=?batch_individual_sizes, "optimized factory_deps into batches");

batches
}
Expand Down
16 changes: 5 additions & 11 deletions crates/zksync/core/src/vm/runner.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use foundry_zksync_compiler::DualCompiledContract;
use itertools::Itertools;
use revm::{
interpreter::{CallInputs, CallScheme, CallValue, CreateInputs},
precompile::{PrecompileSpecId, Precompiles},
primitives::{
Address, CreateScheme, Env, ResultAndState, SpecId, TransactTo, B256, U256 as rU256,
},
Database, EvmContext, JournaledState,
primitives::{Address, CreateScheme, Env, ResultAndState, TransactTo, B256, U256 as rU256},
Database, EvmContext,
};
use tracing::{debug, error, info};
use zksync_basic_types::H256;
Expand Down Expand Up @@ -37,11 +35,7 @@ where
DB: Database + Send,
<DB as Database>::Error: Send + Debug,
{
debug!(calldata = ?env.tx.data, fdeps = factory_deps.as_ref().map(|v| v.len()).unwrap_or_default(), "zk transact");
let mut journaled_state = JournaledState::new(
SpecId::LATEST,
Precompiles::new(PrecompileSpecId::LATEST).addresses().copied().collect(),
);
info!(calldata = ?env.tx.data, fdeps = factory_deps.as_ref().map(|deps| deps.iter().map(|dep| dep.len()).join(",")).unwrap_or_default(), "zk transact");

let mut ecx = EvmContext::new_with_env(db, Box::new(env.clone()));
let caller = env.tx.caller;
Expand Down Expand Up @@ -85,7 +79,7 @@ where

match inspect::<_, DB::Error>(tx, &mut ecx, &mut ccx, call_ctx) {
Ok(ZKVMExecutionResult { execution_result: result, .. }) => {
Ok(ResultAndState { result, state: journaled_state.finalize().0 })
Ok(ResultAndState { result, state: ecx.journaled_state.finalize().0 })
}
Err(err) => eyre::bail!("zk backend: failed while inspecting: {err:?}"),
}
Expand Down

0 comments on commit 238f330

Please sign in to comment.