Skip to content

Commit

Permalink
nit: remove needless logger definitions (#6262)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
srdtrk and crodriguezvega authored May 8, 2024
1 parent 478f4c6 commit edd41da
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,23 @@ func NewMigrator(k *Keeper) Migrator {
// are owned by the controller submodule and ibc.
func (m Migrator) AssertChannelCapabilityMigrations(ctx sdk.Context) error {
if m.keeper != nil {
logger := m.keeper.Logger(ctx)
filteredChannels := m.keeper.channelKeeper.GetAllChannelsWithPortPrefix(ctx, icatypes.ControllerPortPrefix)
for _, ch := range filteredChannels {
name := host.ChannelCapabilityPath(ch.PortId, ch.ChannelId)
capability, found := m.keeper.scopedKeeper.GetCapability(ctx, name)
if !found {
logger.Error(fmt.Sprintf("failed to find capability: %s", name))
m.keeper.Logger(ctx).Error(fmt.Sprintf("failed to find capability: %s", name))
return errorsmod.Wrapf(capabilitytypes.ErrCapabilityNotFound, "failed to find capability: %s", name)
}

isAuthenticated := m.keeper.scopedKeeper.AuthenticateCapability(ctx, capability, name)
if !isAuthenticated {
logger.Error(fmt.Sprintf("expected capability owner: %s", controllertypes.SubModuleName))
m.keeper.Logger(ctx).Error(fmt.Sprintf("expected capability owner: %s", controllertypes.SubModuleName))
return errorsmod.Wrapf(capabilitytypes.ErrCapabilityNotOwned, "expected capability owner: %s", controllertypes.SubModuleName)
}

m.keeper.SetMiddlewareEnabled(ctx, ch.PortId, ch.ConnectionHops[0])
logger.Info("successfully migrated channel capability", "name", name)
m.keeper.Logger(ctx).Info("successfully migrated channel capability", "name", name)
}
}
return nil
Expand Down
7 changes: 3 additions & 4 deletions modules/apps/27-interchain-accounts/host/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ func (im IBCModule) OnRecvPacket(
packet channeltypes.Packet,
_ sdk.AccAddress,
) ibcexported.Acknowledgement {
logger := im.keeper.Logger(ctx)
if !im.keeper.GetParams(ctx).HostEnabled {
logger.Info("host submodule is disabled")
im.keeper.Logger(ctx).Info("host submodule is disabled")
keeper.EmitHostDisabledEvent(ctx, packet)
return channeltypes.NewErrorAcknowledgement(types.ErrHostSubModuleDisabled)
}
Expand All @@ -127,9 +126,9 @@ func (im IBCModule) OnRecvPacket(
ack := channeltypes.NewResultAcknowledgement(txResponse)
if err != nil {
ack = channeltypes.NewErrorAcknowledgement(err)
logger.Error(fmt.Sprintf("%s sequence %d", err.Error(), packet.Sequence))
im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", err.Error(), packet.Sequence))
} else {
logger.Info("successfully handled packet", "sequence", packet.Sequence)
im.keeper.Logger(ctx).Info("successfully handled packet", "sequence", packet.Sequence)
}

// Emit an event indicating a successful or failed acknowledgement.
Expand Down
3 changes: 1 addition & 2 deletions modules/apps/27-interchain-accounts/host/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func (k Keeper) OnChanOpenTry(
counterparty channeltypes.Counterparty,
counterpartyVersion string,
) (string, error) {
logger := k.Logger(ctx)
if portID != icatypes.HostPortID {
return "", errorsmod.Wrapf(icatypes.ErrInvalidHostPort, "expected %s, got %s", icatypes.HostPortID, portID)
}
Expand All @@ -43,7 +42,7 @@ func (k Keeper) OnChanOpenTry(
return "", errorsmod.Wrapf(err, "failed to retrieve connection %s", connectionHops[0])
}

logger.Debug("counterparty version is invalid, proposing default metadata")
k.Logger(ctx).Debug("counterparty version is invalid, proposing default metadata")
metadata = icatypes.NewDefaultMetadata(connection.Counterparty.ConnectionId, connectionHops[0])
}

Expand Down
7 changes: 3 additions & 4 deletions modules/apps/transfer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@ func (im IBCModule) OnRecvPacket(
packet channeltypes.Packet,
relayer sdk.AccAddress,
) ibcexported.Acknowledgement {
logger := im.keeper.Logger(ctx)
ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)})

var data types.FungibleTokenPacketData
var ackErr error
if err := json.Unmarshal(packet.GetData(), &data); err != nil {
ackErr = errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot unmarshal ICS-20 transfer packet data")
logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
ack = channeltypes.NewErrorAcknowledgement(ackErr)
}

Expand All @@ -198,9 +197,9 @@ func (im IBCModule) OnRecvPacket(
if err != nil {
ack = channeltypes.NewErrorAcknowledgement(err)
ackErr = err
logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
} else {
logger.Info("successfully handled ICS-20 packet", "sequence", packet.Sequence)
im.keeper.Logger(ctx).Info("successfully handled ICS-20 packet", "sequence", packet.Sequence)
}
}

Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/07-tendermint/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func PruneExpiredConsensusStates(ctx sdk.Context, cdc codec.BinaryCodec, clientK
totalPruned += ibctm.PruneAllExpiredConsensusStates(ctx, clientStore, cdc, tmClientState)
}

clientLogger := clientKeeper.Logger(ctx)
clientLogger.Info("pruned expired tendermint consensus states", "total", totalPruned)
clientKeeper.Logger(ctx).Info("pruned expired tendermint consensus states", "total", totalPruned)

return totalPruned, nil
}

0 comments on commit edd41da

Please sign in to comment.