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

[Infrastructure] LocalNet on Kubernetes #354

Merged
merged 77 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
f7a82ba
tilt + PO + localnet
okdas Nov 12, 2022
62683a5
--wip-- [skip ci]
okdas Nov 12, 2022
67132eb
--wip-- [skip ci]
okdas Nov 15, 2022
764c722
observability stack
okdas Nov 19, 2022
c2c0fd5
--wip-- [skip ci]
okdas Nov 21, 2022
2960669
grafana is auto provisioned with observability stack
okdas Nov 22, 2022
1455a40
--wip-- [skip ci]
okdas Nov 29, 2022
ca9ebeb
stabilizing tilt
okdas Dec 6, 2022
1fd8bb1
--wip-- [skip ci]
okdas Dec 7, 2022
048947c
more changes to grafana, tilt and docs
okdas Dec 7, 2022
2fb9f04
more docs
okdas Dec 10, 2022
e66bd74
let tilt ignore the same stuff as git, so it wont get triggered by ve…
okdas Dec 10, 2022
cc95782
note about changing pocket-operator code
okdas Dec 10, 2022
5198b1d
Merge branch 'main' into dk-localnet-pocket-operator
okdas Dec 10, 2022
f0aa697
Update Makefile
okdas Dec 14, 2022
8b50310
Update Makefile
okdas Dec 14, 2022
52a44d7
Update Makefile
okdas Dec 14, 2022
846ba6c
requested changes so far
okdas Dec 14, 2022
558768e
more requested changes
okdas Dec 14, 2022
03f3ba3
Merge branch 'main' into dk-localnet-pocket-operator
okdas Dec 27, 2022
5b824af
some requested changes
okdas Dec 28, 2022
d53eded
Merge branch 'main' into dk-localnet-pocket-operator
okdas Jan 4, 2023
5225c3e
add mermaid diagram
okdas Jan 5, 2023
b2cb5af
clarify location of the config files
okdas Jan 5, 2023
80d790d
--wip-- [skip ci]
okdas Jan 5, 2023
c94cb4f
localnet without operator
okdas Jan 10, 2023
78f09da
Merge branch 'main' into dk-localnet-pocket-operator
okdas Jan 10, 2023
372bb6c
latest config
okdas Jan 11, 2023
b92bc03
Merge branch 'main' into dk-localnet-pocket-operator
okdas Jan 11, 2023
1b103d7
fully working operatorless localnet
okdas Jan 11, 2023
0f354d9
auto update now works too
okdas Jan 11, 2023
7631fd3
--wip-- [skip ci]
okdas Jan 12, 2023
1d57ceb
bump documentation
okdas Jan 14, 2023
ac40457
change config a bit
okdas Jan 14, 2023
06c8ef3
this is not needed anymore
okdas Jan 19, 2023
cba72f7
Merge branch 'main' into dk-localnet-pocket-operator
okdas Jan 19, 2023
a778f2c
can scale validators automatically
okdas Jan 20, 2023
2e47e2c
change keys
okdas Jan 28, 2023
fa24420
Merge branch 'main' into dk-localnet-pocket-operator
okdas Jan 28, 2023
ebd5dd8
also replace pubkeys
okdas Jan 28, 2023
defca3b
complete changing the keys // tests passed
okdas Jan 30, 2023
03e5a04
bring bck state hashes
okdas Jan 30, 2023
36b1e5f
Merge branch 'main' into dk-localnet-pocket-operator
okdas Jan 31, 2023
19d6ba4
wip
okdas Jan 31, 2023
fae2775
wip
okdas Jan 31, 2023
28c2ee0
add/change changelogs
okdas Jan 31, 2023
27d0daf
create localnet_config.yaml when it doesn exist
okdas Feb 1, 2023
294ae17
Updated gitinore for Tilt
Olshansk Jan 31, 2023
bc846f3
Made the Makefile help command work
Olshansk Feb 1, 2023
792f973
Renamed the readme file and fixed default formatting
Olshansk Feb 1, 2023
25a4a36
Update error messages
Olshansk Feb 1, 2023
cc96bf3
Update error messages
Olshansk Feb 1, 2023
8364117
WIP commit - review + removing $ everywhere
Olshansk Feb 1, 2023
1261079
Update all the documentation
Olshansk Feb 1, 2023
f75fde2
feat(localnet): initcontainer to wait for postgres
deblasis Feb 2, 2023
b46d2d3
also install helm
okdas Feb 2, 2023
7188a2e
requested changes so far
okdas Feb 2, 2023
1bf5fd4
more requested changes
okdas Feb 3, 2023
54a7629
update links
okdas Feb 3, 2023
7ec2217
include demo
okdas Feb 3, 2023
33a45cf
Update build/localnet/README.md
okdas Feb 3, 2023
469e67a
Update build/localnet/README.md
okdas Feb 3, 2023
a8df9d9
Update build/localnet/README.md
okdas Feb 3, 2023
5a5c042
Update build/localnet/README.md
okdas Feb 3, 2023
62561c6
Update build/localnet/Tiltfile
okdas Feb 3, 2023
46d3f74
Update build/localnet/README.md
okdas Feb 3, 2023
2135d26
Update build/localnet/README.md
okdas Feb 3, 2023
fe98bce
Update build/localnet/README.md
okdas Feb 3, 2023
1e59e9c
Update build/localnet/Tiltfile
okdas Feb 3, 2023
1c17e68
clarify postgres ports
okdas Feb 3, 2023
f3d083b
Merge branch 'main' into dk-localnet-pocket-operator
okdas Feb 3, 2023
8e864f3
fix changelogs
okdas Feb 3, 2023
93851be
oops, this got lost!
okdas Feb 3, 2023
3347fbe
Update build/localnet/README.md
okdas Feb 6, 2023
b8ba1c9
Merge branch 'main' into dk-localnet-pocket-operator
okdas Feb 6, 2023
5a1325b
change date on changelog
okdas Feb 6, 2023
da4a402
redundant changelog
okdas Feb 6, 2023
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
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ shared/modules/mocks/*
p2p/types/mocks/*
!p2p/types/mocks/mocks.go


# TODO(team): Does the `types` directory contain generated or raw type files?
# types/

Expand Down Expand Up @@ -62,9 +61,16 @@ rpc/client.gen.go
# Ignored generated files by build/config/main.go
build/config/gen*.json

# Binary downloads and manipulations by helm
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
**/charts
**/tmpcharts

