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

feat: delete forwarded packet when it is not needed anymore #6621

Merged
merged 40 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
013f883
Create ontimeoutpacket test for forwarding
bznein Jun 13, 2024
83f4582
Propagate ack on A
bznein Jun 13, 2024
59b93ed
Refactoring
bznein Jun 13, 2024
ff35ada
Minor changes
bznein Jun 13, 2024
926d8da
Added comments
bznein Jun 13, 2024
8a3dd36
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6384/ontimeo…
bznein Jun 13, 2024
3f5dc6c
Fix type name.
bznein Jun 14, 2024
10592e1
Gofumpt
bznein Jun 14, 2024
907de8e
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6384/ontimeo…
bznein Jun 14, 2024
6787c74
Update modules/apps/transfer/keeper/relay_forwarding_test.go
bznein Jun 14, 2024
37375ba
Update modules/apps/transfer/keeper/relay_forwarding_test.go
bznein Jun 14, 2024
65a0d0a
Update modules/apps/transfer/keeper/relay_forwarding_test.go
bznein Jun 14, 2024
ca59adf
Update modules/apps/transfer/keeper/relay_forwarding_test.go
bznein Jun 14, 2024
1492378
Add godoc to test.
bznein Jun 14, 2024
288f5f6
Changed trace construction
bznein Jun 14, 2024
d4e9b59
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6384/ontimeo…
bznein Jun 17, 2024
a70e56d
Update modules/apps/transfer/keeper/relay_forwarding_test.go
bznein Jun 17, 2024
6a33a57
remove error msg parameter from helper function
bznein Jun 14, 2024
7fb5569
Add test for forwarded packet
bznein Jun 17, 2024
774d971
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6384/ontimeo…
bznein Jun 17, 2024
d1736dc
Delete packet when not needed anymore.
bznein Jun 17, 2024
8c8feeb
Move deletion of packet in a single place.
bznein Jun 17, 2024
24f82d6
Reintroduce newline
bznein Jun 17, 2024
6528515
Do not ignore error.
bznein Jun 17, 2024
caa3902
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
bznein Jun 17, 2024
bec616f
PR feedback.
bznein Jun 18, 2024
ad4e6f6
Construct packet for B ack check.
bznein Jun 18, 2024
3acd732
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6384/ontimeo…
bznein Jun 18, 2024
61884f0
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
bznein Jun 18, 2024
139facf
PR feedback
bznein Jun 18, 2024
f9c1e70
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
gjermundgaraba Jun 19, 2024
fdd769f
Pass packet to acknowledgeforwardedpacket
bznein Jun 20, 2024
d532007
revert unwanted change
bznein Jun 20, 2024
db52296
Another unwanted change
bznein Jun 20, 2024
8d06bc3
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
bznein Jun 20, 2024
b6684da
Better signature and fix source/dest
bznein Jun 20, 2024
a5c8729
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
crodriguezvega Jun 21, 2024
432fd1f
Added one more test.
bznein Jun 21, 2024
265de48
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
bznein Jun 21, 2024
fc5410e
Merge branch 'feat/ics20-v2-path-forwarding' into bznein/6546/deletep…
bznein Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/apps/transfer/keeper/forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ func (k Keeper) acknowledgeForwardedPacket(ctx sdk.Context, packet channeltypes.
return errorsmod.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
}

return k.ics4Wrapper.WriteAcknowledgement(ctx, capability, packet, ack)
if err := k.ics4Wrapper.WriteAcknowledgement(ctx, capability, packet, ack); err != nil {
return err
}

return k.deleteForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add checks in our testing for deletion of the right packet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done for the OnAcknowledgment, for the timeout case I have #6596 in review and I'll ad it to that test once we merge this.

crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
}

// revertForwardedPacket reverts the logic of receive packet that occurs in the middle chains during a packet forwarding.
Expand Down
13 changes: 13 additions & 0 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,16 @@ func (k Keeper) GetForwardedPacket(ctx sdk.Context, portID, channelID string, se

return storedPacket, true
}

// deleteForwardedPacket deletes the forwarded packet from the store.
func (k Keeper) deleteForwardedPacket(ctx sdk.Context, portID, channelID string, sequence uint64) error {
store := ctx.KVStore(k.storeKey)
packetKey := types.PacketForwardKey(portID, channelID, sequence)
if !store.Has(packetKey) {
return fmt.Errorf("packet with PortID %s, channelID %s and sequence %d not found in the store", portID, channelID, sequence)
}
colin-axner marked this conversation as resolved.
Show resolved Hide resolved

store.Delete(packetKey)

return nil
}
Loading