Skip to content

Commit

Permalink
Apply comments from the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
xgreenx committed Oct 31, 2023
1 parent d64bc45 commit 89cf739
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ pub mod pagination;
pub mod schema;
pub mod types;

type RegisterId = u32;

#[derive(Debug, Clone)]
pub struct FuelClient {
client: reqwest::Client,
Expand Down Expand Up @@ -464,7 +466,7 @@ impl FuelClient {
self.query(query).await.map(|r| r.execute)
}

pub async fn register(&self, id: &str, register: u32) -> io::Result<Word> {
pub async fn register(&self, id: &str, register: RegisterId) -> io::Result<Word> {
let query = schema::Register::build(RegisterArgs {
id: id.into(),
register: register.into(),
Expand Down
7 changes: 6 additions & 1 deletion crates/fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,13 +1494,18 @@ where
.copied()
.map(|result| FuelBacktrace::from_vm_error(vm, result))
{
let sp = usize::try_from(backtrace.registers()[RegId::SP]).expect(
"The `$sp` register points to the memory of the VM. \
Because the VM's memory is limited by the `usize` of the system, \
it is impossible to lose higher bits during truncation.",
);
warn!(
target = "vm",
"Backtrace on contract: 0x{:x}\nregisters: {:?}\ncall_stack: {:?}\nstack\n: {}",
backtrace.contract(),
backtrace.registers(),
backtrace.call_stack(),
hex::encode(&backtrace.memory()[..usize::try_from(backtrace.registers()[RegId::SP]).expect("`$sp` can't be more than memory - `usize`")]), // print stack
hex::encode(&backtrace.memory()[..sp]), // print stack
);
}
}
Expand Down

0 comments on commit 89cf739

Please sign in to comment.