Giter Site home page Giter Site logo

fergarrui / ethereum-graph-debugger Goto Github PK

View Code? Open in Web Editor NEW
352.0 11.0 33.0 6.92 MB

Ethereum solidity graph plain debugger. To have the whole picture when debugging.

License: GNU General Public License v3.0

HTML 0.08% TypeScript 76.82% JavaScript 18.68% Dockerfile 0.08% SCSS 4.34%
ethereum solidity debugger ethereum-contract ethereum-debugger solidity-language debug solidity-debug solidity-debugging ethereum-debug

ethereum-graph-debugger's Introduction

ethereum-graph-debugger

EGD Demo GIF

Graphical EVM debugger. This debugger takes a different approach to traditional debugging. Instead of stepping through the execution of the program, it shows the whole program control flow graph and the actual execution of the transaction highlighted in red. In this way, the developer can see the whole picture and jump where it is necessary in a quick and graphical way.

This project was rewritten with a frontend made by Swolfeyes and backend by fergarrui

Development repository was archived, marked as read-only and moved here, to the main repo.

Existing tools

There are already tools that allow you to debug Ethereum transactions (Solidity):

Usage

Download

Use release link:

If you want to use master (it can be more unstable), clone and start the application

For the first time:

  git clone https://github.com/fergarrui/ethereum-graph-debugger.git
  cd ethereum-graph-debugger
  npm install
  npm start

Subsequents just:

npm start

Go to localhost:9090

With docker

docker-compose up

Go to localhost:9090

Add contracts to ./contracts (you will need to create the directory) and empty string at the 'Load contracts from URI' form.

Use

  • Go to localhost:9090
  • Enter the path where the contracts are in the input text (it will load Solidity contracts recursively)
  • A tab per file found will be created
  • Under a file tab there are a few actions using the left menu

How to debug bytecode (with no source code) [Experimental]

  • Create a file with extension .evm and paste the runtime bytecode (:warning: important: with 0x as prefix)
    • For example: create a file named: contract1.evm with content 0x60806040
  • Scan the directory as described above
  • You won't get source code mappings when clicking in operations of the CFG

