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

Update WriteAcknowledgementV2 to not depend on channels #7238

Merged
merged 16 commits into from
Sep 10, 2024

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Sep 3, 2024

Description

This PR

  • Adds a mock IBCModuleV2 to be used in tests.
  • Updates the WriteAck function to no longer depend on channels.
  • Adds a test case which simulates an async application. (not using transfer/forwarding)

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Comment on lines 427 to 433
mockModuleV2A := ibcmock.NewIBCModuleV2(ibcmock.NewIBCV2App())
ibcAppRouter.AddV2Route(ibcmock.ModuleNameV2+"A", mockModuleV2A)
app.MockV2ModuleA = mockModuleV2A

mockModuleV2B := ibcmock.NewIBCModuleV2(ibcmock.NewIBCV2App())
ibcAppRouter.AddV2Route(ibcmock.ModuleNameV2+"B", mockModuleV2B)
app.MockV2ModuleB = mockModuleV2B
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could probably design a mock module that is a single module, but allows for dynamic modification of behaviour based on payload/version provided etc.

If anyone feels like we should do that now, happy to give it a go, otherwise can just use this dumber approach of having 2 instances.

@chatton chatton requested a review from srdtrk as a code owner September 3, 2024 11:44
@@ -456,112 +456,6 @@ func (k *Keeper) WriteAcknowledgement(
return nil
}

// WriteAcknowledgementAsyncV2 TODO: this has not been tested at all.
func (k *Keeper) WriteAcknowledgementAsyncV2(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to packetServerKeeper

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @chatton! The test with both mock modules is also very nice.

There are a couple TODOs in the code, do you plan to address them in a follow up soon or would you prefer to open issues to keep track of them?

I am guessing that if we implement channel aliasing (and the source/destination channel fields can be channel identifiers), then we will also have to adjust the code to handle that situation, right?

@chatton
Copy link
Contributor Author

chatton commented Sep 4, 2024

@crodriguezvega yes some of these TODOs are still pending design decisions, e.g. what will GetData() look like for a PacketV2, we can create issues to track these for sure! I'll make sure that any TODOs that don't have issues already associated with them are created.

@@ -150,7 +150,7 @@ func EmitSendPacketEventV2(ctx sdk.Context, packet types.PacketV2, channel types
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSendPacket,
//sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), TODO
// sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref #7248

func (k Keeper) WriteAcknowledgementV2(
ctx sdk.Context,
packet channeltypes.PacketV2,
multiAck channeltypes.MultiAcknowledgement,
) error {
// TODO: this should probably error out if any of the acks are async.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -283,9 +283,9 @@ func (k *Keeper) RecvPacketV2(
return errorsmod.Wrap(err, "couldn't verify counterparty packet commitment")
}

//if err := k.applyReplayProtection(ctx, packet, channel); err != nil {
// if err := k.applyReplayProtection(ctx, packet, channel); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know why this is commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may have been commented out to keep diff low, it'll require a duplicate v2 version of all the functions down that code path.

I think we can probably come up with a cleaner solution in the end where the v2 code path is the only path anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also just realised this entire fn doesn't need to exist, channelKeeper.RecvPacketV2 was the impl that existed on the port router branch, we can remove this since the v2 flow will always go through the PacketServerKeeper

}

//defer telemetry.ReportRecvPacket(msg.Packet)
// TODO; move to PacketServerKeeper this will blow up with no channels
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chatton chatton added the priority PRs that need prompt reviews label Sep 5, 2024
@bznein bznein mentioned this pull request Sep 5, 2024
10 tasks
Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me to merge to the poc branch to keep moving! Cheers

@@ -283,9 +283,9 @@ func (k *Keeper) RecvPacketV2(
return errorsmod.Wrap(err, "couldn't verify counterparty packet commitment")
}

//if err := k.applyReplayProtection(ctx, packet, channel); err != nil {
// if err := k.applyReplayProtection(ctx, packet, channel); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know why this is commented out?

@chatton
Copy link
Contributor Author

chatton commented Sep 10, 2024

will merge this one after #7254 since there will be some conflicts

Copy link

sonarcloud bot commented Sep 10, 2024

@chatton chatton merged commit 06b9dd7 into feat/packet-v2 Sep 10, 2024
65 checks passed
@chatton chatton deleted the update-write-ack-v2-to-not-use-channels branch September 10, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants