Skip to content

Commit

Permalink
make call immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Dec 15, 2024
1 parent 2151459 commit e9fbf13
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
6 changes: 1 addition & 5 deletions crates/evm/evm/src/executors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ impl Executor {

#[inline]
pub fn set_transaction_other_fields(&mut self, other_fields: OtherFields) {
println!("SET CONTEXT");
self.strategy
.try_lock()
.expect("failed acquiring strategy")
Expand Down Expand Up @@ -450,11 +451,6 @@ impl Executor {
}

/// Execute the transaction configured in `env.tx`.
///
/// Executes the configured transaction of the `env` without committing state changes
///
/// Note: in case there are any cheatcodes executed that modify the environment, this will
/// update the given `env` with the new values.
#[instrument(name = "transact", level = "debug", skip_all)]
pub fn transact_with_env(&mut self, mut env: EnvWithHandlerCfg) -> eyre::Result<RawCallResult> {
let mut inspector = self.inspector.clone();
Expand Down
5 changes: 3 additions & 2 deletions crates/evm/evm/src/executors/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait ExecutorStrategy: Debug + Send + Sync {
fn set_inspect_context(&mut self, other_fields: OtherFields);

fn call_inspect(
&mut self,
&self,
db: &mut dyn DatabaseExt,
env: &mut EnvWithHandlerCfg,
inspector: &mut dyn InspectorExt,
Expand Down Expand Up @@ -85,7 +85,7 @@ impl ExecutorStrategy for EvmExecutorStrategy {
/// Note: in case there are any cheatcodes executed that modify the environment, this will
/// update the given `env` with the new values.
fn call_inspect(
&mut self,
&self,
db: &mut dyn DatabaseExt,
env: &mut EnvWithHandlerCfg,
inspector: &mut dyn InspectorExt,
Expand All @@ -100,6 +100,7 @@ impl ExecutorStrategy for EvmExecutorStrategy {
}

/// Executes the configured test call of the `env` without committing state changes.
/// Modifications to the state are however allowed.
///
/// Note: in case there are any cheatcodes executed that modify the environment, this will
/// update the given `env` with the new values.
Expand Down
1 change: 1 addition & 0 deletions crates/script/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub async fn send_transaction(
} else {
None
};
println!("ZK_TX {zk_tx_meta:#?}");

if let SendTransactionKind::Raw(tx, _) | SendTransactionKind::Unlocked(tx) = &mut kind {
if sequential_broadcast {
Expand Down
1 change: 1 addition & 0 deletions crates/script/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ impl ScriptRunner {
authorization_list: Option<Vec<SignedAuthorization>>,
other_fields: Option<OtherFields>,
) -> Result<ScriptResult> {
println!("others {:?}", other_fields);
if let Some(other_fields) = other_fields {
self.executor.set_transaction_other_fields(other_fields);
}
Expand Down
10 changes: 5 additions & 5 deletions crates/strategy/zksync/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ impl ExecutorStrategy for ZksyncExecutorStrategy {
}

fn call_inspect(
&mut self,
&self,
db: &mut dyn DatabaseExt,
env: &mut EnvWithHandlerCfg,
inspector: &mut dyn InspectorExt,
) -> eyre::Result<ResultAndState> {
match self.inspect_context.take() {
match self.inspect_context.as_ref() {
None => self.evm.call_inspect(db, env, inspector),
Some(zk_tx) => foundry_zksync_core::vm::transact(
Some(&mut self.persisted_factory_deps),
Some(zk_tx.factory_deps),
zk_tx.paymaster_data,
Some(&mut self.persisted_factory_deps.clone()),
Some(zk_tx.factory_deps.clone()),
zk_tx.paymaster_data.clone(),
env,
db,
),
Expand Down
2 changes: 2 additions & 0 deletions crates/test-utils/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,8 @@ impl TestCommand {
#[track_caller]
pub fn assert(&mut self) -> OutputAssert {
let assert = OutputAssert::new(self.execute());

std::thread::sleep(std::time::Duration::new(60, 0));
if self.redact_output {
return assert.with_assert(test_assert());
};
Expand Down

0 comments on commit e9fbf13

Please sign in to comment.