Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into no-begin-key
Browse files Browse the repository at this point in the history
  • Loading branch information
Benzbeeb authored May 18, 2020
2 parents aba5f63 + cdfb160 commit df6f463
Show file tree
Hide file tree
Showing 117 changed files with 12,232 additions and 2,461 deletions.
35 changes: 35 additions & 0 deletions band-consumer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# # Simple usage with a mounted data directory:
# # > docker build -t gaia .
# # > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.bcd:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli gaia gaiad init
# # > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.bcd:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli gaia gaiad start
# FROM golang:1.14-alpine AS build-env

# # Set up dependencies
# ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python

# # Set working directory for the build
# WORKDIR /go/src/github.com/bandprotocol/band-consumer

# # Add source files
# COPY . ./band-consumer

# COPY ../chain chain

# # Install minimum necessary dependencies, build Cosmos SDK, remove packages
# RUN apk add --no-cache $PACKAGES && \
# make tools && \
# make install

# # Final image
# FROM alpine:edge

# # Install ca-certificates
# RUN apk add --update ca-certificates
# WORKDIR /root

# # Copy over binaries from the build-env
# COPY --from=build-env /go/bin/bcd /usr/bin/bcd
# COPY --from=build-env /go/bin/bccli /usr/bin/bccli

# # Run bcd by default, omit entrypoint to ease using container with bccli
# CMD ["bcd"]
246 changes: 246 additions & 0 deletions band-consumer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
#!/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
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
# TEST_DOCKER_REPO=jackzampolin/gaiatest

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 ($(WITH_CLEVELDB),yes)
build_tags += gcc
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=band-consumer \
-X github.com/cosmos/cosmos-sdk/version.ServerName=bcd \
-X github.com/cosmos/cosmos-sdk/version.ClientName=bccli \
-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)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

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

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

###############################################################################
### Documentation ###
###############################################################################

all: install lint test

build: go.sum
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/bcd.exe ./cmd/bcd
go build -mod=readonly $(BUILD_FLAGS) -o build/bccli.exe ./cmd/bccli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/bcd ./cmd/bcd
go build -mod=readonly $(BUILD_FLAGS) -o build/bccli ./cmd/bccli
endif

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

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

install: go.sum
go install $(BUILD_FLAGS) ./cmd/bcd
go install $(BUILD_FLAGS) ./cmd/bccli

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/bcd -d 2 | dot -Tpng -o dependency-graph.png

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

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 ;

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' ./...

test-build: build
@go test -mod=readonly -p 4 `go list ./cli_test/...` -tags=cli_test -v

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

# 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
# @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


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

lint:
golangci-lint run
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

###############################################################################
### Localnet ###
###############################################################################

build-docker-bcdnode:
$(MAKE) -C networks/local

# Run a 4-node testnet locally
localnet-start: build-linux localnet-stop
@if ! [ -f build/node0/bcd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/bcd:Z tendermint/bcdnode 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

setup-contract-tests-data:
echo 'Prepare data for the contract tests'
rm -rf /tmp/contract_tests ; \
mkdir /tmp/contract_tests ; \
cp "${GOPATH}/pkg/mod/${SDK_PACK}/client/lcd/swagger-ui/swagger.yaml" /tmp/contract_tests/swagger.yaml ; \
./build/bcd init --home /tmp/contract_tests/.bcd --chain-id lcd contract-tests ; \
tar -xzf lcd_test/testdata/state.tar.gz -C /tmp/contract_tests/

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

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

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

contract-tests: setup-transactions
@echo "Running Band-Consumer LCD for contract tests"
dredd && pkill bcd

###############################################################################
### Protobuf ###
###############################################################################

proto-all: proto-gen proto-lint proto-check-breaking

proto-gen:
@./scripts/protocgen.sh

proto-lint:
@buf check lint --error-format=json

proto-check-breaking:
@buf check breaking --against-input '.git#branch=master'

.PHONY: proto-all proto-gen proto-lint proto-check-breaking

.PHONY: all build-linux install install-debug \
go-mod-cache draw-deps clean build \
setup-transactions setup-contract-tests-data start-bc run-lcd-contract-tests contract-tests \
test test-all test-build test-cover test-unit test-race
34 changes: 34 additions & 0 deletions band-consumer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Cosmos Hub
![banner](./docs/images/cosmos-hub-image.jpg)

[![CircleCI](https://circleci.com/gh/cosmos/gaia/tree/master.svg?style=shield)](https://circleci.com/gh/cosmos/gaia/tree/master)
[![codecov](https://codecov.io/gh/cosmos/gaia/branch/master/graph/badge.svg)](https://codecov.io/gh/cosmos/gaia)
[![Go Report Card](https://goreportcard.com/badge/github.com/cosmos/gaia)](https://goreportcard.com/report/github.com/cosmos/gaia)
[![license](https://img.shields.io/github/license/cosmos/gaia.svg)](https://github.com/cosmos/gaia/blob/master/LICENSE)
[![LoC](https://tokei.rs/b1/github/cosmos/gaia)](https://github.com/cosmos/gaia)
[![GolangCI](https://golangci.com/badges/github.com/cosmos/gaia.svg)](https://golangci.com/r/github.com/cosmos/gaia)
[![riot.im](https://img.shields.io/badge/riot.im-JOIN%20CHAT-green.svg)](https://riot.im/app/#/room/#cosmos-sdk:matrix.org)

This repository hosts `Gaia`, the first implementation of the Cosmos Hub based on the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk).

**Note**: Requires [Go 1.13+](https://golang.org/dl/)

## Cosmos Hub Mainnet

To run a full-node for the mainnet of the Cosmos Hub, first [install `gaiad`](./docs/gaia-tutorials/installation.md), then follow [the guide](./docs/gaia-tutorials/join-mainnet.md).

For status updates and genesis file, see the [launch repo](https://github.com/cosmos/launch).

## Quick Start

```
make install
```

## Cosmos Hub Archives

Archives of the Cosmos Hub can be found on this page [here](./docs/resources/archives.md).

## Disambiguation

This Cosmos-SDK project is not related to the [React-Cosmos](https://github.com/react-cosmos/react-cosmos) project (yet). Many thanks to Evan Coury and Ovidiu (@skidding) for this Github organization name. As per our agreement, this disambiguation notice will stay here.
Loading

0 comments on commit df6f463

Please sign in to comment.