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

build(deps): bump cosmos-sdk to v047 #690

Merged
merged 27 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
21 changes: 19 additions & 2 deletions .github/linters/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ run:


linters:
disable-all: true
Eengineer1 marked this conversation as resolved.
Show resolved Hide resolved
enable:
- bodyclose
- depguard
- depguard
Eengineer1 marked this conversation as resolved.
Show resolved Hide resolved
- dogsled
- errcheck
- exportloopref
- goconst
- gocritic
- gofumpt
- gofmt
- goimports
- gosimple
- govet
Expand Down Expand Up @@ -42,7 +45,7 @@ linters-settings:
- badCall # Remove this after CI workflow PR

gofumpt:
lang-version: "1.18"
lang-version: "1.21"

misspell:
ignore-words:
Expand All @@ -52,7 +55,7 @@ linters-settings:

stylecheck:
# Select the Go version to target.
go: "1.18"
go: "1.21"
# STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: ["all"]
Expand All @@ -62,3 +65,17 @@ linters-settings:
- "github.com/onsi/gomega"
# https://staticcheck.io/docs/configuration/options/#initialisms
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]

depguard:
rules:
main:
files:
- $all
list-mode: lax
allow: "*"

goconst:
min-occurrences: 5
ignore-tests: true
ignore-strings: "echo '"

4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
defaults:
run:
shell: bash
permissions:
contents: write
packages: read
checks: write


jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
version: v1.56.2
args: --config .github/linters/.golangci.yaml

proto-lint:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
defaults:
run:
shell: bash
permissions:
contents: write
packages: write


jobs:
# Super Linter only runs on diffs in PRs
Expand Down
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ifeq (,$(VERSION))
endif

SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')

LEDGER_ENABLED ?= true
DB_BACKEND ?= goleveldb
Expand Down Expand Up @@ -103,7 +103,7 @@ ifeq ($(DB_BACKEND), badgerdb)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb
endif

ldflags += -X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)
ldflags += -X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)

ifeq ($(NO_STRIP),false)
ldflags += -w -s
Expand Down Expand Up @@ -173,7 +173,7 @@ go-version:

go.sum: go.mod
@echo "Ensuring app dependencies have not been modified..."
go mod verify
go mod verify
go mod tidy

verify:
Expand All @@ -200,11 +200,17 @@ generate:
### Lint / Format ###
###############################################################################


golangci_version=v1.56.2

lint:
golangci-lint run --out-format=tab
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
golangci-lint run --out-format=tab --config .github/linters/.golangci.yaml

lint-fix:
golangci-lint run --fix --out-format=tab --issues-exit-code=0
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
golangci-lint run --config .github/linters/.golangci.yaml --fix --out-format=tab --issues-exit-code=0

format_filter = -name '*.go' -type f \
-not -path '*.git*' \
Expand Down
1 change: 1 addition & 0 deletions ante/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type BankKeeper interface {
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
}

type DidKeeper interface {
Expand Down
24 changes: 13 additions & 11 deletions ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package ante
import (
"fmt"

"github.com/cosmos/cosmos-sdk/types/errors"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
Expand Down Expand Up @@ -38,11 +40,11 @@ func NewDeductFeeDecorator(ak ante.AccountKeeper, bk BankKeeper, fk ante.Feegran
func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return ctx, errorsmod.Wrap(errors.ErrTxDecode, "Tx must be a FeeTx")
}

if !simulate && ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidGasLimit, "must provide positive gas")
return ctx, errorsmod.Wrap(errors.ErrInvalidGasLimit, "must provide positive gas")
}

