Skip to content

Commit

Permalink
deps: 02-client keeper to use core/log
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Sep 18, 2024
1 parent f6fb263 commit 1c62b24
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 21 deletions.
10 changes: 5 additions & 5 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (k *Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, c
}

initialHeight := clientModule.LatestHeight(ctx, clientID)
k.SDKLogger.Info("client created at height", "client-id", clientID, "height", initialHeight.String())
k.Logger(ctx).Info("client created at height", "client-id", clientID, "height", initialHeight.String())

defer telemetry.ReportCreateClient(clientType)
emitCreateClientEvent(ctx, k.Environment, clientID, clientType, initialHeight)
Expand All @@ -63,7 +63,7 @@ func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg export
if foundMisbehaviour {
clientModule.UpdateStateOnMisbehaviour(ctx, clientID, clientMsg)

k.SDKLogger.Info("client frozen due to misbehaviour", "client-id", clientID)
k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", clientID)

clientType := types.MustParseClientIdentifier(clientID)
defer telemetry.ReportUpdateClient(foundMisbehaviour, clientType, clientID)
Expand All @@ -74,7 +74,7 @@ func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg export

consensusHeights := clientModule.UpdateState(ctx, clientID, clientMsg)

k.SDKLogger.Info("client state updated", "client-id", clientID, "heights", consensusHeights)
k.Logger(ctx).Info("client state updated", "client-id", clientID, "heights", consensusHeights)

clientType := types.MustParseClientIdentifier(clientID)
defer telemetry.ReportUpdateClient(foundMisbehaviour, clientType, clientID)
Expand Down Expand Up @@ -104,7 +104,7 @@ func (k *Keeper) UpgradeClient(
}

latestHeight := clientModule.LatestHeight(ctx, clientID)
k.SDKLogger.Info("client state upgraded", "client-id", clientID, "height", latestHeight.String())
k.Logger(ctx).Info("client state upgraded", "client-id", clientID, "height", latestHeight.String())

clientType := types.MustParseClientIdentifier(clientID)
defer telemetry.ReportUpgradeClient(clientType, clientID)
Expand Down Expand Up @@ -142,7 +142,7 @@ func (k *Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClien
return err
}

k.SDKLogger.Info("client recovered", "client-id", subjectClientID)
k.Logger(ctx).Info("client recovered", "client-id", subjectClientID)

clientType := types.MustParseClientIdentifier(subjectClientID)
defer telemetry.ReportRecoverClient(clientType, subjectClientID)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (q *queryServer) VerifyMembership(c context.Context, req *types.QueryVerify
)

if err := clientModule.VerifyMembership(cachedCtx, req.ClientId, req.ProofHeight, req.TimeDelay, req.BlockDelay, req.Proof, req.MerklePath, req.Value); err != nil {
q.SDKLogger.Debug("proof verification failed", "key", req.MerklePath, "error", err)
q.Logger(ctx).Debug("proof verification failed", "key", req.MerklePath, "error", err)
return &types.QueryVerifyMembershipResponse{
Success: false,
}, nil
Expand Down
10 changes: 3 additions & 7 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"strings"

"cosmossdk.io/log"
"cosmossdk.io/core/log"

"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -34,8 +34,6 @@ type Keeper struct {
router *types.Router
legacySubspace types.ParamSubspace
upgradeKeeper types.UpgradeKeeper

SDKLogger log.Logger
}

// NewKeeper creates a new NewKeeper instance
Expand All @@ -51,7 +49,6 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, legacySubspace
legacySubspace: legacySubspace,
upgradeKeeper: uk,
}
k.SDKLogger = k.Logger(context.Background())
return k
}

Expand All @@ -61,9 +58,8 @@ func (k *Keeper) Codec() codec.BinaryCodec {
}

// Logger returns a module-specific logger.
func (Keeper) Logger(ctx context.Context) log.Logger {
sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917
return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName)
func (k Keeper) Logger(ctx context.Context) log.Logger {
return k.Environment.Logger
}

// AddRoute adds a new route to the underlying router.
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (m Migrator) MigrateParams(ctx sdk.Context) error {
}

m.keeper.SetParams(ctx, params)
m.keeper.SDKLogger.Info("successfully migrated client to self-manage params")
m.keeper.Logger(ctx).Info("successfully migrated client to self-manage params")
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package migrations
import (
"context"

"cosmossdk.io/log"
"cosmossdk.io/core/log"
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/ibc-go/v9/modules/core/exported"
Expand Down
9 changes: 3 additions & 6 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,7 @@ func NewSimApp(
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
// app.AccountsKeeper, // TODO:
nil,
app.AuthKeeper,
app.BankKeeper,
)

Expand All @@ -471,8 +470,7 @@ func NewSimApp(
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper,
// app.AccountsKeeper, // TODO:
nil,
app.AuthKeeper,
scopedICAHostKeeper, app.MsgServiceRouter(), app.GRPCQueryRouter(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
Expand All @@ -490,8 +488,7 @@ func NewSimApp(
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper,
// app.AccountsKeeper, // TODO:
nil,
app.AuthKeeper,
app.BankKeeper, scopedTransferKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
Expand Down

0 comments on commit 1c62b24

Please sign in to comment.