Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Not able to get integer (uint) log for in revert #1585

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,12 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> RpcResult
const MESSAGE_START: usize = 68;

let mut message = "VM Exception while processing transaction: revert".to_string();
let reason_uint = U256::from(&data[4..36]);
let offset :U256 = U256::from(32);

if data.len() == LEN_START {
message = format!("{message}: {}", reason_uint);
}
// A minimum size of error function selector (4) + offset (32) + string length (32)
// should contain a utf-8 encoded revert reason.
if data.len() > MESSAGE_START {
Expand All @@ -985,7 +991,12 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> RpcResult
if data.len() >= message_end {
let body: &[u8] = &data[MESSAGE_START..message_end];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{message} {reason}");
if reason_uint < offset {
message = format!("{message} {reason_uint} {reason}");
}
else {
message = format!("{message}{reason}");
}
}
}
}
Expand Down
Loading