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

KISS Peer discovery, KISS Bootstrapping, Nodes auto-stake/unstake via K8S cluster-manager, Node Finite state machine - Issues #416, #490, #429, #498, #499 #491

Closed
wants to merge 233 commits into from
Closed
Show file tree
Hide file tree
Changes from 164 commits
Commits
Show all changes
233 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
4c1fd86
feat(localnet): initcontainer to wait for postgres
deblasis Feb 2, 2023
f75fde2
feat(localnet): initcontainer to wait for postgres
deblasis Feb 2, 2023
cfca9c6
feat(localnet): cluster-manager POC
deblasis Feb 2, 2023
b46d2d3
also install helm
okdas Feb 2, 2023
f7e41fb
feat(crypto): ed25519
deblasis Feb 2, 2023
e0873d6
refactor(genesis): added accounts for all the validators in Localnet
deblasis Feb 2, 2023
e9689ab
refactor(localnet): renamed cluster-manager serviceAccount
deblasis Feb 2, 2023
23b2d9b
feat(localnet): cluster-manager validator keys from secret - WIP
deblasis Feb 2, 2023
2dc1bae
fix(utility): nil pointer fix
deblasis 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
1ac46b8
chore(docker-compose): renamed deployment to pocket-v1
deblasis Feb 3, 2023
e280594
feat(CLI): allowing non interactive stake and unstake
deblasis Feb 3, 2023
f0eaf43
feat(localnet): cluster-manager dogfoods the CLI to stake/unstake
deblasis Feb 3, 2023
fc7f167
feat(localnet): dogfooding CLI in cluster-manager
deblasis Feb 3, 2023
a920a5d
feat(makefile): localnet_db_cli
deblasis Feb 3, 2023
6237753
feat(utility): clearing mempool on resetToGenesis
deblasis Feb 3, 2023
841d90c
chore(go.mod): tidy
deblasis 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
4b8da0f
Merge remote-tracking branch 'upstream/dk-localnet-pocket-operator' i…
deblasis Feb 5, 2023
778c33d
refactor(localnet): updates from dima's branch
deblasis Feb 5, 2023
aea3359
feat(localnet): cli-client waits for v1-validator001 (target node)
deblasis Feb 5, 2023
61606f7
feat(localnet): accounts updated in genesis for localnet as well
deblasis Feb 5, 2023
104339a
fix(utility): logging error if ApplyTransaction fails...
deblasis Feb 5, 2023
18a6706
feat(consensus): NewHeightEvent
deblasis Feb 6, 2023
ce6b59a
Revert "feat(consensus): NewHeightEvent"
deblasis Feb 6, 2023
cc3c8c7
feat(consensus): NewHeightEvent
deblasis Feb 6, 2023
9a441a4
feat(consensus): resetToGenesis publishes NewHeightEvent
deblasis Feb 6, 2023
00d4d8c
feat(consensus): SetHeight publishes NewHeightEvent
deblasis Feb 6, 2023
d418dc5
refactor(shared): ModulesRegistry
deblasis Feb 6, 2023
347102e
fix(shared): module registration
deblasis Feb 6, 2023
cbd9213
fix(runtime): fixed tests
deblasis Feb 6, 2023
3f0aaeb
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 6, 2023
c51fcfb
fix(utility): missing import
deblasis Feb 6, 2023
6e5e014
fix(bus): GetModulesRegistry implementation
deblasis Feb 7, 2023
ac8c3f9
refactor(rpc): github.com/deepmap/oapi-codegen/pkg/runtime import
deblasis Feb 7, 2023
0a9a7c7
feat(rpc): GET /v1/p2p/address_book implementation
deblasis Feb 7, 2023
0aaa652
feat(shared): baseModules -> DRY
deblasis Feb 7, 2023
e83dc10
fix(p2p): modulesRegistry mock config
deblasis Feb 7, 2023
8260e63
refactor(infra): passing RPC_HOST to debug client
deblasis Feb 7, 2023
fbf013e
feat(p2p): rpc addrbook_provider
deblasis Feb 7, 2023
3b74980
feat(p2p): rpc current_height_provider
deblasis Feb 7, 2023
7e2b809
feat(shared): generalized module options
deblasis Feb 7, 2023
e7b76fd
fix(p2p): raintree using currentHeightProvider
deblasis Feb 7, 2023
0aef8e2
fix(rpc): fixed openapi P2PStakedActorsResponse
deblasis Feb 7, 2023
596d754
refactor(runtime): exposed DefailtRPCPort
deblasis Feb 7, 2023
f840eed
fix(runtime): fixed bus in RuntimeManager
deblasis Feb 7, 2023
378e87b
refactor(cli): debug cli now sources addressbook remotely via RPC
deblasis Feb 7, 2023
00df050
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 7, 2023
727b729
fix(cli): merge fix
deblasis Feb 7, 2023
de7c8c0
fix(rpc): merge fix
deblasis Feb 7, 2023
352c068
refactor(p2p): deprecated debugCurrentHeightProvider
deblasis Feb 7, 2023
18852ee
fix(p2p): fixed tests (mock config)
deblasis Feb 7, 2023
4331a9d
refactor(shared): simplified module registration
deblasis Feb 7, 2023
029fd17
chore(shared): linting
deblasis Feb 7, 2023
d1684cb
chore(shared): linting
deblasis Feb 7, 2023
00af4ac
refactor(cli): centralized not_interactive flag
deblasis Feb 7, 2023
9f5e35e
chore(cli): updated flag description
deblasis Feb 7, 2023
e84977b
refactor(cli): refactored broadcast
deblasis Feb 7, 2023
17137d2
feat(p2p): reacting to height changes => addrbook delta
deblasis Feb 7, 2023
59a0ea1
refactor(rpc): simplified module
deblasis Feb 7, 2023
7a89eec
feat(cluster-manager): wait for validator1
deblasis Feb 8, 2023
1a92565
feat(state_machine): node finite state machine WIP
deblasis Feb 8, 2023
0401e39
fix(state-machine): updated to consider serverMode as independent proc
deblasis Feb 8, 2023
36535ad
fix(cluster-manager): fix port
deblasis Feb 8, 2023
00adc0d
refactor(p2p): bootstrapping
deblasis Feb 8, 2023
a29c2bc
feat(pocket): override bootstrapnodes
deblasis Feb 8, 2023
e6cb404
refactor(rpc): rpcServer implements BaseIntegratableModule
deblasis Feb 8, 2023
3e2c538
fix(consensus): fixed tests (mock cfg)
deblasis Feb 8, 2023
622f4d3
fix(p2p): bus shadowing embed fix
deblasis Feb 8, 2023
8171a05
chore(state_machine): shadowing fix
deblasis Feb 8, 2023
7b4e7c4
fix(p2p): error checking on add/remove peer
deblasis Feb 8, 2023
d08082d
chore(shared): return err on HandleEvent
deblasis Feb 8, 2023
8eba0db
chore(shared): linting
deblasis Feb 8, 2023
4c92b09
docs(consensus): CHANGELOG + nit
deblasis Feb 8, 2023
3f37ba9
docs(p2p): CHANGELOG
deblasis Feb 8, 2023
41dd4a4
chore(p2p): typo
deblasis Feb 8, 2023
78eac4a
chore(cluster-manager): linting
deblasis Feb 9, 2023
a021202
chore(cluster-manager): linting exclusion for CLI
deblasis Feb 9, 2023
0ae1426
docs(shared): CHANGELOGs + nits
deblasis Feb 9, 2023
6d5ff55
docs(shared): CHANGELOGS + nits
deblasis Feb 9, 2023
d6a4a63
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 9, 2023
aab3ecc
docs(state_machine): docs + nits
deblasis Feb 9, 2023
261b634
docs(shared): CHANGELOGs
deblasis Feb 9, 2023
4a7afd6
fix(state_machine): CHANGELOG version
deblasis Feb 9, 2023
e8ae3ad
docs(persistence): typo
deblasis Feb 9, 2023
2854dcb
chore(shared): linter nits
deblasis Feb 9, 2023
41b2bcf
chore(cluster-manager): nit
deblasis Feb 9, 2023
d4a63a8
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 10, 2023
f488c35
fix(shared): processing module options
deblasis Feb 10, 2023
b8f67b6
refactor(shared): base modules in their own package
deblasis Feb 10, 2023
dcee5a8
docs(shared): dates in CHANGELOG
deblasis Feb 10, 2023
ad2e783
Update Makefile
deblasis Feb 12, 2023
ef818eb
Update app/client/cli/actor.go
deblasis Feb 12, 2023
a8caada
refactor(CLI): nonInteractive
deblasis Feb 12, 2023
fbb00db
style(cli): nit
deblasis Feb 12, 2023
085c985
refactor(runtime): renamed WitCustomBootstrapNodes
deblasis Feb 13, 2023
1221760
feat(p2p): bootstrapnodes
deblasis Feb 13, 2023
89cad3c
Update build/docs/CHANGELOG.md
deblasis Feb 13, 2023
7f6d25a
Update build/docs/CHANGELOG.md
deblasis Feb 13, 2023
2acb0dc
Merge branch 'issue/416-kiss-peer-discovery-k8s-base354' of github.co…
deblasis Feb 13, 2023
913ca83
docs(build): added comment regarding RPC_HOST
deblasis Feb 13, 2023
08255ff
refactor(cluster-manager): using PrivateKey abstraction
deblasis Feb 14, 2023
626e695
refactor(runtime): GetEnv
deblasis Feb 14, 2023
87e08d5
docs(shared): modulesOptions explanation
deblasis Feb 14, 2023
5e78dc9
fix(utility): use logger instead of log.xxx
deblasis Feb 14, 2023
f39c97b
refactor(runtime): consolidated RPC defaults
deblasis Feb 14, 2023
4ffce8a
Update state_machine/docs/README.md
deblasis Feb 14, 2023
08622b7
Update shared/modules/modules_registry_module.go
deblasis Feb 14, 2023
8a8db88
Merge branch 'issue/416-kiss-peer-discovery-k8s-base354' of github.co…
deblasis Feb 14, 2023
66b8ee5
Update state_machine/visualizer/main.go
deblasis Feb 14, 2023
b21f0cc
Update p2p/CHANGELOG.md
deblasis Feb 14, 2023
28198fb
chore(runtime): grouping defaults by accessibility
deblasis Feb 14, 2023
8626a2b
refactor(cli): nonInteractive
deblasis Feb 14, 2023
804438c
chore(consensus): nits
deblasis Feb 14, 2023
f37b396
feat(cluster-manager): using logger
deblasis Feb 14, 2023
b9f09f3
Merge branch 'issue/416-kiss-peer-discovery-k8s-base354' of github.co…
deblasis Feb 14, 2023
72eaabb
fix(state_machine): use logger
deblasis Feb 14, 2023
50e8346
Merge branch 'issue/416-kiss-peer-discovery-k8s-base354' of github.co…
deblasis Feb 14, 2023
2806933
docs(shared): base IntegratableModule godoc
deblasis Feb 14, 2023
f8ee78f
docs(shared): InterruptableModule typo
deblasis Feb 14, 2023
8ab9077
Update state_machine/docs/README.md
deblasis Feb 14, 2023
022e6eb
Merge branch 'issue/416-kiss-peer-discovery-k8s-base354' of github.co…
deblasis Feb 14, 2023
309d72d
refactor(state_machine): refactored events and states
deblasis Feb 14, 2023
72b76c4
docs(state_machine): docs
deblasis Feb 14, 2023
84b9ac2
chore(state_machine): formatting
deblasis Feb 14, 2023
029a7c4
docs(state_machine): reading flow
deblasis Feb 14, 2023
37708e3
Update state_machine/docs/README.md
deblasis Feb 14, 2023
87e5dd9
refactor(state_machine): transitionEvent
deblasis Feb 14, 2023
a46e307
Merge branch 'issue/416-kiss-peer-discovery-k8s-base354' of github.co…
deblasis Feb 14, 2023
f2fa5f5
chore(rpc): protocolActorToRPCActorTypeEnum
deblasis Feb 14, 2023
13fbfcd
fix(runtime): using GlobalLogger
deblasis Feb 14, 2023
d37865d
docs(runtime): p2p config example for bootstrap nodes csv
deblasis Feb 14, 2023
393dc43
refactor(rpc): updated endpoint to staked_actors_address_book
deblasis Feb 14, 2023
32373b0
refactor(rpc): updated coreActor -> protocolActor getter logic
deblasis Feb 14, 2023
12df5ff
fix(p2p): interface segregation in providers
deblasis Feb 14, 2023
900f508
refactor(p2p): updated to use runtime.GetEnv
deblasis Feb 14, 2023
7298f5a
Update p2p/module.go
deblasis Feb 14, 2023
2cf4599
refactor(p2p): event_handler.go
deblasis Feb 14, 2023
d800479
refactor(p2p): RemovePeerToAddrBook -> RemovePeerFromAddrBook
deblasis Feb 14, 2023
c237602
refactor(shared): handleEvent same handler
deblasis Feb 14, 2023
db028d1
refactor(consensus): using logger
deblasis Feb 14, 2023
9583834
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 14, 2023
357b4ed
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 14, 2023
fc863b0
chore(p2p): linter regex
deblasis Feb 14, 2023
257f033
fix(shared): rpcUrl sourcing in providers and cluster_manager
deblasis Feb 14, 2023
d3c18f9
feat(cluster-manager): improved logging
deblasis Feb 14, 2023
99ec1e3
fix(keystore): fixed private keys sourcing in k8s
deblasis Feb 15, 2023
89d6a77
fix(cluster-manager): updated to reflect keybase fixes + better logging
deblasis Feb 15, 2023
aa9ddfe
docs(cli): typos in changelog
deblasis Feb 15, 2023
a7dab20
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 15, 2023
47c4514
fix(keystore): fixed private keys sourcing in k8s
deblasis Feb 15, 2023
18b6875
feat(localnet): debug client permissions to read private keys
deblasis Feb 15, 2023
c53a1e2
docs(shared): changelogs
deblasis Feb 15, 2023
59e7559
docs(cli): changelog
deblasis Feb 15, 2023
f24d8b8
Merge branch 'issue/keybase_debug_k8s_localnet_fix' into issue/416-ki…
deblasis Feb 15, 2023
469912f
fix(keybase): doing the heavylifting only when needed
deblasis Feb 15, 2023
0066322
refactor(cluster-manager): updated for keybase changes
deblasis Feb 15, 2023
795588c
refactor(localnet): updated manifests for cluster-manager (splitted)
deblasis Feb 15, 2023
0dd6d1b
fix(makefile): fixed pwd for make go_lint
deblasis Feb 15, 2023
70f3852
refactor(cluster-manager): extracted getPrivateKey func
deblasis Feb 15, 2023
55f893c
refactor(localnet): labels for k8s_resources (better dashboard)
deblasis Feb 15, 2023
2838bc0
chore(makefile): specify container for localnet cli client commands
deblasis Feb 15, 2023
92841a4
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 16, 2023
950e07d
Merge remote-tracking branch 'upstream/main' into issue/416-kiss-peer…
deblasis Feb 16, 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: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ generate_cli_commands_docs: ## (Re)generates the CLI commands docs (this is mean
cd app/client/cli/docgen && go run .
echo "CLI commands docs generated in ${cli_docs_dir}"

.PHONY: generate_node_state_machine_diagram
generate_node_state_machine_diagram: ## (Re)generates the Node State Machine diagram
go run ./state_machine/visualizer/main.go
echo "Node State Machine diagram generated in state_machine/docs/state-machine.diagram.md"

.PHONY: test_all
test_all: ## Run all go unit tests
go test -p 1 -count=1 ./...
Expand Down Expand Up @@ -477,6 +482,11 @@ localnet_down: ## Stops LocalNet and cleans up dependencies (tl;dr `tilt down` +
tilt down --file=build/localnet/Tiltfile
kubectl delete pvc --ignore-not-found=true data-dependencies-postgresql-0

.PHONY: localnet_db_cli
localnet_db_cli: ## Open a CLI to the local containerized postgres instancedb_cli:
echo "View schema by running 'SELECT schema_name FROM information_schema.schemata;'"
kubectl exec -it services/dependencies-postgresql -- bash -c "psql postgresql://postgres:LocalNetPassword@localhost"

.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
12 changes: 7 additions & 5 deletions app/client/cli/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ If no changes are desired for the parameter, just enter the current param value
chains := strings.Split(rawChains, ",")
serviceURI := args[3]

// TODO (team): passphrase is currently not used since there's no keybase yet, the prompt is here to mimick the real world UX
pwd = readPassphrase(pwd)

if !notInteractive {
deblasis marked this conversation as resolved.
Show resolved Hide resolved
// TODO(#484): passphrase is currently not used since there's no keybase yet, the prompt is here to mimick the real world UX
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
pwd = readPassphrase(pwd)
}
msg := &typesUtil.MessageStake{
PublicKey: pk.PublicKey().Bytes(),
Chains: chains,
Expand Down Expand Up @@ -209,8 +210,9 @@ func newUnstakeCmd(cmdDef actorCmdDef) *cobra.Command {
}

// TODO (team): passphrase is currently not used since there's no keybase yet, the prompt is here to mimick the real world UX
pwd = readPassphrase(pwd)

if !notInteractive {
pwd = readPassphrase(pwd)
}
msg := &typesUtil.MessageUnstake{
Address: pk.Address(),
Signer: pk.Address(),
Expand Down
2 changes: 2 additions & 0 deletions app/client/cli/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ const cliExecutableName = "client"
var (
remoteCLIURL string
privateKeyFilePath string
notInteractive bool
deblasis marked this conversation as resolved.
Show resolved Hide resolved
)

func init() {
rootCmd.PersistentFlags().StringVar(&remoteCLIURL, "remote_cli_url", defaults.DefaultRemoteCLIURL, "takes a remote endpoint in the form of <protocol>://<host> (uses RPC Port)")
rootCmd.PersistentFlags().StringVar(&privateKeyFilePath, "path_to_private_key_file", "./pk.json", "Path to private key to use when signing")
rootCmd.PersistentFlags().BoolVar(&notInteractive, "not_interactive", false, "if true skips the interactive prompts wherever possible (useful for scripting)")
deblasis marked this conversation as resolved.
Show resolved Hide resolved
}

var rootCmd = &cobra.Command{
Expand Down
102 changes: 64 additions & 38 deletions app/client/cli/debug.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package cli

import (
"context"
"os"

"github.com/manifoldco/promptui"
"github.com/pokt-network/pocket/logger"
"github.com/pokt-network/pocket/p2p"
debugABP "github.com/pokt-network/pocket/p2p/providers/addrbook_provider/debug"
debugCHP "github.com/pokt-network/pocket/p2p/providers/current_height_provider/debug"
"github.com/pokt-network/pocket/p2p/providers/addrbook_provider"
rpcABP "github.com/pokt-network/pocket/p2p/providers/addrbook_provider/rpc"
"github.com/pokt-network/pocket/p2p/providers/current_height_provider"
rpcCHP "github.com/pokt-network/pocket/p2p/providers/current_height_provider/rpc"
"github.com/pokt-network/pocket/p2p/types"
"github.com/pokt-network/pocket/runtime"
coreTypes "github.com/pokt-network/pocket/shared/core/types"
pocketCrypto "github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/messaging"
"github.com/pokt-network/pocket/shared/modules"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -44,15 +46,17 @@ var (
PromptSendBlockRequest,
}

// 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

configPath string = getEnv("CONFIG_PATH", "build/config/config1.json")
genesisPath string = getEnv("GENESIS_PATH", "build/config/genesis.json")
)

type ctxKey int
deblasis marked this conversation as resolved.
Show resolved Hide resolved

const (
addrBookProviderCtxKey ctxKey = iota
currentHeightProviderCtxKey
)

func getEnv(key, defaultValue string) string {
if value, ok := os.LookupEnv(key); ok {
return value
Expand All @@ -71,24 +75,26 @@ func NewDebugCommand() *cobra.Command {
Short: "Debug utility for rapid development",
Args: cobra.ExactArgs(0),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
runtimeMgr := runtime.NewManagerFromFiles(configPath, genesisPath, runtime.WithClientDebugMode(), runtime.WithRandomPK())

// HACK(#416): this is a temporary solution that guarantees backward compatibility while we implement peer discovery.
validators = runtimeMgr.GetGenesis().Validators
runtimeMgr := runtime.NewManagerFromFiles(
configPath, genesisPath,
runtime.WithClientDebugMode(),
runtime.WithRandomPK(),
)

debugAddressBookProvider := debugABP.NewDebugAddrBookProvider(
runtimeMgr.GetConfig().P2P,
debugABP.WithActorsByHeight(
map[int64][]*coreTypes.Actor{
debugABP.ANY_HEIGHT: validators,
},
modulesRegistry := runtimeMgr.GetBus().GetModulesRegistry()
addressBookProvider := rpcABP.NewRPCAddrBookProvider(
rpcABP.WithP2PConfig(
runtimeMgr.GetConfig().P2P,
),
)
modulesRegistry.RegisterModule(addressBookProvider)
cmd.SetContext(context.WithValue(cmd.Context(), addrBookProviderCtxKey, addressBookProvider))

debugCurrentHeightProvider := debugCHP.NewDebugCurrentHeightProvider(0)
currentHeightProvider := rpcCHP.NewRPCCurrentHeightProvider()
modulesRegistry.RegisterModule(currentHeightProvider)
cmd.SetContext(context.WithValue(cmd.Context(), currentHeightProviderCtxKey, currentHeightProvider))
Olshansk marked this conversation as resolved.
Show resolved Hide resolved

// TODO(#429): refactor injecting the dependencies into the bus so that they can be consumed in an updated `P2PModule.Create()` implementation
p2pM, err := p2p.CreateWithProviders(runtimeMgr.GetBus(), debugAddressBookProvider, debugCurrentHeightProvider)
p2pM, err := p2p.Create(runtimeMgr.GetBus())
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create p2p module")
}
Expand All @@ -105,7 +111,7 @@ func NewDebugCommand() *cobra.Command {
func runDebug(cmd *cobra.Command, args []string) (err error) {
for {
if selection, err := promptGetInput(); err == nil {
handleSelect(selection)
handleSelect(cmd, selection)
} else {
return err
}
Expand Down Expand Up @@ -133,57 +139,57 @@ func promptGetInput() (string, error) {
return result, nil
}

func handleSelect(selection string) {
func handleSelect(cmd *cobra.Command, selection string) {
switch selection {
case PromptResetToGenesis:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_RESET_TO_GENESIS,
Message: nil,
}
broadcastDebugMessage(m)
broadcastDebugMessage(cmd, m)
case PromptPrintNodeState:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_PRINT_NODE_STATE,
Message: nil,
}
broadcastDebugMessage(m)
broadcastDebugMessage(cmd, m)
case PromptTriggerNextView:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_TRIGGER_NEXT_VIEW,
Message: nil,
}
broadcastDebugMessage(m)
broadcastDebugMessage(cmd, m)
case PromptTogglePacemakerMode:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_TOGGLE_PACE_MAKER_MODE,
Message: nil,
}
broadcastDebugMessage(m)
broadcastDebugMessage(cmd, m)
case PromptShowLatestBlockInStore:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_SHOW_LATEST_BLOCK_IN_STORE,
Message: nil,
}
sendDebugMessage(m)
sendDebugMessage(cmd, m)
case PromptSendMetadataRequest:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_SEND_METADATA_REQ,
Message: nil,
}
broadcastDebugMessage(m)
broadcastDebugMessage(cmd, m)
case PromptSendBlockRequest:
m := &messaging.DebugMessage{
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_SEND_BLOCK_REQ,
Message: nil,
}
broadcastDebugMessage(m)
broadcastDebugMessage(cmd, m)
default:
logger.Global.Error().Msg("Selection not yet implemented...")
}
}

// Broadcast to the entire validator set
func broadcastDebugMessage(debugMsg *messaging.DebugMessage) {
func broadcastDebugMessage(cmd *cobra.Command, debugMsg *messaging.DebugMessage) {
anyProto, err := anypb.New(debugMsg)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create Any proto")
Expand All @@ -192,33 +198,40 @@ func broadcastDebugMessage(debugMsg *messaging.DebugMessage) {
// TODO(olshansky): Once we implement the cleanup layer in RainTree, we'll be able to use
// broadcast. The reason it cannot be done right now is because this client is not in the
// address book of the actual validator nodes, so `node1.consensus` never receives the message.
// p2pMod.Broadcast(anyProto, messaging.PocketTopic_DEBUG_TOPIC)
// p2pMod.Broadcast(anyProto)

for _, valAddr := range validators {
addr, err := pocketCrypto.NewAddress(valAddr.GetAddress())
addrBook, err := fetchAddressBook(cmd)
for _, val := range addrBook {
addr := val.Address
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to convert validator address into pocketCrypto.Address")
}
if err := p2pMod.Send(addr, anyProto); err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to send debug message")
}
}

}

// Send to just a single (i.e. first) validator in the set
func sendDebugMessage(debugMsg *messaging.DebugMessage) {
func sendDebugMessage(cmd *cobra.Command, debugMsg *messaging.DebugMessage) {
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
anyProto, err := anypb.New(debugMsg)
if err != nil {
logger.Global.Error().Err(err).Msg("Failed to create Any proto")
}

addrBook, err := fetchAddressBook(cmd)
if err != nil {
logger.Global.Fatal().Msg("Unable to retrieve the addrBook")
}

var validatorAddress []byte
if len(validators) == 0 {
if len(addrBook) == 0 {
logger.Global.Fatal().Msg("No validators found")
}

// if the message needs to be broadcast, it'll be handled by the business logic of the message handler
validatorAddress, err = pocketCrypto.NewAddress(validators[0].GetAddress())
validatorAddress = addrBook[0].Address
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to convert validator address into pocketCrypto.Address")
}
Expand All @@ -227,3 +240,16 @@ func sendDebugMessage(debugMsg *messaging.DebugMessage) {
logger.Global.Fatal().Err(err).Msg("Failed to send debug message")
}
}

// fetchAddressBook retrieves the providers from the CLI context and uses them to retrieve the address book for the current height
func fetchAddressBook(cmd *cobra.Command) (types.AddrBook, error) {
addrBookProvider := cmd.Context().Value(addrBookProviderCtxKey)
currentHeightProvider := cmd.Context().Value(currentHeightProviderCtxKey)

height := currentHeightProvider.(current_height_provider.CurrentHeightProvider).CurrentHeight()
addrBook, err := addrBookProvider.(addrbook_provider.AddrBookProvider).GetStakedAddrBookAtHeight(height)
if err != nil {
logger.Global.Fatal().Msg("Unable to retrieve the addrBook")
}
return addrBook, err
}
5 changes: 5 additions & 0 deletions app/client/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.12] - 2023-02-10

- Added `not_interactive` flag to allow for non-interactive `Stake` and `Unstake` transactions (dogfooding in `cluster-manager`)
- Updated CLI to use to source the address book and the current height from the RPC server leveraging the `rpcAddressBookProvider` and `rpcCurrentHeightProvider` respectively and the `bus` for dependency injection
Olshansk marked this conversation as resolved.
Show resolved Hide resolved

## [0.0.0.11] - 2023-02-09

- Added debugging prompts to drive state sync requests
Expand Down
4 changes: 4 additions & 0 deletions app/pocket/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.5] - 2023-02-10

- Updated to handle `bootstrap-nodes` flag that can be used to override the default bootstrap nodes

## [0.0.0.4] - 2023-02-07

- Added GITHUB_WIKI tags where it was missing
Expand Down
8 changes: 7 additions & 1 deletion app/pocket/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
func main() {
configFilename := flag.String("config", "", "Relative or absolute path to the config file.")
genesisFilename := flag.String("genesis", "", "Relative or absolute path to the genesis file.")
bootstrapNodes := flag.String("bootstrap-nodes", "", "Comma separated list of bootstrap nodes.")

v := flag.Bool("version", false, "")
flag.Parse()
Expand All @@ -21,7 +22,12 @@ func main() {
return
}

runtimeMgr := runtime.NewManagerFromFiles(*configFilename, *genesisFilename)
options := []func(*runtime.Manager){}
if bootstrapNodes != nil && *bootstrapNodes != "" {
options = append(options, runtime.WithCustomBootstrapNodes(*bootstrapNodes))
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
}

runtimeMgr := runtime.NewManagerFromFiles(*configFilename, *genesisFilename, options...)
bus, err := runtime.CreateBus(runtimeMgr)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create bus")
Expand Down
Loading