Features

  • Now interactive 🌟: it has a sepparate frontend and API instead of building a static HTML file like in earlier versions
  • Control flow graph: the CFG can be built without debugging a transaction.
  • Disassembler: just disassembled opcodes can be seen, from runtime and constructor
  • Source mapping: snippet of code related to the selected instruction is highlighted in the editor left panel
  • Debug transaction: a transaction can be debugged using the contract's CFG and the execution trace
  • Storage viewer: Storage layout and values can be retrieved (including dynamic arrays and mappings ❗ )
  • Supports contracts calls. All contracts involved in the transaction can be debugged (going to the caller/called tab to see the contract-specific trace)
  • EVM state in transaction: it is shown below the editor when selecting an opcode present in the execution trace of the provided transaction hash
  • Settings: right now, there are settings to point to a different chain (by default it connects to http://127.0.0.1:8545) and basic authentication can be configured, so the RPC endpoint can be accessed if authentication is needed (to be compatible with platforms like Kaleido)
  • When building the CFG a basic dynamic execution is made to calculate jumps and to remove most of orphan blocks (this will be improved in the future, probably with SymExec)
  • To debug directly bytecode, use .evm extension files
  • Constructor CFG is supported
  • Debugging constructor transactions is supported

Limitations/Considerations

  • Only Solidity is supported at the moment
  • Only runtime debugging is supported for now (no constructor)
  • You must run it against a node that supports debug_traceTransaction, like Geth or Ganache, therefore, Infura is not supported
  • It was rewritten, so new bugs may appear

ethereum-graph-debugger's People

Contributors

dependabot[bot] avatar fergarrui avatar nebojsa94 avatar swolfeyes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethereum-graph-debugger's Issues

not working

Hey ! I try to use your debugger but it is not working,
I tried both with and without the docker but it raises the same issues :

What should I do ?

debugger_1 | ERROR in ./src/client/components/Version/Version.js debugger_1 | Module not found: Error: Can't resolve '../../_redux/actions' in '/opt/app/src/client/components/Version' debugger_1 | @ ./src/client/components/Version/Version.js 16:38-69 debugger_1 | @ ./src/client/components/TopNavBar/TopNavBar.js debugger_1 | @ ./src/client/App.js debugger_1 | @ ./src/index.js debugger_1 | debugger_1 | ERROR in ./src/client/components/Graph/Graph.js debugger_1 | Module not found: Error: Can't resolve '../../_redux/actions.js' in '/opt/app/src/client/components/Graph' debugger_1 | @ ./src/client/components/Graph/Graph.js 32:38-72 debugger_1 | @ ./src/client/components/TransactionDebugger/TransactionDebugger.js debugger_1 | @ ./src/client/components/Panel/Panel.js debugger_1 | @ ./src/client/components/Main/Main.js debugger_1 | @ ./src/client/App.js debugger_1 | @ ./src/index.js debugger_1 | debugger_1 | ERROR in ./src/client/components/Main/Main.js debugger_1 | Module not found: Error: Can't resolve '../../_redux/actions.js' in '/opt/app/src/client/components/Main' debugger_1 | @ ./src/client/components/Main/Main.js 34:38-72 debugger_1 | @ ./src/client/App.js debugger_1 | @ ./src/index.js debugger_1 | debugger_1 | ERROR in ./src/client/components/MessageComp/MessageComp.js debugger_1 | Module not found: Error: Can't resolve '../../_redux/actions.js' in '/opt/app/src/client/components/MessageComp' debugger_1 | @ ./src/client/components/MessageComp/MessageComp.js 28:38-72 debugger_1 | @ ./src/client/App.js debugger_1 | @ ./src/index.js debugger_1 | debugger_1 | ERROR in ./src/client/App.js debugger_1 | Module not found: Error: Can't resolve './_redux/actions.js' in '/opt/app/src/client' debugger_1 | @ ./src/client/App.js 30:38-68 debugger_1 | @ ./src/index.js debugger_1 | debugger_1 | ERROR in ./src/index.js debugger_1 | Module not found: Error: Can't resolve './client/_redux/store.js' in '/opt/app/src' debugger_1 | @ ./src/index.js 13:36-71 debugger_1 | npm ERR! code ELIFECYCLE debugger_1 | npm ERR! errno 2 debugger_1 | npm ERR! [email protected] webpack:prod: `webpack --mode production` debugger_1 | npm ERR! Exit status 2 debugger_1 | npm ERR! debugger_1 | npm ERR! Failed at the [email protected] webpack:prod script. debugger_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above. debugger_1 | debugger_1 | npm ERR! A complete log of this run can be found in: debugger_1 | npm ERR! /root/.npm/_logs/2020-02-18T15_07_38_674Z-debug.log debugger_1 | ERROR: "webpack:prod" exited with 2. debugger_1 | npm ERR! code ELIFECYCLE debugger_1 | npm ERR! errno 1 debugger_1 | npm ERR! [email protected] build: `$(npm bin)/npm-run-all -s routes-gen tsc copy-index webpack:prod` debugger_1 | npm ERR! Exit status 1 debugger_1 | npm ERR! debugger_1 | npm ERR! Failed at the [email protected] build script. debugger_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above. debugger_1 | debugger_1 | npm ERR! A complete log of this run can be found in: debugger_1 | npm ERR! /root/.npm/_logs/2020-02-18T15_07_38_796Z-debug.log debugger_1 | ERROR: "build" exited with 1. debugger_1 | npm ERR! code ELIFECYCLE debugger_1 | npm ERR! errno 1 debugger_1 | npm ERR! [email protected] start: `$(npm bin)/npm-run-all -s clean build start:simple` debugger_1 | npm ERR! Exit status 1 debugger_1 | npm ERR! debugger_1 | npm ERR! Failed at the [email protected] start script. debugger_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above. debugger_1 | debugger_1 | npm ERR! A complete log of this run can be found in:

Can't start program

My current node version is 10.15.3.

npm install works, but npm start crash when running tsc. I get these kind of errors :

src/api/bytecode/EVMDisassembler.test.ts:4:10 - error TS2305: Module '"../../../node_modules/@types/bn.js"' has no exported member 'BN'.

4 import { BN } from 'bn.js'
           ~~

src/api/bytecode/EVMDisassembler.test.ts:4:20 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

4 import { BN } from 'bn.js'
                     ~~~~~~~

src/api/bytecode/EVMDisassembler.ts:5:10 - error TS2305: Module '"../../../node_modules/@types/bn.js"' has no exported member 'BN'.

5 import { BN } from 'bn.js'
           ~~

src/api/bytecode/EVMDisassembler.ts:5:20 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

5 import { BN } from 'bn.js'
                     ~~~~~~~

Is there something else I need to install ?

WSL or Updated Version

This is a great tool only wish it was in either WSL or windows the idea to have an overview of transactions in the evm is very clever

"Bad source code" when trying to debug a transation

I deployed a contract to Ganache (compiled with solc 6.6 without optimization) via Remix, called a function, and tried to debug the transaction from the tab of the same source code (both using solc 6.6), and I am getting a "Bad source code".

Happens on 3.6.0 and latest master. Logs below are from latest master. Running node 8.9.4.

error:
{ message: 'Bad source code',
  stack: 'Error: Bad source code\n    at ContractService.compileContract (/Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/service/service/ContractService.js:54:19)\n    at EVMDisassembler.disassembleSourceCode (/Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/bytecode/EVMDisassembler.js:32:47)\n    at CFGService.buildCFGFromSource (/Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/service/service/CFGService.js:36:42)\n    at DebuggerController.<anonymous> (/Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/service/controller/DebuggerController.js:47:62)\n    at Generator.next (<anonymous>)\n    at /Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/service/controller/DebuggerController.js:19:71\n    at new Promise (<anonymous>)\n    at __awaiter (/Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/service/controller/DebuggerController.js:15:12)\n    at DebuggerController.debug (/Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/api/service/controller/DebuggerController.js:38:16)\n    at /Users/michaeldeluca/Projects/ethereum-graph-debugger/dist/routes.js:146:42\n    at Layer.handle [as handle_request] (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/layer.js:95:5)\n    at next (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/route.js:137:13)\n    at Route.dispatch (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/route.js:112:3)\n    at Layer.handle [as handle_request] (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/layer.js:95:5)\n    at /Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/index.js:281:22\n    at param (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/index.js:354:14)\n    at param (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/index.js:365:14)\n    at Function.process_params (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/index.js:410:3)\n    at next (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/index.js:275:10)\n    at methodOverride (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/method-override/index.js:79:5)\n    at Layer.handle [as handle_request] (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/layer.js:95:5)\n    at trim_prefix (/Users/michaeldeluca/Projects/ethereum-graph-debugger/node_modules/express/lib/router/index.js:317:13)' }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.