Debugging go-quai is useful when there are specific events occurring within the codebase that need to be checked.
Steps to start debugging
Open VSCode and navigate to the debug panel on the left-hand side.
Click on the highlighted text to create launch.json file.
Copy and paste the below launch.json to run a Zone node.
Example launch.json
1
{
2
"version": "0.2.0",
3
"configurations": [
4
{
5
"name": "Launch Prime",
6
"type": "go",
7
"request": "launch",
8
"mode": "exec",
9
"program": "${workspaceRoot}/build/bin/quai",
10
"env": {},
11
"args": [
12
"--ws",
13
"--http",
14
"--mine",
15
"--miner.threads=4",
16
"--miner.etherbase",
17
"0x00114a47a5d39ea2022dd4d864cb62cfd16879fc",
18
"--syncmode",
19
"full",
20
"--http.port",
21
"8546",
22
"--ws.port",
23
"8547",
24
"--port",
25
"30303",
26
"--allow-insecure-unlock",
27
"--verbosity",
28
"4",
29
],
30
"showLog": true,
31
},
32
]
33
}
Copied!
Run make debug within the go-quai folder to create an executable that contains the proper compiler flags -gcflags=all="-N -l"
Navigate back to the VSCode debug panel which should look similar to this.
Click on the green arrow in the top left of the debug panel to launch the build executable and start your debugging session. You can set breakpoints and specify variables throughout the codebase.