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

Bytecode decompiler #857

Open
SimiHunjan opened this issue Jan 23, 2024 · 3 comments
Open

Bytecode decompiler #857

SimiHunjan opened this issue Jan 23, 2024 · 3 comments
Labels
blocked enhancement New feature or request P1 An issue impacting production environments or impacting multiple releases or multiple individuals smart contracts Features that involve smart contracts

Comments

@SimiHunjan
Copy link
Collaborator

Problem

Users especially developers will occasionally want to learn more about a contracts contents. This usually requires verification first to ensure the matching code. However, it is possible given bytecode to decompile the bytecode and get a sense of the method flows in the contract.

This is useful for debugging situations to have a better understanding of a contract contents when the original source code is not available it may be useful to decompile the run time bytecode to have a better understanding

Examples of usage can be seen at https://etherscan.io/bytecode-decompiler & https://ethervm.io/decompile

User Story

  1. As a user I want to obtain a more human readable form of the contract code to troubleshoot when I don’t have access to the actual contract files

Solution

Add feature to decompile bytecode

Alternatives

No response

@SimiHunjan SimiHunjan added enhancement New feature or request smart contracts Features that involve smart contracts P1 An issue impacting production environments or impacting multiple releases or multiple individuals labels Jan 23, 2024
@SimiHunjan
Copy link
Collaborator Author

@Nana-EC what is the latest on this issue? I know @quiet-node was working on this last and hit some blockers.

@quiet-node
Copy link
Member

quiet-node commented Jan 23, 2024

Hello, @SimiHunjan, thank you for opening this ticket! I've come across a highly maintained decompiler project called Heimdall-rs that seems perfect for this task. However, integrating Heimdall-rs into Hashscan presents certain challenges, considering that Heimdall-rs is fully engineered in Rust while Hashscan operates with Typescript. To implement Heimdall-rs, we're exploring two solutions:

1. Hosting Heimdall-rs as a RESTful service

  • Pros:
    • Easy to implement and build
    • Simple decompilation of Bytecode into Solidity smart contracts through RESTful requests
    • Customizable returned RESTful object
  • Cons:
    • Requires a new instance for server deployment
    • Demands ongoing maintenance
    • Potential latency due to a client-server relationship
  • Status: Completed with a POC at https://github.com/quiet-node/evm-decompiler-rest

2. Building Heimdall-rs into an NPM package using wasm-pack library

  • Pros:
    • No need for deployment
    • Seamless integration into Hashscan as an NPM package (minimal latency)
  • Cons:
    • Challenges arising from Heimdall-rs being CLI-first and intricately linked with various Rust packages at its foundation. Building this decompiler into an NPM package using wasm-pack requires expertise in Rust and wasm-pack.
  • Status: Blocked. I've opened a ticket on the Heimdall-rs' repo regarding this issue. The challenge involves expertise in Rust and wasm-pack. The maintainer, acknowledging a lack of wasm technology experience, has initiated a feature ticket to support wasm within the repo. However, no visible progress has been made.

I currently remain open to and seeking alternative solutions if wasm doesn't work out

cc: @Nana-EC @ericleponner @svienot

@Jon-Becker
Copy link

Hey! Maintainer of heimdall here. In order for heimdall to support wasm, I would need to remove all instances of the std library and completely overhaul the existing library. Your best bet as of now is to host heimdall as a restful service. Let me know if you need any assistance there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request P1 An issue impacting production environments or impacting multiple releases or multiple individuals smart contracts Features that involve smart contracts
Projects
Status: Backlog
Development

No branches or pull requests

3 participants