Please note that this repository is under very active development and breaking changes are likely to occur. If the documentation falls out of date please see our guide on how to contribute!
- Install Docker
- Install Docker Compose
- Install Golang
protoc-gen-go
,protoc-go-inject-tag
andmockgen
by runningmake install_cli_deps
Note to the reader: Please update this list if you found anything missing.
Last tested by with:
$ docker --version
Docker version 20.10.14, build a224086
$ protoc --version
libprotoc 3.19.4
$ which protoc-go-inject-tag && echo "protoc-go-inject-tag Installed"
/your$HOME/go/bin/protoc-go-inject-tag
protoc-go-inject-tag Installed
$ go version
go version go1.18.1 darwin/arm64
$ mockgen --version
v1.6.0
$ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 12.3.1 (21E258)
Kernel Version: Darwin 21.4.0
Generate local files
$ git clone [email protected]:pokt-network/pocket.git && cd pocket
$ make protogen_clean && make protogen_local
$ make mockgen
$ make go_clean_deps
$ make
$ make test_all
Note that there are a few tests in the library that are prone to race conditions and we are working on improving them. This can be checked with make test_race
.
- Delete any previous docker state
$ make docker_wipe
- In one shell, run the 4 nodes setup:
$ make compose_and_watch
- In another shell, run the development client:
$ make client_start && make client_connect
- Check the state of each node:
✔ PrintNodeState
- Trigger the next view to ensure everything is working:
✔ TriggerNextView
- Reset the ResetToGenesis if you want to:
✔ ResetToGenesis
- Set the client to automatic and watch it go:
✔ TogglePacemakerMode
✔ TriggerNextView
- [Optional] Common manual set of verification steps
✔ ResetToGenesis
✔ PrintNodeState # Check committed height is 0
✔ TriggerNextView
✔ PrintNodeState # Check committed height is 1
✔ TriggerNextView
✔ PrintNodeState # Check committed height is 2
✔ TogglePacemakerMode # Check that it’s automatic now
✔ TriggerNextView # Let it rip!
Pocket
├── app # Entrypoint to running the Pocket node and clients
| ├── client # Entrypoint to running a local Pocket debug client
| ├── pocket # Entrypoint to running a local Pocket node
├── bin # [currently-unused] Destination for compiled pocket binaries
├── build # Build related source files including Docker, scripts, etc
| ├── config # Configuration files for to run nodes in development
| ├── deployments # Docker-compose to run different cluster of services for development
| ├── Docker* # Various Dockerfile(s)
├── consensus # Implementation of the Consensus module
├── core # [currently-unused]
├── docs # Links to V1 Protocol implementation documentation (excluding the protocol specification)
├── p2p # Implementation of the P2P module
├── persistence # Implementation of the Persistence module
├── shared # [to-be-refactored] Shared types, modules and utils
├── utility # Implementation of the Utility module
├── Makefile # [to-be-deleted] The source of targets used to develop, build and test
We utilize golangci-lint
to run the linters. It is a wrapper around a number of linters and is configured to run many at once. The linters are configured to run on every commit and pull request via CI, and all code issues are populated as GitHub annotations to let developers and reviewers easily locate an issue.
Please follow the instructions on the golangci-lint website.
You can run golangci-lint
locally against all packages with:
make go_lint
If you need to specify any additional flags, you can run golangci-lint
directly as it picks up the configuration from the .golangci.yml
file.
golangci-lint
has an integration with VSCode. Per documentation, recommended settings are:
"go.lintTool":"golangci-lint",
"go.lintFlags": [
"--fast"
]
golangci-lint
is a sophisticated tool including both default and custom linters. The configuration file, which can grow quite large, is located at .golangci.yml
.
The official documentation includes a list of different linters and their configuration options. Please refer to this page for more information.
We can write custom linters using go-ruleguard
. The rules are located in the build/linters
directory. The rules are written in the Ruleguard DSL, if you've never worked with ruleguard in the past, it makes sense to go through introduction article and Ruleguard by example tour.
Ruleguard is run via gocritic
linter which is a part of golangci-lint
, so if you wish to change configuration or debug a particular rule, you can modify the .golangci.yml
file.