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

[Development] Add LocalDev pod debugging #945

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions build/localnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,40 @@ The k8s manifests that `tilt` submits to the cluster can be found in [this direc

Tilt continuously monitors files on local filesystem in [specific directories](Tiltfile#L27), and it rebuilds the binary and distributes it to the pods on every code change. This allows developers to iterate on the code and see the changes immediately (i.e. hot-reloading).

## Debug with dlv
red-0ne marked this conversation as resolved.
Show resolved Hide resolved

### k8s LocalNet: Connect to a node debugging server

LocalNet Pocket nodes have a dlv debugging server opened on port 7081. In order to connect a debugging client (VSCode, GoLand) and be able to set breakpoints, we need to setup a tunnel with the pod we want to debug.
red-0ne marked this conversation as resolved.
Show resolved Hide resolved

```
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
kubectl port-forward validator-001-pocket-0 7081:7081
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
```

#### Configure VSCode debugger

Add the following to VSCode `launch.json` configuration
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
red-0ne marked this conversation as resolved.
Show resolved Hide resolved

```
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
{
"name": "Debug Pocket Node",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 7081,
"host": "localhost"
}
```

Then you have just to set your breakpoints and start the debugging session (no need to rebuild or restart the binary).

[Watch demo](https://github.com/pokt-network/pocket/assets/231488/3525161f-2098-488a-8f36-8747e40320a6)

### docker-compose based LocalNet

### Debug tests

## Troubleshooting

### Why?
Expand Down
15 changes: 12 additions & 3 deletions build/localnet/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,24 @@ local_resource(
docker_build_with_restart(
"pocket-image",
root_dir,
dockerfile_contents="""FROM debian:bullseye
dockerfile_contents="""FROM golang:1.20-bullseye
RUN go install github.com/go-delve/delve/cmd/dlv@latest
COPY bin/pocket-linux /usr/local/bin/pocket
WORKDIR /
""",
only=["./bin/pocket-linux"],
entrypoint=[
"dlv",
"exec",
"/usr/local/bin/pocket",
"-config=/pocket/configs/config.json",
"-genesis=/pocket/configs/genesis.json",
"--headless",
"--listen=:7081",
"--api-version=2",
"--accept-multiclient",
"--continue",
"--",
"--config=/pocket/configs/config.json",
"--genesis=/pocket/configs/genesis.json",
],
live_update=[sync("bin/pocket-linux", "/usr/local/bin/pocket")],
)
Expand Down