Skip to content

Commit

Permalink
init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed Feb 28, 2023
1 parent bc75f81 commit 41aa302
Show file tree
Hide file tree
Showing 20 changed files with 3,595 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
*.so
*.dylib

**state.json
**test.py
**test.sh
**test.py
# build
launch.sh
build/*
state/*
scripts/state
scripts/logs
dockernet/state
dockernet/logs
dockernet/upgrades/binaries
dockernet/upgrades/cosmovisor
dockernet/temp.sh
scripts/temp.sh
vue/*
# Test binary, built with `go test -c`
*.test

Expand All @@ -13,3 +30,13 @@

# Dependency directories (remove the comment below to include it)
# vendor/


.DS_Store
.terraform
*.pem

.vscode
!.vscode/settings.json
.vendor
vendor
34 changes: 34 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[submodule "deps/hermes"]
# Commit: fd92eb6d17342bc83003f2067d6a9cd8261f2884
path = deps/hermes
url = https://github.com/informalsystems/ibc-rs.git
[submodule "deps/relayer"]
# Commit: 2d9fe1acf9081ec7bdcefd8c212a21d28febaba7
path = deps/relayer
url = https://github.com/cosmos/relayer.git
[submodule "deps/gaia"]
# Commit: 5db8fcc9a229730f5115bed82d0f85b6db7184b4
path = deps/gaia
url = https://github.com/cosmos/gaia.git
[submodule "deps/juno"]
# Commit: 955892041359443fbb5addd34c0ab8b66bd8d75c
path = deps/juno
url = https://github.com/CosmosContracts/juno.git
[submodule "deps/osmosis"]
# Commit: 08669da8509059980dc964976ee1ca60c84f5c8a
path = deps/osmosis
url = https://github.com/osmosis-labs/osmosis.git
[submodule "deps/stargaze"]
# Commit: b0bea28fc695a2a5c567e56a37b289a5b75830cc
path = deps/stargaze
url = https://github.com/public-awesome/stargaze.git
# bats
[submodule "dockernet/tests/bats/bats-core"]
path = dockernet/tests/bats/bats-core
url = https://github.com/bats-core/bats-core.git
[submodule "dockernet/tests/bats/bats-assert"]
path = dockernet/tests/bats/bats-assert
url = https://github.com/bats-core/bats-assert.git
[submodule "dockernet/tests/bats/bats-support"]
path = dockernet/tests/bats/bats-support
url = https://github.com/bats-core/bats-support.git
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax = docker/dockerfile:1

ARG GO_VERSION="1.19"
ARG RUNNER_IMAGE="alpine:3.16"

FROM golang:${GO_VERSION}-alpine as builder

WORKDIR /opt
RUN apk add --no-cache make git gcc musl-dev openssl-dev linux-headers

COPY go.mod .
COPY go.sum .

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Copy the remaining files
COPY . .

RUN LINK_STATICALLY=true make build

# Add to a distroless container
FROM ${RUNNER_IMAGE}

COPY --from=builder /opt/build/strided /usr/local/bin/strided
RUN apk add bash vim sudo dasel \
&& addgroup -g 1000 stride \
&& adduser -S -h /home/stride -D stride -u 1000 -G stride

RUN mkdir -p /etc/sudoers.d \
&& echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel \
&& echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers \
&& adduser stride wheel

USER 1000
ENV HOME /home/stride
WORKDIR $HOME

EXPOSE 26657 26656 1317 9090

CMD ["strided", "start"]
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2022 Stride Labs, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
211 changes: 211 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#!/usr/bin/make -f

BUILDDIR ?= $(CURDIR)/build
build=s
cache=false
COMMIT := $(shell git log -1 --format='%H')
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.7.0
DOCKERNET_HOME=./dockernet
DOCKERNET_COMPOSE_FILE=$(DOCKERNET_HOME)/docker-compose.yml
LOCALSTRIDE_HOME=./testutil/localstride
LOCALNET_COMPOSE_FILE=$(LOCALSTRIDE_HOME)/localnet/docker-compose.yml
STATE_EXPORT_COMPOSE_FILE=$(LOCALSTRIDE_HOME)/state-export/docker-compose.yml

# process build tags

LEDGER_ENABLED ?= true
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

build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

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=stride \
-X github.com/cosmos/cosmos-sdk/version.AppName=strided \
-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 ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

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

.PHONY: build

###############################################################################
### Build & Clean ###
###############################################################################

build:
mkdir -p $(BUILDDIR)/
go build -mod=readonly -ldflags '$(ldflags)' -trimpath -o $(BUILDDIR) ./...;

install: go.sum
go install $(BUILD_FLAGS) ./cmd/strided

clean:
rm -rf $(BUILDDIR)/*

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

gosec:
gosec -exclude-dir=deps -severity=high ./...

lint:
golangci-lint run

###############################################################################
### Tests ###
###############################################################################

test-unit:
@go test -mod=readonly ./x/... ./app/...

test-unit-path:
@go test -mod=readonly ./x/$(path)/...

test-cover:
@go test -mod=readonly -race -coverprofile=coverage.out -covermode=atomic ./x/$(path)/...

test-integration-docker:
bash $(DOCKERNET_HOME)/tests/run_all_tests.sh

###############################################################################
### DockerNet ###
###############################################################################

build-docker:
@bash $(DOCKERNET_HOME)/build.sh -${build} ${BUILDDIR}

start-docker: build-docker
@bash $(DOCKERNET_HOME)/start_network.sh

start-docker-all: build-docker
@ALL_HOST_CHAINS=true bash $(DOCKERNET_HOME)/start_network.sh

clean-docker:
@docker-compose -f $(DOCKERNET_COMPOSE_FILE) stop
@docker-compose -f $(DOCKERNET_COMPOSE_FILE) down
rm -rf $(DOCKERNET_HOME)/state
docker image prune -a

stop-docker:
@bash $(DOCKERNET_HOME)/pkill.sh
docker-compose -f $(DOCKERNET_COMPOSE_FILE) down

upgrade-init:
PART=1 bash $(DOCKERNET_HOME)/tests/run_tests_upgrade.sh

upgrade-submit:
UPGRADE_HEIGHT=400 bash $(DOCKERNET_HOME)/upgrades/submit_upgrade.sh

upgrade-validate:
PART=2 bash $(DOCKERNET_HOME)/tests/run_tests_upgrade.sh

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

containerProtoVer=v0.7
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)

proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace ghcr.io/cosmos/proto-builder sh ./scripts/protocgen.sh

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./proto -name "*.proto" -exec clang-format -i {} \; ; fi

proto-lint:
@$(DOCKER_BUF) lint --error-format=json

.PHONY: proto-all proto-gen proto-format proto-lint


###############################################################################
### LocalStride ###
###############################################################################

localnet-keys:
. $(LOCALSTRIDE_HOME)/localnet/add_keys.sh

localnet-init: localnet-clean localnet-build

localnet-clean:
@rm -rfI $(HOME)/.stride/

localnet-build:
@docker-compose -f $(LOCALNET_COMPOSE_FILE) build

localnet-start:
@docker-compose -f $(LOCALNET_COMPOSE_FILE) up

localnet-startd:
@docker-compose -f $(LOCALNET_COMPOSE_FILE) up -d

localnet-stop:
@docker-compose -f $(LOCALNET_COMPOSE_FILE) down

localnet-state-export-init: localnet-state-export-clean localnet-state-export-build

localnet-state-export-build:
@DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose -f $(STATE_EXPORT_COMPOSE_FILE) build

localnet-state-export-start:
@docker-compose -f $(STATE_EXPORT_COMPOSE_FILE) up

localnet-state-export-startd:
@docker-compose -f $(STATE_EXPORT_COMPOSE_FILE) up -d

localnet-state-export-upgrade:
bash $(LOCALSTRIDE_HOME)/state-export/scripts/submit_upgrade.sh

localnet-state-export-stop:
@docker-compose -f $(STATE_EXPORT_COMPOSE_FILE) down

localnet-state-export-clean: localnet-clean
Loading

0 comments on commit 41aa302

Please sign in to comment.