Skip to content

Commit

Permalink
chore: sdk v46 (#786)
Browse files Browse the repository at this point in the history
* sdk v46

* app.go work

* additional 46 conversion work.  mainly gov and math.

* hooks and schedule.go

* fixes for dev env

* generate protos

* fix test

* Revert "generate protos"

This reverts commit 344b7eb.

* change multiply calculate from Int * Int to Dec * Dec

* fix signers type to mapping

* fix logic test claim TestClaimOfDecayed

* tidy

* fixes (params_test.go)

* fix genaccounts.go

* fix testnet.go

* sdk.Int -> math.Int

* fix logic claim_test

* fix more tests

* remove gov SetHook

* fix imports

* fix integration test

* evmos v7 ibc-go v5

* import cosmossdk math

* add NextVals to TestChain

* lint

* linter passes: use nolint for deprecated gov prop techniques

* fix test x/vesting

* sdk.Int -> math.Int

* updated ethermint

* various fixes for tests

* fix valset is nil

* add validator to setup test

* revert validator

* format, regenerate protos

* fumpt

* fix invariant error in TestOnAcknowledgementPacketIBC

* remove redundant third_party

* fix error DeliverTx performEthTx integration_test

* add validator to Test Keeper erc20

* add mock

* fix test x/erc20 bonded pool balance is different from bonded coins

* newer ibc-go v5 module

* apply the valset patch

* fix test erc20 integration_test => Should init eth account in app.go

* protos...

* add tools

* bond denom

* replace all acoin with aevmos

* fix Case_no-op:_error_Ack

* fix bonded pool balances not equal bonded coin

* msgEth from =

* fix calculate fee

* fix vesting test

* remove debug log

* change TruncateInt to RoundInt

* fix golangci-lint

* fix test ibc callback recovery module

* revert denom aevmos to acoin

* add correct dependencies version

* change ibcante in handler_options.go

* Update Makefile

* add proto lint tool to gitpod image

* update genproto

* update golangci and Makefile

* proto tools

* update scripts and .gitpod.yml

* gitpod

* gitpod

* remove cosmos-proto

* minor go mod

* fix proto lint

* restore original protogen

* fix some bash, tidy

* fix some bash

* bash and ++ instead of += 1

* gofumpt

* fix hooks.go issue

* .golangci.yml

* minor fix in testutil network

* Update cmd/evmosd/cmd_test.go

Co-authored-by: Daniel Burckhardt <daniel.m.burckhardt@gmail.com>

* Update cmd/evmosd/main.go

Co-authored-by: Daniel Burckhardt <daniel.m.burckhardt@gmail.com>

* Update cmd/evmosd/root.go

Co-authored-by: Daniel Burckhardt <daniel.m.burckhardt@gmail.com>

* add implementation for ICS4 GetAppVarsion

* minor

* Update x/erc20/client/cli/tx.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update x/erc20/client/cli/tx.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update x/erc20/client/cli/tx.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* minor refactor

* update path to v10 and bump deps

* Update ibc/testing/README.md

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update evm_hooks.go

* GetParamSetIfExists

* Update handler_options.go

* Update root.go

* fix shellcheck feedback

* comment on GetAppVersion

* use ethermint's power reduction

* note need to update ethermint import in go.mod

* use cosmossdk.io/errors

* minor hygiene

* add NewExtensionOptionsDecorator

Co-authored-by: GNaD <cpt.meoz@gmail.com>
Co-authored-by: nghuyenthevinh2000 <nghuyenthevinh@gmail.com>
Co-authored-by: GNaD13 <89174180+GNaD13@users.noreply.github.com>
Co-authored-by: Daniel Burckhardt <daniel.m.burckhardt@gmail.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
6 people committed Sep 13, 2022
1 parent 732447b commit 54182b5
Show file tree
Hide file tree
Showing 276 changed files with 6,190 additions and 2,878 deletions.
4 changes: 3 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ image: ghcr.io/notional-labs/cosmos

tasks:
- name: install tools
command:
command: |
go install golang.org/x/tools/cmd/goimports@latest
go install mvdan.cc/gofumpt@latest
sudo pacman -Syyu clang --noconfirm
sudo make tools
sudo bash scripts/proto-tools-installer.sh
15 changes: 7 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ linters:
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- gofumpt
- revive
- gosec
- gosimple
Expand Down Expand Up @@ -76,9 +75,9 @@ linters-settings:
gomodguard:
blocked:
versions: # List of blocked module version constraints
- https://github.com/etcd-io/etcd: # Blocked module with version constraint
version: ">= 3.4.10 || ~3.3.23" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional)
- https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint
version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional)
- https://github.com/etcd-io/etcd: # Blocked module with version constraint
version: ">= 3.4.10 || ~3.3.23" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional)
- https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint
version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional)
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,15 @@ lint-fix-contracts:
.PHONY: lint lint-fix

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs misspell -w
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/evmos/evmos
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofumpt -w -l

