-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e23e44c
Showing
25 changed files
with
4,364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
#!/usr/bin/make -f | ||
|
||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
COMMIT := $(shell git log -1 --format='%H') | ||
|
||
# don't override user values | ||
ifeq (,$(VERSION)) | ||
VERSION := $(shell git describe --exact-match 2>/dev/null) | ||
# if VERSION is empty, then populate it with branch's name and raw commit hash | ||
ifeq (,$(VERSION)) | ||
VERSION := $(BRANCH)-$(COMMIT) | ||
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') | ||
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7" | ||
DOCKER := $(shell which docker) | ||
BUILDDIR ?= $(CURDIR)/build | ||
TEST_DOCKER_REPO=jackzampolin/nxtpoptest | ||
|
||
export GO111MODULE = on | ||
|
||
# process build tags | ||
|
||
build_tags = netgo | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifeq ($(OS),Windows_NT) | ||
GCCEXE = $(shell where gcc.exe 2> NUL) | ||
ifeq ($(GCCEXE),) | ||
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
else | ||
UNAME_S = $(shell uname -s) | ||
ifeq ($(UNAME_S),OpenBSD) | ||
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) | ||
else | ||
GCC = $(shell command -v gcc 2> /dev/null) | ||
ifeq ($(GCC),) | ||
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
ifeq (cleveldb,$(findstring cleveldb,$(NXTPOP_BUILD_OPTIONS))) | ||
build_tags += gcc cleveldb | ||
endif | ||
build_tags += $(BUILD_TAGS) | ||
build_tags := $(strip $(build_tags)) | ||
|
||
whitespace := | ||
whitespace += $(whitespace) | ||
comma := , | ||
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) | ||
|
||
# process linker flags | ||
|
||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=nxtpop \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=nxtpopd \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ | ||
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \ | ||
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) | ||
|
||
ifeq (cleveldb,$(findstring cleveldb,$(NXTPOP_BUILD_OPTIONS))) | ||
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb | ||
endif | ||
ifeq (,$(findstring nostrip,$(NXTPOP_BUILD_OPTIONS))) | ||
ldflags += -w -s | ||
endif | ||
ldflags += $(LDFLAGS) | ||
ldflags := $(strip $(ldflags)) | ||
|
||
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' | ||
# check for nostrip option | ||
ifeq (,$(findstring nostrip,$(NXTPOP_BUILD_OPTIONS))) | ||
BUILD_FLAGS += -trimpath | ||
endif | ||
|
||
#$(info $$BUILD_FLAGS is [$(BUILD_FLAGS)]) | ||
|
||
# The below include contains the tools target. | ||
include contrib/devtools/Makefile | ||
|
||
############################################################################### | ||
### Documentation ### | ||
############################################################################### | ||
|
||
all: install lint test | ||
|
||
BUILD_TARGETS := build install | ||
|
||
build: BUILD_ARGS=-o $(BUILDDIR)/ | ||
|
||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/ | ||
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... | ||
|
||
$(BUILDDIR)/: | ||
mkdir -p $(BUILDDIR)/ | ||
|
||
build-reproducible: go.sum | ||
$(DOCKER) rm latest-build || true | ||
$(DOCKER) run --volume=$(CURDIR):/sources:ro \ | ||
--env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm64 windows/amd64' \ | ||
--env APP=nxtpopd \ | ||
--env VERSION=$(VERSION) \ | ||
--env COMMIT=$(COMMIT) \ | ||
--env LEDGER_ENABLED=$(LEDGER_ENABLED) \ | ||
--name latest-build cosmossdk/rbuilder:latest | ||
$(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/ | ||
|
||
build-linux: go.sum | ||
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build | ||
|
||
build-contract-tests-hooks: | ||
mkdir -p $(BUILDDIR) | ||
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./cmd/contract_tests | ||
|
||
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 get github.com/RobotsAndPencils/goviz | ||
@goviz -i ./cmd/nxtpopd -d 2 | dot -Tpng -o dependency-graph.png | ||
|
||
clean: | ||
rm -rf $(BUILDDIR)/ artifacts/ | ||
|
||
distclean: clean | ||
rm -rf vendor/ | ||
|
||
############################################################################### | ||
### Devdoc ### | ||
############################################################################### | ||
|
||
build-docs: | ||
@cd docs && \ | ||
while read p; do \ | ||
(git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \ | ||
mkdir -p ~/output/$${p} ; \ | ||
cp -r .vuepress/dist/* ~/output/$${p}/ ; \ | ||
cp ~/output/$${p}/index.html ~/output ; \ | ||
done < versions ; | ||
.PHONY: build-docs | ||
|
||
sync-docs: | ||
cd ~/output && \ | ||
echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \ | ||
echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \ | ||
aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \ | ||
aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ; | ||
.PHONY: sync-docs | ||
|
||
|
||
############################################################################### | ||
### Tests & Simulation ### | ||
############################################################################### | ||
|
||
include sims.mk | ||
|
||
test: test-unit test-build | ||
|
||
test-all: check test-race test-cover | ||
|
||
test-unit: | ||
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./... | ||
|
||
test-race: | ||
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./... | ||
|
||
test-cover: | ||
@go test -mod=readonly -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' ./... | ||
|
||
benchmark: | ||
@go test -mod=readonly -bench=. ./... | ||
|
||
|
||
############################################################################### | ||
### Linting ### | ||
############################################################################### | ||
|
||
lint: | ||
golangci-lint run | ||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s | ||
|
||
format: | ||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s | ||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -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/cosmos/cosmos-sdk | ||
|
||
############################################################################### | ||
### Localnet ### | ||
############################################################################### | ||
|
||
build-docker-nxtpopdnode: | ||
$(MAKE) -C networks/local | ||
|
||
# Run a 4-node testnet locally | ||
localnet-start: build-linux localnet-stop | ||
@if ! [ -f build/node0/nxtpopd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/nxtpopd:Z tendermint/nxtpopdnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi | ||
docker-compose up -d | ||
|
||
# Stop testnet | ||
localnet-stop: | ||
docker-compose down | ||
|
||
test-docker: | ||
@docker build -f contrib/Dockerfile.test -t ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) . | ||
@docker tag ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) ${TEST_DOCKER_REPO}:$(shell git rev-parse --abbrev-ref HEAD | sed 's#/#_#g') | ||
@docker tag ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) ${TEST_DOCKER_REPO}:latest | ||
|
||
test-docker-push: test-docker | ||
@docker push ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) | ||
@docker push ${TEST_DOCKER_REPO}:$(shell git rev-parse --abbrev-ref HEAD | sed 's#/#_#g') | ||
@docker push ${TEST_DOCKER_REPO}:latest | ||
|
||
.PHONY: all build-linux install format lint \ | ||
go-mod-cache draw-deps clean build \ | ||
setup-transactions setup-contract-tests-data start-nxtpop run-lcd-contract-tests contract-tests \ | ||
test test-all test-build test-cover test-unit test-race \ | ||
benchmark \ | ||
build-docker-nxtpopdnode localnet-start localnet-stop \ | ||
docker-single-node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# NxtPop chain | ||
|
||
NxtPop chain is based on Cosmos SDK - initiated from Cosmos SDK's gaia repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package nxtpop | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
"github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
channelkeeper "github.com/cosmos/ibc-go/v2/modules/core/04-channel/keeper" | ||
ibcante "github.com/cosmos/ibc-go/v2/modules/core/ante" | ||
) | ||
|
||
// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC | ||
// channel keeper. | ||
type HandlerOptions struct { | ||
ante.HandlerOptions | ||
|
||
IBCChannelkeeper channelkeeper.Keeper | ||
} | ||
|
||
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { | ||
if options.AccountKeeper == nil { | ||
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler") | ||
} | ||
if options.BankKeeper == nil { | ||
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler") | ||
} | ||
if options.SignModeHandler == nil { | ||
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") | ||
} | ||
|
||
var sigGasConsumer = options.SigGasConsumer | ||
if sigGasConsumer == nil { | ||
sigGasConsumer = ante.DefaultSigVerificationGasConsumer | ||
} | ||
|
||
anteDecorators := []sdk.AnteDecorator{ | ||
ante.NewSetUpContextDecorator(), | ||
ante.NewRejectExtensionOptionsDecorator(), | ||
ante.NewMempoolFeeDecorator(), | ||
ante.NewValidateBasicDecorator(), | ||
ante.NewTxTimeoutHeightDecorator(), | ||
ante.NewValidateMemoDecorator(options.AccountKeeper), | ||
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), | ||
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper), | ||
// SetPubKeyDecorator must be called before all signature verification decorators | ||
ante.NewSetPubKeyDecorator(options.AccountKeeper), | ||
ante.NewValidateSigCountDecorator(options.AccountKeeper), | ||
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer), | ||
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), | ||
ante.NewIncrementSequenceDecorator(options.AccountKeeper), | ||
ibcante.NewAnteDecorator(options.IBCChannelkeeper), | ||
} | ||
|
||
return sdk.ChainAnteDecorators(anteDecorators...), nil | ||
} |
Oops, something went wrong.