# Ignored generated files by build
bin/*

# Validator keys used for testing/demoes
val1.json
val2.json
val2.json

# Generated by Tilt (tilt.dev)
localnet_config.yaml
56 changes: 56 additions & 0 deletions .tiltignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Binaries for programs and plugins
Olshansk marked this conversation as resolved.
Show resolved Hide resolved

*.exe
*.exe~
*.dll
*.so
*.dylib

# Vim swap files
*.swp**

# Vscode
.vscode

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# MacOS metadata
.DS_Store

# Intellij / Goland dot files
.idea/

# Generated Mocks (for testing)
shared/modules/mocks/
p2p/types/mocks/

# TODO(team): Does the `types` directory contain generated or raw type files?
# types/

# ignore protobuf generated files
*.pb.go

# Local debugging
temp_test.go

# Output of the go test results and coverage report (used by CI)
test_results.json
coverage.out

# Output of `make build_and_watch`
main

# generated RPC server and client from openapi.yaml
rpc/server.gen.go
rpc/client.gen.go

# Ignored generated files by build/config/main.go
build/config/gen*.json

# Binary downloads and manipulations by helm
**/charts
**/tmpcharts
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CWD ?= CURRENT_WORKING_DIRECTIONRY_NOT_SUPPLIED
# IMPROVE: Add `-shuffle=on` to the `go test` command to randomize the order in which tests are run.

# An easy way to turn off verbose test output for some of the test targets. For example
# `$ make test_persistence` by default enables verbose testing
# `make test_persistence` by default enables verbose testing
# `VERBOSE_TEST="" make test_persistence` is an easy way to run the same tests without verbose output
VERBOSE_TEST ?= -v

Expand Down Expand Up @@ -101,6 +101,8 @@ install_cli_deps: ## Installs `protoc-gen-go`, `mockgen`, 'protoc-go-inject-tag'
go install "github.com/golang/mock/mockgen@v1.6.0" && mockgen --version
go install "github.com/favadi/protoc-go-inject-tag@latest"
go install "github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.11.0"
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine (Windows with Ubuntu 20.04 running in WSL2)

this command fails with

 @alex  curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
+ brew bundle --file=-
Error: Formulae dependency graph sorting failed (likely due to a circular dependency):
binutils: ["linux-headers@5.15", "glibc", "zlib", "gcc@5"]
zstd: ["linux-headers@5.15", "glibc", "lz4", "xz", "zlib", "gcc@5"]
Please run the following commands and try again:
  brew update
  brew uninstall --ignore-dependencies --force binutils zstd
  brew install binutils zstd

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I guess that helm CLI binary is a requirement that should be considered in the install_cli_deps as well

Copy link
Member Author

@okdas okdas Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this command fails with

Oh no, I was sure tilt install script can be executed on Linux because the same script is offered for both macOS and Linux. https://docs.tilt.dev/install.html

