## Description This is a feat and adds functionality for a developer to remote-debug a testnet node. This is made possible with `delve` remote debugging. I received some help from here: https://kupczynski.info/2020/05/17/remote-debug-go-code.html Also, @creachadair I made a tiny modification in the testnet file generation. I removed the `localnet` folder and simply let the `testnet init-files` to use the default `.testnets`, since this is also being `.gitignore`d in the repo, and we don't usually want these files in the main repo. Let me know if there are any implications to your update that you made a few days ago. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [x] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [x] manually tested (if applicable) |
||
---|---|---|
.. | ||
Dockerfile | ||
README.md | ||
wrapper.sh |
README.md
Remote Debugging with go-delve
Delve is a debugger for the Go programming language. The goal of the project is to provide a simple, full featured debugging tool for Go. Delve should be easy to invoke and easy to use. Chances are if you're using a debugger, things aren't going your way. With that in mind, Delve should stay out of your way as much as possible.
Use-case
Cosmos-SDK provides you with a local network to bootstrap a chain in your machine, but how does one debug a node or module?
If we start a single node, we won't be able to debug transactions as the machine will be in bootstrapping phase trying to find peers to connect too, thats why we need to start a local network.
But the current localnet-start
does not provide us with debugging tools so that's why there is a different image for debugging a local network, that is to avoid any issues in the future were debugging won't be needed.
Both simd-env
and simd-dlv
work and run the same, except that simd-dlv
uses go-delve
to run the binaries.
How to use
The command to start a local network in debug mode is:
# make localnet-debug
The command to stop the local network and destroy its containers is:
# make localnet-stop
note: this works the same for both localnet-start
and localnet-debug
Now, by default only simdnode0
is run in debug mode, but you can run any of the other nodes in debug mode by changing the DEBUG
environment variable to 1
in docker-compose.yml
.
How to connect
Delve will open a port on 2345
for simdnode0
and it will increment for each of the other nodes that have DEBUG
set to 1
.
You can connect to the debugging server either through GoLand IDE or you can use delve cli command.