Skip to content

Commit

Permalink
update to cosmos-v0.37.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Yun committed Sep 4, 2019
1 parent a84bb2a commit 23ea272
Show file tree
Hide file tree
Showing 418 changed files with 19,990 additions and 23,809 deletions.
455 changes: 334 additions & 121 deletions .circleci/config.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ mytestnet
# Testing
coverage.txt
profile.out
sim_log_file

# Vagrant
.vagrant/
Expand Down
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ linters:
- ineffassign
- unconvert
- misspell
- govet
# - unused
# - deadcode
- goconst
- gosec
# - staticcheck
linters-settings:
gocyclo:
min-complexity: 11
errcheck:
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag
golint:
min-confidence: 1.1
issues:
exclude:
- composite
run:
tests: false
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project_name: terra

before:
hooks:
- make get_tools
- make tools
- make go-mod-cache

builds:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY . .

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apk add --no-cache $PACKAGES && \
make get_tools && \
make tools && \
make go-mod-cache && \
make build-linux && \
make install
Expand Down
197 changes: 108 additions & 89 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
#!/usr/bin/make -f

PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
GOTOOLS = \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/rakyll/statik
GOBIN ?= $(GOPATH)/bin
SHASUM := $(shell which sha256sum)
CORE_PACK := $(shell go list -m github.com/terra-project/core | sed 's/ /\@/g')

export GO111MODULE = on

# process build tags

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
Expand All @@ -22,133 +20,136 @@ ifeq ($(LEDGER_ENABLED),true)
build_tags += ledger
endif
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)
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
build_tags += ledger
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 ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

# process linker flags
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

ldflags = -X github.com/terra-project/core/version.Version=$(VERSION) \
-X github.com/terra-project/core/version.Commit=$(COMMIT) \
-X "github.com/terra-project/core/version.BuildTags=$(build_tags)" \
# process linker flags

ifneq ($(SHASUM),)
ldflags += -X github.com/terra-project/core/version.GoSumHash=$(shell sha256sum go.sum | cut -d ' ' -f1)
endif
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=terra \
-X github.com/cosmos/cosmos-sdk/version.ServerName=terrad \
-X github.com/cosmos/cosmos-sdk/version.ClientName=terracli \
-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)"

ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'

########################################
### All
# The below include contains the tools target.
include contrib/devtools/Makefile

all: clean go-mod-cache install lint test
all: install lint check

########################################
### CI

ci: get_tools install lint test
build: go.sum
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/terrad.exe ./cmd/terrad
go build -mod=readonly $(BUILD_FLAGS) -o build/terracli.exe ./cmd/terracli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/terrad ./cmd/terrad
go build -mod=readonly $(BUILD_FLAGS) -o build/terracli ./cmd/terracli
endif

########################################
### Build/Install
build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

build: update_terra_lite_docs
build-contract-tests-hooks:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/terrad.exe ./cmd/terrad
go build $(BUILD_FLAGS) -o build/terracli.exe ./cmd/terracli
go build $(BUILD_FLAGS) -o build/terrakeyutil.exe ./cmd/terrakeyutil
go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests
else
go build $(BUILD_FLAGS) -o build/terrad ./cmd/terrad
go build $(BUILD_FLAGS) -o build/terracli ./cmd/terracli
go build $(BUILD_FLAGS) -o build/terrakeyutil ./cmd/terrakeyutil
go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
endif

build-linux:
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
install: go.sum check-ledger
go install -mod=readonly $(BUILD_FLAGS) ./cmd/terrad
go install -mod=readonly $(BUILD_FLAGS) ./cmd/terracli

update_terra_lite_docs:
@statik -src=client/lcd/swagger-ui -dest=client/lcd -f
install-debug: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/terradebug

install: update_terra_lite_docs
go install $(BUILD_FLAGS) ./cmd/terrad
go install $(BUILD_FLAGS) ./cmd/terracli
go install $(BUILD_FLAGS) ./cmd/terrakeyutil


########################################
### Tools & dependencies

get_tools:
go get github.com/rakyll/statik
go get github.com/golangci/golangci-lint/cmd/golangci-lint

update_tools:
@echo "--> Updating tools to correct version"
$(MAKE) --always-make get_tools

