Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ci #329

Merged
merged 3 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/

# Primary repo maintainers
* @joe-bowman @ajansari95 @aljo242
7 changes: 5 additions & 2 deletions .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19.4'
go-version: '1.19.6'
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.19.4'
go-version: '1.19.6'
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
Expand All @@ -75,11 +75,14 @@ jobs:
cat coverage.txt | grep .pb.go -v | grep .pb.gw.go -v | grep osmosis-types -v > coverage_nogen.txt

- name: "Go vulnerability checks"
continue-on-error: true #temp-till we upgrade to v1.20
run: make vulncheck


- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # needed for private repo
files: ./coverage_nogen.txt
flags: unittests
fail_ci_if_error: true
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -21,9 +22,22 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push evinced
uses: docker/build-push-action@v3
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.19.6'

- name: Setup Golang caches
uses: actions/cache@v3
with:
push: true
tags: quicksilverzone/quicksilver:latest
file: Dockerfile
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-

- name: build and push container
run: |
DOCKER_BUILDKIT=1 /usr/bin/docker build . -f Dockerfile -t quicksilverzone/quicksilver:latest
/usr/bin/docker push quicksilverzone/quicksilver:latest
1 change: 0 additions & 1 deletion .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
Expand Down
19 changes: 3 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
# Cosmwasm - download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a \
-O /lib/libwasmvm_muslc.a && \
wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/checksums.txt -O /tmp/checksums.txt && \
-O /lib/libwasmvm_muslc.a && \
wget https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1)

COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
VERSION=$(echo $(git describe --tags) | sed 's/^v//') && \
COMMIT=$(git log -1 --format='%H') && \
go build \
-mod=readonly \
-tags "netgo,ledger,muslc" \
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="quicksilver" \
-X github.com/cosmos/cosmos-sdk/version.AppName="quicksilverd" \
-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='netgo,ledger,muslc' \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o /src/app/build/ \
./...
LINK_STATICALLY=true make build

# Add to a distroless container
FROM alpine:3.17
Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ endif

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
build_tags += muslc
endif

build_tags += $(BUILD_TAGS)
Expand Down Expand Up @@ -144,7 +145,7 @@ $(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

build-docker:
DOCKER_BUILDKIT=1 $(DOCKER) build . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION)
DOCKER_BUILDKIT=1 $(DOCKER) build . -f Dockerfile -t quicksilverzone/quicksilver:$(DOCKER_VERSION) -t quicksilverzone/quicksilver:latest

build-docker-local: build
DOCKER_BUILDKIT=1 $(DOCKER) build -f Dockerfile.local . -t quicksilverzone/quicksilver:$(DOCKER_VERSION)
Expand Down Expand Up @@ -316,13 +317,13 @@ test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)

run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
go test -short -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
else
go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
go test -short -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
endif

test-import:
@go test ./tests/importer -v --vet=off --run=TestImportBlocks --datadir tmp \
@go test -short ./tests/importer -v --vet=off --run=TestImportBlocks --datadir tmp \
--blockchain blockchain
rm -rf tests/importer/tmp

Expand Down Expand Up @@ -404,6 +405,13 @@ format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/ingenuity-build/quicksilver
.PHONY: format

mdlint:
@echo "--> Running markdown linter"
@docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md"

mdlint-fix:
@docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --fix

