Skip to content

Commit

Permalink
proper call with vm-backtrace
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Jan 20, 2022
1 parent 8355743 commit 0140dff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fuel-client/tests/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ async fn get_transactions_from_manual_blcoks() {
};

// process blocks and save block height
executor.execute(&first_test_block).await.unwrap();
executor.execute(&second_test_block).await.unwrap();
executor.execute(&first_test_block, false).await.unwrap();
executor.execute(&second_test_block, false).await.unwrap();

// Query for first 3: [0,1,2]
let page_request_forwards = PaginationRequest {
Expand Down
14 changes: 7 additions & 7 deletions fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use fuel_asm::Word;
use fuel_storage::Storage;
use fuel_tx::{Address, Bytes32, Color, Input, Output, Receipt, Transaction, UtxoId};
use fuel_vm::{
consts::REG_SP,
prelude::{Backtrace as FuelBacktrace, Interpreter, InterpreterError},
consts::REG_SP, transactor::Transactor,
prelude::{Backtrace as FuelBacktrace, InterpreterError},
};
use std::error::Error as StdError;
use std::ops::DerefMut;
Expand Down Expand Up @@ -44,9 +44,9 @@ impl Executor {
self.persist_owners_index(block.fuel_height, &tx, tx_id, idx, block_tx.deref_mut())?;

// execute vm
let mut vm = Interpreter::with_storage(tx_db.clone());
let result = vm.transact(tx);
match result {
let mut vm = Transactor::new(tx_db.clone());
let vm = vm.transact(tx);
match vm.result() {
Ok(result) => {
// persist any outputs
self.persist_outputs(block.fuel_height, result.tx(), tx_db)?;
Expand Down Expand Up @@ -96,21 +96,21 @@ impl Executor {
sub_tx.commit()?;
}
}
// save error status on block_tx since the sub_tx changes are dropped
Err(e) => {
if with_backtrace {
if let Some(backtrace) = vm.backtrace() {
warn!(
target = "vm",
"Execution panic {:?} on contract: 0x{:x}\nregisters: {:?}\ncall_stack: {:?}\nstack\n: {}",
backtrace.error(),
e,
backtrace.contract(),
backtrace.registers(),
backtrace.call_stack(),
hex::encode(&backtrace.memory()[..backtrace.registers()[REG_SP] as usize]), // print stack
);
}
}
// save error status on block_tx since the sub_tx changes are dropped
block_tx.update_tx_status(
tx_id,
TransactionStatus::Failed {
Expand Down

0 comments on commit 0140dff

Please sign in to comment.