Skip to content

Commit f1328c0

Browse files
authored
chore: make artificially shortened executions count as successes (matter-labs#3204)
Currently, successful validations are reported as reverts, which is super confusing. Why this is safe: - `TracerExecutionStopReason::Finished` is only emitted on success, Errors always emit Abort instead - Some of the removed code was just dead code. `self.result` was checked twice. I'd rather fix the strange behaviour than emulate it to make ShadowVm line up.
1 parent 9ad1f0d commit f1328c0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ impl<S: WriteStorage, H: HistoryMode> Tracer for DefaultExecutionTracer<S, H> {
228228
);
229229

230230
match hook {
231-
VmHook::TxHasEnded => self.tx_has_been_processed = true,
231+
VmHook::TxHasEnded if matches!(self.execution_mode, VmExecutionMode::OneTx) => {
232+
self.result_tracer.tx_finished_in_one_tx_mode = true;
233+
self.tx_has_been_processed = true;
234+
}
232235
VmHook::NoValidationEntered => self.in_account_validation = false,
233236
VmHook::AccountValidationEntered => self.in_account_validation = true,
234237
VmHook::FinalBatchInfo => self.final_batch_info_requested = true,

core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ pub(crate) struct ResultTracer<S> {
104104
far_call_tracker: FarCallTracker,
105105
subversion: MultiVMSubversion,
106106

107+
pub(crate) tx_finished_in_one_tx_mode: bool,
108+
107109
_phantom: PhantomData<S>,
108110
}
109111

@@ -115,6 +117,7 @@ impl<S> ResultTracer<S> {
115117
execution_mode,
116118
far_call_tracker: Default::default(),
117119
subversion,
120+
tx_finished_in_one_tx_mode: false,
118121
_phantom: PhantomData,
119122
}
120123
}
@@ -297,7 +300,7 @@ impl<S: WriteStorage> ResultTracer<S> {
297300

298301
let has_failed =
299302
tx_has_failed(state, bootloader_state.current_tx() as u32, self.subversion);
300-
if has_failed {
303+
if self.tx_finished_in_one_tx_mode && has_failed {
301304
self.result = Some(Result::Error {
302305
error_reason: VmRevertReason::General {
303306
msg: "Transaction reverted with empty reason. Possibly out of gas"
@@ -306,9 +309,9 @@ impl<S: WriteStorage> ResultTracer<S> {
306309
},
307310
});
308311
} else {
309-
self.result = Some(self.result.clone().unwrap_or(Result::Success {
312+
self.result = Some(Result::Success {
310313
return_data: vec![],
311-
}));
314+
});
312315
}
313316
}
314317
}

0 commit comments

Comments
 (0)