Skip to content

Commit

Permalink
chore: transfer telemetry and events in eureka
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba committed Feb 5, 2025
1 parent 76d0407 commit 21fd761
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/apps/transfer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (im IBCModule) OnRecvPacket(

ack = channeltypes.NewResultAcknowledgement([]byte{byte(1)})

telemetry.ReportOnRecvPacket(packet, data.Tokens)
telemetry.ReportOnRecvPacket(packet.SourcePort, packet.SourceChannel, packet.DestinationPort, packet.DestinationChannel, data.Tokens)

im.keeper.Logger.Info("successfully handled ICS-20 packet", "sequence", packet.Sequence)

Expand Down
13 changes: 6 additions & 7 deletions modules/apps/transfer/internal/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/telemetry"

"github.com/cosmos/ibc-go/v9/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
coremetrics "github.com/cosmos/ibc-go/v9/modules/core/metrics"
)

Expand Down Expand Up @@ -40,18 +39,18 @@ func ReportTransfer(sourcePort, sourceChannel, destinationPort, destinationChann
)
}

func ReportOnRecvPacket(packet channeltypes.Packet, tokens types.Tokens) {
func ReportOnRecvPacket(sourcePort, sourceChannel, destinationPort, destinationChannel string, tokens types.Tokens) {
labels := []metrics.Label{
telemetry.NewLabel(coremetrics.LabelSourcePort, packet.SourcePort),
telemetry.NewLabel(coremetrics.LabelSourceChannel, packet.SourceChannel),
telemetry.NewLabel(coremetrics.LabelSourcePort, sourcePort),
telemetry.NewLabel(coremetrics.LabelSourceChannel, sourceChannel),
}

for _, token := range tokens {
// Modify trace as Recv does.
if token.Denom.HasPrefix(packet.SourcePort, packet.SourceChannel) {
if token.Denom.HasPrefix(sourcePort, sourceChannel) {
token.Denom.Trace = token.Denom.Trace[1:]
} else {
trace := []types.Hop{types.NewHop(packet.DestinationPort, packet.DestinationChannel)}
trace := []types.Hop{types.NewHop(destinationPort, destinationChannel)}
token.Denom.Trace = append(trace, token.Denom.Trace...)
}

Expand All @@ -65,7 +64,7 @@ func ReportOnRecvPacket(packet channeltypes.Packet, tokens types.Tokens) {
)
}

labels = append(labels, telemetry.NewLabel(coremetrics.LabelSource, fmt.Sprintf("%t", token.Denom.HasPrefix(packet.SourcePort, packet.SourceChannel))))
labels = append(labels, telemetry.NewLabel(coremetrics.LabelSource, fmt.Sprintf("%t", token.Denom.HasPrefix(sourcePort, sourceChannel))))
}

telemetry.IncrCounterWithLabels(
Expand Down
10 changes: 4 additions & 6 deletions modules/apps/transfer/v2/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v9/modules/apps/transfer/internal/telemetry"
"github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper"
"github.com/cosmos/ibc-go/v9/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
Expand Down Expand Up @@ -70,11 +71,9 @@ func (im *IBCModule) OnSendPacket(goCtx context.Context, sourceChannel string, d
return err
}

// TODO: events
// events.EmitTransferEvent(ctx, sender.String(), receiver, tokens, memo, hops)
im.keeper.EmitTransferEvent(goCtx, sender.String(), data.Receiver, data.Tokens, data.Memo, data.Forwarding.Hops)

Check failure on line 74 in modules/apps/transfer/v2/ibc_module.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `im.keeper.EmitTransferEvent` is not checked (errcheck)

Check failure on line 74 in modules/apps/transfer/v2/ibc_module.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `im.keeper.EmitTransferEvent` is not checked (errcheck)

// TODO: telemetry
// telemetry.ReportTransfer(sourcePort, sourceChannel, destinationPort, destinationChannel, tokens)
telemetry.ReportTransfer(payload.SourcePort, sourceChannel, payload.DestinationPort, destinationChannel, data.Tokens)

return nil
}
Expand Down Expand Up @@ -137,8 +136,7 @@ func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, des

im.keeper.Logger.Info("successfully handled ICS-20 packet", "sequence", sequence)

// TODO: telemetry
// telemetry.ReportOnRecvPacket(packet, data.Tokens)
telemetry.ReportOnRecvPacket(payload.SourcePort, sourceChannel, payload.DestinationPort, destinationChannel, data.Tokens)

if data.HasForwarding() {
// we are now sending from the forward escrow address to the final receiver address.
Expand Down

0 comments on commit 21fd761

Please sign in to comment.