From 0b089cd0f4ea82f601c0c4e4d11c6202bb7545d5 Mon Sep 17 00:00:00 2001 From: Vladyslav Budichenko Date: Tue, 12 Nov 2024 20:02:56 -0500 Subject: [PATCH] wip: add logging --- app/app.go | 67 +------------------------------ app/genesis.go | 6 ++- cmd/kava/cmd/assert-invariants.go | 8 +++- cmd/kava/cmd/query.go | 8 +++- cmd/kava/cmd/root.go | 12 +++--- go.mod | 4 +- go.sum | 8 ++-- tests/e2e-ibc/chainconfig.go | 8 ++-- x/precisebank/keeper/send.go | 4 -- 9 files changed, 37 insertions(+), 88 deletions(-) diff --git a/app/app.go b/app/app.go index fff65dc0f0..ebe7d43aac 100644 --- a/app/app.go +++ b/app/app.go @@ -98,12 +98,10 @@ import ( ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v8/modules/core/02-client/client/cli" ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/ethereum/go-ethereum/core/vm" evmante "github.com/evmos/ethermint/app/ante" @@ -130,15 +128,12 @@ import ( cdpkeeper "github.com/kava-labs/kava/x/cdp/keeper" cdptypes "github.com/kava-labs/kava/x/cdp/types" "github.com/kava-labs/kava/x/committee" - committeeclient "github.com/kava-labs/kava/x/committee/client" committeekeeper "github.com/kava-labs/kava/x/committee/keeper" committeetypes "github.com/kava-labs/kava/x/committee/types" "github.com/kava-labs/kava/x/community" - communityclient "github.com/kava-labs/kava/x/community/client" communitykeeper "github.com/kava-labs/kava/x/community/keeper" communitytypes "github.com/kava-labs/kava/x/community/types" earn "github.com/kava-labs/kava/x/earn" - earnclient "github.com/kava-labs/kava/x/earn/client" earnkeeper "github.com/kava-labs/kava/x/earn/keeper" earntypes "github.com/kava-labs/kava/x/earn/types" evmutil "github.com/kava-labs/kava/x/evmutil" @@ -154,7 +149,6 @@ import ( issuancekeeper "github.com/kava-labs/kava/x/issuance/keeper" issuancetypes "github.com/kava-labs/kava/x/issuance/types" "github.com/kava-labs/kava/x/kavadist" - kavadistclient "github.com/kava-labs/kava/x/kavadist/client" kavadistkeeper "github.com/kava-labs/kava/x/kavadist/keeper" kavadisttypes "github.com/kava-labs/kava/x/kavadist/types" "github.com/kava-labs/kava/x/liquid" @@ -195,65 +189,6 @@ var ( LegacyProposalHandler = govclient.NewProposalHandler(func() *cobra.Command { return upgradecli.NewCmdSubmitUpgradeProposal(ac) }) LegacyCancelProposalHandler = govclient.NewProposalHandler(func() *cobra.Command { return upgradecli.NewCmdSubmitCancelUpgradeProposal(ac) }) - ModuleBasics = module.NewBasicManager( - genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - auth.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic([]govclient.ProposalHandler{ - paramsclient.ProposalHandler, - LegacyProposalHandler, - LegacyCancelProposalHandler, - //upgradeclient.LegacyProposalHandler, - //upgradeclient.LegacyCancelProposalHandler, - govclient.NewProposalHandler(ibcclientclient.NewTxCmd), - //ibcclientclient, - kavadistclient.ProposalHandler, - committeeclient.ProposalHandler, - earnclient.DepositProposalHandler, - earnclient.WithdrawProposalHandler, - communityclient.LendDepositProposalHandler, - communityclient.LendWithdrawProposalHandler, - }), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - ibc.AppModuleBasic{}, - ibctm.AppModuleBasic{}, - solomachine.AppModuleBasic{}, - packetforward.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - transfer.AppModuleBasic{}, - vesting.AppModuleBasic{}, - evm.AppModuleBasic{}, - feemarket.AppModuleBasic{}, - kavadist.AppModuleBasic{}, - auction.AppModuleBasic{}, - issuance.AppModuleBasic{}, - bep3.AppModuleBasic{}, - pricefeed.AppModuleBasic{}, - swap.AppModuleBasic{}, - cdp.AppModuleBasic{}, - hard.AppModuleBasic{}, - committee.AppModuleBasic{}, - incentive.AppModuleBasic{}, - savings.AppModuleBasic{}, - validatorvesting.AppModuleBasic{}, - evmutil.AppModuleBasic{}, - liquid.AppModuleBasic{}, - earn.AppModuleBasic{}, - router.AppModuleBasic{}, - mint.AppModuleBasic{}, - community.AppModuleBasic{}, - metrics.AppModuleBasic{}, - consensus.AppModuleBasic{}, - precisebank.AppModuleBasic{}, - ) - // module account permissions // If these are changed, the permissions stored in accounts // must also be migrated during a chain upgrade. @@ -1238,7 +1173,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig // Register GRPC Gateway routes tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Swagger API configuration is ignored diff --git a/app/genesis.go b/app/genesis.go index 87596284ef..e8aa9305e4 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -1,7 +1,9 @@ package app import ( + "cosmossdk.io/log" "encoding/json" + dbm "github.com/cosmos/cosmos-db" ) // GenesisState represents the genesis state of the blockchain. It is a map from module names to module genesis states. @@ -10,5 +12,7 @@ type GenesisState map[string]json.RawMessage // NewDefaultGenesisState generates the default state for the application. func NewDefaultGenesisState() GenesisState { encCfg := MakeEncodingConfig() - return ModuleBasics.DefaultGenesis(encCfg.Marshaler) + tempApp := NewApp(log.NewNopLogger(), dbm.NewMemDB(), DefaultNodeHome, nil, encCfg, DefaultOptions) + + return tempApp.BasicModuleManager.DefaultGenesis(encCfg.Marshaler) } diff --git a/cmd/kava/cmd/assert-invariants.go b/cmd/kava/cmd/assert-invariants.go index de4ef717cb..ad9d1878e5 100644 --- a/cmd/kava/cmd/assert-invariants.go +++ b/cmd/kava/cmd/assert-invariants.go @@ -1,8 +1,10 @@ package cmd import ( + "cosmossdk.io/log" "encoding/json" "fmt" + dbm "github.com/cosmos/cosmos-db" tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/version" @@ -32,7 +34,11 @@ func AssertInvariantsCmd(config params.EncodingConfig) *cobra.Command { if err := json.Unmarshal(genDoc.AppState, &newAppState); err != nil { return fmt.Errorf("failed to marshal app state from genesis doc: %s: %w", importGenesis, err) } - err = app.ModuleBasics.ValidateGenesis(config.Marshaler, config.TxConfig, newAppState) + + encodingConfig := app.MakeEncodingConfig() + tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) + + err = tempApp.BasicModuleManager.ValidateGenesis(config.Marshaler, config.TxConfig, newAppState) if err != nil { return fmt.Errorf("genesis doc did not pass validate genesis: %s: %w", importGenesis, err) } diff --git a/cmd/kava/cmd/query.go b/cmd/kava/cmd/query.go index 7884ceee15..3b5d6ec9d7 100644 --- a/cmd/kava/cmd/query.go +++ b/cmd/kava/cmd/query.go @@ -1,6 +1,8 @@ package cmd import ( + "cosmossdk.io/log" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/rpc" @@ -21,6 +23,7 @@ func newQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } + // TODO(boodyvo): Add query commands cmd.AddCommand( //authcmd.GetAccountCmd(), rpc.ValidatorCommand(), @@ -29,7 +32,10 @@ func newQueryCmd() *cobra.Command { authcmd.QueryTxCmd(), ) - app.ModuleBasics.AddQueryCommands(cmd) + encodingConfig := app.MakeEncodingConfig() + tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) + + tempApp.BasicModuleManager.AddQueryCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd diff --git a/cmd/kava/cmd/root.go b/cmd/kava/cmd/root.go index 63b108418f..b23c1b2446 100644 --- a/cmd/kava/cmd/root.go +++ b/cmd/kava/cmd/root.go @@ -109,7 +109,9 @@ func dbOpener(opts servertypes.AppOptions, rootDir string, backend dbm.BackendTy // addSubCmds registers all the sub commands used by kava. func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, defaultNodeHome string) { - gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) + tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) + + gentxModule, ok := tempApp.BasicModuleManager[genutiltypes.ModuleName].(genutil.AppModuleBasic) if !ok { panic(fmt.Errorf("expected %s module to be an instance of type %T", genutiltypes.ModuleName, genutil.AppModuleBasic{})) } @@ -117,17 +119,17 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de rootCmd.AddCommand( StatusCommand(), ethermintclient.ValidateChainID( - genutilcli.InitCmd(app.ModuleBasics, defaultNodeHome), + genutilcli.InitCmd(tempApp.BasicModuleManager, defaultNodeHome), ), genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome, gentxModule.GenTxValidator, encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), AssertInvariantsCmd(encodingConfig), - genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome, encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), - genutilcli.ValidateGenesisCmd(app.ModuleBasics), + genutilcli.GenTxCmd(tempApp.BasicModuleManager, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome, encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), + genutilcli.ValidateGenesisCmd(tempApp.BasicModuleManager), AddGenesisAccountCmd(defaultNodeHome), tmcli.NewCompletionCmd(rootCmd, true), // TODO add other shells, drop tmcli dependency, unhide? // testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), // TODO add debug.Cmd(), - // TODO(boodyvo): was removed + // TODO(boodyvo): was removed, should be added convix //config.Cmd(), ) diff --git a/go.mod b/go.mod index 0744c62fb5..8674e1dc3b 100644 --- a/go.mod +++ b/go.mod @@ -261,7 +261,7 @@ replace ( // Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support //github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.47.10-iavl-v1-kava.1 //github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.50.10-test-patch 5f9239e3147358ef034bfc4d19aacb34e5ea2064 - github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.0.0-20241112165205-09a815df9157 + github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.0.0-20241112215550-dfd34308fe09 //github.com/cosmos/cosmos-sdk => ../cosmos-sdk //github.com/cosmos/cosmos-sdk/store => cosmossdk.io/store v1.1.1 @@ -281,7 +281,7 @@ replace ( // Tracking kava-labs/etheremint master branch // TODO: Tag before release //github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.21.1-0.20240802224012-586960857184 - github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.0.0-20241107232649-d8ee91e8450e + github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.0.0-20241112214305-986ef503477d //github.com/evmos/ethermint => ../ethermint // See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0 diff --git a/go.sum b/go.sum index fa5f8fa6e0..e855ab2f06 100644 --- a/go.sum +++ b/go.sum @@ -832,10 +832,10 @@ github.com/kava-labs/cometbft v0.0.0-20241024200036-527d8df9ff12 h1:RqnpnEGEuykj github.com/kava-labs/cometbft v0.0.0-20241024200036-527d8df9ff12/go.mod h1:5awmm7t/X8LJ+Wd7/TXHcv4hLfFLcexy6fdS9WvOepA= github.com/kava-labs/cometbft-db v0.0.0-20241007145430-b2740b2e4bed h1:3FNJ3fcD9aA9oOwDphrSEJ8u2kBNj9YoYAwl16UKyv4= github.com/kava-labs/cometbft-db v0.0.0-20241007145430-b2740b2e4bed/go.mod h1:buPRZKyVp+u5fmwN7tDtOk1zc5xA2z9BJJTy61tNnws= -github.com/kava-labs/cosmos-sdk v0.0.0-20241112165205-09a815df9157 h1:BA9IEg9oEGkGXmc+rG8rwvxb9ZlzCvb9H6dE2NzHrZU= -github.com/kava-labs/cosmos-sdk v0.0.0-20241112165205-09a815df9157/go.mod h1:Yf8jj8R5+9NWCbdot0IMId92WeAIF22Thc/pRR2hSoI= -github.com/kava-labs/ethermint v0.0.0-20241107232649-d8ee91e8450e h1:79mJSoWItAG2gPLOzVfdRJnMWy3vwAPdnahjh3jmUno= -github.com/kava-labs/ethermint v0.0.0-20241107232649-d8ee91e8450e/go.mod h1:Vulovod3ZhLTCfs9RkILIDK8WSDyYhnEp665kTRv530= +github.com/kava-labs/cosmos-sdk v0.0.0-20241112215550-dfd34308fe09 h1:x5NASpmOdjmPRP9POPz3qbxRxrGpPkplquMDXGG0wJY= +github.com/kava-labs/cosmos-sdk v0.0.0-20241112215550-dfd34308fe09/go.mod h1:Yf8jj8R5+9NWCbdot0IMId92WeAIF22Thc/pRR2hSoI= +github.com/kava-labs/ethermint v0.0.0-20241112214305-986ef503477d h1:AYN0gn9INsHew7bRtnwxmEsKCUjKiq+EPbuhe605/sA= +github.com/kava-labs/ethermint v0.0.0-20241112214305-986ef503477d/go.mod h1:Mr24kGiuG5TBUNS9d/velQrHofo3fdpz54aVL4bWeUM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= diff --git a/tests/e2e-ibc/chainconfig.go b/tests/e2e-ibc/chainconfig.go index fb93f99382..f5a734806c 100644 --- a/tests/e2e-ibc/chainconfig.go +++ b/tests/e2e-ibc/chainconfig.go @@ -18,8 +18,8 @@ const ( func DefaultKavaChainConfig(chainId string) ibc.ChainConfig { kavaImageTag := os.Getenv("KAVA_TAG") if kavaImageTag == "" { - kavaImageTag = "v0.26.0-rocksdb" - //kavaImageTag = "local" + //kavaImageTag = "v0.26.0-rocksdb" + kavaImageTag = "local" } // app.toml overrides @@ -34,8 +34,8 @@ func DefaultKavaChainConfig(chainId string) ibc.ChainConfig { genesis := []cosmos.GenesisKV{ // TODO(boodyvo): investigate why it is "consensus.params" as there is one test for ethermint in interchaintest, that works with "consensus_params" // Updatae: It was impacted by kava docker, not interchaintest - cosmos.NewGenesisKV("consensus_params.block.max_gas", "20000000"), - //cosmos.NewGenesisKV("consensus.params.block.max_gas", "20000000"), + //cosmos.NewGenesisKV("consensus_params.block.max_gas", "20000000"), + cosmos.NewGenesisKV("consensus.params.block.max_gas", "20000000"), cosmos.NewGenesisKV("app_state.evm.params.evm_denom", "akava"), // update for fast voting periods diff --git a/x/precisebank/keeper/send.go b/x/precisebank/keeper/send.go index c031aa1bc3..7450924a98 100644 --- a/x/precisebank/keeper/send.go +++ b/x/precisebank/keeper/send.go @@ -60,7 +60,6 @@ func (k Keeper) SendCoins( // Send the extended coin amount through x/precisebank if extendedCoinAmount.IsPositive() { - fmt.Println("send extended coins") if err := k.sendExtendedCoins(sdkCtx, from, to, extendedCoinAmount); err != nil { return err } @@ -157,7 +156,6 @@ func (k Keeper) sendExtendedCoins( // Full integer amount transfer, including direct transfer of borrow/carry // if any. if integerAmt.IsPositive() { - fmt.Println("inside IsPositive") transferCoin := sdk.NewCoin(types.IntegerCoinDenom, integerAmt) if err := k.bk.SendCoins(ctx, from, to, sdk.NewCoins(transferCoin)); err != nil { return k.updateInsufficientFundsError(ctx, from, amt, err) @@ -168,7 +166,6 @@ func (k Keeper) sendExtendedCoins( // Sender borrows by transferring 1 integer amount to reserve to account for // lack of fractional balance. if senderNeedsBorrow && !recipientNeedsCarry { - fmt.Println("inside senderNeedsBorrow") borrowCoin := sdk.NewCoin(types.IntegerCoinDenom, sdkmath.NewInt(1)) err := k.bk.SendCoinsFromAccountToModule( ctx, @@ -176,7 +173,6 @@ func (k Keeper) sendExtendedCoins( types.ModuleName, sdk.NewCoins(borrowCoin), ) - fmt.Println("err", err) if err != nil { return k.updateInsufficientFundsError(ctx, from, amt, err) }