Skip to content

Commit b0dbfec

Browse files
Merge remote-tracking branch 'pokt/main' into chore/libp2p
* pokt/main: [Infra] KISS 3 - Cluster Manager [Merge me after #521] - (Issues: #490) (#522) Refactor/fix state sync logs (#515) [P2P] KISS 2 - Peer discovery [Merge me after #520] - (Issues: #416, #429) (#521) [Core] KISS 1 - Finite State Machine [Merge me first] - (Issue: #499) (#520) [CLI] Stake command bugfix (#518) [CLI] Cannot run make localnet_client_debug: Cannot initialise the keybase with the validator keys: Unable to find YAML file (#517) Fix the link shown by `make go_doc` Fixed duplicate GITHUB_WIKI tag [Documentation] Update Devlog Formatting (#512) [Docs & Bugs] Minor fixes post keybase changes (#513) [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) (#503) [Tooling] Integrate Keybase w/ CLI (Issue #484 ) (#501) update devlog2.md update devlog2.md Update devlog1.md
2 parents a6a8f9b + 6da420c commit b0dbfec

File tree

229 files changed

+17859
-4143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+17859
-4143
lines changed

Makefile

+26-12
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ go_staticcheck: ## Run `go staticcheck` on all files in the current project
5858
go_doc:
5959
{ \
6060
if command -v godoc >/dev/null; then \
61-
echo "Visit http://localhost:6060/pocket"; \
61+
echo "Visit http://localhost:6060/pkg/github.com/pokt-network/pocket"; \
6262
godoc -http=localhost:6060 -goroot=${PWD}/..; \
6363
else \
6464
echo "Install with 'go install golang.org/x/tools/cmd/godoc@latest'"; \
@@ -89,7 +89,7 @@ go_clean_deps: ## Runs `go mod tidy` && `go mod vendor`
8989

9090
.PHONY: go_lint
9191
go_lint: ## Run all linters that are triggered by the CI pipeline
92-
golangci-lint run ./...
92+
docker run -t --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.51.1 golangci-lint run -v --timeout 2m
9393

9494
.PHONY: gofmt
9595
gofmt: ## Format all the .go files in the project in place.
@@ -222,15 +222,15 @@ mockgen: clean_mocks ## Use `mockgen` to generate mocks used for testing purpose
222222
$(eval modules_dir = "shared/modules")
223223
go generate ./${modules_dir}
224224
echo "Mocks generated in ${modules_dir}/mocks"
225-
225+
226226
$(eval DIRS = p2p libp2p persistence)
227227
for dir in $(DIRS); do \
228228
echo "Processing $$dir mocks..."; \
229229
find $$dir/types/mocks -type f ! -name "mocks.go" -exec rm {} \;; \
230230
go generate ./${dir_name}/...; \
231231
echo "$$dir mocks generated in $$dir/types/mocks"; \
232232
done
233-
233+
234234
# TODO(team): Tested locally with `protoc` version `libprotoc 3.19.4`. In the near future, only the Dockerfiles will be used to compile protos.
235235

236236
.PHONY: protogen_show
@@ -248,9 +248,10 @@ PROTOC_SHARED = $(PROTOC) -I=./shared
248248
.PHONY: protogen_local
249249
protogen_local: go_protoc-go-inject-tag ## Generate go structures for all of the protobufs
250250
# Shared
251-
$(PROTOC) -I=./shared/core/types/proto --go_out=./shared/core/types ./shared/core/types/proto/*.proto
252-
$(PROTOC) -I=./shared/messaging/proto --go_out=./shared/messaging ./shared/messaging/proto/*.proto
253-
$(PROTOC) -I=./shared/codec/proto --go_out=./shared/codec ./shared/codec/proto/*.proto
251+
$(PROTOC) -I=./shared/core/types/proto --go_out=./shared/core/types ./shared/core/types/proto/*.proto
252+
$(PROTOC) -I=./shared/modules/types/proto --go_out=./shared/modules/types ./shared/modules/types/proto/*.proto
253+
$(PROTOC) -I=./shared/messaging/proto --go_out=./shared/messaging ./shared/messaging/proto/*.proto
254+
$(PROTOC) -I=./shared/codec/proto --go_out=./shared/codec ./shared/codec/proto/*.proto
254255

255256
# Runtime
256257
$(PROTOC) -I=./runtime/configs/types/proto --go_out=./runtime/configs/types ./runtime/configs/types/proto/*.proto
@@ -260,8 +261,6 @@ protogen_local: go_protoc-go-inject-tag ## Generate go structures for all of the
260261

261262
# Persistence
262263
$(PROTOC_SHARED) -I=./persistence/indexer/proto --go_out=./persistence/indexer ./persistence/indexer/proto/*.proto
263-
$(PROTOC_SHARED) -I=./persistence/proto --go_out=./persistence/types ./persistence/proto/*.proto
264-
protoc-go-inject-tag -input="./persistence/types/*.pb.go"
265264

266265
# Utility
267266
$(PROTOC_SHARED) -I=./utility/types/proto --go_out=./utility/types ./utility/types/proto/*.proto
@@ -305,6 +304,11 @@ generate_cli_commands_docs: ## (Re)generates the CLI commands docs (this is mean
305304
cd app/client/cli/docgen && go run .
306305
echo "CLI commands docs generated in ${cli_docs_dir}"
307306

307+
.PHONY: generate_node_state_machine_diagram
308+
generate_node_state_machine_diagram: ## (Re)generates the Node State Machine diagram
309+
go run ./state_machine/visualizer/main.go
310+
echo "Node State Machine diagram generated in state_machine/docs/state-machine.diagram.md"
311+
308312
.PHONY: test_all
309313
test_all: ## Run all go unit tests
310314
go test -p 1 -count=1 ./...
@@ -411,9 +415,10 @@ benchmark_p2p_addrbook: ## Benchmark all P2P addr book related tests
411415
# DEPRECATE - Code that should be removed in the future
412416
# RESEARCH - A non-trivial action item that requires deep research and investigation being next steps can be taken
413417
# DOCUMENT - A comment that involves the creation of a README or other documentation
418+
# BUG - There is a known existing bug in this code
414419
# DISCUSS_IN_THIS_COMMIT - SHOULD NEVER BE COMMITTED TO MASTER. It is a way for the reviewer of a PR to start / reply to a discussion.
415420
# TODO_IN_THIS_COMMIT - SHOULD NEVER BE COMMITTED TO MASTER. It is a way to start the review process while non-critical changes are still in progress
416-
TODO_KEYWORDS = -e "TODO" -e "TECHDEBT" -e "IMPROVE" -e "DISCUSS" -e "INCOMPLETE" -e "INVESTIGATE" -e "CLEANUP" -e "HACK" -e "REFACTOR" -e "CONSIDERATION" -e "TODO_IN_THIS_COMMIT" -e "DISCUSS_IN_THIS_COMMIT" -e "CONSOLIDATE" -e "DEPRECATE" -e "ADDTEST" -e "RESEARCH"
421+
TODO_KEYWORDS = -e "TODO" -e "TECHDEBT" -e "IMPROVE" -e "DISCUSS" -e "INCOMPLETE" -e "INVESTIGATE" -e "CLEANUP" -e "HACK" -e "REFACTOR" -e "CONSIDERATION" -e "TODO_IN_THIS_COMMIT" -e "DISCUSS_IN_THIS_COMMIT" -e "CONSOLIDATE" -e "DEPRECATE" -e "ADDTEST" -e "RESEARCH" -e "BUG"
417422

418423
# How do I use TODOs?
419424
# 1. <KEYWORD>: <Description of follow up work>;
@@ -458,11 +463,11 @@ localnet_up: ## Starts up a k8s LocalNet with all necessary dependencies (tl;dr
458463

459464
.PHONY: localnet_client_debug
460465
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.
461-
kubectl exec -it deploy/pocket-v1-cli-client -- client debug
466+
kubectl exec -it deploy/pocket-v1-cli-client --container pocket -- client debug
462467

463468
.PHONY: localnet_shell
464469
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).
465-
kubectl exec -it deploy/pocket-v1-cli-client -- /bin/bash
470+
kubectl exec -it deploy/pocket-v1-cli-client --container pocket -- /bin/bash
466471

467472
.PHONY: localnet_logs_validators
468473
localnet_logs_validators: ## Outputs logs from all validators
@@ -477,6 +482,11 @@ localnet_down: ## Stops LocalNet and cleans up dependencies (tl;dr `tilt down` +
477482
tilt down --file=build/localnet/Tiltfile
478483
kubectl delete pvc --ignore-not-found=true data-dependencies-postgresql-0
479484

485+
.PHONY: localnet_db_cli
486+
localnet_db_cli: ## Open a CLI to the local containerized postgres instancedb_cli:
487+
echo "View schema by running 'SELECT schema_name FROM information_schema.schemata;'"
488+
kubectl exec -it services/dependencies-postgresql -- bash -c "psql postgresql://postgres:LocalNetPassword@localhost"
489+
480490
.PHONY: check_cross_module_imports
481491
check_cross_module_imports: ## Lists cross-module imports
482492
$(eval exclude_common=--exclude=Makefile --exclude-dir=shared --exclude-dir=app --exclude-dir=runtime)
@@ -497,3 +507,7 @@ check_cross_module_imports: ## Lists cross-module imports
497507
echo "-----------------------"
498508
echo "runtime:\n"
499509
grep ${exclude_common} --exclude-dir=runtime -r "github.com/pokt-network/pocket/runtime" || echo "✅ OK!"
510+
511+
.PHONY: send_local_tx
512+
send_local_tx: ## A hardcoded send tx to make LocalNet debugging easier
513+
go run app/client/*.go Account Send 00104055c00bed7c983a48aac7dc6335d7c607a7 00204737d2a165ebe4be3a7d5b0af905b0ea91d8 1000

app/client/cli/account.go

+32-14
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ package cli
22

33
import (
44
"fmt"
5+
"path/filepath"
6+
"strings"
57

8+
"github.com/pokt-network/pocket/app/client/keybase"
69
"github.com/pokt-network/pocket/shared/crypto"
710
"github.com/pokt-network/pocket/utility/types"
811
"github.com/spf13/cobra"
912
)
1013

1114
func init() {
12-
accountCmd := NewAccountCommand()
13-
accountCmd.Flags().StringVar(&pwd, "pwd", "", "passphrase used by the cmd, non empty usage bypass interactive prompt")
14-
rootCmd.AddCommand(accountCmd)
15+
rootCmd.AddCommand(NewAccountCommand())
1516
}
1617

1718
func NewAccountCommand() *cobra.Command {
@@ -22,7 +23,9 @@ func NewAccountCommand() *cobra.Command {
2223
Args: cobra.ExactArgs(0),
2324
}
2425

25-
cmd.AddCommand(accountCommands()...)
26+
cmds := accountCommands()
27+
applySubcommandOptions(cmds, attachPwdFlagToSubcommands())
28+
cmd.AddCommand(cmds...)
2629

2730
return cmd
2831
}
@@ -34,22 +37,37 @@ func accountCommands() []*cobra.Command {
3437
Short: "Send <fromAddr> <to> <amount>",
3538
Long: "Sends <amount> to address <to> from address <fromAddr>",
3639
Aliases: []string{"send"},
37-
Args: cobra.ExactArgs(3), // REFACTOR(#150): <fromAddr> not being used at the moment. Update once a keybase is implemented.
40+
Args: cobra.ExactArgs(3),
3841
RunE: func(cmd *cobra.Command, args []string) error {
39-
// TODO(#150): update when we have keybase
40-
pk, err := readEd25519PrivateKeyFromFile(privateKeyFilePath)
42+
// Unpack CLI arguments
43+
fromAddrHex := args[0]
44+
fromAddr := crypto.AddressFromString(args[0])
45+
toAddr := crypto.AddressFromString(args[1])
46+
amount := args[2]
47+
48+
// Open the debug keybase at the specified path
49+
pocketDir := strings.TrimSuffix(dataDir, "/")
50+
keybasePath, err := filepath.Abs(pocketDir + keybaseSuffix)
4151
if err != nil {
4252
return err
4353
}
44-
// NOTE: since we don't have a keybase yet (tracked in #150), we are currently inferring the `fromAddr` from the PrivateKey supplied via the flag `--path_to_private_key_file`
45-
// the following line is commented out to show that once we have a keybase, `fromAddr` should come from the command arguments and not the PrivateKey (pk) anymore.
46-
//
47-
// fromAddr := crypto.AddressFromString(args[0])
48-
toAddr := crypto.AddressFromString(args[1])
49-
amount := args[2]
54+
kb, err := keybase.NewKeybase(keybasePath)
55+
if err != nil {
56+
return err
57+
}
58+
59+
pwd = readPassphrase(pwd)
60+
61+
pk, err := kb.GetPrivKey(fromAddrHex, pwd)
62+
if err != nil {
63+
return err
64+
}
65+
if err := kb.Stop(); err != nil {
66+
return err
67+
}
5068

5169
msg := &types.MessageSend{
52-
FromAddress: pk.Address(),
70+
FromAddress: fromAddr,
5371
ToAddress: toAddr,
5472
Amount: amount,
5573
}

0 commit comments

Comments
 (0)