Skip to content

Commit

Permalink
Improve out of gas warning log
Browse files Browse the repository at this point in the history
For the setTrieSlots and setTransientBytes32 HostIOs, when there is an
out-of-gas error, Nitro emits a warning line with `Caused by:\n \x02`.
This commit improves this error message by printing the debug
representation of the API status code and the warning becomes:
`Caused by:\n OutOfGas`.
This commit also solves a potential panic when the API does not return
the status code.
  • Loading branch information
gligneul committed Aug 28, 2024
1 parent e7e9d1b commit 9644416
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions arbitrator/arbutil/src/evm/req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ impl<D: DataReader, H: RequestHandler<D>> EvmApi<D> for EvmApiRequestor<D, H> {
}

let (res, _, cost) = self.request(EvmApiMethod::SetTrieSlots, data);
if res[0] != EvmApiStatus::Success.into() {
bail!("{}", String::from_utf8_or_hex(res));
let status = res
.first()
.copied()
.map(EvmApiStatus::from)
.unwrap_or(EvmApiStatus::Failure);
if status != EvmApiStatus::Success {
bail!("{:?}", status);
}
Ok(cost)
}
Expand All @@ -156,8 +161,13 @@ impl<D: DataReader, H: RequestHandler<D>> EvmApi<D> for EvmApiRequestor<D, H> {
data.extend(key);
data.extend(value);
let (res, ..) = self.request(EvmApiMethod::SetTransientBytes32, data);
if res[0] != EvmApiStatus::Success.into() {
bail!("{}", String::from_utf8_or_hex(res));
let status = res
.first()
.copied()
.map(EvmApiStatus::from)
.unwrap_or(EvmApiStatus::Failure);
if status != EvmApiStatus::Success {
bail!("{:?}", status);
}
Ok(())
}
Expand Down

0 comments on commit 9644416

Please sign in to comment.