Looking at the script, even on Linux, they check if brew CLI is available. That is probably because Homebrew supports Linux. When brew cli is available, they try to install tilt with it. Do you use brew a lot on your Linux WSL2 set up? It is possible your local brew set up might be out of date, have you tried to run the commands mentioned to fix this?

It would be easier to install tilt with go install like we do with other binaries, but unfortunately this is not supported.

Also, I guess that helm CLI binary is a requirement that should be considered in the install_cli_deps as well

Thanks for mentioning this, I added a helm install script to that make target. 🫡

curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

.PHONY: develop_start
develop_start: ## Run all of the make commands necessary to develop on the project
Expand Down Expand Up @@ -447,6 +449,31 @@ gen_genesis_and_config: ## Generate the genesis and config files for LocalNet
clear_genesis_and_config: ## Clear the genesis and config files for LocalNet
rm build/config/gen.*.json

.PHONY: localnet_up
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
localnet_up: ## Starts up a k8s LocalNet with all necessary dependencies (tl;dr `tilt up`)
tilt up --file=build/localnet/Tiltfile

.PHONY: localnet_client_debug
localnet_client_debug: ## Opens a `client debug` cli to interact with blockchain (e.g. change pacemaker mode, reset to genesis, etc). Though the node binary updates automatiacally on every code change (i.e. hot reloads), if client is already open you need to re-run this command to execute freshly compiled binary.
kubectl exec -it deploy/pocket-v1-cli-client -- client debug

.PHONY: localnet_shell
localnet_shell: ## Opens a shell in the pod that has the `client` cli available. The binary updates automatically whenever the code changes (i.e. hot reloads).
kubectl exec -it deploy/pocket-v1-cli-client -- /bin/bash

.PHONY: localnet_logs_validators
localnet_logs_validators: ## Outputs logs from all validators
kubectl logs -l v1-purpose=validator --all-containers=true --tail=-1

.PHONY: localnet_logs_validators_follow
localnet_logs_validators_follow: ## Outputs logs from all validators and follows them (i.e. tail)
kubectl logs -l v1-purpose=validator --all-containers=true --max-log-requests=1000 --tail=-1 -f

.PHONY: localnet_down
localnet_down: ## Stops LocalNet and cleans up dependencies (tl;dr `tilt down` + postgres database)
tilt down --file=build/localnet/Tiltfile
kubectl delete pvc --ignore-not-found=true data-dependencies-postgresql-0

Olshansk marked this conversation as resolved.
Show resolved Hide resolved
.PHONY: check_cross_module_imports
check_cross_module_imports: ## Lists cross-module imports
$(eval exclude_common=--exclude=Makefile --exclude-dir=shared --exclude-dir=app --exclude-dir=runtime)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you'd like to contribute to the Pocket V1 Protocol, start by:

<!--
The list of documents below was created by manually curating the output of the following command:
$ find .. -name "*.md" | grep -v -e "vendor" -e "prototype" -e "SUMMARY.md" -e "TASTE.md"
find .. -name "*.md" | grep -v -e "vendor" -e "prototype" -e "SUMMARY.md" -e "TASTE.md"
-->

### Guides
Expand Down
13 changes: 10 additions & 3 deletions app/client/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const (
PromptTriggerNextView string = "TriggerNextView"
PromptTogglePacemakerMode string = "TogglePacemakerMode"
PromptShowLatestBlockInStore string = "ShowLatestBlockInStore"

defaultConfigPath = "build/config/config1.json"
defaultGenesisPath = "build/config/genesis.json"
)

var (
Expand All @@ -41,12 +38,22 @@ var (
PromptShowLatestBlockInStore,
}

defaultConfigPath = getEnv("CONFIG_PATH", "build/config/config1.json")
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
defaultGenesisPath = getEnv("GENESIS_PATH", "build/config/genesis.json")

// validators holds the list of the validators at genesis time so that we can use it to create a debug address book provider.
// Its purpose is to allow the CLI to "discover" the nodes in the network. Since currently we don't have churn and we run nodes only in LocalNet, we can rely on the genesis state.
// HACK(#416): This is a temporary solution that guarantees backward compatibility while we implement peer discovery
validators []*coreTypes.Actor
)

func getEnv(key, defaultValue string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return defaultValue
}

func init() {
rootCmd.AddCommand(NewDebugCommand())
}
Expand Down
12 changes: 12 additions & 0 deletions app/pocket/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to CLI binaries will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.0.0.1] - 2023-02-03

