Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- [895](https://github.com/FuelLabs/fuel-vm/pull/895): Fix elided lifetimes compilation warnings that became errors after the release of rust 1.83.0.
- [895](https://github.com/FuelLabs/fuel-vm/pull/895): Bump proptest-derive to version `0.5.1` to fix non-local impl errors on the derivation of `proptest_derive::Arbitrary` introduced by rust 1.83.0.
- [889](https://github.com/FuelLabs/fuel-vm/pull/889): Debugger breakpoint caused receipts to be produced incorrectly.
- [889](https://github.com/FuelLabs/fuel-vm/pull/889) and [908](https://github.com/FuelLabs/fuel-vm/pull/908): Debugger breakpoint caused receipts to be produced incorrectly.
- [903](https://github.com/FuelLabs/fuel-vm/pull/903): Fixed warning being emitted when using packages with Node@22+.

## [Version 0.59.1]
Expand Down
24 changes: 12 additions & 12 deletions fuel-vm/src/interpreter/executors/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ where
&base_asset_id,
gas_price,
)?;
self.update_transaction_outputs()?;
ProgramState::Return(1)
} else if let Some(upgrade) = self.tx.as_upgrade_mut() {
Self::upgrade_inner(
Expand All @@ -920,6 +921,7 @@ where
&base_asset_id,
gas_price,
)?;
self.update_transaction_outputs()?;
ProgramState::Return(1)
} else if let Some(upload) = self.tx.as_upload_mut() {
Self::upload_inner(
Expand All @@ -931,6 +933,7 @@ where
&base_asset_id,
gas_price,
)?;
self.update_transaction_outputs()?;
ProgramState::Return(1)
} else if let Some(blob) = self.tx.as_blob_mut() {
Self::blob_inner(
Expand All @@ -942,21 +945,20 @@ where
&base_asset_id,
gas_price,
)?;
self.update_transaction_outputs()?;
ProgramState::Return(1)
} else {
// `Interpreter` supports only `Create` and `Script` transactions. It is not
// `Create` -> it is `Script`.
// This must be a `Script`.
self.run_program()?
};
self.update_transaction_outputs()?;

Ok(state)
}

pub(crate) fn run_program(
&mut self,
) -> Result<ProgramState, InterpreterError<S::DataError>> {
let Some(script) = self.transaction().as_script() else {
let Some(script) = self.tx.as_script() else {
unreachable!("Only `Script` transactions can be executed inside of the VM")
};
let gas_limit = *script.script_gas_limit();
Expand Down Expand Up @@ -1042,15 +1044,14 @@ where
&self.balances,
gas_price,
)?;
self.update_transaction_outputs()?;

Ok(state)
}
let Some(script) = self.tx.as_script_mut() else {
unreachable!("This is checked to hold in the beginning of this function");
};
*script.receipts_root_mut() = self.receipts.root();

/// Update tx fields after execution
pub(crate) fn post_execute(&mut self) {
if let Some(script) = self.tx.as_script_mut() {
*script.receipts_root_mut() = self.receipts.root();
}
Ok(state)
}
}

Expand All @@ -1073,7 +1074,6 @@ where
self.verify_ready_tx(&tx)?;

let state_result = self.init_script(tx).and_then(|_| self.run());
self.post_execute();

#[cfg(feature = "profile-any")]
{
Expand Down
8 changes: 4 additions & 4 deletions fuel-vm/src/interpreter/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
{
pub(crate) fn update_memory_output(&mut self, idx: usize) -> SimpleResult<()> {
let tx_offset = self.tx_offset();
update_memory_output(&mut self.tx, self.memory.as_mut(), tx_offset, idx)
update_memory_output(&self.tx, self.memory.as_mut(), tx_offset, idx)
}
}

Expand Down Expand Up @@ -80,7 +80,7 @@ pub(crate) fn absolute_output_mem_range<Tx: Outputs>(
}

pub(crate) fn update_memory_output<Tx: ExecutableTransaction>(
tx: &mut Tx,
tx: &Tx,
memory: &mut MemoryInstance,
tx_offset: usize,
idx: usize,
Expand All @@ -89,8 +89,8 @@ pub(crate) fn update_memory_output<Tx: ExecutableTransaction>(
.ok_or(PanicReason::OutputNotFound)?;
let mut mem = memory.write_noownerchecks(range.start, range.len())?;
let output = tx
.outputs_mut()
.get_mut(idx)
.outputs()
.get(idx)
.expect("Invalid output index; checked above");
output
.encode(&mut mem)
Expand Down
2 changes: 1 addition & 1 deletion fuel-vm/src/interpreter/internal/message_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn test_update_memory_output(tx_offset: usize) -> SimpleResult<MemoryInstance> {
*tx.policies_mut() = Policies::default();
*tx.outputs_mut() = vec![Output::default()];
let mut memory: MemoryInstance = vec![0; MEM_SIZE].try_into().unwrap();
update_memory_output(&mut tx, &mut memory, tx_offset, 0).map(|_| memory)
update_memory_output(&tx, &mut memory, tx_offset, 0).map(|_| memory)
}

fn check_memory(result: MemoryInstance, expected: &[(usize, Vec<u8>)]) {
Expand Down
4 changes: 4 additions & 0 deletions fuel-vm/src/tests/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use fuel_asm::{
RegId,
};
use fuel_tx::{
field::ReceiptsRoot,
ConsensusParameters,
Finalizable,
GasCosts,
Expand Down Expand Up @@ -47,6 +48,7 @@ fn receipts_are_produced_correctly_with_stepping() {
let mut vm = Interpreter::<_, _, Script>::with_memory_storage();
vm.transact(tx.clone()).expect("panicked");
let receipts_without_debugger = vm.receipts().to_vec();
let receipts_root_without_debugger = vm.transaction().receipts_root();

let mut vm = Interpreter::<_, _, Script>::with_memory_storage();
vm.set_single_stepping(true);
Expand All @@ -67,6 +69,8 @@ fn receipts_are_produced_correctly_with_stepping() {
}
}
let receipts_with_debugger = vm.receipts();
let receipts_root_with_debugger = vm.transaction().receipts_root();

assert_eq!(receipts_without_debugger, receipts_with_debugger);
assert_eq!(receipts_root_without_debugger, receipts_root_with_debugger);
}
Loading