Skip to content

Commit

Permalink
State dump always
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Oct 30, 2024
1 parent 0fcec27 commit b6253c2
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions replay/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,20 @@ fn show_execution_data(

let previous_block_number = BlockNumber(block_number - 1);

let execution_info = match execute_tx_configurable(
let execution_info = execute_tx_configurable(
state,
&tx_hash,
previous_block_number,
false,
true,
charge_fee,
) {
Ok(x) => x,
Err(error_reason) => {
error!("execution failed unexpectedly: {}", error_reason);
return;
}
};
);

#[cfg(feature = "state_dump")]
{
use std::fs::File;
use std::path::Path;

#[cfg(feature = "only_cairo_vm")]
let root = Path::new("state_dumps/vm");
#[cfg(not(feature = "only_cairo_vm"))]
Expand All @@ -304,9 +300,27 @@ fn show_execution_data(
let mut path = root.join(&tx_hash);
path.set_extension("json");

state_dump::dump_state_diff(state, &execution_info, &path).unwrap();
match &execution_info {
Ok(execution_info) => {
state_dump::dump_state_diff(state, &execution_info, &path).unwrap();
}
Err(err) => {
// If we have no execution info, we write the error to a file so that it can be compared anyway
let file = File::create(path).unwrap();
let err = err.to_string();
serde_json::to_writer_pretty(file, &err).unwrap();
}
}
}

let execution_info = match execution_info {
Ok(x) => x,
Err(error_reason) => {
error!("execution failed unexpectedly: {}", error_reason);
return;
}
};

let transaction_hash = TransactionHash(StarkHash::from_hex(&tx_hash).unwrap());
match state.state.get_transaction_receipt(&transaction_hash) {
Ok(rpc_receipt) => {
Expand Down

0 comments on commit b6253c2

Please sign in to comment.