Skip to content

Commit

Permalink
wip: add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Nov 13, 2024
1 parent a77e61d commit 0b089cd
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 88 deletions.
67 changes: 1 addition & 66 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/genesis.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
}
8 changes: 7 additions & 1 deletion cmd/kava/cmd/assert-invariants.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 7 additions & 1 deletion cmd/kava/cmd/query.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -21,6 +23,7 @@ func newQueryCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

// TODO(boodyvo): Add query commands
cmd.AddCommand(
//authcmd.GetAccountCmd(),
rpc.ValidatorCommand(),
Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions cmd/kava/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,27 @@ 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{}))
}

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(),
)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e-ibc/chainconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions x/precisebank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand All @@ -168,15 +166,13 @@ 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,
from, // sender borrowing
types.ModuleName,
sdk.NewCoins(borrowCoin),
)
fmt.Println("err", err)
if err != nil {
return k.updateInsufficientFundsError(ctx, from, amt, err)
}
Expand Down

0 comments on commit 0b089cd

Please sign in to comment.