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 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
0c57ec6
wip: upgrade kava to sdk v0.50
boodyvo Oct 11, 2024
9965571
wip: upgrade kava to sdk v0.50
boodyvo Oct 11, 2024
7bf3bd4
wip: upgrade kava to sdk v0.50
boodyvo Oct 16, 2024
4e68e11
wip: upgrade kava to sdk v0.50
boodyvo Oct 16, 2024
5edaaab
wip: upgrade kava to sdk v0.50
boodyvo Oct 17, 2024
c86dd84
wip: test updates
boodyvo Oct 17, 2024
2540d18
wip: test updates
boodyvo Oct 17, 2024
2f4ec0a
wip: testing cdp
boodyvo Oct 18, 2024
df58f4f
wip: testing cdp
boodyvo Oct 18, 2024
9dbd8bd
wip: testing cdp
boodyvo Oct 18, 2024
9d86411
wip: testing
boodyvo Oct 19, 2024
7e43f2f
wip: testing
boodyvo Oct 19, 2024
05c6e53
wip: fixed test context
boodyvo Oct 21, 2024
3f125e4
wip: add some logging
boodyvo Oct 21, 2024
d0841da
wip: fixing modules
boodyvo Oct 22, 2024
fd550b4
wip: fixing modules
boodyvo Oct 22, 2024
99e1317
wip: debugging incentive test
boodyvo Oct 22, 2024
90dc903
wip: debugging incentive test
boodyvo Oct 22, 2024
20fc8df
wip: fix few tests
boodyvo Oct 22, 2024
bb5b41c
wip: fix few tests
boodyvo Oct 22, 2024
69c0300
wip: fix few tests
boodyvo Oct 22, 2024
f283376
wip: fix few tests
boodyvo Oct 22, 2024
98a3fdb
wip: fix few tests
boodyvo Oct 23, 2024
fec0ea2
wip: fix few tests
boodyvo Oct 23, 2024
149ef99
wip: fix few tests
boodyvo Oct 23, 2024
fec9d4b
wip: add upgrade handler
boodyvo Oct 23, 2024
0b25819
wip: add upgrade handler
boodyvo Oct 23, 2024
d03eb38
wip: internal debug
boodyvo Oct 23, 2024
db3ab21
wip: internal debug
boodyvo Oct 23, 2024
0180a7e
wip: internal debug
boodyvo Oct 23, 2024
de2ca02
wip: internal debug
boodyvo Oct 23, 2024
2457513
wip: internal debug
boodyvo Oct 23, 2024
9373135
wip: internal debug
boodyvo Oct 23, 2024
4b42fcc
wip: internal debug
boodyvo Oct 23, 2024
df5d106
wip: internal debug
boodyvo Oct 23, 2024
58b02a6
wip: internal debug
boodyvo Oct 23, 2024
033042b
wip: internal debug
boodyvo Oct 23, 2024
e98d411
wip: internal debug
boodyvo Oct 24, 2024
9e498b4
wip: internal debug
boodyvo Oct 24, 2024
fe9174d
wip: internal debug
boodyvo Oct 24, 2024
881b298
wip: internal debug
boodyvo Oct 24, 2024
94e7769
wip: internal debug
boodyvo Oct 24, 2024
ea87135
wip: internal debug
boodyvo Oct 24, 2024
1b6a724
wip: internal debug
boodyvo Oct 24, 2024
d370d23
wip: comment parts trying to run app
boodyvo Oct 24, 2024
d217823
wip: change cmd processing
boodyvo Oct 24, 2024
2688ac0
kava-cosmos-v50-test-patched
boodyvo Oct 24, 2024
418c68d
kava-cosmos-v50-test-patched
boodyvo Oct 25, 2024
648b247
wip: updated the server and cmd to run in kava
boodyvo Oct 25, 2024
0d3d058
wip: updated mod
boodyvo Oct 25, 2024
141188b
wip: add debug print
boodyvo Oct 25, 2024
57b1607
wip: add debug print
boodyvo Oct 25, 2024
6a613bd
wip: update tests and initialization
boodyvo Oct 28, 2024
bd1e31f
wip: update tests and initialization
boodyvo Oct 28, 2024
7ee4ec3
wip: update tests and initialization
boodyvo Oct 28, 2024
08f411f
wip: update tests and initialization
boodyvo Oct 28, 2024
bba75ee
wip: update tests and initialization
boodyvo Oct 28, 2024
ce8ad6d
wip: remove extra logging
boodyvo Oct 28, 2024
efd0a53
wip: remove extra logging
boodyvo Oct 29, 2024
200097a
wip: add logging
boodyvo Oct 29, 2024
26017d4
wip: update signing
boodyvo Nov 1, 2024
f3401b1
wip: update e2e test for debugging
boodyvo Nov 4, 2024
1de642c
wip: update e2e test for debugging
boodyvo Nov 4, 2024
fbb35d9
wip: update e2e test for debugging
boodyvo Nov 4, 2024
c496494
wip: update e2e test for debugging
boodyvo Nov 5, 2024
78d7ba7
wip: update e2e test for debugging
boodyvo Nov 5, 2024
fedeac5
wip: add cdp signers
boodyvo Nov 5, 2024
540f4ae
wip: add debug for handler
boodyvo Nov 7, 2024
90af7a6
wip: removed one debug log
boodyvo Nov 7, 2024
7d2925a
wip: removed one debug log
boodyvo Nov 8, 2024
17f7b2e
wip: removed one debug log
boodyvo Nov 8, 2024
96919dd
wip: removed one debug log
boodyvo Nov 12, 2024
a77e61d
wip: removed one debug log
boodyvo Nov 12, 2024
0b089cd
wip: add logging
boodyvo Nov 13, 2024
24e03bc
wip: add logging
boodyvo Nov 13, 2024
74cdfbd
wip: add logging
boodyvo Nov 13, 2024
59a239a
wip: add logging
boodyvo Nov 13, 2024
5526bcf
wip: add logging
boodyvo Nov 13, 2024
a8be83e
wip: add logging
boodyvo Nov 13, 2024
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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM golang:1.21-alpine AS build-env
# bash, jq, curl for debugging
# git, make for installation
# libc-dev, gcc, linux-headers, eudev-dev are used for cgo and ledger installation
RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq curl
RUN apk add bash git make libc-dev gcc linux-headers eudev-dev jq curl binutils-gold

# Set working directory for the build
WORKDIR /root/kava
Expand Down
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