Skip to content

Commit

Permalink
[v2] sdk v0.47.x migration & ibc v7 (#93)
Browse files Browse the repository at this point in the history
* update app to v2

* upgrade to sdk v0.47 & ibc-go v7

* update ibc storekey

* cosmos-sdk v0.47 updates, improvements & cleanup

* update go version

* add v2 upgrade handler

* update sdkerrors to errorsmod

* update github workflows

* fix github workflows

* fix lint issues

* fix lint issues

* gofumpted

* fix tests

* lint

* fix tests

* add update params message

* add migrations

* removed unused handler

* seperated params and legacy params

* add store migration logic

* add update params message and it's types

* add params store key for module

* update init genesis to panic on error

* include subspace argument in alloc module call

* fix lint

* fix codec register msg

* update protos

* add paramset in exported types for migration

* seperated legacy fuciton of params

* add msg types for update params

* updated params get & set fuctions to fetch data from module store

* fix lint

* add upgrade params msg

* fix params grpc query

* fix itc keeper init

* add & register migration

* register params msg with codec

* migration tests

* fix lint

* fix sdk msg implementation

* refactor: remove unused legacy handler

* replace gogo protobuf with cosmos gogoproto

* add update params msg protos

* add update params related types

* add updateParams message

* add & register migration

* lint

* feat: x/streampay params migration

* fix streampay module initialization

* feat: onft params migration

* feat: update upgrade handler sdk & ibc migrations

* add consensus and crisis modules to store upgrades

* update go lint config

* fix lint issues

* fix lint issues

* remove min commission decorator

* add migration test for alloc params

* fix params migration issue
  • Loading branch information
harish551 authored Oct 4, 2023
1 parent 6136e48 commit 031fa86
Show file tree
Hide file tree
Showing 186 changed files with 5,265 additions and 5,466 deletions.
63 changes: 41 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,65 @@ name: omniflixhub
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
push:
branches:
- master
- main
- development
tags:
- v*
pull_request:
branches:
- master
- main
- development
- "**"
push:
branches:
- "main"
- "v[0-9]**"
workflow_dispatch:

env:
GO_VERSION: "1.20.5"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# This workflow makes x86_64 binaries for mac, windows, and linux.

jobs:
build:
name: omniflixhub ${{ matrix.arch }} for ${{ matrix.targetos }}
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ amd64, arm64 ]
targetos: [ darwin, linux ]
name: omniflixhub ${{ matrix.arch }} for ${{ matrix.targetos }}
include:
- targetos: darwin
arch: arm64

steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
- name: Check out repository code
uses: actions/checkout@v4
- name: Get git diff
uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.wasm
!tests/**
**/**.go !**/*_test.go
go.mod
go.sum
Makefile
.github/workflows/build.yml
- name: Setup Golang
uses: actions/setup-go@v4
if: env.GIT_DIFF
with:
go-version: 1.18
go-version: ${{env.GO_VERSION}}
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}

- name: Compile
- name: Download Dependencies
if: env.GIT_DIFF
run: go mod download
- name: Build omnniflixhubd
if: env.GIT_DIFF
run: |
go mod download
cd cmd/omniflixhubd
go build .
- uses: actions/upload-artifact@v2
GOWRK=off go build cmd/omniflixhubd/main.go
- uses: actions/upload-artifact@v3
with:
name: omniflixhubd ${{ matrix.targetos }} ${{ matrix.arch }}
path: cmd/omniflixhubd/omniflixhubd
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,31 @@ on:
- master
- main
pull_request:
paths:
- '**.go'

env:
GO_VERSION: '1.20.0'

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 }}
cancel-in-progress: true

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.20.0
go-version: ${{env.GO_VERSION}}
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m0s
args: --timeout 10m
16 changes: 9 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ linters:
- unused

issues:
gofumpt:
# Module path which contains the source code being formatted.
# Default: ""
module-path: github.com/cosmos/interchain-security
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
exclude-rules:
- text: "Use of weak random number generator"
linters:
Expand All @@ -54,11 +47,20 @@ issues:
- text: "leading space"
linters:
- nolintlint
- path: "legacy"
text: "SA1019:"
linters:
- staticcheck

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
gosec:
excludes:
- G404
- G101
- G601
gocritic:
disabled-checks:
- appendAssign
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:

before:
hooks:
- go mod tidy -compat=1.19
- go mod tidy -compat=1.20

builds:
- main: ./cmd/omniflixhubd
Expand Down
55 changes: 48 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@ APP_NAME = OmniFlixHub
DAEMON_NAME = omniflixhubd
LEDGER_ENABLED ?= true

PACKAGES=$(shell go list ./... | grep -v '/simulation')
VERSION := $(shell echo $(shell git describe --tags --always) | sed 's/^v//')
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
COSMOS_SDK := $(shell grep -i cosmos-sdk go.mod | awk '{print $$2}')

# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif

PACKAGES_SIMTEST=$(shell go list ./... | grep -v '/simulation')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BFT_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build

GO_SYSTEM_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1-2)
REQUIRE_GO_VERSION = 1.20

export GO111MODULE = on

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
Expand All @@ -30,6 +49,13 @@ ifeq ($(LEDGER_ENABLED),true)
endif
endif
endif

ifeq (cleveldb,$(findstring cleveldb,$(OMNIFLIXHUB_BUILD_OPTIONS)))
build_tags += gcc cleveldb
else ifeq (rocksdb,$(findstring rocksdb,$(OMNIFLIXHUB_BUILD_OPTIONS)))
build_tags += gcc rocksdb
endif

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

Expand All @@ -44,27 +70,42 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=${APP_NAME} \
-X github.com/cosmos/cosmos-sdk/version.AppName=${DAEMON_NAME} \
-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),cosmos-sdk $(COSMOS_SDK)"
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(BFT_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(OMNIFLIXHUB_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
else ifeq (rocksdb,$(findstring rocksdb,$(OMNIFLIXHUB_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
endif

ifeq (,$(findstring nostrip,$(OMNIFLIXHUB_BUILD_OPTIONS)))
ldflags += -w -s
endif

ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

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

ifeq (,$(findstring nostrip,$(ONFT_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

all: go.sum install

install: go.sum
go install $(BUILD_FLAGS) ./cmd/omniflixhubd/
go install -mod=readonly $(BUILD_FLAGS) ./cmd/omniflixhubd
build:
go build $(BUILD_FLAGS) -o ./build/omniflixhubd ./cmd/omniflixhubd/
go build $(BUILD_FLAGS) -o ${BUILDDIR}/${DAEMON_NAME} ./cmd/omniflixhubd

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

lint:
@echo "--> Running linter"
@golangci-lint run
@golangci-lint run --timeout 10m
@go mod verify


Expand Down
29 changes: 16 additions & 13 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package app

import (
"github.com/OmniFlix/omniflixhub/app/decorators"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
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"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand All @@ -18,19 +19,19 @@ type HandlerOptions struct {

GovKeeper govkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
TxCounterStoreKey sdk.StoreKey
TxCounterStoreKey storetypes.StoreKey
Codec codec.BinaryCodec
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
}
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 @@ -40,22 +41,24 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // Outermost AnteDecorator, SetUpContext must be called first
decorators.NewMinCommissionDecorator(options.Codec),
ante.NewRejectExtensionOptionsDecorator(),
decorators.NewMinimumInitialDepositDecorator(options.Codec, options.GovKeeper),
ante.NewMempoolFeeDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
ante.NewDeductFeeDecorator(
options.AccountKeeper,
options.BankKeeper,
options.FeegrantKeeper,
options.TxFeeChecker,
),
// 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 031fa86

Please sign in to comment.