From 92ae67a651165ba9dfddc0a6cecbcadf8957e4e1 Mon Sep 17 00:00:00 2001 From: Brandon Kite Date: Thu, 17 Feb 2022 06:57:44 -0700 Subject: [PATCH 1/3] always save receipts even on panic --- fuel-core/src/executor.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fuel-core/src/executor.rs b/fuel-core/src/executor.rs index 06942d72048..c7c06ed4098 100644 --- a/fuel-core/src/executor.rs +++ b/fuel-core/src/executor.rs @@ -48,13 +48,19 @@ impl Executor { // execute vm let mut vm = Transactor::new(tx_db.clone()); vm.transact(tx); + + // only commit state changes if execution was a success + if !result.should_revert() { + sub_tx.commit()?; + } + match vm.result() { Ok(result) => { // persist any outputs - self.persist_outputs(block.fuel_height, result.tx(), tx_db)?; + self.persist_outputs(block.fuel_height, result.tx(), block_tx.deref_mut())?; // persist receipts - self.persist_receipts(tx_id, result.receipts(), tx_db)?; + self.persist_receipts(tx_id, result.receipts(), block_tx.deref_mut())?; let status = if result.should_revert() { if config.backtrace { @@ -104,14 +110,9 @@ impl Executor { // persist tx status at the block level block_tx.update_tx_status(tx_id, status)?; - - // only commit state changes if execution was a success - if !result.should_revert() { - sub_tx.commit()?; - } } Err(e) => { - // save error status on block_tx since the sub_tx changes are dropped + // save error status on block_tx block_tx.update_tx_status( tx_id, TransactionStatus::Failed { From 014e2ae1072ed3b39286880203084770452e7238 Mon Sep 17 00:00:00 2001 From: vnepveu Date: Thu, 17 Feb 2022 15:39:20 +0100 Subject: [PATCH 2/3] fix: commit transaction success --- fuel-core/src/executor.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fuel-core/src/executor.rs b/fuel-core/src/executor.rs index c7c06ed4098..f58931a438e 100644 --- a/fuel-core/src/executor.rs +++ b/fuel-core/src/executor.rs @@ -49,13 +49,13 @@ impl Executor { let mut vm = Transactor::new(tx_db.clone()); vm.transact(tx); - // only commit state changes if execution was a success - if !result.should_revert() { - sub_tx.commit()?; - } match vm.result() { Ok(result) => { + // only commit state changes if execution was a success + if !result.should_revert() { + sub_tx.commit()?; + } // persist any outputs self.persist_outputs(block.fuel_height, result.tx(), block_tx.deref_mut())?; From cd8684043025bbec1f46d76e9c56372423f57fb2 Mon Sep 17 00:00:00 2001 From: vnepveu Date: Thu, 17 Feb 2022 16:11:24 +0100 Subject: [PATCH 3/3] style: remove newline for rustfmt --- fuel-core/src/executor.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/fuel-core/src/executor.rs b/fuel-core/src/executor.rs index f58931a438e..6e0da2fc387 100644 --- a/fuel-core/src/executor.rs +++ b/fuel-core/src/executor.rs @@ -49,7 +49,6 @@ impl Executor { let mut vm = Transactor::new(tx_db.clone()); vm.transact(tx); - match vm.result() { Ok(result) => { // only commit state changes if execution was a success