Skip to content

Commit 88d3922

Browse files
committed
Pushing 2.0 from ethereum-graph-debugger-ts
1 parent dd04d41 commit 88d3922

File tree

299 files changed

+9994
-3327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+9994
-3327
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"]
3+
}

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
.idea/*
2-
*.asm
3-
*.iml
4-
target/*
5-
todo.txt
1+
node_modules/*
2+
token
3+
dist/*
4+
.DS_Store
5+
coverage/*
6+
.vscode/*
7+
package-lock.json

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/routes.ts

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
printWidth: 120
2+
semi: false
3+
singleQuote: true

README.md

Lines changed: 35 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,53 @@
11
# ethereum-graph-debugger
22

3-
![Graph example](images/screen-1.png)
3+
![EGD Demo GIF](./egd_demo_gif.gif)
44

5-
Graphical Solidity debugger. This debugger takes a different approach to traditional debugging.
6-
Instead of stepping through the execution of the program, it shows the whole program control flow graph and
7-
the actual execution of the transaction highlighted in red. In this way, the developer can see the whole picture
8-
and jump where it is necessary in a quick and graphical way.
5+
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.
96

10-
### Update with interactive UI coming soon...
7+
This project was rewritten with a frontend made by [Swolfeyes](https://github.com/Swolfeyes) and backend by [fergarrui](https://github.com/fergarrui)
118

12-
# Usage
13-
14-
```
15-
edebugger-<VERSION>.jar <OPTIONS>
16-
Options category 'mandatory':
17-
--address [-a] (a string; default: "")
18-
The Address of the contract the transaction is executed against. Cannot be
19-
set in combination with -f
20-
--node [-n] (a string; default: "")
21-
The node where the transaction was run. It must support
22-
debug_traceTransaction
23-
--source-file [-f] (a string; default: "")
24-
The source file of the contract the transaction is executed against. Cannot
25-
be set in combination with -a
26-
--transaction-hash [-t] (a string; default: "")
27-
Transaction hash to debug
28-
29-
Options category 'optional':
30-
--d3-memory [-m] (a string; default: "537395200")
31-
D3 graph memory. If the graph is too large, you may want to increase this
32-
value (by multiplying it)
33-
--[no]only-trace [-o] (a boolean; default: "false")
34-
Exclude opcodes that are not executed in the transaction when creating the
35-
graph. This may help if the graph is too large and the opcodes not executed
36-
are not important
37-
```
38-
39-
Example:
40-
```
41-
java -jar edebugger-<VERSION>.jar -f ~/tests/Program.sol -n http://127.0.0.1:8545 -t 0x0c971feb820d2bca26c3e7a0a27b5015694d9ec8ea0169935ff7168a63da3f6f
42-
```
43-
44-
# Download
45-
46-
Go to the [releases](https://github.com/fergarrui/ethereum-graph-debugger/releases) section of this repo
47-
48-
# Example debug file
49-
50-
This file is made as a demo to see what this debugger does at this stage. The file can be found here: [Example debug file](http://htmlpreview.github.com/?https://raw.githubusercontent.com/fergarrui/ethereum-graph-debugger/master/examples/debug.html)
9+
[Development repository](https://github.com/fergarrui/ethereum-graph-debugger-ts) was archived, marked as read-only and moved here, to the main repo.
5110

5211
# Existing tools
5312
There are already tools that allow you to debug Ethereum transactions (Solidity):
5413

5514
* [Remix](https://remix.ethereum.org)
5615
* [Truffle](http://truffleframework.com)
5716

58-
# Important note
59-
The bytecode generated by this debugger is compiled **without** compiler optimizations. Make sure to turn it off if you are, for example, using Remix to deploy the contracts. An option should be added anyway to this debugger to support contracts deployed with optimized bytecode.
60-
61-
# Features
62-
63-
* It compiles the provided source code and draws a control flow graph (also imported contracts)
64-
* It supports debugging of transactions even if no source code is provided (option `-a`). It will draw the CFG and trace the transaction
65-
* From the provided transaction hash (using `debug_traceTransaction`) it gets the trace of the transaction
66-
* Combines the control flow graph with the execution trace, highlighting the executed instructions in red
67-
* Supports contracts calls. All contracts involved in the transaction can be debugged
68-
* Instructions opcodes can be clicked in the graph, and the Solidity source code in the left panel involving that instruction is highlighted.
69-
* For the selected opcode, The EVM state is shown (stack, memory, storage, gas, gasCost)
17+
# Usage
7018

71-
# Limitations
19+
Clone and start the application
7220

73-
For now there are many limitations since this is a very early release of the debugger
21+
For the first time:
22+
```
23+
git clone https://github.com/fergarrui/ethereum-graph-debugger.git
24+
cd ethereum-graph-debugger
25+
npm install
26+
npm start
27+
```
28+
Subsequents just:
7429

75-
* The control flow graph is drawn from the static bytecode, so there can be nodes without all edges, a symbolic execution would be needed. Maybe will be added in future releases
76-
* Transactions executed in the runtime bytecode are supported (for example, the constructor execution of a contract cannot be debugged right now)
77-
* You must provide a node URL that supports `debug_traceTransaction`, like Geth or Ganache, therefore, Infura is not supported
78-
* It only supports Solidity or bytecode for now, but planning to make it more modular to support different languages (if the compiler gives source mappings)
79-
* The interface is quite ugly, but usable
80-
* Not really a limitation, but the editor syntax highlighting is set to Javascript at the moment
81-
* Probably many more
30+
```
31+
npm start
32+
```
8233

83-
# Build the project
34+
Go to localhost:9090
8435

85-
`mvn clean package` creates a fat executable jar at: `target/edebugger-<version>.jar`
36+
# Features
8637

87-
A dependency needs to be in your local maven repository (I want to rewrite that in the future).
88-
The project [Ethereum disassembler](https://github.com/fergarrui/ethereum-disassembler) must be installed using `mvn clean install`.
38+
* Now interactive :star2:: it has a sepparate frontend and API instead of building a static HTML file like in earlier versions
39+
* Control flow graph: the CFG can be built without debugging a transaction.
40+
* Disassembler: just disassembled opcodes can be seen, from runtime and constructor
41+
* Source mapping: snippet of code related to the selected instruction is highlighted in the editor left panel
42+
* Debug transaction: a transaction can be debugged using the contract's CFG and the execution trace
43+
* Supports contracts calls. All contracts involved in the transaction can be debugged (going to the caller/called tab to see the contract-specific trace)
44+
* EVM state in transaction: it is shown below the editor when selecting an opcode present in the execution trace of the provided transaction hash
45+
* 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](http://kaleido.io))
46+
* 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)
47+
48+
# Limitations/Considerations
49+
50+
* Only Solidity is supported at the moment
51+
* Only runtime debugging is supported for now (no constructor)
52+
* You must run it against a node that supports `debug_traceTransaction`, like Geth or Ganache, therefore, Infura is not supported
53+
* It was rewritten, so new bugs may appear

egd_demo_gif.gif

1.42 MB
Loading

examples/debug.html

Lines changed: 0 additions & 1064 deletions
This file was deleted.

images/screen-1.png

-149 KB
Binary file not shown.

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Ethereum Debugger</title>
8+
</head>
9+
<body>
10+
<div id='app'></div>
11+
<script src='/bundle.js'></script>
12+
</body>
13+
</html>

package.json

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"name": "ethereum-graph-debugger",
3+
"author": "Fernando Garcia",
4+
"license": "GPL",
5+
"version": "1.0.0",
6+
"description": "Ethereum graph debugger",
7+
"main": "dist/run-server.js",
8+
"scripts": {
9+
"build": "$(npm bin)/npm-run-all -s routes-gen tsc copy-index webpack:prod",
10+
"clean": "$(npm bin)/npm-run-all -p clean:*",
11+
"clean:dist": "$(npm bin)/rimraf dist",
12+
"clean:cov": "$(npm bin)/rimraf coverage",
13+
"start": "$(npm bin)/npm-run-all -s clean build start:simple",
14+
"start:simple": "node ./dist/run-server.js",
15+
"start:dev": "$(npm bin)/npm-run-all -s clean build -p watch:*",
16+
"watch:node": "$(npm bin)/nodemon --inspect=0.0.0.0:9229 --watch './src/**/*.*' --delay 2.5 --exec npm run server-webpack -e ts",
17+
"watch:ts": "tsc --watch",
18+
"prettier": "prettier --write 'src/**/*.{ts,json}'",
19+
"prettier:check": "prettier --list-different 'src/**/*.{ts,json}'",
20+
"test": "jest",
21+
"test:coverage": "npm run test -- --coverage",
22+
"tsc": "$(npm bin)/tsc",
23+
"copy-index": "copyfiles ./index.html ./dist/",
24+
"routes-gen": "tsoa routes",
25+
"server-webpack": "$(npm bin)/npm-run-all -s webpack:prod copy-index start:simple",
26+
"webpack:prod": "webpack --mode production"
27+
},
28+
"jest": {
29+
"coverageThreshold": {
30+
"global": {
31+
"statements": 0,
32+
"branches": 0,
33+
"functions": 0,
34+
"lines": 0
35+
}
36+
},
37+
"globals": {
38+
"ts-jest": {
39+
"skipBabel": true,
40+
"enableTsDiagnostics": true
41+
}
42+
},
43+
"clearMocks": true,
44+
"collectCoverageFrom": [
45+
"src/*/**/*.{ts,js}",
46+
"!src/**/{routes,index}.{ts,js}"
47+
],
48+
"modulePathIgnorePatterns": [
49+
"<rootDir>/dist/",
50+
"<rootDir>/node_modules/"
51+
],
52+
"transform": {
53+
"^.+\\.tsx?$": "ts-jest"
54+
},
55+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
56+
"moduleFileExtensions": [
57+
"ts",
58+
"js",
59+
"json",
60+
"node"
61+
],
62+
"testEnvironment": "node"
63+
},
64+
"dependencies": {
65+
"@types/express": "^4.16.0",
66+
"async-polling": "^0.2.1",
67+
"bn.js": "^4.11.8",
68+
"body-parser": "^1.18.3",
69+
"brace": "^0.11.1",
70+
"copyfiles": "^2.1.0",
71+
"d3": "^5.7.0",
72+
"d3-graphviz": "^2.6.0",
73+
"ethereumjs-util": "^6.0.0",
74+
"express": "^4.16.4",
75+
"express-winston": "^1.4.2",
76+
"inversify": "^4.13.0",
77+
"inversify-binding-decorators": "^3.2.0",
78+
"method-override": "^3.0.0",
79+
"react": "^16.6.0",
80+
"react-dom": "^16.6.0",
81+
"react-redux": "^6.0.0",
82+
"react-svg-inline": "^2.1.1",
83+
"recursive-readdir": "^2.2.2",
84+
"redux-thunk": "^2.3.0",
85+
"reflect-metadata": "^0.1.12",
86+
"solc": "^0.4.25",
87+
"tsoa": "2.1.8",
88+
"terser": "3.14.1",
89+
"web3": "^1.0.0-beta.36",
90+
"winston": "^2.2.0"
91+
},
92+
"devDependencies": {
93+
"@babel/core": "^7.1.5",
94+
"@babel/preset-env": "^7.1.5",
95+
"@babel/preset-react": "^7.0.0",
96+
"@types/jest": "^23.3.1",
97+
"@types/node": "^10.12.18",
98+
"babel-core": "^6.26.3",
99+
"babel-loader": "^8.0.4",
100+
"classnames": "^2.2.6",
101+
"css-loader": "^1.0.1",
102+
"jest": "^23.5.0",
103+
"node-sass": "^4.10.0",
104+
"nodemon": "^1.18.3",
105+
"npm-run-all": "^4.1.3",
106+
"onchange": "^4.1.0",
107+
"postcss-loader": "^3.0.0",
108+
"prettier": "^1.14.2",
109+
"prop-types": "^15.6.2",
110+
"raw-loader": "^0.5.1",
111+
"react-simple-storage": "^1.4.1",
112+
"redux": "^4.0.1",
113+
"rimraf": "^2.5.2",
114+
"sass-loader": "^7.1.0",
115+
"sass-resources-loader": "^2.0.0",
116+
"style-loader": "^0.23.1",
117+
"ts-jest": "^22.4.6",
118+
"tslint-config-prettier": "^1.14.0",
119+
"typescript": "^3.1.3",
120+
"webpack": "^4.25.1",
121+
"webpack-cli": "^3.1.2",
122+
"webpack-dev-server": "^3.1.10"
123+
}
124+
}

0 commit comments

Comments
 (0)