- Introduced `CONFIG_PATH` and `GENESIS_PATH` environment variables for debug CLI commands
6 changes: 3 additions & 3 deletions build/config/config1.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "c6c136d010d07d7f5e9944aa3594a10f9210dd3e26ebc1bc1516a6d957fd0df353ee26c82826694ffe1773d7b60d5f20dd9e91bdf8745544711bec5ff9c6fb4a",
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
"timeout_msec": 5000,
"manual": true,
"debug_time_between_steps_msec": 1000
},
"private_key": "c6c136d010d07d7f5e9944aa3594a10f9210dd3e26ebc1bc1516a6d957fd0df353ee26c82826694ffe1773d7b60d5f20dd9e91bdf8745544711bec5ff9c6fb4a"
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e"
},
"utility": {
"max_mempool_transaction_bytes": 1073741824,
Expand All @@ -30,7 +30,7 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "c6c136d010d07d7f5e9944aa3594a10f9210dd3e26ebc1bc1516a6d957fd0df353ee26c82826694ffe1773d7b60d5f20dd9e91bdf8745544711bec5ff9c6fb4a",
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"max_mempool_count": 100000
},
"telemetry": {
Expand Down
6 changes: 3 additions & 3 deletions build/config/config2.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "b37d3ba2f232060c41ba1177fea6008d885fcccad6826d64ee7d49f94d1dbc49a8b6be75d7551da093f788f7286c3a9cb885cfc8e52710eac5f1d5e5b4bf19b2",
"private_key": "ba81e6e56d293895b299bc495ae75d490644429a5e0028fabeb5e1871c1098e7eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
"timeout_msec": 5000,
"manual": true,
"debug_time_between_steps_msec": 1000
},
"private_key": "b37d3ba2f232060c41ba1177fea6008d885fcccad6826d64ee7d49f94d1dbc49a8b6be75d7551da093f788f7286c3a9cb885cfc8e52710eac5f1d5e5b4bf19b2"
"private_key": "ba81e6e56d293895b299bc495ae75d490644429a5e0028fabeb5e1871c1098e7eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91"
},
"utility": {
"max_mempool_transaction_bytes": 1073741824,
Expand All @@ -30,7 +30,7 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "b37d3ba2f232060c41ba1177fea6008d885fcccad6826d64ee7d49f94d1dbc49a8b6be75d7551da093f788f7286c3a9cb885cfc8e52710eac5f1d5e5b4bf19b2",
"private_key": "ba81e6e56d293895b299bc495ae75d490644429a5e0028fabeb5e1871c1098e7eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"max_mempool_count": 100000
},
"telemetry": {
Expand Down
6 changes: 3 additions & 3 deletions build/config/config3.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "5db3e9d97d04d6d70359de924bb02039c602080d6bf01a692bad31ad5ef93524c16043323c83ffd901a8bf7d73543814b8655aa4695f7bfb49d01926fc161cdb",
"private_key": "25b385b367a827eaafcdb1003bd17a25f2ecc0d10d41f138846f52ae1015aa941041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
"timeout_msec": 5000,
"manual": true,
"debug_time_between_steps_msec": 1000
},
"private_key": "5db3e9d97d04d6d70359de924bb02039c602080d6bf01a692bad31ad5ef93524c16043323c83ffd901a8bf7d73543814b8655aa4695f7bfb49d01926fc161cdb"
"private_key": "25b385b367a827eaafcdb1003bd17a25f2ecc0d10d41f138846f52ae1015aa941041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50"
},
"utility": {
"max_mempool_transaction_bytes": 1073741824,
Expand All @@ -30,7 +30,7 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "5db3e9d97d04d6d70359de924bb02039c602080d6bf01a692bad31ad5ef93524c16043323c83ffd901a8bf7d73543814b8655aa4695f7bfb49d01926fc161cdb",
"private_key": "25b385b367a827eaafcdb1003bd17a25f2ecc0d10d41f138846f52ae1015aa941041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"max_mempool_count": 100000
},
"telemetry": {
Expand Down
6 changes: 3 additions & 3 deletions build/config/config4.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4",
"private_key": "4ff3292ff14213149446f8208942b35439cb4b2c5e819f41fb612e880b5614bdd6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
"timeout_msec": 5000,
"manual": true,
"debug_time_between_steps_msec": 1000
},
"private_key": "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4"
"private_key": "4ff3292ff14213149446f8208942b35439cb4b2c5e819f41fb612e880b5614bdd6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45"
},
"utility": {
"max_mempool_transaction_bytes": 1073741824,
Expand All @@ -30,7 +30,7 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4",
"private_key": "4ff3292ff14213149446f8208942b35439cb4b2c5e819f41fb612e880b5614bdd6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"max_mempool_count": 100000
},
"telemetry": {
Expand Down
Loading