Skip to content

Commit

Permalink
Merge branch 'feat/tx-client' into refactor/keyring-errors-helpers
Browse files Browse the repository at this point in the history
* feat/tx-client:
  chore: fix import paths post-update
  chore: refactor & condense godoc comments
  chore: update go.mod
  chore: revise (and move to godoc.go) `testblock` & `testeventsquery` pkg godoc comment
  [Tooling] add `go_lint` & `go_imports` make targets & CI step (#129)
  Update README.md
  [Code Health] Support `godoc` by replacing the `pocket `module name with `github.com/pokt-network/poktroll` (#128)
  • Loading branch information
bryanchriswhite committed Nov 6, 2023
2 parents 2d0eead + 338b66e commit 846c93c
Show file tree
Hide file tree
Showing 296 changed files with 1,346 additions and 1,963 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Generate mocks
run: make go_mockgen

- name: Run golangci-lint
run: make go_lint

- name: Build
run: ignite chain build --debug --skip-proto

Expand Down
56 changes: 56 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
linters-settings:
govet:
check-shadowing: true

# TODO_TECHDEBT: Enable each linter listed, 1 by 1, fixing issues as they appear.
# Don't forget to delete the `disable-all: true` line as well.
linters:
disable-all: true
enable:
# - govet
# - revive
# - errcheck
# - unused
- goimports

issues:
exclude-use-default: true
max-issues-per-linter: 0
max-same-issues: 0
# TODO_CONSIDERATION/TODO_TECHDEBT: Perhaps we should prefer enforcing the best
# practices suggested by the linters over convention or the default in generated
# code (where possible). The more exceptions we have, the bigger the gaps will be
# in our linting coverage. We could eliminate or reduce these exceptions step-
# by-step.
exclude-rules:
# Exclude cosmos-sdk module genesis.go files as they are generated with an
# empty import block containing a comment used by ignite CLI.
- path: ^x/.+/genesis\.go$
linters:
- goimports
# Exclude cosmos-sdk module module.go files as they are generated with unused
# parameters and unchecked errors.
- path: ^x/.+/module\.go$
linters:
- revive
- errcheck
# Exclude cosmos-sdk module tx.go files as they are generated with unused
# constants.
- path: ^x/.+/cli/tx\.go$
linters:
- unused
# Exclude simulation code as it's generated with lots of unused parameters.
- path: .*/simulation/.*|_simulation\.go$
linters:
- revive
# Exclude cosmos-sdk module codec files as they are scaffolded with a unused
# paramerters and a comment used by ignite CLI.
- path: ^x/.+/codec.go$
linters:
- revive
- path: _test\.go$
linters:
- errcheck
# TODO_IMPROVE: see https://golangci-lint.run/usage/configuration/#issues-configuration
#new: true,
#fix: true,
50 changes: 41 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ POCKET_ADDR_PREFIX = pokt
.PHONY: install_ci_deps
install_ci_deps: ## Installs `mockgen`
go install "github.com/golang/mock/[email protected]" && mockgen --version
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest && golangci-lint --version
go install golang.org/x/tools/cmd/goimports@latest

########################
### Makefile Helpers ###
Expand All @@ -35,9 +37,9 @@ help: ## Prints all the targets in all the Makefiles
### Checks ###
##############

.PHONY: go_version_check
.PHONY: check_go_version
# Internal helper target - check go version
go_version_check:
check_go_version:
@# Extract the version number from the `go version` command.
@GO_VERSION=$$(go version | cut -d " " -f 3 | cut -c 3-) && \
MAJOR_VERSION=$$(echo $$GO_VERSION | cut -d "." -f 1) && \
Expand All @@ -48,16 +50,27 @@ go_version_check:
exit 1; \
fi

.PHONY: docker_check
.PHONY: check_docker
# Internal helper target - check if docker is installed
docker_check:
check_docker:
{ \
if ( ! ( command -v docker >/dev/null && (docker compose version >/dev/null || command -v docker-compose >/dev/null) )); then \
echo "Seems like you don't have Docker or docker-compose installed. Make sure you review build/localnet/README.md and docs/development/README.md before continuing"; \
exit 1; \
fi; \
}

.PHONY: check_godoc
# Internal helper target - check if godoc is installed
check_godoc:
{ \
if ( ! ( command -v godoc >/dev/null )); then \
echo "Seems like you don't have godoc installed. Make sure you install it via 'go install golang.org/x/tools/cmd/godoc@latest' before continuing"; \
exit 1; \
fi; \
}


.PHONY: warn_destructive
warn_destructive: ## Print WARNING to the user
@echo "This is a destructive action that will affect docker resources outside the scope of this repo!"
Expand All @@ -76,7 +89,7 @@ proto_regen: ## Delete existing protobuf artifacts and regenerate them
#######################

.PHONY: docker_wipe
docker_wipe: docker_check warn_destructive prompt_user ## [WARNING] Remove all the docker containers, images and volumes.
docker_wipe: check_docker warn_destructive prompt_user ## [WARNING] Remove all the docker containers, images and volumes.
docker ps -a -q | xargs -r -I {} docker stop {}
docker ps -a -q | xargs -r -I {} docker rm {}
docker images -q | xargs -r -I {} docker rmi {}
Expand Down Expand Up @@ -104,6 +117,17 @@ localnet_regenesis: ## Regenerate the localnet genesis file
cp ${HOME}/.pocket/config/*_key.json $(POCKETD_HOME)/config/
cp ${HOME}/.pocket/config/genesis.json $(POCKETD_HOME)/config/

###############
### Linting ###
###############

.PHONY: go_lint
go_lint: ## Run all go linters
golangci-lint run --timeout 5m

go_imports: check_go_version ## Run goimports on all go files
go run ./tools/scripts/goimports

#############
### Tests ###
#############
Expand All @@ -113,22 +137,21 @@ test_e2e: ## Run all E2E tests
export POCKET_NODE=$(POCKET_NODE) POCKETD_HOME=../../$(POCKETD_HOME) && go test -v ./e2e/tests/... -tags=e2e

.PHONY: go_test
go_test: go_version_check ## Run all go tests
go_test: check_go_version ## Run all go tests
go test -v -race -tags test ./...

.PHONY: go_test_integration
go_test_integration: go_version_check ## Run all go tests, including integration
go_test_integration: check_go_version ## Run all go tests, including integration
go test -v -race -tags test,integration ./...

.PHONY: itest
itest: go_version_check ## Run tests iteratively (see usage for more)
itest: check_go_version ## Run tests iteratively (see usage for more)
./tools/scripts/itest.sh $(filter-out $@,$(MAKECMDGOALS))
# catch-all target for itest
%:
# no-op
@:


.PHONY: go_mockgen
go_mockgen: ## Use `mockgen` to generate mocks used for testing purposes of all the modules.
find . -name "*_mock.go" | xargs --no-run-if-empty rm
Expand Down Expand Up @@ -391,3 +414,12 @@ acc_balance_total_supply: ## Query the total supply of the network
.PHONY: ignite_acc_list
ignite_acc_list: ## List all the accounts in LocalNet
ignite account list --keyring-dir=$(POCKETD_HOME) --keyring-backend test --address-prefix $(POCKET_ADDR_PREFIX)

#####################
### Documentation ###
#####################
.PHONY: go_docs
go_docs: check_godoc ## Generate documentation for the project
echo "Visit http://localhost:6060/pkg/pocket/"
godoc -http=:6060

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@

**poktroll** is a rollup built using [Rollkit](https://rollkit.dev/), [Cosmos SDK](https://docs.cosmos.network) and [CometBFT](https://cometbft.com/), created with [Ignite CLI](https://ignite.com/cli) for the Shannon upgrade of the [Pocket Network](https://pokt.network) blockchain.

- [Where are the docs?](#where-are-the-docs)
- [Roadmap](#roadmap)
- [Godoc](#godoc)
- [Pocket V1 (Shannon) Docs](#pocket-v1-shannon-docs)
- [Getting Started](#getting-started)
- [Makefile](#makefile)
- [Development](#development)
- [LocalNet](#localnet)

## Where are the docs?

_This repository is still young & early._
_This repository is still young & early. We're focusing on development right now._

### Roadmap

You can find our Roadmap Changelog [here](https://github.com/pokt-network/poktroll/blob/main/docs/roadmap_changelog.md).

### Godoc

The godocs for this repository can be found at [pkg.go.dev/github.com/pokt-network/poktroll](https://pkg.go.dev/github.com/pokt-network/poktroll).

### Pocket V1 (Shannon) Docs

It is the result of a research spike conducted by the Core [Pocket Network](https://pokt.network/) Protocol Team at [GROVE](https://grove.city/) documented [here](https://www.pokt.network/why-pokt-network-is-rolling-with-rollkit-a-technical-deep-dive/) (deep dive) and [here](https://www.pokt.network/a-sovereign-rollup-and-a-modular-future/) (summary).

Expand Down
40 changes: 20 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,26 @@ import (
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/spf13/cast"

appparams "pocket/app/params"
"pocket/docs"
applicationmodule "pocket/x/application"
applicationmodulekeeper "pocket/x/application/keeper"
applicationmoduletypes "pocket/x/application/types"
gatewaymodule "pocket/x/gateway"
gatewaymodulekeeper "pocket/x/gateway/keeper"
gatewaymoduletypes "pocket/x/gateway/types"
pocketmodule "pocket/x/pocket"
pocketmodulekeeper "pocket/x/pocket/keeper"
pocketmoduletypes "pocket/x/pocket/types"
servicemodule "pocket/x/service"
servicemodulekeeper "pocket/x/service/keeper"
servicemoduletypes "pocket/x/service/types"
sessionmodule "pocket/x/session"
sessionmodulekeeper "pocket/x/session/keeper"
sessionmoduletypes "pocket/x/session/types"
suppliermodule "pocket/x/supplier"
suppliermodulekeeper "pocket/x/supplier/keeper"
suppliermoduletypes "pocket/x/supplier/types"
appparams "github.com/pokt-network/poktroll/app/params"
"github.com/pokt-network/poktroll/docs"
applicationmodule "github.com/pokt-network/poktroll/x/application"
applicationmodulekeeper "github.com/pokt-network/poktroll/x/application/keeper"
applicationmoduletypes "github.com/pokt-network/poktroll/x/application/types"
gatewaymodule "github.com/pokt-network/poktroll/x/gateway"
gatewaymodulekeeper "github.com/pokt-network/poktroll/x/gateway/keeper"
gatewaymoduletypes "github.com/pokt-network/poktroll/x/gateway/types"
pocketmodule "github.com/pokt-network/poktroll/x/pocket"
pocketmodulekeeper "github.com/pokt-network/poktroll/x/pocket/keeper"
pocketmoduletypes "github.com/pokt-network/poktroll/x/pocket/types"
servicemodule "github.com/pokt-network/poktroll/x/service"
servicemodulekeeper "github.com/pokt-network/poktroll/x/service/keeper"
servicemoduletypes "github.com/pokt-network/poktroll/x/service/types"
sessionmodule "github.com/pokt-network/poktroll/x/session"
sessionmodulekeeper "github.com/pokt-network/poktroll/x/session/keeper"
sessionmoduletypes "github.com/pokt-network/poktroll/x/session/types"
suppliermodule "github.com/pokt-network/poktroll/x/supplier"
suppliermodulekeeper "github.com/pokt-network/poktroll/x/supplier/keeper"
suppliermoduletypes "github.com/pokt-network/poktroll/x/supplier/types"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"

"pocket/app/params"
"github.com/pokt-network/poktroll/app/params"
)

// makeEncodingConfig creates an EncodingConfig for an amino based test configuration.
Expand Down
2 changes: 1 addition & 1 deletion app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"

"pocket/app"
"github.com/pokt-network/poktroll/app"
)

type storeKeysPrefixes struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/pocketd/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
sdk "github.com/cosmos/cosmos-sdk/types"

"pocket/app"
"github.com/pokt-network/poktroll/app"
)

// InitSDKConfig initializes the SDK's config with the appropriate parameters
Expand Down
4 changes: 2 additions & 2 deletions cmd/pocketd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import (

// this line is used by starport scaffolding # root/moduleImport

"pocket/app"
appparams "pocket/app/params"
"github.com/pokt-network/poktroll/app"
appparams "github.com/pokt-network/poktroll/app/params"
)

// NewRootCmd creates a new root command for a Cosmos SDK application
Expand Down
4 changes: 2 additions & 2 deletions cmd/pocketd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"pocket/app"
"pocket/cmd/pocketd/cmd"
"github.com/pokt-network/poktroll/app"
"github.com/pokt-network/poktroll/cmd/pocketd/cmd"
)

func main() {
Expand Down
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: 1
build:
main: cmd/pocketd
accounts:
- name: faucet
mnemonic: "baby advance work soap slow exclude blur humble lucky rough teach wide chuckle captain rack laundry butter main very cannon donate armor dress follow"
Expand Down
Loading

0 comments on commit 846c93c

Please sign in to comment.