Skip to content

Commit

Permalink
Merge pull request #646 from CosmosContracts/47-upgrade
Browse files Browse the repository at this point in the history
SDK v47 upgrade
  • Loading branch information
Reecepbcups authored May 22, 2023
2 parents 8e2efdf + 39d2867 commit aab43aa
Show file tree
Hide file tree
Showing 172 changed files with 7,734 additions and 3,653 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
name: build

on:
push:
paths:
- '**.go'
- 'go.sum'
pull_request:
pull_request:
types: [review_requested, closed, auto_merge_enabled]
paths:
- '**.go'
- 'go.sum'
name: build

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ name: Build Docker Image on PR

on:
push:
paths:
- "**docker**"
- "**.sh"
- "**.bash"
branches:
- master
- main

env:
REGISTRY: ghcr.io
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ on:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/integration.yml

This file was deleted.

19 changes: 8 additions & 11 deletions .github/workflows/interchaintest-E2E.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: ictest E2E
name: ictest E2E

on:
push:
Expand All @@ -10,7 +9,8 @@ on:
paths:
- '**.yml'
- '**.go'
- 'go.sum'
- '**.mod'
- '**.sum'

env:
REGISTRY: ghcr.io
Expand All @@ -20,9 +20,6 @@ env:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true




jobs:
build-and-push-image:
Expand All @@ -39,11 +36,17 @@ jobs:

# We setup go & cache dependencies here. This way each child job
# does not have to reinstall all dependencies individually.
# Should ID be unique to this job only?
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Download dependencies
run: |
go mod download
cd interchaintest && go mod download
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -81,19 +84,13 @@ jobs:

# TODO: Add reusable job template here, just changing the `make` command for each

# make juno:branchname here for all needs.build-and-push-image.outputs.branchTag
# then upload to github. Then download for each as a cache. This way its only built once

test-juno-basic:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: checkout chain
uses: actions/checkout@v2

- name: checkout chain
uses: actions/checkout@v2

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ tmp-swagger-gen

heighliner*

x/**/data/wasm/*

# emacs editor config
\#*\#
.\#*
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ linters-settings:
gosec:
excludes:
- G404

issues:
max-issues-per-linter: 0
56 changes: 22 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
BFT_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/cometbft/cometbft v0.34.7"
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8
BUILDDIR ?= $(CURDIR)/build
Expand Down Expand Up @@ -68,7 +68,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=juno \
-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)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(BFT_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(JUNO_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
Expand Down Expand Up @@ -122,37 +122,37 @@ benchmark:
###############################################################################

# Executes basic chain tests via interchaintest
ictest-basic:
ictest-basic: rm-testcache
cd interchaintest && go test -race -v -run TestBasicJunoStart .

ictest-tokenfactory:
ictest-tokenfactory: rm-testcache
cd interchaintest && go test -race -v -run TestJunoTokenFactory .

ictest-feeshare:
ictest-feeshare: rm-testcache
cd interchaintest && go test -race -v -run TestJunoFeeShare .

# Executes a basic chain upgrade test via interchaintest
ictest-upgrade:
ictest-upgrade: rm-testcache
cd interchaintest && go test -race -v -run TestBasicJunoUpgrade .

# Executes a basic chain upgrade locally via interchaintest after compiling a local image as juno:local
ictest-upgrade-local: local-image ictest-upgrade

# Executes IBC tests via interchaintest
ictest-ibc:
ictest-ibc: rm-testcache
cd interchaintest && go test -race -v -run TestJunoGaiaIBCTransfer .

# Unity contract CI
ictest-unity-deploy:
ictest-unity-deploy: rm-testcache
cd interchaintest && go test -race -v -run TestJunoUnityContractDeploy .

ictest-unity-gov:
ictest-unity-gov: rm-testcache
cd interchaintest && go test -race -v -run TestJunoUnityContractGovSubmit .

# Executes all tests via interchaintest after compling a local image as juno:local
ictest-all: local-image ictest-basic ictest-upgrade ictest-ibc
rm-testcache:
go clean -testcache

.PHONY: test-mutation ictest-basic ictest-upgrade ictest-ibc ictest-all
.PHONY: test-mutation ictest-basic ictest-upgrade ictest-ibc ictest-unity-deploy ictest-unity-gov

###############################################################################
### heighliner ###
Expand All @@ -172,43 +172,31 @@ endif
.PHONY: get-heighliner local-image

###############################################################################
### Proto ###
### Protobuf ###
###############################################################################

protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
containerProtoGen=juno-proto-gen-$(protoVer)
containerProtoGenAny=juno-proto-gen-any-$(protoVer)
containerProtoGenSwagger=juno-proto-gen-swagger-$(protoVer)
containerProtoFmt=juno-proto-fmt-$(protoVer)
protoVer=0.11.6
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

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

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen.sh; fi

# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
proto-gen-any:
@echo "Generating Protobuf Any"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenAny}$$"; then docker start -a $(containerProtoGenAny); else docker run --name $(containerProtoGenAny) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen-any.sh; fi
@$(protoImage) sh ./scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protoc-swagger-gen.sh; fi
@$(protoImage) sh ./scripts/protoc-swagger-gen.sh
$(MAKE) update-swagger-docs

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 ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

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

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps docs
29 changes: 12 additions & 17 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package app

import (
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

Expand All @@ -15,19 +16,16 @@ import (

wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
decorators "github.com/CosmosContracts/juno/v15/app/decorators"
storetypes "github.com/cosmos/cosmos-sdk/store/types"

feeshareante "github.com/CosmosContracts/juno/v15/x/feeshare/ante"
feesharekeeper "github.com/CosmosContracts/juno/v15/x/feeshare/keeper"

gaiafeeante "github.com/cosmos/gaia/v9/x/globalfee/ante"
gaiafeeante "github.com/CosmosContracts/juno/v15/x/globalfee/ante"
)

const maxBypassMinFeeMsgGasUsage = 1_000_000

func updateAppSimulationFlag(flag bool) {
decorators.DefaultIsAppSimulation = flag
}

// HandlerOptions extends the SDK's AnteHandler options by requiring the IBC
// channel keeper and a BankKeeper with an added method for fee sharing.
type HandlerOptions struct {
Expand All @@ -37,7 +35,7 @@ type HandlerOptions struct {
IBCKeeper *ibckeeper.Keeper
FeeShareKeeper feesharekeeper.Keeper
BankKeeperFork feeshareante.BankKeeper
TxCounterStoreKey sdk.StoreKey
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
Cdc codec.BinaryCodec
StakingSubspace paramtypes.Subspace
Expand All @@ -51,15 +49,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, errorsmod.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, errorsmod.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, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
Expand All @@ -69,27 +67,24 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
decorators.NewMinCommissionDecorator(options.Cdc),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
decorators.MsgFilterDecorator{},
decorators.NewGovPreventSpamDecorator(options.Cdc, options.GovKeeper),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
gaiafeeante.NewFeeDecorator(options.BypassMinFeeMsgTypes, options.GlobalFeeSubspace, options.StakingSubspace, maxBypassMinFeeMsgGasUsage),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
feeshareante.NewFeeSharePayoutDecorator(options.BankKeeperFork, options.FeeShareKeeper),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down
Loading

0 comments on commit aab43aa

Please sign in to comment.