From 3c3cc45b7f4d43c04d5a798b33f164ca2e485860 Mon Sep 17 00:00:00 2001 From: hard-nett Date: Tue, 19 Mar 2024 18:33:57 -0400 Subject: [PATCH] add scripts, md & proto lint --- Makefile | 295 ++++-------------- README.md | 19 +- SECURITY.md | 1 - contrib/devtools/README.md | 2 +- contrib/relayer-tests/README.md | 3 +- docs/README.md | 2 +- docs/static/openapi.yml | 0 proto/Dockerfile | 39 +++ proto/buf.gen.gogo.yaml | 4 +- proto/buf.lock | 13 +- proto/gaia/globalfee/v1beta1/query.proto | 5 +- proto/gaia/globalfee/v1beta1/tx.proto | 5 +- .../osmosis/tokenfactory/v1beta1/params.proto | 6 +- proto/osmosis/tokenfactory/v1beta1/tx.proto | 4 +- proto/terp/clock/v1/genesis.proto | 5 +- proto/terp/clock/v1/query.proto | 16 +- proto/terp/clock/v1/tx.proto | 4 +- proto/terp/drip/v1/genesis.proto | 6 +- proto/terp/drip/v1/query.proto | 1 - proto/terp/drip/v1/tx.proto | 26 +- proto/terp/feeshare/v1/tx.proto | 9 +- scripts/README.md | 4 +- scripts/generate-docs.sh | 40 +++ scripts/makefiles/build.mk | 144 +++++++++ scripts/makefiles/deps.mk | 45 +++ scripts/makefiles/e2e.mk | 66 ++++ scripts/makefiles/lint.mk | 38 +++ scripts/makefiles/proto.mk | 101 ++++++ scripts/makefiles/release.mk | 52 +++ scripts/makefiles/tests.mk | 29 ++ .../create_upgrade_guide/UPGRADE_TEMPLATE.md | 2 +- scripts/replace_import_paths.sh | 61 ++++ x/clock/types/genesis.pb.go | 3 +- x/clock/types/query.pb.go | 6 +- x/drip/spec/01_authorization.md | 2 +- x/drip/spec/02_distribute_tokens.md | 6 +- x/drip/spec/03_example.md | 2 +- x/drip/spec/README.md | 4 +- x/drip/types/genesis.pb.go | 3 +- x/drip/types/tx.pb.go | 12 +- 40 files changed, 786 insertions(+), 299 deletions(-) delete mode 100644 docs/static/openapi.yml create mode 100644 proto/Dockerfile create mode 100644 scripts/generate-docs.sh create mode 100644 scripts/makefiles/build.mk create mode 100644 scripts/makefiles/deps.mk create mode 100644 scripts/makefiles/e2e.mk create mode 100644 scripts/makefiles/lint.mk create mode 100644 scripts/makefiles/proto.mk create mode 100644 scripts/makefiles/release.mk create mode 100644 scripts/makefiles/tests.mk create mode 100644 scripts/replace_import_paths.sh diff --git a/Makefile b/Makefile index ca10cee0..38a635a4 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,67 @@ #!/usr/bin/make -f +include scripts/makefiles/proto.mk +include scripts/makefiles/release.mk +include scripts/makefiles/lint.mk +include scripts/makefiles/tests.mk +include scripts/makefiles/e2e.mk +include scripts/makefiles/heighliner.mk +include scripts/makefiles/build.mk +include scripts/makefiles/deps.mk + + +.DEFAULT_GOAL := help +help: + @echo "Available top-level commands:" + @echo "" + @echo "Usage:" + @echo " make [command]" + @echo "" + @echo " make build Build terpd binary" + @echo " make build-help Show available build commands" + @echo " make deps Show available deps commands" + @echo " make heighliner Show available docker commands" + @echo " make e2e Show available e2e commands" + @echo " make install Install terpd binary" + @echo " make lint Show available lint commands" + @echo " make proto Show available proto commands" + @echo " make release Show available release commands" + @echo " make release-help Show available release commands" + @echo " make test Show available test commands" + @echo "" + @echo "Run 'make [subcommand]' to see the available commands for each subcommand." + +# git info BRANCH := $(shell git rev-parse --abbrev-ref HEAD) -COMMIT := $(shell git log -1 --format='%H') VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') -BINDIR ?= $(GOPATH)/bin -APP = ./app +COMMIT := $(shell git log -1 --format='%H') + +LEDGER_ENABLED ?= true +SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') +BUILDDIR ?= $(CURDIR)/build +DOCKER := $(shell which docker) +E2E_UPGRADE_VERSION := "v4" + + + +DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE) +PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') +BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0 +SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') +HTTPS_GIT := https://github.com/terpnetwork/terp-core.git + + +GO_MODULE := $(shell cat go.mod | grep "module " | cut -d ' ' -f 2) +GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2) +GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1) +GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2) +GO_MINIMUM_MAJOR_VERSION = $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f2 | cut -d'.' -f1) +GO_MINIMUM_MINOR_VERSION = $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f2 | cut -d'.' -f2) +# message to be printed if Go does not meet the minimum required version +GO_VERSION_ERR_MSG = "ERROR: Go version $(GO_MINIMUM_MAJOR_VERSION).$(GO_MINIMUM_MINOR_VERSION)+ is required" + + +export GO111MODULE = on # don't override user values ifeq (,$(VERSION)) @@ -15,10 +72,6 @@ ifeq (,$(VERSION)) endif endif -PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') -LEDGER_ENABLED ?= true -SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') - # don't override user values ifeq (,$(VERSION)) VERSION := $(shell git describe --tags) @@ -28,12 +81,6 @@ ifeq (,$(VERSION)) endif endif -# for dockerized protobuf tools -DOCKER := $(shell which docker) -BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0 -DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE) -HTTPS_GIT := https://github.com/terpnetwork/terp-core.git - export GO111MODULE = on # process build tags @@ -69,9 +116,9 @@ build_tags += $(BUILD_TAGS) build_tags := $(strip $(build_tags)) whitespace := -empty = $(whitespace) $(whitespace) +whitespace := $(whitespace) $(whitespace) comma := , -build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags)) +build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) # process linker flags @@ -93,195 +140,20 @@ ldflags := $(strip $(ldflags)) BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath -# The below include contains the tools and runsim targets. -include contrib/devtools/Makefile - -all: install - @echo "--> project root: go mod tidy" - @go mod tidy - @echo "--> project root: linting --fix" - @GOGC=1 golangci-lint run --fix --timeout=8m - -install: go.sum - go install -mod=readonly $(BUILD_FLAGS) ./cmd/terpd - -build: go.sum -ifeq ($(OS),Windows_NT) - $(error terpd server not supported. Use "make build-windows-client" for client) - exit 1 -else - go build -mod=readonly $(BUILD_FLAGS) -o build/terpd ./cmd/terpd -endif - -build-windows-client: go.sum - GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/terpd.exe ./cmd/terpd - -build-contract-tests-hooks: -ifeq ($(OS),Windows_NT) - go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests -else - go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests -endif - -test-node: - CHAIN_ID="local-1" HOME_DIR="~/.terp1" TIMEOUT_COMMIT="500ms" CLEAN=true sh scripts/test_node.sh - ############################################################################### -### Testing ### +### Build & Install ### ############################################################################### -test: test-unit -test-all: check test-race test-cover - -test-unit: - @VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./... - -benchmark: - @go test -mod=readonly -bench=. ./... +build: build-check-version go.sum + mkdir -p $(BUILDDIR)/ + GOWORK=off go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ $(GO_MODULE)/cmd/terpd -test-sim-multi-seed-short: runsim - @echo "Running short multi-seed application simulation. This may take awhile!" - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 5 TestFullAppSimulation - -test-sim-deterministic: runsim - @echo "Running short multi-seed application simulation. This may take awhile!" - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 1 1 TestAppStateDeterminism - -############################################################################### -### Tools & dependencies ### -############################################################################### - -go-mod-cache: go.sum - @echo "--> Download go modules to local cache" - @go mod download - -go.sum: go.mod - @echo "--> Ensure dependencies have not been modified" - @go mod verify - -draw-deps: - @# requires brew install graphviz or apt-get install graphviz - go install github.com/RobotsAndPencils/goviz@latest - @goviz -i ./cmd/terpd -d 2 | dot -Tpng -o dependency-graph.png - -clean: - rm -rf snapcraft-local.yaml build/ - -distclean: clean - rm -rf vendor/ - -############################################################################### -### Linting ### -############################################################################### - -format-tools: - go install mvdan.cc/gofumpt@v0.4.0 - go install github.com/client9/misspell/cmd/misspell@v0.3.4 - go install golang.org/x/tools/cmd/goimports@latest - -lint: format-tools - golangci-lint run --tests=false - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*_test.go" | xargs gofumpt -d -format: format-tools - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofumpt -w -s - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofumpt -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/terpnetwork/terp-core - -############################################################################### -### e2e interchain test ### -############################################################################### - - # Executes basic chain tests via interchaintest -ictest-basic: rm-testcache - cd interchaintest && go test -race -v -run TestBasicTerpStart . - -ictest-statesync: rm-testcache - cd interchaintest && go test -race -v -run TestTerpStateSync . - -ictest-ibchooks: rm-testcache - cd interchaintest && go test -race -v -run TestTerpIBCHooks . - -ictest-pfm: rm-testcache - cd interchaintest && go test -race -v -run TestPacketForwardMiddlewareRouter . - -ictest-tokenfactory: rm-testcache - cd interchaintest && go test -race -v -run TestTerpTokenFactory . - -# ictest-clock: rm-testcache -# cd interchaintest && go test -race -v -run TestTerpClock . - -ictest-feeshare: rm-testcache - cd interchaintest && go test -race -v -run TestTerpFeeShare . - -# Executes a basic chain upgrade test via interchaintest -ictest-upgrade: rm-testcache - cd interchaintest && go test -race -v -run TestBasicTerpUpgrade . - -# Executes a basic chain upgrade locally via interchaintest after compiling a local image as terpnetwork:local -ictest-upgrade-local: local-image ictest-upgrade - -# Executes IBC tests via interchaintest -ictest-ibc: rm-testcache - cd interchaintest && go test -race -v -run TestTerpGaiaIBCTransfer . - -rm-testcache: - go clean -testcache - -.PHONY: test-mutation ictest-basic ictest-upgrade ictest-ibc - -############################################################################### -### heighliner ### -############################################################################### - -get-heighliner: - git clone https://github.com/strangelove-ventures/heighliner.git - cd heighliner && go install - -local-image: -ifeq (,$(shell which heighliner)) - echo 'heighliner' binary not found. Consider running `make get-heighliner` -else - heighliner build -c terpnetwork --local -f ./chains.yaml -endif - -.PHONY: get-heighliner local-image -############################################################################### -### Protobuf ### -############################################################################### -protoVer=0.13.1 -protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) -protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) - -proto-all: proto-format proto-lint proto-gen format - -proto-gen: - @echo "Generating Protobuf files" - @$(protoImage) sh ./scripts/protocgen.sh - -proto-swagger-gen: - @echo "Generating Protobuf Swagger" - @$(protoImage) sh ./scripts/protoc_swagger_openapi_gen.sh - $(MAKE) update-swagger-docs - -proto-format: - @echo "Formatting Protobuf files" - @$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \; - -proto-lint: - @$(DOCKER_BUF) lint --error-format=json - -proto-check-breaking: - @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main - -.PHONY: all install install-debug \ - go-mod-cache draw-deps clean build format \ - test test-all test-build test-cover test-unit test-race \ - test-sim-import-export build-windows-client \ +install: build-check-version go.sum + GOWORK=off go install -mod=readonly $(BUILD_FLAGS) $(GO_MODULE)/cmd/terpd ############################################################################### ### Release ### ############################################################################### - GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') @@ -300,33 +172,4 @@ release: else release: @echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'." -endif - -release-dry-run: - docker run \ - --rm \ - -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v `pwd`:/go/src/terpd \ - -w /go/src/terpd \ - $(GORELEASER_IMAGE) \ - release \ - --clean \ - --skip-publish - -release-snapshot: - docker run \ - --rm \ - -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v `pwd`:/go/src/terpd \ - -w /go/src/terpd \ - $(GORELEASER_IMAGE) \ - release \ - --clean \ - --snapshot \ - --skip-validate \ - --skip-publish - -create-binaries: - \ No newline at end of file +endif \ No newline at end of file diff --git a/README.md b/README.md index dd0ef659..68b71dd5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ For issues & disclosure, see [SECURITY.md](SECURITY.md) ## Stability **This is beta software** It is run in some production systems, but we cannot yet provide a stability guarantee -and have not yet gone through and audit of this codebase. +and have not yet gone through and audit of this codebase. Thank you to all projects who have run this code in your mainnets and testnets and given feedback to improve stability. @@ -21,6 +21,7 @@ make test ``` ## Protobuf + ``` make proto-gen ``` @@ -29,26 +30,33 @@ make proto-gen ### Dev server - ### CI -#### Github + +#### Github + Some pre-commit scripts to help with quality code practices: **Linter** + ```sh sh scripts/git/linter.sh ``` + **Markdown Linter** + ```sh sh scripts/git/markdown_lint.sh ``` + **Tidy** + ```sh sh scripts/git/markdown_lint.sh ``` ## Contributors + This framework is like a craft genetics lineage, one that has been fine tuned with love, trial and error, patience, and iterations. The following is a list of teams, companies, and contributors that are impactful to Terp Network's creation, massive respect! - CosmosSDK Contributors @@ -60,7 +68,8 @@ This framework is like a craft genetics lineage, one that has been fine tuned wi If we forgot you in this list, let us know or open a PR ::) - ## DISCLAIMER + # Disclaimer -TERP-CORE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in running terp-core software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of Stargaze, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. Although Discover Decentralization, LLC and it's affiliates developed the initial code for Terp-Core, it does not own or control the Terp Network, which is run by a decentralized validator set. \ No newline at end of file + +TERP-CORE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in running terp-core software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of Stargaze, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. Although Discover Decentralization, LLC and it's affiliates developed the initial code for Terp-Core, it does not own or control the Terp Network, which is run by a decentralized validator set. diff --git a/SECURITY.md b/SECURITY.md index 1cc01ada..f3326aa8 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -47,4 +47,3 @@ Please assist the Terp Network Security team by following these guidelines: - Demonstrate good faith by not disrupting the Terp Network's networks, data, services or communities; _Every effort will be made to handle and address security issues as quickly and efficiently as possible._ - diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md index b005dc25..e5415df6 100644 --- a/contrib/devtools/README.md +++ b/contrib/devtools/README.md @@ -3,4 +3,4 @@ Thanks to the entire Cosmos SDK team and the contributors who put their efforts into making simulation testing easier to implement. 🤗 - \ No newline at end of file + diff --git a/contrib/relayer-tests/README.md b/contrib/relayer-tests/README.md index cdeeadb5..60530133 100644 --- a/contrib/relayer-tests/README.md +++ b/contrib/relayer-tests/README.md @@ -8,7 +8,6 @@ Make sure you run below scripts under `terpd/contrib/relayer-tests` directory. - `./test_ibc_transfer.sh` will setup a path between chains and send tokens between chains. ## Thank you + The setup scripts here are taken from [cosmos/relayer](https://github.com/cosmos/relayer) Thank your relayer team for these scripts. - - diff --git a/docs/README.md b/docs/README.md index 8beace18..b9d7f985 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,3 @@ # Generated doc only -Tutorials and project doc is available on https://docs.cosmwasm.com/ +Tutorials and project doc is available on diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/proto/Dockerfile b/proto/Dockerfile new file mode 100644 index 00000000..1f6860bd --- /dev/null +++ b/proto/Dockerfile @@ -0,0 +1,39 @@ +# This Dockerfile is used for proto generation +# To build, run `make proto-image-build` + +FROM bufbuild/buf:1.7.0 as BUILDER + +FROM golang:1.21-alpine + + +RUN apk add --no-cache \ + nodejs \ + npm \ + git \ + make + +ENV GOLANG_PROTOBUF_VERSION=1.28.0 \ + GOGO_PROTOBUF_VERSION=1.3.2 \ + GRPC_GATEWAY_VERSION=1.16.0 + + +RUN go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} +RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION} + +# install all gogo protobuf binaries +RUN git clone https://github.com/regen-network/protobuf.git; \ + cd protobuf; \ + go mod download; \ + make install + +# we need to use git clone because we use 'replace' directive in go.mod +# protoc-gen-gocosmos was moved to to in cosmos/gogoproto but pending a migration there. +RUN git clone https://github.com/regen-network/cosmos-proto.git; \ + cd cosmos-proto/protoc-gen-gocosmos; \ + go install . + +RUN npm install -g swagger-combine + +COPY --from=BUILDER /usr/local/bin /usr/local/bin \ No newline at end of file diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml index 4e8fb72d..855ea251 100644 --- a/proto/buf.gen.gogo.yaml +++ b/proto/buf.gen.gogo.yaml @@ -2,7 +2,7 @@ version: v1 plugins: - name: gocosmos out: .. - opt: plugins=grpc,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1alpha1/orm.proto=github.com/cosmos/cosmos-sdk/api/cosmos/orm/v1alpha1 + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types - name: grpc-gateway out: .. - opt: logtostderr=true,allow_colon_final_segments=true + opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file diff --git a/proto/buf.lock b/proto/buf.lock index f802501e..7906031c 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -14,10 +14,15 @@ deps: - remote: buf.build owner: cosmos repository: gogo-proto - commit: 5e5b9fdd01804356895f8f79a6f1ddc1 - digest: shake256:0b85da49e2e5f9ebc4806eae058e2f56096ff3b1c59d1fb7c190413dd15f45dd456f0b69ced9059341c80795d2b6c943de15b120a9e0308b499e43e4b5fc2952 + commit: 34d970b699f84aa382f3c29773a60836 + digest: shake256:3d3bee5229ba579e7d19ffe6e140986a228b48a8c7fe74348f308537ab95e9135210e81812489d42cd8941d33ff71f11583174ccc5972e86e6112924b6ce9f04 + - remote: buf.build + owner: cosmos + repository: ics23 + commit: 55085f7c710a45f58fa09947208eb70b + digest: shake256:9bf0bc495b5a11c88d163d39ef521bc4b00bc1374a05758c91d82821bdc61f09e8c2c51dda8452529bf80137f34d852561eacbe9550a59015d51cecb0dacb628 - remote: buf.build owner: googleapis repository: googleapis - commit: 28151c0d0a1641bf938a7672c500e01d - digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de + commit: 8d7204855ec14631a499bd7393ce1970 + digest: shake256:40bf4112960cad01281930beed85829910768e32e80e986791596853eccd42c0cbd9d96690b918f658020d2d427e16f8b6514e2ac7f4a10306fd32e77be44329 diff --git a/proto/gaia/globalfee/v1beta1/query.proto b/proto/gaia/globalfee/v1beta1/query.proto index 6d2cc114..b68ee6a6 100644 --- a/proto/gaia/globalfee/v1beta1/query.proto +++ b/proto/gaia/globalfee/v1beta1/query.proto @@ -9,11 +9,10 @@ option go_package = "github.com/cosmos/gaia/x/globalfee/types"; // Query defines the gRPC querier service. service Query { - // MinimumGasPrices returns the minimum gas prices. + // MinimumGasPrices returns the minimum gas prices. rpc MinimumGasPrices(QueryMinimumGasPricesRequest) returns (QueryMinimumGasPricesResponse) { - option (google.api.http).get = - "/gaia/globalfee/v1beta1/minimum_gas_prices"; + option (google.api.http).get = "/gaia/globalfee/v1beta1/minimum_gas_prices"; } } diff --git a/proto/gaia/globalfee/v1beta1/tx.proto b/proto/gaia/globalfee/v1beta1/tx.proto index 3db2354e..da6e37d5 100644 --- a/proto/gaia/globalfee/v1beta1/tx.proto +++ b/proto/gaia/globalfee/v1beta1/tx.proto @@ -24,12 +24,12 @@ message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; // authority is the address of the governance account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the x/mint parameters to update. // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; + Params params = 2 [ (gogoproto.nullable) = false ]; } // MsgUpdateParamsResponse defines the response structure for executing a @@ -37,4 +37,3 @@ message MsgUpdateParams { // // Since: cosmos-sdk 0.47 message MsgUpdateParamsResponse {} - \ No newline at end of file diff --git a/proto/osmosis/tokenfactory/v1beta1/params.proto b/proto/osmosis/tokenfactory/v1beta1/params.proto index 0e82a242..0131c116 100644 --- a/proto/osmosis/tokenfactory/v1beta1/params.proto +++ b/proto/osmosis/tokenfactory/v1beta1/params.proto @@ -16,10 +16,10 @@ message Params { (gogoproto.nullable) = false ]; - // if denom_creation_fee is an empty array, then this field is used to add more gas consumption - // to the base cost. + // if denom_creation_fee is an empty array, then this field is used to add + // more gas consumption to the base cost. // https://github.com/CosmWasm/token-factory/issues/11 - uint64 denom_creation_gas_consume = 2 [ + uint64 denom_creation_gas_consume = 2 [ (gogoproto.moretags) = "yaml:\"denom_creation_gas_consume\"", (gogoproto.nullable) = true ]; diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto index b859f42c..758de60d 100644 --- a/proto/osmosis/tokenfactory/v1beta1/tx.proto +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -124,12 +124,12 @@ message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; // authority is the address of the governance account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the x/mint parameters to update. // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; + Params params = 2 [ (gogoproto.nullable) = false ]; } // MsgUpdateParamsResponse defines the response structure for executing a diff --git a/proto/terp/clock/v1/genesis.proto b/proto/terp/clock/v1/genesis.proto index 7e661371..0b6d678d 100644 --- a/proto/terp/clock/v1/genesis.proto +++ b/proto/terp/clock/v1/genesis.proto @@ -17,8 +17,9 @@ message GenesisState { // Params defines the set of module parameters. message Params { - // contract_addresses stores the list of executable contracts to be ticked on every block. - repeated string contract_addresses = 1 [ + // contract_addresses stores the list of executable contracts to be ticked on + // every block. + repeated string contract_addresses = 1 [ (gogoproto.jsontag) = "contract_addresses,omitempty", (gogoproto.moretags) = "yaml:\"contract_addresses\"" ]; diff --git a/proto/terp/clock/v1/query.proto b/proto/terp/clock/v1/query.proto index db0485a1..02190054 100644 --- a/proto/terp/clock/v1/query.proto +++ b/proto/terp/clock/v1/query.proto @@ -13,8 +13,7 @@ service Query { // ClockContracts rpc ClockContracts(QueryClockContracts) returns (QueryClockContractsResponse) { - option (google.api.http).get = - "/terp/clock/v1/contracts"; + option (google.api.http).get = "/terp/clock/v1/contracts"; } // Params rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { @@ -25,9 +24,10 @@ service Query { // QueryClockContracts is the request type to get all contracts. message QueryClockContracts {} -// QueryClockContractsResponse is the response type for the Query/ClockContracts RPC method. +// QueryClockContractsResponse is the response type for the Query/ClockContracts +// RPC method. message QueryClockContractsResponse { - repeated string contract_addresses = 1 [ + repeated string contract_addresses = 1 [ (gogoproto.jsontag) = "contract_addresses,omitempty", (gogoproto.moretags) = "yaml:\"contract_addresses\"" ]; @@ -36,7 +36,11 @@ message QueryClockContractsResponse { // QueryParams is the request type to get all module params. message QueryParamsRequest {} -// QueryClockContractsResponse is the response type for the Query/ClockContracts RPC method. +// QueryClockContractsResponse is the response type for the Query/ClockContracts +// RPC method. message QueryParamsResponse { - Params params = 1 [(gogoproto.jsontag) = "params", (gogoproto.moretags) = "yaml:\"params\""]; + Params params = 1 [ + (gogoproto.jsontag) = "params", + (gogoproto.moretags) = "yaml:\"params\"" + ]; } diff --git a/proto/terp/clock/v1/tx.proto b/proto/terp/clock/v1/tx.proto index 6b1bf027..8dade155 100644 --- a/proto/terp/clock/v1/tx.proto +++ b/proto/terp/clock/v1/tx.proto @@ -25,12 +25,12 @@ message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; // authority is the address of the governance account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the x/clock parameters to update. // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; + Params params = 2 [ (gogoproto.nullable) = false ]; } // MsgUpdateParamsResponse defines the response structure for executing a diff --git a/proto/terp/drip/v1/genesis.proto b/proto/terp/drip/v1/genesis.proto index 4075e137..1a6fd5be 100644 --- a/proto/terp/drip/v1/genesis.proto +++ b/proto/terp/drip/v1/genesis.proto @@ -15,6 +15,8 @@ message Params { // enable_drip defines a parameter to enable the drip module bool enable_drip = 1; - // allowed_addresses defines the list of addresses authorized to use the module - repeated string allowed_addresses = 3 [ (gogoproto.moretags) = "yaml:\"addresses\"" ]; + // allowed_addresses defines the list of addresses authorized to use the + // module + repeated string allowed_addresses = 3 + [ (gogoproto.moretags) = "yaml:\"addresses\"" ]; } diff --git a/proto/terp/drip/v1/query.proto b/proto/terp/drip/v1/query.proto index 4a901d99..890fbf85 100644 --- a/proto/terp/drip/v1/query.proto +++ b/proto/terp/drip/v1/query.proto @@ -15,7 +15,6 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/terp/drip/v1/params"; } - } // QueryParamsRequest is the request type for the Query/Params RPC method. message QueryParamsRequest {} diff --git a/proto/terp/drip/v1/tx.proto b/proto/terp/drip/v1/tx.proto index 0f305bf3..3a928a93 100644 --- a/proto/terp/drip/v1/tx.proto +++ b/proto/terp/drip/v1/tx.proto @@ -13,7 +13,8 @@ option go_package = "github.com/terpnetwork/terp-core/x/drip/types"; // Msg defines the fees Msg service. service Msg { - // DistributeTokens distribute the sent tokens to all stakers in the next block + // DistributeTokens distribute the sent tokens to all stakers in the next + // block rpc DistributeTokens(MsgDistributeTokens) returns (MsgDistributeTokensResponse) { option (google.api.http).post = "/terp/drip/v1/tx/distribute_tokens"; @@ -22,17 +23,18 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } -// MsgDistributeTokens defines a message that registers a Distribution of tokens. +// MsgDistributeTokens defines a message that registers a Distribution of +// tokens. message MsgDistributeTokens { option (gogoproto.equal) = false; - // sender_address is the bech32 address of message sender. + // sender_address is the bech32 address of message sender. string sender_address = 1; - + // amount is the amount being airdropped to stakers repeated cosmos.base.v1beta1.Coin amount = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } @@ -45,15 +47,17 @@ message MsgDistributeTokensResponse {} // Since: cosmos-sdk 0.47 message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "cosmos-sdk/x/auth/MsgUpdateParams"; + option (amino.name) = "cosmos-sdk/x/auth/MsgUpdateParams"; - // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the x/auth parameters to update. // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Params params = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } message MsgUpdateParamsResponse {} diff --git a/proto/terp/feeshare/v1/tx.proto b/proto/terp/feeshare/v1/tx.proto index e8b51ae5..830d09a7 100644 --- a/proto/terp/feeshare/v1/tx.proto +++ b/proto/terp/feeshare/v1/tx.proto @@ -79,15 +79,16 @@ message MsgCancelFeeShareResponse {} // // Since: cosmos-sdk 0.47 message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; + option (cosmos.msg.v1.signer) = "authority"; - // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the x/feeshare parameters to update. // // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false]; + Params params = 2 [ (gogoproto.nullable) = false ]; } // MsgUpdateParamsResponse defines the response structure for executing a diff --git a/scripts/README.md b/scripts/README.md index c0aba168..948fa379 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,7 +1,7 @@ # Scripts -These scripts are copied from the [Cosmos-SDK](https://github.com/cosmos/cosmos-sdk/tree/v0.42.1/scripts) respository +These scripts are copied from the [Cosmos-SDK](https://github.com/cosmos/cosmos-sdk/tree/v0.42.1/scripts) respository with minor modifications. All credits and big thanks go to the original authors. Please note that a custom [fork](github.com/regen-network/protobuf) by the Regen network team is used. -See [`go.mod`](../go.mod) for version. \ No newline at end of file +See [`go.mod`](../go.mod) for version. diff --git a/scripts/generate-docs.sh b/scripts/generate-docs.sh new file mode 100644 index 00000000..de993524 --- /dev/null +++ b/scripts/generate-docs.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +SWAGGER_DIR=./swagger-proto + +set -eo pipefail + +# prepare swagger generation +mkdir -p "$SWAGGER_DIR/proto" +printf "version: v1\ndirectories:\n - proto\n \n" > "$SWAGGER_DIR/buf.work.yaml" +printf "version: v1\nname: buf.build/terpnetwork/terp-core\n" > "$SWAGGER_DIR/proto/buf.yaml" +cp ./proto/buf.gen.swagger.yaml "$SWAGGER_DIR/proto/buf.gen.swagger.yaml" + +# copy existing proto files +cp -r ./proto/ "$SWAGGER_DIR/proto" + +# create temporary folder to store intermediate results from `buf generate` +mkdir -p ./tmp-swagger-gen + +# step into swagger folder +cd "$SWAGGER_DIR" + +# create swagger files on an individual basis w/ `buf build` and `buf generate` (needed for `swagger-combine`) +proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) +for dir in $proto_dirs; do + # generate swagger files (filter query files) + query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' -o -name 'service.proto' \)) + if [[ -n "$query_file" ]]; then + buf generate --template proto/buf.gen.swagger.yaml "$query_file" + fi +done + +cd .. + +# combine swagger files +# uses nodejs package `swagger-combine`. +# all the individual swagger files need to be configured in `config.json` for merging +swagger-combine ./client/docs/config.json -o ./client/docs/static/swagger/swagger.yaml -f yaml --continueOnConflictingPaths true --includeDefinitions true + +# clean swagger files +rm -rf ./tmp-swagger-gen +rm -rf "$SWAGGER_DIR" \ No newline at end of file diff --git a/scripts/makefiles/build.mk b/scripts/makefiles/build.mk new file mode 100644 index 00000000..f5007aab --- /dev/null +++ b/scripts/makefiles/build.mk @@ -0,0 +1,144 @@ +############################################################################### +### Build & Install ### +############################################################################### + +build-help: + @echo "build subcommands" + @echo "" + @echo "Usage:" + @echo " make build-[command]" + @echo "" + @echo "Available Commands:" + @echo " all Build all targets" + @echo " check-version Check Go version" + @echo " dev-build Build development version" + @echo " dev-install Install development build" + @echo " linux Build for Linux" + @echo " windows Build for Windows" + @echo " reproducible Build reproducible binaries" + @echo " reproducible-amd64 Build reproducible amd64 binary" + @echo " reproducible-arm64 Build reproducible arm64 binary" + +build-check-version: + @echo "Go version: $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION)" + @if [ $(GO_MAJOR_VERSION) -gt $(GO_MINIMUM_MAJOR_VERSION) ]; then \ + echo "Go version is sufficient"; \ + exit 0; \ + elif [ $(GO_MAJOR_VERSION) -lt $(GO_MINIMUM_MAJOR_VERSION) ]; then \ + echo '$(GO_VERSION_ERR_MSG)'; \ + exit 1; \ + elif [ $(GO_MINOR_VERSION) -lt $(GO_MINIMUM_MINOR_VERSION) ]; then \ + echo '$(GO_VERSION_ERR_MSG)'; \ + exit 1; \ + fi + +all: install + @echo "--> project root: go mod tidy" + @go mod tidy + @echo "--> project root: linting --fix" + @GOGC=1 golangci-lint run --fix --timeout=8m + +install: go.sum + go install -mod=readonly $(BUILD_FLAGS) ./cmd/terpd + +build: go.sum +ifeq ($(OS),Windows_NT) + $(error terpd server not supported. Use "make build-windows" for client) + exit 1 +else + go build -mod=readonly $(BUILD_FLAGS) -o build/terpd ./cmd/terpd +endif + +build-windows: go.sum + GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/terpd.exe ./cmd/terpd + +build-dev-install: go.sum + GOWORK=off go install $(DEBUG_BUILD_FLAGS) $(GC_FLAGS) $(GO_MODULE)/cmd/terpd + +build-dev-build: + mkdir -p $(BUILDDIR)/ + GOWORK=off go build $(GC_FLAGS) -mod=readonly -ldflags '$(DEBUG_LDFLAGS)' -gcflags "all=-N -l" -trimpath -o $(BUILDDIR) ./...; + +# Cross-building for arm64 from amd64 (or vice-versa) takes +# a lot of time due to QEMU virtualization but it's the only way (afaik) +# to get a statically linked binary with CosmWasm + +build-reproducible: build-reproducible-amd64 build-reproducible-arm64 + +build-reproducible-amd64: go.sum + mkdir -p $(BUILDDIR) + $(DOCKER) buildx create --name terpbuilder || true + $(DOCKER) buildx use terpbuilder + $(DOCKER) buildx build \ + --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GIT_VERSION=$(VERSION) \ + --build-arg GIT_COMMIT=$(COMMIT) \ + --build-arg RUNNER_IMAGE=alpine:3.17 \ + --platform linux/amd64 \ + -t terp-core:local-amd64 \ + --load \ + -f Dockerfile . + $(DOCKER) rm -f terpbinary || true + $(DOCKER) create -ti --name terpbinary terpn-core:local-amd64 + $(DOCKER) cp terpbinary:/bin/terpd $(BUILDDIR)/terpd-linux-amd64 + $(DOCKER) rm -f terpbinary + +build-reproducible-arm64: go.sum + mkdir -p $(BUILDDIR) + $(DOCKER) buildx create --name terpbuilder || true + $(DOCKER) buildx use terpbuilder + $(DOCKER) buildx build \ + --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GIT_VERSION=$(VERSION) \ + --build-arg GIT_COMMIT=$(COMMIT) \ + --build-arg RUNNER_IMAGE=alpine:3.17 \ + --platform linux/arm64 \ + -t terp-core:local-arm64 \ + --load \ + -f Dockerfile . + $(DOCKER) rm -f terpbinary || true + $(DOCKER) create -ti --name terpbinary terp-core:local-arm64 + $(DOCKER) cp osmobinary:/bin/terpd $(BUILDDIR)/terpd-linux-arm64 + $(DOCKER) rm -f terpbinary + +build-linux: go.sum + LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build + + +# build-install-with-autocomplete: build-check-version go.sum +# GOWORK=off go install -mod=readonly $(BUILD_FLAGS) $(GO_MODULE)/cmd/terpd +# @PARENT_SHELL=$$(ps -o ppid= -p $$PPID | xargs ps -o comm= -p); \ +# if echo "$$PARENT_SHELL" | grep -q "zsh"; then \ +# if ! grep -q ". <(terpd enable-cli-autocomplete zsh)" ~/.zshrc; then \ +# echo ". <(terpd enable-cli-autocomplete zsh)" >> ~/.zshrc; \ +# echo; \ +# echo "Autocomplete enabled. Run 'source ~/.zshrc' to complete installation."; \ +# else \ +# echo; \ +# echo "Autocomplete already enabled in ~/.zshrc"; \ +# fi \ +# elif echo "$$PARENT_SHELL" | grep -q "bash" && [ "$$(uname)" = "Darwin" ]; then \ +# if ! grep -q -e "\. <(terpd enable-cli-autocomplete bash)" -e '\[\[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" \]\] && \. "/opt/homebrew/etc/profile.d/bash_completion.sh"' ~/.bash_profile; then \ +# brew install bash-completion; \ +# echo '[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ] && . "/opt/homebrew/etc/profile.d/bash_completion.sh"' >> ~/.bash_profile; \ +# echo ". <(terpd enable-cli-autocomplete bash)" >> ~/.bash_profile; \ +# echo; \ +# echo; \ +# echo "Autocomplete enabled. Run 'source ~/.bash_profile' to complete installation."; \ +# else \ +# echo "Autocomplete already enabled in ~/.bash_profile"; \ +# fi \ +# elif echo "$$PARENT_SHELL" | grep -q "bash" && [ "$$(uname)" = "Linux" ]; then \ +# if ! grep -q ". <(terpd enable-cli-autocomplete bash)" ~/.bash_profile; then \ +# sudo apt-get install -y bash-completion; \ +# echo '[ -r "/etc/bash_completion" ] && . "/etc/bash_completion"' >> ~/.bash_profile; \ +# echo ". <(terpd enable-cli-autocomplete bash)" >> ~/.bash_profile; \ +# echo; \ +# echo "Autocomplete enabled. Run 'source ~/.bash_profile' to complete installation."; \ +# else \ +# echo; \ +# echo "Autocomplete already enabled in ~/.bash_profile"; \ +# fi \ +# else \ +# echo "Shell or OS not recognized. Skipping autocomplete setup."; \ +# fi \ No newline at end of file diff --git a/scripts/makefiles/deps.mk b/scripts/makefiles/deps.mk new file mode 100644 index 00000000..af1b7bc4 --- /dev/null +++ b/scripts/makefiles/deps.mk @@ -0,0 +1,45 @@ +############################################################################### +### Dependency Updates ### +############################################################################### +deps-help: + @echo "Dependency Update subcommands" + @echo "" + @echo "Usage:" + @echo " make deps-[command]" + @echo "" + @echo "Available Commands:" + @echo " clean Remove artifacts" + @echo " distclean Remove vendor directory" + @echo " draw Create a dependency graph" + @echo " go-mod-cache Download go modules to local cache" + @echo " go.sum Ensure dependencies have not been modified" + @echo " tidy-workspace Tidy workspace" + @echo " update-sdk-version Update SDK version" + + +go-mod-cache: go.sum + @echo "--> Download go modules to local cache" + @go mod download + +go.sum: go.mod + @echo "--> Ensure dependencies have not been modified" + @go mod verify + +draw-deps: + @# requires brew install graphviz or apt-get install graphviz + go install github.com/RobotsAndPencils/goviz@latest + @goviz -i ./cmd/terpd -d 2 | dot -Tpng -o dependency-graph.png + +deps-clean: + rm -rf $(CURDIR)/artifacts/ + +deps-distclean: clean + rm -rf vendor/ + +MODFILES := ./go.mod ./interchaintest/go.mod +# run with VERSION argument specified +# e.g) make update-sdk-version VERSION=v0.45.1-0.20230523200430-193959b898ec +# This will change sdk dependencyu version for go.mod in root directory + all sub-modules in this rep + +deps-tidy-workspace: + @./scripts/tidy_workspace.sh \ No newline at end of file diff --git a/scripts/makefiles/e2e.mk b/scripts/makefiles/e2e.mk new file mode 100644 index 00000000..33a4eab3 --- /dev/null +++ b/scripts/makefiles/e2e.mk @@ -0,0 +1,66 @@ +############################################################################### +### e2e interchain test ### +############################################################################### + +e2e-help: + @echo "e2e subcommands" + @echo "" + @echo "Usage:" + @echo " make e2e-[command]" + @echo "" + @echo "Available Commands:" + @echo " build-script Build e2e script" + @echo " check-image-sha Check e2e image SHA" + @echo " docker-build-debug Build e2e debug Docker image" + @echo " docker-build-e2e-init-chain Build e2e init chain Docker image" + @echo " docker-build-e2e-init-node Build e2e init node Docker image" + @echo " remove-resources Remove e2e resources" + @echo " setup Set up e2e environment" + @echo " ictest-basic Run basic test" + @echo " ictest-upgrade Run basic planned upgrade test" + @echo " ictest-upgrade-local Run basic upgrade locally after compiling a local image as terpnetwork:local" + @echo " ictest-statesync Run basic test on node statesync capabilities" + @echo " ictest-ibc Run basic ibc test" + @echo " ictest-pfm Run basic packet-forward-middleware test" + @echo " ictest-ibchooks Run basic ibc-hooks test" + @echo " ictest-tokenfactory Run basic x/tokenfactory test" + @echo " ictest-feeshare Run basic x/feeshare test" + +e2e: e2e-help + + + # Executes basic chain tests via interchaintest +ictest-basic: rm-testcache + cd interchaintest && go test -race -v -run TestBasicTerpStart . + +ictest-statesync: rm-testcache + cd interchaintest && go test -race -v -run TestTerpStateSync . + +ictest-ibchooks: rm-testcache + cd interchaintest && go test -race -v -run TestTerpIBCHooks . + +ictest-pfm: rm-testcache + cd interchaintest && go test -race -v -run TestPacketForwardMiddlewareRouter . + +ictest-tokenfactory: rm-testcache + cd interchaintest && go test -race -v -run TestTerpTokenFactory . + +# ictest-clock: rm-testcache +# cd interchaintest && go test -race -v -run TestTerpClock . + +ictest-feeshare: rm-testcache + cd interchaintest && go test -race -v -run TestTerpFeeShare . + +ictest-upgrade: rm-testcache + cd interchaintest && go test -race -v -run TestBasicTerpUpgrade . + +ictest-upgrade-local: local-image ictest-upgrade + +# Executes IBC tests via interchaintest +ictest-ibc: rm-testcache + cd interchaintest && go test -race -v -run TestTerpGaiaIBCTransfer . + +rm-testcache: + go clean -testcache + +.PHONY: test-mutation ictest-basic ictest-upgrade ictest-ibc \ No newline at end of file diff --git a/scripts/makefiles/lint.mk b/scripts/makefiles/lint.mk new file mode 100644 index 00000000..85d200fa --- /dev/null +++ b/scripts/makefiles/lint.mk @@ -0,0 +1,38 @@ +############################################################################### +### Linting ### +############################################################################### + +lint-help: + @echo "" + @echo "" + @echo "lint subcommands" + @echo "" + @echo "Usage:" + @echo " make lint-[command]" + @echo "" + @echo "Available Commands:" + @echo " format-tools Run linters with auto-fix" + @echo " markdown Run markdown linter with auto-fix" + @echo " mdlint Run markdown linter" + @echo "" +# lint: lint-help + +lint-format-tools: + go install mvdan.cc/gofumpt@v0.4.0 + go install github.com/client9/misspell/cmd/misspell@v0.3.4 + go install golang.org/x/tools/cmd/goimports@latest + +lint: lint-format-tools + golangci-lint run --tests=false + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*_test.go" | xargs gofumpt -d +format: format-tools + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofumpt -w -s + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofumpt -w + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/terpnetwork/terp-core + +lint-mdlint: + @echo "--> Running markdown linter" + @docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" + +lint-markdown: + @docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --fix \ No newline at end of file diff --git a/scripts/makefiles/proto.mk b/scripts/makefiles/proto.mk new file mode 100644 index 00000000..8e2fb247 --- /dev/null +++ b/scripts/makefiles/proto.mk @@ -0,0 +1,101 @@ +############################################################################### +### Proto ### +############################################################################### + +proto-help: + @echo "proto subcommands" + @echo "" + @echo "Usage:" + @echo " make proto-[command]" + @echo "" + @echo "Available Commands:" + @echo " all Run proto-format and proto-gen" + @echo " format Format Protobuf files" + @echo " gen Generate Protobuf files" + @echo " image-build Build the protobuf Docker image" + @echo " image-push Push the protobuf Docker image" + +proto: proto-help +proto-all: proto-format proto-gen + +PROTO_BUILDER_IMAGE=ghcr.io/cosmos/proto-builder:0.14.0 +protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(PROTO_BUILDER_IMAGE) + +proto-all: proto-format proto-gen + +proto-gen: + @echo "Generating Protobuf files" + @$(DOCKER) run --rm -u 0 -v $(CURDIR):/workspace --workdir /workspace $(PROTO_BUILDER_IMAGE) sh ./scripts/protocgen.sh + +proto-format: + @echo "Formatting Protobuf files" + @$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \ + find ./proto -name "*.proto" -exec clang-format -i {} \; + + +SWAGGER_DIR=./swagger-proto +THIRD_PARTY_DIR=$(SWAGGER_DIR)/third_party + +proto-download-deps: + mkdir -p "$(THIRD_PARTY_DIR)/cosmos_tmp" && \ + cd "$(THIRD_PARTY_DIR)/cosmos_tmp" && \ + git init && \ + git remote add origin "https://github.com/cosmos/cosmos-sdk.git" && \ + git config core.sparseCheckout true && \ + printf "proto\nthird_party\n" > .git/info/sparse-checkout && \ + git pull origin main && \ + rm -f ./proto/buf.* && \ + mv ./proto/* .. + rm -rf "$(THIRD_PARTY_DIR)/cosmos_tmp" + + mkdir -p "$(THIRD_PARTY_DIR)/ibc_tmp" && \ + cd "$(THIRD_PARTY_DIR)/ibc_tmp" && \ + git init && \ + git remote add origin "https://github.com/cosmos/ibc-go.git" && \ + git config core.sparseCheckout true && \ + printf "proto\n" > .git/info/sparse-checkout && \ + git pull origin main && \ + rm -f ./proto/buf.* && \ + mv ./proto/* .. + rm -rf "$(THIRD_PARTY_DIR)/ibc_tmp" + + mkdir -p "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" && \ + cd "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" && \ + git init && \ + git remote add origin "https://github.com/cosmos/cosmos-proto.git" && \ + git config core.sparseCheckout true && \ + printf "proto\n" > .git/info/sparse-checkout && \ + git pull origin main && \ + rm -f ./proto/buf.* && \ + mv ./proto/* .. + rm -rf "$(THIRD_PARTY_DIR)/cosmos_proto_tmp" + + mkdir -p "$(THIRD_PARTY_DIR)/gogoproto" && \ + curl -SSL https://raw.githubusercontent.com/cosmos/gogoproto/main/gogoproto/gogo.proto > "$(THIRD_PARTY_DIR)/gogoproto/gogo.proto" + + mkdir -p "$(THIRD_PARTY_DIR)/google/api" && \ + curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > "$(THIRD_PARTY_DIR)/google/api/annotations.proto" + curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > "$(THIRD_PARTY_DIR)/google/api/http.proto" + + mkdir -p "$(THIRD_PARTY_DIR)/cosmos/ics23/v1" && \ + curl -sSL https://raw.githubusercontent.com/cosmos/ics23/master/proto/cosmos/ics23/v1/proofs.proto > "$(THIRD_PARTY_DIR)/cosmos/ics23/v1/proofs.proto" + + +docs: + @echo + @echo "=========== Generate Message ============" + @echo + @make proto-download-deps + ./scripts/generate-docs.sh + + statik -src=client/docs/static -dest=client/docs -f -m + @if [ -n "$(git status --porcelain)" ]; then \ + echo "\033[91mSwagger docs are out of sync!!!\033[0m";\ + exit 1;\ + else \ + echo "\033[92mSwagger docs are in sync\033[0m";\ + fi + @echo + @echo "=========== Generate Complete ============" + @echo +.PHONY: docs \ No newline at end of file diff --git a/scripts/makefiles/release.mk b/scripts/makefiles/release.mk new file mode 100644 index 00000000..d041c423 --- /dev/null +++ b/scripts/makefiles/release.mk @@ -0,0 +1,52 @@ +############################################################################### +### Release ### +############################################################################### + +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) +COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') + +ifdef GITHUB_TOKEN +release: + docker run \ + --rm \ + -e GITHUB_TOKEN=$(GITHUB_TOKEN) \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/terpd \ + -w /go/src/terpd \ + $(GORELEASER_IMAGE) \ + release \ + --clean +else +release: + @echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'." +endif + +release-dry-run: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/terpd \ + -w /go/src/terpd \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --skip-publish + +release-snapshot: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/terpd \ + -w /go/src/terpd \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --snapshot \ + --skip-validate \ + --skip-publish + +create-binaries: + \ No newline at end of file diff --git a/scripts/makefiles/tests.mk b/scripts/makefiles/tests.mk new file mode 100644 index 00000000..55b9afe9 --- /dev/null +++ b/scripts/makefiles/tests.mk @@ -0,0 +1,29 @@ +############################################################################### +### Testing ### +############################################################################### + +APP = ./app +BINDIR ?= $(GOPATH)/bin + +# The below include contains the tools and runsim targets. +include contrib/devtools/Makefile + +test: test-unit +test-all: check test-race test-cover + +test-node: + CHAIN_ID="local-1" HOME_DIR="~/.terp1" TIMEOUT_COMMIT="500ms" CLEAN=true sh scripts/test_node.sh + +test-unit: + @VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./... + +benchmark: + @go test -mod=readonly -bench=. ./... + +test-sim-multi-seed-short: runsim + @echo "Running short multi-seed application simulation. This may take awhile!" + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 5 TestFullAppSimulation + +test-sim-deterministic: runsim + @echo "Running short multi-seed application simulation. This may take awhile!" + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 1 1 TestAppStateDeterminism \ No newline at end of file diff --git a/scripts/release/create_upgrade_guide/UPGRADE_TEMPLATE.md b/scripts/release/create_upgrade_guide/UPGRADE_TEMPLATE.md index 97147d2c..a84f4c8c 100644 --- a/scripts/release/create_upgrade_guide/UPGRADE_TEMPLATE.md +++ b/scripts/release/create_upgrade_guide/UPGRADE_TEMPLATE.md @@ -113,4 +113,4 @@ make install ## Additional Resources - Terp Network Documentation: [Website](https://docs.terp.network) -- Community Support: [Discord](https://discord.gg/pAxjcFnAFH) \ No newline at end of file +- Community Support: [Discord](https://discord.gg/pAxjcFnAFH) diff --git a/scripts/replace_import_paths.sh b/scripts/replace_import_paths.sh new file mode 100644 index 00000000..6b850767 --- /dev/null +++ b/scripts/replace_import_paths.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +set -euo pipefail + +NEXT_MAJOR_VERSION=$1 +import_path_to_replace=$(go list -m) + +version_to_replace=$(echo $import_path_to_replace | sed -n 's/.*v\([0-9]*\).*/\1/p') + +echo $version_to_replace +echo Current import paths are $version_to_replace, replacing with $NEXT_MAJOR_VERSION + +# list all folders containing Go modules. +modules=$(go list -tags e2e ./... | sed "s/g.*v${version_to_replace}\///") + +while IFS= read -r line; do + modules_to_upgrade_manually+=("$line") +done < <(find . -name go.mod -exec grep -l "github.com/terpnetwork/terp-core/v4" {} \; | grep -v "^./go.mod$" | sed 's|/go.mod||' | sed 's|^./||') + +replace_paths() { + file="${1}" + sed -i "s/github.com\/terpnetwork\/terp-core/v4\/v${version_to_replace}/github.com\/terpnetwork\/terp-core/v4\/v${NEXT_MAJOR_VERSION}/g" ${file} +} + +echo "Replacing import paths in all files" + +while IFS= read -r line; do + files+=("$line") +done < <(find ./ -type f -not \( -path "./vendor*" -or -path "./.git*" -or -name "*.md" \)) + +echo "Updating all files" + +for file in "${files[@]}"; do + if test -f "$file"; then + # skip files that need manual upgrading + for excluded_file in "${modules_to_upgrade_manually[@]}"; do + if [[ "$file" == *"$excluded_file"* ]]; then + continue 2 + fi + done + replace_paths $file + fi +done + +exit 0 + +echo "Updating go.mod and vendoring" +# go.mod +replace_paths "go.mod" +go mod vendor >/dev/null + +# ensure that generated files are updated. +# N.B.: This must be run after go mod vendor. +echo "running make proto-gen" +make proto-gen >/dev/null + +echo "Run go mod vendor after proto-gen to avoid vendoring issues" +go mod vendor >/dev/null + +echo "running make run-querygen" +make run-querygen >/dev/null \ No newline at end of file diff --git a/x/clock/types/genesis.pb.go b/x/clock/types/genesis.pb.go index c3c51227..535883e2 100644 --- a/x/clock/types/genesis.pb.go +++ b/x/clock/types/genesis.pb.go @@ -72,7 +72,8 @@ func (m *GenesisState) GetParams() Params { // Params defines the set of module parameters. type Params struct { - // contract_addresses stores the list of executable contracts to be ticked on every block. + // contract_addresses stores the list of executable contracts to be ticked on + // every block. ContractAddresses []string `protobuf:"bytes,1,rep,name=contract_addresses,json=contractAddresses,proto3" json:"contract_addresses,omitempty" yaml:"contract_addresses"` ContractGasLimit uint64 `protobuf:"varint,2,opt,name=contract_gas_limit,json=contractGasLimit,proto3" json:"contract_gas_limit,omitempty" yaml:"contract_gas_limit"` } diff --git a/x/clock/types/query.pb.go b/x/clock/types/query.pb.go index 2d92ef01..739d83ee 100644 --- a/x/clock/types/query.pb.go +++ b/x/clock/types/query.pb.go @@ -67,7 +67,8 @@ func (m *QueryClockContracts) XXX_DiscardUnknown() { var xxx_messageInfo_QueryClockContracts proto.InternalMessageInfo -// QueryClockContractsResponse is the response type for the Query/ClockContracts RPC method. +// QueryClockContractsResponse is the response type for the Query/ClockContracts +// RPC method. type QueryClockContractsResponse struct { ContractAddresses []string `protobuf:"bytes,1,rep,name=contract_addresses,json=contractAddresses,proto3" json:"contract_addresses,omitempty" yaml:"contract_addresses"` } @@ -149,7 +150,8 @@ func (m *QueryParamsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo -// QueryClockContractsResponse is the response type for the Query/ClockContracts RPC method. +// QueryClockContractsResponse is the response type for the Query/ClockContracts +// RPC method. type QueryParamsResponse struct { Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` } diff --git a/x/drip/spec/01_authorization.md b/x/drip/spec/01_authorization.md index b447c9f2..c6163c11 100644 --- a/x/drip/spec/01_authorization.md +++ b/x/drip/spec/01_authorization.md @@ -4,7 +4,7 @@ order: 1 # Authorization -For security reasons, only specific addresses can distribute tokens to $JUNO stakers. We accept any kind of address: multisig, smart contracts, regular and [https://daodao.zone](DAODAO) DAOs. +For security reasons, only specific addresses can distribute tokens to $JUNO stakers. We accept any kind of address: multisig, smart contracts, regular and [https://daodao.zone](DAODAO) DAOs. Governance can decide wether to approve or deny a new address to be added to the authorized list. diff --git a/x/drip/spec/02_distribute_tokens.md b/x/drip/spec/02_distribute_tokens.md index f7fd29f9..b32c051d 100644 --- a/x/drip/spec/02_distribute_tokens.md +++ b/x/drip/spec/02_distribute_tokens.md @@ -4,7 +4,7 @@ order: 2 # Distributing Tokens -Once an address is authorized, at any time it can use the `MsgDistributToken` message to distribute all the attached funds at the next block. +Once an address is authorized, at any time it can use the `MsgDistributToken` message to distribute all the attached funds at the next block. From command line is as easy as running the follwing instruction @@ -12,6 +12,6 @@ From command line is as easy as running the follwing instruction terpd tx drip distribute-tokens 100000tf/yourcontract/yourtoken ``` -Only native tokens and the ones made with tokenfactory are allowed. +Only native tokens and the ones made with tokenfactory are allowed. -If you have a CW-20 token, you can wrap it to native using [https://github.com/CosmosContracts/tokenfactory-contracts/tree/main/contracts/migrate](this contract). \ No newline at end of file +If you have a CW-20 token, you can wrap it to native using [https://github.com/CosmosContracts/tokenfactory-contracts/tree/main/contracts/migrate](this contract). diff --git a/x/drip/spec/03_example.md b/x/drip/spec/03_example.md index 340d70ed..d14f008d 100644 --- a/x/drip/spec/03_example.md +++ b/x/drip/spec/03_example.md @@ -30,4 +30,4 @@ fn encode_msg_create_vesting_acct(vest_to: &Addr, env: Env) -> Result