From 546e191e8a9f081f83c0a9357497b93d28fc0275 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Wed, 26 Apr 2023 17:11:30 +0300 Subject: [PATCH] fix(tree): atomical execution unwind (#2412) --- crates/storage/provider/src/transaction.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/storage/provider/src/transaction.rs b/crates/storage/provider/src/transaction.rs index 40c6961d41..b9717701e8 100644 --- a/crates/storage/provider/src/transaction.rs +++ b/crates/storage/provider/src/transaction.rs @@ -916,10 +916,10 @@ where for (address, (account, storage)) in local_plain_state.into_iter() { // revert account if let Some(account) = account { - plain_accounts_cursor.seek_exact(address)?; + let existing_entry = plain_accounts_cursor.seek_exact(address)?; if let Some(account) = account { plain_accounts_cursor.upsert(address, account)?; - } else { + } else if existing_entry.is_some() { plain_accounts_cursor.delete_current()?; } } @@ -940,7 +940,7 @@ where // TODO: This does not use dupsort features // insert value if needed if storage_value != U256::ZERO { - plain_storage_cursor.insert(address, storage_entry)?; + plain_storage_cursor.upsert(address, storage_entry)?; } } }