.PHONY: format

###############################################################################
### Protobuf ###
###############################################################################

containerProtoVer=v0.2
containerProtoVer=v0.7
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
Expand All @@ -468,19 +467,18 @@ proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.15/proto/tendermint
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.20/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.45.1
ETHERMINT_URL = https://raw.githubusercontent.com/tharsis/ethermint/v0.10.0
IBC_GO_URL = https://raw.githubusercontent.com/cosmos/ibc-go/v3.0.0-rc0
COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.46.0
ETHERMINT_URL = https://raw.githubusercontent.com/evmos/ethermint/v0.6.1
IBC_GO_URL = https://raw.githubusercontent.com/cosmos/ibc-go/v5.0.0-beta1
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master

TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
TM_ABCI_TYPES = third_party/proto/tendermint/abci
TM_TYPES = third_party/proto/tendermint/types

GOGO_PROTO_TYPES = third_party/proto/gogoproto

COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto

proto-update-deps:
Expand Down
7 changes: 4 additions & 3 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ante

import (
sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"

ethante "github.com/evmos/ethermint/app/ante"
Expand Down Expand Up @@ -33,7 +34,7 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
anteHandler = newCosmosAnteHandlerEip712(options)
default:
return ctx, sdkerrors.Wrapf(
sdkerrors.ErrUnknownExtensionOptions,
errortypes.ErrUnknownExtensionOptions,
"rejecting tx with unsupported extension option: %s", typeURL,
)
}
Expand All @@ -47,7 +48,7 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
case sdk.Tx:
anteHandler = newCosmosAnteHandler(options)
default:
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid transaction type: %T", tx)
return ctx, sdkerrors.Wrapf(errortypes.ErrUnknownRequest, "invalid transaction type: %T", tx)
}

return anteHandler(ctx, tx, sim)
Expand Down
7 changes: 4 additions & 3 deletions app/ante/comission.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package ante
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkerrors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/x/authz"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down Expand Up @@ -70,13 +71,13 @@ func (vcd ValidatorCommissionDecorator) validateMsg(_ sdk.Context, msg sdk.Msg)
case *stakingtypes.MsgCreateValidator:
if msg.Commission.Rate.LT(minCommission) {
return sdkerrors.Wrapf(
sdkerrors.ErrInvalidRequest,
errortypes.ErrInvalidRequest,
"validator commission %s be lower than minimum of %s", msg.Commission.Rate, minCommission)
}
case *stakingtypes.MsgEditValidator:
if msg.CommissionRate != nil && msg.CommissionRate.LT(minCommission) {
return sdkerrors.Wrapf(
sdkerrors.ErrInvalidRequest,
errortypes.ErrInvalidRequest,
"validator commission %s be lower than minimum of %s", msg.CommissionRate, minCommission)
}
}
Expand Down
57 changes: 29 additions & 28 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
package ante

import (
sdkerrors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v5/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"

ethante "github.com/evmos/ethermint/app/ante"
evmtypes "github.com/evmos/ethermint/x/evm/types"

vestingtypes "github.com/evmos/evmos/v8/x/vesting/types"
vestingtypes "github.com/evmos/evmos/v9/x/vesting/types"
)

// HandlerOptions defines the list of module keepers required to run the Evmos
// AnteHandler decorators.
type HandlerOptions struct {
AccountKeeper evmtypes.AccountKeeper
BankKeeper evmtypes.BankKeeper
IBCKeeper *ibckeeper.Keeper
FeeMarketKeeper evmtypes.FeeMarketKeeper
StakingKeeper vestingtypes.StakingKeeper
EvmKeeper ethante.EVMKeeper
FeegrantKeeper ante.FeegrantKeeper
SignModeHandler authsigning.SignModeHandler
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
Cdc codec.BinaryCodec
MaxTxGasWanted uint64
AccountKeeper evmtypes.AccountKeeper
BankKeeper evmtypes.BankKeeper
ExtensionOptionChecker ante.ExtensionOptionChecker
IBCKeeper *ibckeeper.Keeper
FeeMarketKeeper evmtypes.FeeMarketKeeper
StakingKeeper vestingtypes.StakingKeeper
EvmKeeper ethante.EVMKeeper
FeegrantKeeper ante.FeegrantKeeper
SignModeHandler authsigning.SignModeHandler
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
Cdc codec.BinaryCodec
MaxTxGasWanted uint64
TxFeeChecker ante.TxFeeChecker
}