###############################################################################
### Protobuf ###
###############################################################################
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 (
sdkioerrors "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand All @@ -24,13 +25,13 @@ type HandlerOptions struct {

func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
if options.AccountKeeper == nil {
panic(sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler"))
panic(sdkioerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler"))
}
if options.BankKeeper == nil {
panic(sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler"))
panic(sdkioerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler"))
}
if options.SignModeHandler == nil {
panic(sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder"))
panic(sdkioerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder"))
}

sigGasConsumer := options.SigGasConsumer
Expand Down
7 changes: 3 additions & 4 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"fmt"
"path"

"github.com/spf13/viper"

sdkioerrors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/server/config"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/spf13/viper"
)

const (
Expand Down Expand Up @@ -122,7 +121,7 @@ func ParseConfig(v *viper.Viper) (*Config, error) {
// ValidateBasic returns an error any of the application configuration fields are invalid
func (c Config) ValidateBasic() error {
if err := c.TLS.Validate(); err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrAppConfig, "invalid tls config value: %s", err.Error())
return sdkioerrors.Wrapf(sdkerrors.ErrAppConfig, "invalid tls config value: %s", err.Error())
}

return c.Config.ValidateBasic()
Expand Down
30 changes: 15 additions & 15 deletions wasmbinding/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package wasmbinding
import (
"encoding/json"

sdkioerrors "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

"github.com/ingenuity-build/quicksilver/wasmbinding/bindings"
Expand Down Expand Up @@ -41,7 +41,7 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre
// leave everything else for the wrapped version
var contractMsg bindings.TokenFactoryMsg
if err := json.Unmarshal(msg.Custom, &contractMsg); err != nil {
return nil, nil, sdkerrors.Wrap(err, "TokenFactoryMsg msg")
return nil, nil, sdkioerrors.Wrap(err, "TokenFactoryMsg msg")
}
if contractMsg.CreateDenom != nil {
return m.createDenom(ctx, contractAddr, contractMsg.CreateDenom)
Expand All @@ -63,7 +63,7 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre
func (m *CustomMessenger) createDenom(ctx sdk.Context, contractAddr sdk.AccAddress, createDenom *bindings.CreateDenom) ([]sdk.Event, [][]byte, error) {
err := PerformCreateDenom(m.tokenFactory, m.bank, ctx, contractAddr, createDenom)
if err != nil {
return nil, nil, sdkerrors.Wrap(err, "perform create denom")
return nil, nil, sdkioerrors.Wrap(err, "perform create denom")
}
return nil, nil, nil
}
Expand All @@ -79,7 +79,7 @@ func PerformCreateDenom(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper,
msgCreateDenom := tokenfactorytypes.NewMsgCreateDenom(contractAddr.String(), createDenom.Subdenom)

if err := msgCreateDenom.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "failed validating MsgCreateDenom")
return sdkioerrors.Wrap(err, "failed validating MsgCreateDenom")
}

// Create denom
Expand All @@ -88,7 +88,7 @@ func PerformCreateDenom(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper,
msgCreateDenom,
)
if err != nil {
return sdkerrors.Wrap(err, "creating denom")
return sdkioerrors.Wrap(err, "creating denom")
}
return nil
}
Expand All @@ -97,7 +97,7 @@ func PerformCreateDenom(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper,
func (m *CustomMessenger) mintTokens(ctx sdk.Context, contractAddr sdk.AccAddress, mint *bindings.MintTokens) ([]sdk.Event, [][]byte, error) {
err := PerformMint(m.tokenFactory, m.bank, ctx, contractAddr, mint)
if err != nil {
return nil, nil, sdkerrors.Wrap(err, "perform mint")
return nil, nil, sdkioerrors.Wrap(err, "perform mint")
}
return nil, nil, nil
}
Expand All @@ -122,11 +122,11 @@ func PerformMint(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, ctx sdk
msgServer := tokenfactorykeeper.NewMsgServerImpl(*f)
_, err = msgServer.Mint(sdk.WrapSDKContext(ctx), sdkMsg)
if err != nil {
return sdkerrors.Wrap(err, "minting coins from message")
return sdkioerrors.Wrap(err, "minting coins from message")
}
err = b.SendCoins(ctx, contractAddr, rcpt, sdk.NewCoins(coin))
if err != nil {
return sdkerrors.Wrap(err, "sending newly minted coins from message")
return sdkioerrors.Wrap(err, "sending newly minted coins from message")
}
return nil
}
Expand All @@ -135,7 +135,7 @@ func PerformMint(f *tokenfactorykeeper.Keeper, b *bankkeeper.BaseKeeper, ctx sdk
func (m *CustomMessenger) changeAdmin(ctx sdk.Context, contractAddr sdk.AccAddress, changeAdmin *bindings.ChangeAdmin) ([]sdk.Event, [][]byte, error) {
err := ChangeAdmin(m.tokenFactory, ctx, contractAddr, changeAdmin)
if err != nil {
return nil, nil, sdkerrors.Wrap(err, "failed to change admin")
return nil, nil, sdkioerrors.Wrap(err, "failed to change admin")
}
return nil, nil, nil
}
Expand All @@ -158,7 +158,7 @@ func ChangeAdmin(f *tokenfactorykeeper.Keeper, ctx sdk.Context, contractAddr sdk
msgServer := tokenfactorykeeper.NewMsgServerImpl(*f)
_, err = msgServer.ChangeAdmin(sdk.WrapSDKContext(ctx), changeAdminMsg)
if err != nil {
return sdkerrors.Wrap(err, "failed changing admin from message")
return sdkioerrors.Wrap(err, "failed changing admin from message")
}
return nil
}
Expand All @@ -167,7 +167,7 @@ func ChangeAdmin(f *tokenfactorykeeper.Keeper, ctx sdk.Context, contractAddr sdk
func (m *CustomMessenger) burnTokens(ctx sdk.Context, contractAddr sdk.AccAddress, burn *bindings.BurnTokens) ([]sdk.Event, [][]byte, error) {
err := PerformBurn(m.tokenFactory, ctx, contractAddr, burn)
if err != nil {
return nil, nil, sdkerrors.Wrap(err, "perform burn")
return nil, nil, sdkioerrors.Wrap(err, "perform burn")
}
return nil, nil, nil
}
Expand All @@ -191,7 +191,7 @@ func PerformBurn(f *tokenfactorykeeper.Keeper, ctx sdk.Context, contractAddr sdk
msgServer := tokenfactorykeeper.NewMsgServerImpl(*f)
_, err := msgServer.Burn(sdk.WrapSDKContext(ctx), sdkMsg)
if err != nil {
return sdkerrors.Wrap(err, "burning coins from message")
return sdkioerrors.Wrap(err, "burning coins from message")
}
return nil
}
Expand All @@ -204,7 +204,7 @@ func GetFullDenom(contract string, subDenom string) (string, error) {
}
fullDenom, err := tokenfactorytypes.GetTokenDenom(contract, subDenom)
if err != nil {
return "", sdkerrors.Wrap(err, "validate sub-denom")
return "", sdkioerrors.Wrap(err, "validate sub-denom")
}

return fullDenom, nil
Expand All @@ -214,11 +214,11 @@ func GetFullDenom(contract string, subDenom string) (string, error) {
func parseAddress(addr string) (sdk.AccAddress, error) {
parsed, err := sdk.AccAddressFromBech32(addr)
if err != nil {
return nil, sdkerrors.Wrap(err, "address from bech32")
return nil, sdkioerrors.Wrap(err, "address from bech32")
}
err = sdk.VerifyAddressFormat(parsed)
if err != nil {
return nil, sdkerrors.Wrap(err, "verify address format")
return nil, sdkioerrors.Wrap(err, "verify address format")
}
return parsed, nil
}
11 changes: 5 additions & 6 deletions wasmbinding/query_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"encoding/json"
"fmt"

sdkioerrors "cosmossdk.io/errors"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/ingenuity-build/quicksilver/wasmbinding/bindings"
abci "github.com/tendermint/tendermint/abci/types"
)

// StargateQuerier dispatches whitelisted stargate queries
Expand Down Expand Up @@ -49,7 +48,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag
return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) {
var contractQuery bindings.QuickSilverQuery
if err := json.Unmarshal(request, &contractQuery); err != nil {
return nil, sdkerrors.Wrap(err, "quicksilver query")
return nil, sdkioerrors.Wrap(err, "quicksilver query")
}

switch {
Expand All @@ -59,7 +58,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag

fullDenom, err := GetFullDenom(creator, subdenom)
if err != nil {
return nil, sdkerrors.Wrap(err, "osmo full denom query")
return nil, sdkioerrors.Wrap(err, "osmo full denom query")
}

res := bindings.FullDenomResponse{
Expand All @@ -68,7 +67,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag

bz, err := json.Marshal(res)
if err != nil {
return nil, sdkerrors.Wrap(err, "osmo full denom query response")
return nil, sdkioerrors.Wrap(err, "osmo full denom query response")
}

return bz, nil
Expand Down
Loading