Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokt/main' into chore/libp2p
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bryanchriswhite committed Feb 20, 2023
2 parents a6a8f9b + 6da420c commit e8a19b9
Show file tree
Hide file tree
Showing 229 changed files with 17,860 additions and 4,145 deletions.
38 changes: 26 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ go_staticcheck: ## Run `go staticcheck` on all files in the current project
go_doc:
{ \
if command -v godoc >/dev/null; then \
echo "Visit http://localhost:6060/pocket"; \
echo "Visit http://localhost:6060/pkg/github.com/pokt-network/pocket"; \
godoc -http=localhost:6060 -goroot=${PWD}/..; \
else \
echo "Install with 'go install golang.org/x/tools/cmd/godoc@latest'"; \
Expand Down Expand Up @@ -89,7 +89,7 @@ go_clean_deps: ## Runs `go mod tidy` && `go mod vendor`

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

.PHONY: gofmt
gofmt: ## Format all the .go files in the project in place.
Expand Down Expand Up @@ -222,15 +222,15 @@ mockgen: clean_mocks ## Use `mockgen` to generate mocks used for testing purpose
$(eval modules_dir = "shared/modules")
go generate ./${modules_dir}
echo "Mocks generated in ${modules_dir}/mocks"

$(eval DIRS = p2p libp2p persistence)
for dir in $(DIRS); do \
echo "Processing $$dir mocks..."; \
find $$dir/types/mocks -type f ! -name "mocks.go" -exec rm {} \;; \
go generate ./${dir_name}/...; \
echo "$$dir mocks generated in $$dir/types/mocks"; \
done

# TODO(team): Tested locally with `protoc` version `libprotoc 3.19.4`. In the near future, only the Dockerfiles will be used to compile protos.

.PHONY: protogen_show
Expand All @@ -248,9 +248,10 @@ PROTOC_SHARED = $(PROTOC) -I=./shared
.PHONY: protogen_local
protogen_local: go_protoc-go-inject-tag ## Generate go structures for all of the protobufs
# Shared
$(PROTOC) -I=./shared/core/types/proto --go_out=./shared/core/types ./shared/core/types/proto/*.proto
$(PROTOC) -I=./shared/messaging/proto --go_out=./shared/messaging ./shared/messaging/proto/*.proto
$(PROTOC) -I=./shared/codec/proto --go_out=./shared/codec ./shared/codec/proto/*.proto
$(PROTOC) -I=./shared/core/types/proto --go_out=./shared/core/types ./shared/core/types/proto/*.proto
$(PROTOC) -I=./shared/modules/types/proto --go_out=./shared/modules/types ./shared/modules/types/proto/*.proto
$(PROTOC) -I=./shared/messaging/proto --go_out=./shared/messaging ./shared/messaging/proto/*.proto
$(PROTOC) -I=./shared/codec/proto --go_out=./shared/codec ./shared/codec/proto/*.proto

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

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

# Utility
$(PROTOC_SHARED) -I=./utility/types/proto --go_out=./utility/types ./utility/types/proto/*.proto
Expand Down Expand Up @@ -305,6 +304,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 @@ -411,9 +415,10 @@ benchmark_p2p_addrbook: ## Benchmark all P2P addr book related tests
# DEPRECATE - Code that should be removed in the future
# RESEARCH - A non-trivial action item that requires deep research and investigation being next steps can be taken
# DOCUMENT - A comment that involves the creation of a README or other documentation
# BUG - There is a known existing bug in this code
# 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.
# 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
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"
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"

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

.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
kubectl exec -it deploy/pocket-v1-cli-client --container pocket -- 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
kubectl exec -it deploy/pocket-v1-cli-client --container pocket -- /bin/bash

.PHONY: localnet_logs_validators
localnet_logs_validators: ## Outputs logs from all validators
Expand All @@ -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 All @@ -497,3 +507,7 @@ check_cross_module_imports: ## Lists cross-module imports
echo "-----------------------"
echo "runtime:\n"
grep ${exclude_common} --exclude-dir=runtime -r "github.com/pokt-network/pocket/runtime" || echo "✅ OK!"

.PHONY: send_local_tx
send_local_tx: ## A hardcoded send tx to make LocalNet debugging easier
go run app/client/*.go Account Send 00104055c00bed7c983a48aac7dc6335d7c607a7 00204737d2a165ebe4be3a7d5b0af905b0ea91d8 1000
46 changes: 32 additions & 14 deletions app/client/cli/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package cli

import (
"fmt"
"path/filepath"
"strings"

"github.com/pokt-network/pocket/app/client/keybase"
"github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/utility/types"
"github.com/spf13/cobra"
)

func init() {
accountCmd := NewAccountCommand()
accountCmd.Flags().StringVar(&pwd, "pwd", "", "passphrase used by the cmd, non empty usage bypass interactive prompt")
rootCmd.AddCommand(accountCmd)
rootCmd.AddCommand(NewAccountCommand())
}

func NewAccountCommand() *cobra.Command {
Expand All @@ -22,7 +23,9 @@ func NewAccountCommand() *cobra.Command {
Args: cobra.ExactArgs(0),
}

cmd.AddCommand(accountCommands()...)
cmds := accountCommands()
applySubcommandOptions(cmds, attachPwdFlagToSubcommands())
cmd.AddCommand(cmds...)

return cmd
}
Expand All @@ -34,22 +37,37 @@ func accountCommands() []*cobra.Command {
Short: "Send <fromAddr> <to> <amount>",
Long: "Sends <amount> to address <to> from address <fromAddr>",
Aliases: []string{"send"},
Args: cobra.ExactArgs(3), // REFACTOR(#150): <fromAddr> not being used at the moment. Update once a keybase is implemented.
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
// TODO(#150): update when we have keybase
pk, err := readEd25519PrivateKeyFromFile(privateKeyFilePath)
// Unpack CLI arguments
fromAddrHex := args[0]
fromAddr := crypto.AddressFromString(args[0])
toAddr := crypto.AddressFromString(args[1])
amount := args[2]

// Open the debug keybase at the specified path
pocketDir := strings.TrimSuffix(dataDir, "/")
keybasePath, err := filepath.Abs(pocketDir + keybaseSuffix)
if err != nil {
return err
}
// 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`
// 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.
//
// fromAddr := crypto.AddressFromString(args[0])
toAddr := crypto.AddressFromString(args[1])
amount := args[2]
kb, err := keybase.NewKeybase(keybasePath)
if err != nil {
return err
}

pwd = readPassphrase(pwd)

pk, err := kb.GetPrivKey(fromAddrHex, pwd)
if err != nil {
return err
}
if err := kb.Stop(); err != nil {
return err
}

msg := &types.MessageSend{
FromAddress: pk.Address(),
FromAddress: fromAddr,
ToAddress: toAddr,
Amount: amount,
}
Expand Down
Loading

0 comments on commit e8a19b9

Please sign in to comment.