// Validate checks if the keepers are defined
func (options HandlerOptions) Validate() error {
if options.AccountKeeper == nil {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return sdkerrors.Wrap(errortypes.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return sdkerrors.Wrap(errortypes.ErrLogic, "bank keeper is required for AnteHandler")
}
if options.StakingKeeper == nil {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "staking keeper is required for AnteHandler")
return sdkerrors.Wrap(errortypes.ErrLogic, "staking keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return sdkerrors.Wrap(errortypes.ErrLogic, "sign mode handler is required for ante builder")
}
if options.FeeMarketKeeper == nil {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "fee market keeper is required for AnteHandler")
return sdkerrors.Wrap(errortypes.ErrLogic, "fee market keeper is required for AnteHandler")
}
if options.EvmKeeper == nil {
return sdkerrors.Wrap(sdkerrors.ErrLogic, "evm keeper is required for AnteHandler")
return sdkerrors.Wrap(errortypes.ErrLogic, "evm keeper is required for AnteHandler")
}
return nil
}
Expand Down Expand Up @@ -79,14 +82,13 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.RejectMessagesDecorator{}, // reject MsgEthereumTxs
ante.NewSetUpContextDecorator(),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewMempoolFeeDecorator(),
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
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),
NewVestingDelegationDecorator(options.AccountKeeper, options.StakingKeeper, options.Cdc),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
Expand All @@ -95,7 +97,7 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
)
}
Expand All @@ -105,13 +107,12 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.RejectMessagesDecorator{}, // reject MsgEthereumTxs
ante.NewSetUpContextDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
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),
NewVestingDelegationDecorator(options.AccountKeeper, options.StakingKeeper, options.Cdc),
NewValidatorCommissionDecorator(options.Cdc),
// SetPubKeyDecorator must be called before all signature verification decorators
Expand All @@ -121,7 +122,7 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
// Note: signature verification uses EIP instead of the cosmos signature validator
ethante.NewEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
)
}
9 changes: 5 additions & 4 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"cosmossdk.io/math"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand All @@ -18,8 +19,8 @@ import (
"github.com/evmos/ethermint/encoding"
evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
"github.com/evmos/evmos/v8/app"
claimstypes "github.com/evmos/evmos/v8/x/claims/types"
"github.com/evmos/evmos/v9/app"
claimstypes "github.com/evmos/evmos/v9/x/claims/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down Expand Up @@ -91,7 +92,7 @@ func (suite *AnteTestSuite) CommitAfter(t time.Duration) {
suite.app.EndBlock(abci.RequestEndBlock{Height: header.Height})
_ = suite.app.Commit()

header.Height += 1
header.Height++
header.Time = header.Time.Add(t)
suite.app.BeginBlock(abci.RequestBeginBlock{
Header: header,
Expand All @@ -101,7 +102,7 @@ func (suite *AnteTestSuite) CommitAfter(t time.Duration) {
suite.ctx = suite.app.BaseApp.NewContext(false, header)
}

func (s *AnteTestSuite) CreateTestTxBuilder(gasPrice sdk.Int, denom string, msgs ...sdk.Msg) client.TxBuilder {
func (s *AnteTestSuite) CreateTestTxBuilder(gasPrice math.Int, denom string, msgs ...sdk.Msg) client.TxBuilder {
encodingConfig := encoding.MakeConfig(app.ModuleBasics)
gasLimit := uint64(1000000)

Expand Down
11 changes: 6 additions & 5 deletions app/ante/vesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkerrors "cosmossdk.io/errors"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/authz"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
vestingtypes "github.com/evmos/evmos/v8/x/vesting/types"
vestingtypes "github.com/evmos/evmos/v9/x/vesting/types"
)

// EthVestingTransactionDecorator validates if clawback vesting accounts are
Expand Down Expand Up @@ -36,14 +37,14 @@ func (vtd EthVestingTransactionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx,
for _, msg := range tx.GetMsgs() {
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
if !ok {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest,
return ctx, sdkerrors.Wrapf(errortypes.ErrUnknownRequest,
"invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil),
)
}

acc := vtd.ak.GetAccount(ctx, msgEthTx.GetFrom())
if acc == nil {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress,
return ctx, sdkerrors.Wrapf(errortypes.ErrUnknownAddress,
"account %s does not exist", acc)
}

Expand Down Expand Up @@ -141,7 +142,7 @@ func (vdd VestingDelegationDecorator) validateMsg(ctx sdk.Context, msg sdk.Msg)
acc := vdd.ak.GetAccount(ctx, addr)
if acc == nil {
return sdkerrors.Wrapf(
sdkerrors.ErrUnknownAddress,
errortypes.ErrUnknownAddress,
"account %s does not exist", addr,
)
}
Expand Down

0 comments on commit 54182b5

Please sign in to comment.