Skip to content

Commit

Permalink
Return right error in the case of non existing source
Browse files Browse the repository at this point in the history
  • Loading branch information
xgreenx committed Dec 3, 2024
1 parent 4e228be commit ba2d17a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions fuel-vm/src/interpreter/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ where
&blob_id,
blob_offset,
blob_len,
PanicReason::BlobNotFound,
)?;

Ok(inc_pc(self.registers.pc_mut())?)
Expand Down
3 changes: 3 additions & 0 deletions fuel-vm/src/interpreter/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ where
&contract_id,
contract_offset,
contract_len,
PanicReason::ContractNotFound,
)?;

// Update frame code size, if we have a stack frame (i.e. fp > 0)
Expand Down Expand Up @@ -747,6 +748,7 @@ where
&blob_id,
blob_offset,
blob_len,
PanicReason::BlobNotFound,
)?;

// Update frame code size, if we have a stack frame (i.e. fp > 0)
Expand Down Expand Up @@ -1011,6 +1013,7 @@ where
&contract_id,
contract_offset,
contract_len,
PanicReason::ContractNotFound,
)?;

Ok(inc_pc(self.pc)?)
Expand Down
3 changes: 2 additions & 1 deletion fuel-vm/src/interpreter/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ pub(crate) fn copy_from_storage_zero_fill<M, S>(
src_id: &M::Key,
src_offset: u64,
src_len: usize,
no_found_error: PanicReason,
) -> IoResult<(), S::Error>
where
M: Mappable,
Expand All @@ -1068,7 +1069,7 @@ where
storage
.read(src_id, src_offset as usize, src_read_buffer)
.transpose()
.ok_or(PanicReason::ContractNotFound)?
.ok_or(no_found_error)?
.map_err(RuntimeError::Storage)?;

empty_offset = src_read_length;
Expand Down
1 change: 1 addition & 0 deletions fuel-vm/src/interpreter/memory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ fn test_copy_from_storage_zero_fill(
&contract_id,
src_offset,
contract_size,
PanicReason::ContractNotFound,
)
.is_ok();
let memory: [u8; 5] = memory[..5].try_into().unwrap();
Expand Down

0 comments on commit ba2d17a

Please sign in to comment.