From 9127b65a6901819941eaa0c9b34f66db1c8d6a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Wed, 30 Oct 2024 16:20:18 -0300 Subject: [PATCH 1/2] State dump always --- replay/src/main.rs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/replay/src/main.rs b/replay/src/main.rs index ae09a87..7dc3b2d 100644 --- a/replay/src/main.rs +++ b/replay/src/main.rs @@ -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"))] @@ -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) => { From 96a193633fa63a11b3b5267013de1c2bc534ebb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Wed, 30 Oct 2024 16:21:41 -0300 Subject: [PATCH 2/2] Fix error message --- replay/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replay/src/main.rs b/replay/src/main.rs index 7dc3b2d..3546bb0 100644 --- a/replay/src/main.rs +++ b/replay/src/main.rs @@ -316,7 +316,7 @@ fn show_execution_data( let execution_info = match execution_info { Ok(x) => x, Err(error_reason) => { - error!("execution failed unexpectedly: {}", error_reason); + error!("execution failed: {}", error_reason); return; } };