Skip to content

Commit

Permalink
feat: TokenFactory, IBC Hooks and fixes (#12)
Browse files Browse the repository at this point in the history
* feat: add ibc hooks

* feat: token factory integration as a module

* feat: github actions

* wip: fix lint and sec issues

* fix: linting

* fix: gosec

* feat: remove build from test coverage

* feat: remove redundant encoding config

* feat: remove start.sh

* feat: remove start.sh

* feat: feather connect

* feat: feather connection

* wip: connection module

* feat: query server

* wip: proto, swagger and connection

* wip: connection

* fix: params keystore

* fix: proto, swagger and token-factory urls

* fix: leveldb access

* feat: feather query server

* feat: refact module code and write tests

* feat: rename module

* feat: feather module with tests and codecs

* wip: integration tests

* feat: integration tests

* feat: make codecov report optional

* fix: comments and linting

* fix: ibctm app module and tests

* feat: remove mounting keystore

* feat: apply simulation suggestions

* feat: simulate on feather module height
  • Loading branch information
emidev98 authored May 29, 2023
1 parent ae74afd commit 2d092c2
Show file tree
Hide file tree
Showing 74 changed files with 33,800 additions and 35,433 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on: [push, pull_request]
name: every commit
jobs:

build:
runs-on: ubuntu-latest
name: build
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- run: go build ./...

test:
runs-on: ubuntu-latest
name: test
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: go test ./...

# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
tidy:
runs-on: ubuntu-latest
name: tidy
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- run: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
27 changes: 27 additions & 0 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run Gosec
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v3
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- name: Run Gosec Security Scanner
uses: informalsystems/gosec@master
with:
args: ./...
if: "env.GIT_DIFF != ''"
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint
# Lint runs golangci-lint over the entire Gaia repository
# This workflow is run on every pull request and push to main
# The `golangci` job will pass without running if no *.{go, mod, sum} files have been modified.
on:
pull_request:
push:
branches:
- main
jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.51.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: "env.GIT_DIFF != ''"
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:

- name: Test
id: test
run: go test -v -run=TestFullAppSimulation ./app -NumBlocks 200 -BlockSize 50 -Commit -Enabled -Period 1 -Seed 39
run: go test -v -run=TestFullAppSimulation ./app -NumBlocks 200 -BlockSize 50 -Commit -Enabled -Period 1
47 changes: 47 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# name: Test Coverage
# on:
# pull_request:
# push:
# branches:
# - main
# jobs:
# cleanup-runs:
# runs-on: ubuntu-latest
# steps:
# - uses: rokroskar/workflow-run-cleanup-action@master
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
#
# test-coverage-upload:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/setup-go@v4
# with:
# go-version: 1.20.0
# - uses: actions/checkout@v3
# - uses: technote-space/get-diff-action@v4
# with:
# PATTERNS: |
# **/**.go
# go.mod
# go.sum
# - name: test & coverage report creation
# run: |
# go test ./... -mod=readonly -timeout 12m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
# if: "env.GIT_DIFF != ''"
# - name: filter out DONTCOVER
# run: |
# excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
# excludelist+=" $(find ./ -type f -name '*.pb.go')"
# for filename in ${excludelist}; do
# filename=$(echo $filename | sed 's/^./github.com\/terra-money\/core\/v2/g')
# echo "Excluding ${filename} from coverage report..."
# sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
# done
# if: "env.GIT_DIFF != ''"
# - uses: codecov/codecov-action@v1
# with:
# file: ./coverage.txt # optional
# fail_ci_if_error: true
# if: "env.GIT_DIFF != ''"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ release/
.DS_Store
dist
build
vendor/
vendor/
tmp-swagger-gen/
.test-data/
coverage.txt
67 changes: 44 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
JQ := $(shell which jq)

# for dockerized protobuf tools
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/CosmWasm/wasmd.git
HTTPS_GIT := https://github.com/terra-money/feather-core.git

export GO111MODULE = on

Expand Down Expand Up @@ -233,12 +229,12 @@ clean:
distclean: clean
rm -rf vendor/

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

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

test: test-unit
test-all: check test-race test-cover
test-all: test-race test-cover

test-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./...
Expand All @@ -259,6 +255,31 @@ test-sim-import-export: runsim
test-sim-multi-seed-short: runsim
@echo "Running short multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation

simulate:
@go test -v -run=TestFullAppSimulation ./app -NumBlocks 200 -BlockSize 50 -Commit -Enabled -Period 1

integration-test: clean-integration-test-data install
@echo "Initializing both blockchains..."
./scripts/tests/start.sh
@echo "Create relayer..."
./scripts/tests/relayer/rly-init.sh
@echo "Transfer coin from chain test-1 to test-2..."
./scripts/tests/feather/transfer.sh
@echo "Validate the creation of alliance throught feather..."
./scripts/tests/feather/validate-alliance.sh
@echo "Killing feather-cored and removing previous data"
-@rm -rf ./.test-data
-@killall feather-cored 2>/dev/null
-@killall rly 2>/dev/null

clean-integration-test-data:
@echo "Killing feather-cored and removing previous data"
-@rm -rf ./.test-data
-@killall feather-cored 2>/dev/null
-@killall rly 2>/dev/null

.PHONY: integration-test clean-integration-test-data

###############################################################################
### Linting ###
Expand All @@ -273,39 +294,39 @@ lint: format-tools
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*_test.go" | xargs gofumpt -d -s

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 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/CosmWasm/wasmd
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofumpt -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs goimports -w -local github.com/CosmWasm/wasmd


###############################################################################
### Protobuf ###
###############################################################################
PROTO_BUILDER_IMAGE=tendermintdev/sdk-proto-gen:v0.7
PROTO_FORMATTER_IMAGE=tendermintdev/docker-build-proto@sha256:aabcfe2fc19c31c0f198d4cd26393f5e5ca9502d7ea3feafbfe972448fee7cae
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace ghcr.io/cosmos/proto-builder

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

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

proto-format:
@echo "Formatting Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace \
--workdir /workspace $(PROTO_FORMATTER_IMAGE) \
find ./ -name *.proto -exec clang-format -i {} \;
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh
@echo "Generating Protobuf Swagger"
sh ./scripts/protoc-swagger-gen.sh

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@echo "Lint Protobuf files"
@$(protoImage) buf lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
@echo "Check Protobuf breaking changes"
@$(protoImage) 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 \
test test-all test-build test-cover test-unit \
test-race simulate test-sim-import-export \
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ git push origin v0.1

After a draft release is created, make your final changes from the release page and publish it.

## Test Coverage

If you want to have a test coverage report when commiting to a branch you must create an account on [codecov](https://docs.codecov.com/docs#getting-started) and uncomment all lines from `.github/workflows/test-coverage.yml` file. If the repo is private you also need to add the `CODECOV_TOKEN` to the GitHub repo secrets.

## Learn more

- [Ignite CLI](https://ignite.com/cli)
Expand Down
7 changes: 4 additions & 3 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
errors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -30,15 +31,15 @@ type HandlerOptions struct {
// signer.
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
return nil, errors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
}

if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
return nil, errors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
}

if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

anteDecorators := []sdk.AnteDecorator{
Expand Down
Loading

0 comments on commit 2d092c2

Please sign in to comment.