Skip to content
Snippets Groups Projects
Unverified Commit 4fd4427f authored by Alexander Theißen's avatar Alexander Theißen
Browse files

Do not clone pending changes

Discarding prospective changes should be equivalent as a state machine
is not to be called with peding changes.

This will be replaced by a storage transaction that is rolled back before
executing the call the second time removing this constraint.
parent 8874a8ed
No related merge requests found
......@@ -345,11 +345,10 @@ impl<'a, B, H, N, Exec> StateMachine<'a, B, H, N, Exec> where
CallResult<R, Exec::Error>,
) -> CallResult<R, Exec::Error>
{
let pending_changes = self.overlay.clone_pending();
let (result, was_native) = self.execute_aux(true, native_call.take());
if was_native {
self.overlay.set_pending(pending_changes);
self.overlay.discard_prospective();
let (wasm_result, _) = self.execute_aux(
false,
native_call,
......@@ -376,7 +375,6 @@ impl<'a, B, H, N, Exec> StateMachine<'a, B, H, N, Exec> where
R: Decode + Encode + PartialEq,
NC: FnOnce() -> result::Result<R, String> + UnwindSafe,
{
let pending_changes = self.overlay.clone_pending();
let (result, was_native) = self.execute_aux(
true,
native_call.take(),
......@@ -385,7 +383,7 @@ impl<'a, B, H, N, Exec> StateMachine<'a, B, H, N, Exec> where
if !was_native || result.is_ok() {
result
} else {
self.overlay.set_pending(pending_changes);
self.overlay.discard_prospective();
let (wasm_result, _) = self.execute_aux(
false,
native_call,
......
......@@ -535,16 +535,6 @@ impl OverlayedChanges {
committed.into_iter().flatten().chain(prospective.into_iter().flatten())
}
/// Return a clone of the currently pending changes.
pub fn clone_pending(&self) -> OverlayedChangeSet {
self.prospective.clone()
}
/// Replace the currently pending changes.
pub fn set_pending(&mut self, pending: OverlayedChangeSet) {
self.prospective = pending;
}
/// Convert this instance with all changes into a [`StorageChanges`] instance.
pub fn into_storage_changes<
B: Backend<H>, H: Hasher, N: BlockNumber
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment