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

[SPIKE: Will not be merged] Kava cosmos v50 test patched #2036

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions app/_sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

"github.com/stretchr/testify/require"

dbm "github.com/cometbft/cometbft-db"
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
dbm "github.com/cosmos/cosmos-db"

"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down
10 changes: 5 additions & 5 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"runtime/debug"

errorsmod "cosmossdk.io/errors"
tmlog "github.com/cometbft/cometbft/libs/log"
tmlog "cosmossdk.io/log"
txsigning "cosmossdk.io/x/tx/signing"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
evmante "github.com/evmos/ethermint/app/ante"
evmtypes "github.com/evmos/ethermint/x/evm/types"
)
Expand All @@ -25,7 +25,7 @@ type HandlerOptions struct {
IBCKeeper *ibckeeper.Keeper
EvmKeeper evmante.EVMKeeper
FeegrantKeeper authante.FeegrantKeeper
SignModeHandler authsigning.SignModeHandler
SignModeHandler *txsigning.HandlerMap
SigGasConsumer authante.SignatureVerificationGasConsumer
FeeMarketKeeper evmtypes.FeeMarketKeeper
MaxTxGasWanted uint64
Expand Down
44 changes: 28 additions & 16 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"testing"
"time"

"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
tmdb "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmdb "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down Expand Up @@ -129,12 +129,13 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
txBytes, err := encodingConfig.TxConfig.TxEncoder()(stdTx)
require.NoError(t, err)

res := tApp.CheckTx(
abci.RequestCheckTx{
res, err := tApp.CheckTx(
&abci.RequestCheckTx{
Tx: txBytes,
Type: abci.CheckTxType_New,
},
)
require.NoError(t, err)

if tc.expectPass {
require.Zero(t, res.Code, res.Log)
Expand Down Expand Up @@ -166,13 +167,13 @@ func newBep3GenStateMulti(cdc codec.JSONCodec, deputyAddress sdk.AccAddress) app
SupplyLimit: bep3types.SupplyLimit{
Limit: sdkmath.NewInt(350000000000000),
TimeLimited: false,
TimeBasedLimit: sdk.ZeroInt(),
TimeBasedLimit: sdkmath.ZeroInt(),
TimePeriod: time.Hour,
},
Active: true,
DeputyAddress: deputyAddress,
FixedFee: sdkmath.NewInt(1000),
MinSwapAmount: sdk.OneInt(),
MinSwapAmount: sdkmath.OneInt(),
MaxSwapAmount: sdkmath.NewInt(1000000000000),
MinBlockLock: bep3types.DefaultMinBlockLock,
MaxBlockLock: bep3types.DefaultMaxBlockLock,
Expand All @@ -181,10 +182,10 @@ func newBep3GenStateMulti(cdc codec.JSONCodec, deputyAddress sdk.AccAddress) app
},
Supplies: bep3types.AssetSupplies{
bep3types.NewAssetSupply(
sdk.NewCoin("bnb", sdk.ZeroInt()),
sdk.NewCoin("bnb", sdk.ZeroInt()),
sdk.NewCoin("bnb", sdk.ZeroInt()),
sdk.NewCoin("bnb", sdk.ZeroInt()),
sdk.NewCoin("bnb", sdkmath.ZeroInt()),
sdk.NewCoin("bnb", sdkmath.ZeroInt()),
sdk.NewCoin("bnb", sdkmath.ZeroInt()),
sdk.NewCoin("bnb", sdkmath.ZeroInt()),
time.Duration(0),
),
},
Expand Down Expand Up @@ -255,20 +256,31 @@ func TestAppAnteHandler_RejectMsgsInAuthz(t *testing.T) {
txBytes, err := encodingConfig.TxConfig.TxEncoder()(stdTx)
require.NoError(t, err)

resCheckTx := tApp.CheckTx(
abci.RequestCheckTx{
resCheckTx, err := tApp.CheckTx(
&abci.RequestCheckTx{
Tx: txBytes,
Type: abci.CheckTxType_New,
},
)
require.NoError(t, err)
require.Equal(t, resCheckTx.Code, tc.expectedCode, resCheckTx.Log)

resDeliverTx := tApp.DeliverTx(
abci.RequestDeliverTx{
Tx: txBytes,
//resDeliverTx := tApp.DeliverTx(
// abci.RequestDeliverTx{
// Tx: txBytes,
// },
//)
// TODO(boodyvo): validate if this is the correct way to test deliver tx
resDeliverTx, err := tApp.FinalizeBlock(
&abci.RequestFinalizeBlock{
Txs: [][]byte{txBytes},
},
)
require.Equal(t, resDeliverTx.Code, tc.expectedCode, resDeliverTx.Log)
require.NoError(t, err)
for _, tx := range resDeliverTx.TxResults {
require.Equal(t, tx.Code, tc.expectedCode, tx.Log)
}
//require.Equal(t, resDeliverTx.Code, tc.expectedCode, resDeliverTx.Log)
})
}
}
22 changes: 16 additions & 6 deletions app/ante/authorized.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
"bytes"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -31,29 +32,38 @@ func (amd AuthenticatedMempoolDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx,
if !ok {
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "tx must be sig verifiable tx")
}
if !commonAddressesExist(sigTx.GetSigners(), amd.fetchAuthorizedAddresses(ctx)) {
signers, err := sigTx.GetSigners()
if err != nil {
return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "tx contains no signers")
}
if !commonAddressesExist(signers, amd.fetchAuthorizedAddresses(ctx)) {
return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "tx contains no signers authorized for this mempool")
}
}
return next(ctx, tx, simulate)
}

func (amd AuthenticatedMempoolDecorator) fetchAuthorizedAddresses(ctx sdk.Context) []sdk.AccAddress {
addrs := []sdk.AccAddress{}
func (amd AuthenticatedMempoolDecorator) fetchAuthorizedAddresses(ctx sdk.Context) [][]byte {
addrs := make([][]byte, 0)
for _, fetch := range amd.addressFetchers {
addrs = append(addrs, fetch(ctx)...)
addresses := fetch(ctx)
for _, addr := range addresses {
addrs = append(addrs, addr.Bytes())
}
}

return addrs
}

// commonAddressesExist checks if there is any intersection between two lists of addresses
func commonAddressesExist(addresses1, addresses2 []sdk.AccAddress) bool {
func commonAddressesExist(addresses1, addresses2 [][]byte) bool {
for _, a1 := range addresses1 {
for _, a2 := range addresses2 {
if a1.Equals(a2) {
if bytes.Equal(a1, a2) {
return true
}
}
}

return false
}
Loading
Loading