go-mod-cache: go-sum
go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@go mod download

go-sum: get_tools
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify

go-release:
@echo "--> Dry run for go-release"
BUILD_TAGS=$(shell echo \"$(build_tags)\") GOSUM=$(shell sha256sum go.sum | cut -d ' ' -f1) goreleaser release --skip-publish --rm-dist --debug
draw-deps:
@# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@goviz -i ./cmd/terrad -d 2 | dot -Tpng -o dependency-graph.png

clean:
rm -rf ./dist
rm -rf ./build
rm -rf snapcraft-local.yaml build/

distclean: clean
rm -rf vendor/

########################################
### Testing

test: test_unit

test_unit:
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock'
check: check-unit check-build
check-all: check check-race check-cover

test_race:
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)
check-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./...

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/terra-project/core
check-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./...

benchmark:
@go test -bench=. $(PACKAGES_NOSIMULATION)
check-cover:
@go test -mod=readonly -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' ./...

lint: get_tools ci-lint
ci-lint:
@echo "--> Running lint..."
check-build: build
@go test -mod=readonly -p 4 `go list ./cli_test/...` -tags=cli_test -v


lint: golangci-lint
golangci-lint run
go vet -composites=false -tests=false ./...
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify

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

benchmark:
@go test -mod=readonly -bench=. ./...


########################################
### Local validator nodes using docker and docker-compose
Expand All @@ -158,23 +159,41 @@ build-docker-terradnode:

# Run a 4-node testnet locally
localnet-start: localnet-stop
@if ! [ -f build/node0/terrad/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/terrad:Z tendermint/terradnode testnet --v 5 -o . --starting-ip-address 192.168.10.2; fi
# replace docker ip to local port, mapped
sed -i -e 's/192.168.10.2:26656/localhost:26656/g; s/192.168.10.3:26656/localhost:26659/g; s/192.168.10.4:26656/localhost:26661/g; s/192.168.10.5:26656/localhost:26663/g' $(CURDIR)/build/node4/terrad/config/config.toml
# change allow duplicated ip option to prevent the error : cant not route ~
sed -i -e 's/allow_duplicate_ip \= false/allow_duplicate_ip \= true/g' `find $(CURDIR)/build -name "config.toml"`
@if ! [ -f build/node0/terrad/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/terrad:Z tendermint/terradnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi
docker-compose up -d

# Stop testnet
localnet-stop:
docker-compose down

# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build install clean distclean update_terra_lite_docs \
get_tools update_tools \
test test_cli test_unit benchmark \
build-linux build-docker-terradnode localnet-start localnet-stop \
format update_dev_tools lint ci ci-lint\
go-mod-cache go-sum
setup-contract-tests-data:
echo 'Prepare data for the contract tests'
rm -rf /tmp/contract_tests ; \
mkdir /tmp/contract_tests ; \
cp "${GOPATH}/pkg/mod/${CORE_PACK}/client/lcd/swagger-ui/swagger.yaml" /tmp/contract_tests/swagger.yaml ; \
./build/terrad init --home /tmp/contract_tests/.terrad --chain-id lcd contract-tests ; \
tar -xzf lcd_test/testdata/state.tar.gz -C /tmp/contract_tests/

start-terra: setup-contract-tests-data
./build/terrad --home /tmp/contract_tests/.terrad start &
@sleep 2s

setup-transactions: start-terra
@bash ./lcd_test/testdata/setup.sh

run-lcd-contract-tests:
@echo "Running Terra LCD for contract tests"
./build/terracli rest-server --laddr tcp://0.0.0.0:8080 --home /tmp/contract_tests/.terracli --node http://localhost:26657 --chain-id lcd --trust-node true

contract-tests: setup-transactions
@echo "Running Terra LCD for contract tests"
dredd && pkill terrad

# include simulations
include sims.mk

.PHONY: all build-linux install install-debug \
go-mod-cache draw-deps clean build \
setup-transactions setup-contract-tests-data start-terra run-lcd-contract-tests contract-tests \
check check-all check-build check-cover check-ledger check-unit check-race

51 changes: 0 additions & 51 deletions Vagrantfile

This file was deleted.

Binary file added app.test
Binary file not shown.
Loading

0 comments on commit 23ea272

Please sign in to comment.