var (
Expand Down Expand Up @@ -82,7 +84,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error {
feeTx, ok := sdkTx.(sdk.FeeTx)
if !ok {
return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return errorsmod.Wrap(errors.ErrTxDecode, "Tx must be a FeeTx")
}

if addr := dfd.accountKeeper.GetModuleAddress(types.FeeCollectorName); addr == nil {
Expand All @@ -97,11 +99,11 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
// this works with only when feegrant enabled.
if feeGranter != nil {
if dfd.feegrantKeeper == nil {
return sdkerrors.ErrInvalidRequest.Wrap("fee grants are not enabled")
return errors.ErrInvalidRequest.Wrap("fee grants are not enabled")
} else if !feeGranter.Equals(feePayer) {
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, sdkTx.GetMsgs())
if err != nil {
return sdkerrors.Wrapf(err, "%s does not not allow to pay fees for %s", feeGranter, feePayer)
return errorsmod.Wrapf(err, "%s does not not allow to pay fees for %s", feeGranter, feePayer)
}
}

Expand All @@ -110,7 +112,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee

deductFeesFromAcc := dfd.accountKeeper.GetAccount(ctx, deductFeesFrom)
if deductFeesFromAcc == nil {
return sdkerrors.ErrUnknownAddress.Wrapf("fee payer address: %s does not exist", deductFeesFrom)
return errors.ErrUnknownAddress.Wrapf("fee payer address: %s does not exist", deductFeesFrom)
}

// deduct the fees
Expand All @@ -136,12 +138,12 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
// DeductFees deducts fees from the given account.
func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error {
if !fees.IsValid() {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
return errorsmod.Wrapf(errors.ErrInsufficientFee, "invalid fee amount: %s", fees)
}

err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
return errorsmod.Wrapf(errors.ErrInsufficientFunds, err.Error())
}

return nil
Expand All @@ -150,7 +152,7 @@ func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI
func IsSufficientFee(ctx sdk.Context, tax, reward, burn, feeProvided sdk.Coins, gasRequested int64) (bool, int64, error) {
// check if the provided fee is enough for `did`, `resource` module specific Msg
if !feeProvided.IsAnyGTE(tax) {
return false, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeProvided, tax)
return false, 0, errorsmod.Wrapf(errors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeProvided, tax)
}

// check with the default validator min gas prices based on rewards distribution
Expand All @@ -169,7 +171,7 @@ func IsSufficientFee(ctx sdk.Context, tax, reward, burn, feeProvided sdk.Coins,

// check if the fee is sufficient
if !reward.IsAnyGTE(requiredFees) {
return false, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", reward, requiredFees)
return false, 0, errorsmod.Wrapf(errors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", reward, requiredFees)
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions ante/feedistrib.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand All @@ -22,7 +23,7 @@ func GetDistributionFee(ctx sdk.Context, fee sdk.Coins, burnFeePortion sdk.Coins
}

if ValidateDistributionFee(fee, distrFeeAlloc) != nil {
return distrFeeAlloc, sdkerrors.Wrap(sdkerrors.ErrLogic, "fee distribution is invalid")
return distrFeeAlloc, errorsmod.Wrap(sdkerrors.ErrLogic, "fee distribution is invalid")
}

return distrFeeAlloc, nil
Expand All @@ -40,11 +41,11 @@ func SumDistributionFee(distrFeeAlloc DistributionFeeAllocation) sdk.Coins {

func ValidateDistributionFee(fee sdk.Coins, distrFeeAlloc DistributionFeeAllocation) error {
if fee.IsZero() {
return sdkerrors.Wrap(sdkerrors.ErrInsufficientFee, "fee cannot be zero")
return errorsmod.Wrap(sdkerrors.ErrInsufficientFee, "fee cannot be zero")
}

if !fee.IsEqual(SumDistributionFee(distrFeeAlloc)) {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "fee distribution is invalid")
return errorsmod.Wrap(sdkerrors.ErrLogic, "fee distribution is invalid")
}

return nil
Expand Down
19 changes: 11 additions & 8 deletions ante/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"errors"
"fmt"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

cheqdapp "github.com/cheqd/cheqd-node/app"
"github.com/cheqd/cheqd-node/simapp"
didtypes "github.com/cheqd/cheqd-node/x/did/types"
resourcetypes "github.com/cheqd/cheqd-node/x/resource/types"

Expand All @@ -34,21 +33,24 @@ type TestAccount struct {
type AnteTestSuite struct {
suite.Suite

app *simapp.SimApp
app *cheqdapp.TestApp
anteHandler sdk.AnteHandler
ctx sdk.Context
clientCtx client.Context
txBuilder client.TxBuilder
}

// returns context and app with params set on account keeper
func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context, error) {
app, err := simapp.Setup(isCheckTx)
func createTestApp(isCheckTx bool) (*cheqdapp.TestApp, sdk.Context, error) {
app, err := cheqdapp.Setup(isCheckTx)
if err != nil {
return nil, sdk.Context{}, err
}
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
err = app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
if err != nil {
return nil, sdk.Context{}, err
}

// cheqd specific params
didFeeParams := didtypes.DefaultGenesis().FeeParams
Expand Down Expand Up @@ -76,15 +78,16 @@ func (s *AnteTestSuite) SetupTest(isCheckTx bool) error {
s.clientCtx = client.Context{}.
WithTxConfig(encodingConfig.TxConfig)

anteHandler, err := simapp.NewAnteHandler(
simapp.HandlerOptions{
anteHandler, err := cheqdapp.NewAnteHandler(
cheqdapp.HandlerOptions{
AccountKeeper: s.app.AccountKeeper,
BankKeeper: s.app.BankKeeper,
FeegrantKeeper: s.app.FeeGrantKeeper,
DidKeeper: s.app.DidKeeper,
ResourceKeeper: s.app.ResourceKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: sdkante.DefaultSigVerificationGasConsumer,
IBCKeeper: s.app.IBCKeeper,
},
)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions ante/validator_tx_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ante
import (
"math"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand All @@ -12,7 +13,7 @@ import (
func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return nil, 0, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}

feeCoins := feeTx.GetFee()
Expand All @@ -35,7 +36,7 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins,
}

if !feeCoins.IsAnyGTE(requiredFees) {
return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions api/cheqd/did/v2/fee.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading