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

chore: support debugging devnet process #23

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to devnet process",
"type": "go",
"request": "attach",
"mode": "local",
"processId": "${command:pickGoProcess}",
"substitutePath": [
{
"from":"${workspaceFolder}",
"to": "/app"
},
{
"from": "${env:GOPATH}",
"to": "/go"
}
]
},
]
}
31 changes: 27 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,45 @@ COPY ./.git /app/.git
WORKDIR /app
RUN make build

FROM alpine:3.17 as runner

RUN addgroup user && \
adduser -G user -s /bin/sh -h /home/user -D user

USER user
WORKDIR /home/user/

FROM alpine:3.17 as runner-with-kanvas-log

RUN addgroup user && \
adduser -G user -s /bin/sh -h /home/user -D user

RUN mkdir /kanvas_log/ && \
chown user:user /kanvas_log

USER user
WORKDIR /home/user/

# Node
FROM alpine:3.17 as kanvas-node
FROM runner-with-kanvas-log as kanvas-node
COPY --from=builder /app/bin/kanvas-node /usr/local/bin

ENTRYPOINT ["kanvas-node"]

# Stateviz
FROM alpine:3.17 as kanvas-stateviz
FROM runner-with-kanvas-log as kanvas-stateviz
COPY --from=builder /app/bin/kanvas-stateviz /usr/local/bin

CMD ["kanvas-stateviz"]

# Batcher
FROM alpine:3.17 as kanvas-batcher
FROM runner as kanvas-batcher
COPY --from=builder /app/bin/kanvas-batcher /usr/local/bin

ENTRYPOINT ["kanvas-batcher"]

# Validator
FROM alpine:3.17 as kanvas-validator
FROM runner as kanvas-validator
COPY --from=builder /app/bin/kanvas-validator /usr/local/bin

ENTRYPOINT ["kanvas-validator"]
7 changes: 7 additions & 0 deletions ops-devnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ volumes:

services:
l1:
pid: host # allow debugging
image: ethereum/client-go:v1.10.22
ports:
- "8545:8545"
Expand All @@ -28,6 +29,7 @@ services:
- "/entrypoint.sh"

l2:
pid: host # allow debugging
image: wemixkanvas/geth:dev-6ec404a78abc
ports:
- "9545:8545"
Expand All @@ -45,6 +47,7 @@ services:
- "--authrpc.jwtsecret=/config/test-jwt-secret.txt"

kanvas-node:
pid: host # allow debugging
depends_on:
- l1
- l2
Expand Down Expand Up @@ -86,6 +89,7 @@ services:
- kanvas_log:/kanvas_log

kanvas-validator:
pid: host # allow debugging
depends_on:
- l1
- l2
Expand Down Expand Up @@ -115,6 +119,7 @@ services:
VALIDATOR_CHALLENGER_DISABLED: "true"

kanvas-challenger:
pid: host # allow debugging
depends_on:
- l1
- l2
Expand All @@ -138,6 +143,7 @@ services:
VALIDATOR_OUTPUT_SUBMITTER_DISABLED: "true"

kanvas-batcher:
pid: host # allow debugging
depends_on:
- l1
- l2
Expand Down Expand Up @@ -169,6 +175,7 @@ services:
BATCHER_METRICS_ENABLED: "true"

stateviz:
pid: host # allow debugging
build:
context: ..
target: "kanvas-stateviz"
Expand Down
Binary file added specs/assets/vscode_debug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions specs/meta/devnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**Table of Contents**

- [Local Devnet Setup](#local-devnet-setup)
- [Debugging VS Code](#debugging-vs-code)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -51,3 +52,17 @@ The batch submitter uses the account below to submit batches to L1:

- Address: `0xde3829a23df1479438622a08a116e8eb3f620bb5`
- Private key: `bf7604d9d3a1c7748642b1b7b05c2bd219c9faa91458b370f85e5a40f3b03af7`

## Debugging VS Code

We added a debugging configuration called 'Attach to devnet process' to .vscode/launch.json. Therefore, on Linux, you
can use VS Code to attach to the devnet process and perform debugging as shown in the figure below.

![vscode_debug](../asset/../assets/vscode_debug.png)

You might need to disable linux ptrace protection.

```shell
> sudo su
> echo 0 > /proc/sys/kernel/yama/ptrace_scope
```