Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The packet and its payloads are sent in separate events #7607

Closed
4 tasks
srdtrk opened this issue Nov 29, 2024 · 0 comments
Closed
4 tasks

The packet and its payloads are sent in separate events #7607

srdtrk opened this issue Nov 29, 2024 · 0 comments

Comments

@srdtrk
Copy link
Member

srdtrk commented Nov 29, 2024

Summary

Reconstructing a packet from a relayer's perspective is unnecessarily complex due to the need to process multiple events, which complicates event handling and increases the likelihood of errors.

Problem Definition

func emitSendPacketEvents(ctx context.Context, packet types.Packet) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSendPacket,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyPayloadLength, fmt.Sprintf("%d", len(packet.Payloads))),
sdk.NewAttribute(types.AttributeKeyVersion, packet.Payloads[0].Version),
sdk.NewAttribute(types.AttributeKeyEncoding, packet.Payloads[0].Encoding),
sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(packet.Payloads[0].Value)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
for i, payload := range packet.Payloads {
sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSendPayload,
sdk.NewAttribute(types.AttributeKeySrcChannel, packet.SourceChannel),
sdk.NewAttribute(types.AttributeKeyDstChannel, packet.DestinationChannel),
sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.Sequence)),
sdk.NewAttribute(types.AttributeKeyPayloadSequence, fmt.Sprintf("%d", i)),
sdk.NewAttribute(types.AttributeKeyVersion, payload.Version),
sdk.NewAttribute(types.AttributeKeyEncoding, payload.Encoding),
sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(payload.Value)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
}
}

Since event support has not yet fully arrived (#7386), the same problem would also occur for write acknowledgement events once they are implemented.

Use cases

Improved Developer Experience

  • Relayer developers can work with a more intuitive event model, reducing development and debugging time.

Cleaner Codebase in IBC-Go

  • Consolidating packet data into a single event simplifies code logic, reducing maintenance overhead and potential for bugs.

Enhanced Ecosystem Interoperability

  • A more streamlined event structure aligns with modern approaches, like Solidity-IBC-Eureka, fostering consistency across implementations.

Proposal

We can simply include the all payload information in the same event or do what solidity-ibc-eureka is doing and encode the entire packet as a single key-value pair.

We may also want to modify the spec so that all packet info is contained in a single event.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
  • Estimate provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant