Skip to content

Commit

Permalink
fix: out of range case in gas estimation (polkadot-evm#596)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3aa4b0f)
(cherry picked from commit 153095f)

Co-authored-by: librelois <c@elo.tf>
  • Loading branch information
tgmichel and librelois authored Mar 7, 2022
1 parent 68b64e5 commit bfa4c7b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<()
// should contain a utf-8 encoded revert reason.
if data.len() > 68 {
let message_len = data[36..68].iter().sum::<u8>();
let body: &[u8] = &data[68..68 + message_len as usize];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{} {}", message, reason.to_string());
if data.len() >= 68 + message_len as usize {
let body: &[u8] = &data[68..68 + message_len as usize];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{} {}", message, reason.to_string());
}
}
}
Err(Error {
Expand Down

0 comments on commit bfa4c7b

Please sign in to comment.