Skip to content

Commit 84974e6

Browse files
authored
Merge pull request #6277 from csgui/fix/function-context-rollback
[clarity-wasm] fix function context rollback
2 parents 86af212 + b299de5 commit 84974e6

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clarity/src/vm/clarity_wasm.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -428,28 +428,11 @@ pub fn initialize_contract(
428428
results.push(placeholder_for_type(result_ty));
429429
}
430430

431-
let top_level_result = top_level.call(&mut store, &[], results.as_mut_slice());
432-
match top_level_result {
433-
Ok(_) => {}
434-
Err(e) => {
435-
// Before propagating the error, attempt to roll back the function context.
436-
// If the rollback fails, immediately return a rollback-specific error.
437-
if store.data_mut().global_context.roll_back().is_err() {
438-
return Err(Error::Wasm(WasmError::Expect(
439-
"Expected entry to rollback".into(),
440-
)));
441-
}
442-
443-
// Rollback succeeded, so resolve and return the original runtime error.
444-
return Err(error_mapping::resolve_error(
445-
e,
446-
instance,
447-
&mut store,
448-
&epoch,
449-
&clarity_version,
450-
));
451-
}
452-
}
431+
top_level
432+
.call(&mut store, &[], results.as_mut_slice())
433+
.map_err(|e| {
434+
error_mapping::resolve_error(e, instance, &mut store, &epoch, &clarity_version)
435+
})?;
453436

454437
// Save the compiled Wasm module into the contract context
455438
store.data_mut().contract_context_mut()?.set_wasm_module(

0 commit comments

Comments
 (0)