From 24e03bcbb3143e00043246b0b6280ca025b0c157 Mon Sep 17 00:00:00 2001 From: Vladyslav Budichenko Date: Tue, 12 Nov 2024 21:59:13 -0500 Subject: [PATCH] wip: add logging --- app/app.go | 85 ++++++++++++++++++++++++++++++++++++++++--- cmd/kava/cmd/query.go | 8 ++-- cmd/kava/cmd/root.go | 10 ++--- go.mod | 2 +- go.sum | 4 +- 5 files changed, 91 insertions(+), 18 deletions(-) diff --git a/app/app.go b/app/app.go index ebe7d43aa..9b22ccf91 100644 --- a/app/app.go +++ b/app/app.go @@ -98,10 +98,12 @@ 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" @@ -128,12 +130,15 @@ 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" @@ -149,6 +154,7 @@ 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" @@ -189,6 +195,65 @@ 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. @@ -861,11 +926,21 @@ func NewApp( app.mm, map[string]module.AppModuleBasic{ genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - govtypes.ModuleName: gov.NewAppModuleBasic( - []govclient.ProposalHandler{ - paramsclient.ProposalHandler, - }, - ), + govtypes.ModuleName: 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, + }), ibctm.ModuleName: ibctm.NewAppModule(), }) app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) diff --git a/cmd/kava/cmd/query.go b/cmd/kava/cmd/query.go index 3b5d6ec9d..4d6e9ec74 100644 --- a/cmd/kava/cmd/query.go +++ b/cmd/kava/cmd/query.go @@ -1,8 +1,6 @@ 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" @@ -32,10 +30,10 @@ func newQueryCmd() *cobra.Command { authcmd.QueryTxCmd(), ) - encodingConfig := app.MakeEncodingConfig() - tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) + //encodingConfig := app.MakeEncodingConfig() + //tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) - tempApp.BasicModuleManager.AddQueryCommands(cmd) + app.ModuleBasics.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 b23c1b244..e790404ca 100644 --- a/cmd/kava/cmd/root.go +++ b/cmd/kava/cmd/root.go @@ -109,9 +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) { - tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) + //tempApp := app.NewApp(log.NewNopLogger(), dbm.NewMemDB(), app.DefaultNodeHome, nil, encodingConfig, app.DefaultOptions) - gentxModule, ok := tempApp.BasicModuleManager[genutiltypes.ModuleName].(genutil.AppModuleBasic) + gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) if !ok { panic(fmt.Errorf("expected %s module to be an instance of type %T", genutiltypes.ModuleName, genutil.AppModuleBasic{})) } @@ -119,12 +119,12 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de rootCmd.AddCommand( StatusCommand(), ethermintclient.ValidateChainID( - genutilcli.InitCmd(tempApp.BasicModuleManager, defaultNodeHome), + genutilcli.InitCmd(app.ModuleBasics, defaultNodeHome), ), genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome, gentxModule.GenTxValidator, encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), AssertInvariantsCmd(encodingConfig), - genutilcli.GenTxCmd(tempApp.BasicModuleManager, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome, encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), - genutilcli.ValidateGenesisCmd(tempApp.BasicModuleManager), + genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome, encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec()), + genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(defaultNodeHome), tmcli.NewCompletionCmd(rootCmd, true), // TODO add other shells, drop tmcli dependency, unhide? // testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), // TODO add diff --git a/go.mod b/go.mod index 8674e1dc3..1e29c8374 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-20241112215550-dfd34308fe09 + github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.0.0-20241113023842-ac2790809d16 //github.com/cosmos/cosmos-sdk => ../cosmos-sdk //github.com/cosmos/cosmos-sdk/store => cosmossdk.io/store v1.1.1 diff --git a/go.sum b/go.sum index e855ab2f0..bb5df0723 100644 --- a/go.sum +++ b/go.sum @@ -832,8 +832,8 @@ 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-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/cosmos-sdk v0.0.0-20241113023842-ac2790809d16 h1:v/1pHMyrNV7zPPz50Zof7YkB0SRamC4PDFNzqyW93BE= +github.com/kava-labs/cosmos-sdk v0.0.0-20241113023842-ac2790809d16/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=