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

Add helper function for decoding bytes containing ABI-encoded error message #720

Open
Wodann opened this issue Oct 29, 2024 · 0 comments
Open

Comments

@Wodann
Copy link
Member

Wodann commented Oct 29, 2024

When an execution result reverts with an error, the output bytes contain an ABI-encoded error string.

It would be convenient if EDR exposes an easy way of decoding this to the error string.

Definition of Done

  • API for decoding ABI-encoded bytecode

Example (generated using ChatGPT)

Could you please decode this error string returned from executing an Ethereum contract: 0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000038456967656e506f642e676574506172656e74426c6f636b526f6f743a20696e76616c696420626c6f636b20726f6f742072657475726e65640000000000000000

To decode this error string, let's break down the structure and translate it into human-readable form. The string here appears to follow the standard format for Ethereum contract error messages encoded with ABI (Application Binary Interface) encoding.
Structure of the Error String

The error string can be divided as follows:

Function Selector: The first 4 bytes (0x08c379a0) represent the error type.
Data: The remaining part contains the error message in encoded form.

Step 1: Decode the Function Selector

The function selector 0x08c379a0 corresponds to the Error(string) signature in Solidity.
    This is a standard way in Ethereum to indicate an error has occurred with a string message.

Step 2: Decode the Error Message

The next part encodes the actual error message as follows:

Offset: The next 32 bytes (0x0000000000000000000000000000000000000000000000000000000000000020) point to where the string data begins.
Length: The following 32 bytes (0x0000000000000000000000000000000000000000000000000000000000000038) indicate the length of the error message in bytes. Here, it's 0x38 in hexadecimal, which is 56 in decimal.
Message: The remaining bytes represent the ASCII-encoded message:
456967656e506f642e676574506172656e74426c6f636b526f6f743a20696e76616c696420626c6f636b20726f6f742072657475726e6564.

When decoded, this ASCII string translates to:

Message: EigenPod.getParentBlockRoot: invalid block root returned
Final Decoding Summary

The error message indicates that the Ethereum contract attempted to retrieve a "block root," but it returned an invalid value. This suggests an issue within the function getParentBlockRoot in the EigenPod contract, possibly due to either invalid inputs or a malfunction in retrieving the required data.

This should help in diagnosing what might have caused this specific failure in the contract execution.

@github-project-automation github-project-automation bot moved this to Unconfirmed in EDR Oct 29, 2024
@Wodann Wodann moved this from Unconfirmed to Todo in EDR Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant