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

Ibcmodulev2 transfer application spike #7524

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7a257c3
chore: adding ibc module v2 and on recv implementation with hard code…
chatton Oct 23, 2024
6608b93
chore: adding ack callback
chatton Oct 23, 2024
3c23128
chore: adding send packet
chatton Oct 23, 2024
c7a74a6
chore: adding transfer v2 module to app wiring
chatton Oct 24, 2024
4f70fc4
chore: adding happy path and basic failure for send and recv for tran…
chatton Oct 24, 2024
49392cd
chore: adding ack test for transfer
chatton Oct 24, 2024
d3b19c9
chore: fix some linter errors
chatton Oct 24, 2024
615f956
chore: adding timeout test for transfer v2
chatton Oct 24, 2024
c03b8c9
chore: adding test case which ensures tokens can be transfered over b…
chatton Oct 29, 2024
0e72c17
chore: full transfer flow from A - B - C - B - A
chatton Oct 29, 2024
198996b
chore: separated test out into subtests
chatton Oct 29, 2024
973f2f7
chore: add sequence as argument to OnRecvPacket
Oct 29, 2024
f53d865
chore: adding TODOs for next steps
chatton Oct 31, 2024
cec9d52
chore: adding transferv2 module to wasm simapp
chatton Nov 4, 2024
8d6f0a8
chore: refactor OnTimeout to accept sequence
chatton Nov 4, 2024
756c52b
chore: refactor OnAck to accept sequence
chatton Nov 4, 2024
20bae59
chore: switch argument order
chatton Nov 4, 2024
16700f9
wip: mid merge with feature branch, build will be broken
chatton Nov 4, 2024
c2f6937
Merge branch 'feat/ibc-eureka' into cian/issue#7510-ibcmodulev2-trans…
Nov 4, 2024
b2a1514
Fix timeoutTimestamp for tests
Nov 4, 2024
20afb28
linter
Nov 4, 2024
29f1151
chore: removing duplicate imports in wasm simapp
chatton Nov 4, 2024
a6c801a
chore: adding channelkeeperv2 query server
chatton Nov 6, 2024
6d68fb6
Merge branch 'feat/ibc-eureka' into cian/issue#7510-ibcmodulev2-trans…
Nov 6, 2024
dbf6f2c
register grpc gateway routes
gjermundgaraba Nov 6, 2024
739af65
Merge branch 'feat/ibc-eureka' into cian/issue#7510-ibcmodulev2-trans…
Nov 15, 2024
d7c9437
fix ack structure for v2 transfer tests
Nov 15, 2024
8a4fb46
Merge branch 'feat/ibc-eureka' into cian/issue#7510-ibcmodulev2-trans…
gjermundgaraba Nov 15, 2024
468035e
lint
gjermundgaraba Nov 15, 2024
1992fde
make signature consistent
Nov 19, 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
Prev Previous commit
Next Next commit
chore: add sequence as argument to OnRecvPacket
  • Loading branch information
bznein committed Oct 29, 2024
commit 973f2f7c49049be8585561d81c1b811c317282a4
5 changes: 1 addition & 4 deletions modules/apps/transfer/v2/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@

var _ api.IBCModule = (*IBCModule)(nil)

// TODO: pass sequence as argument to OnRecvPacket
const sequence = 1

// NewIBCModule creates a new IBCModule given the keeper
func NewIBCModule(keeper *keeper.Keeper) *IBCModule {

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

View workflow job for this annotation

GitHub Actions / lint

import-shadowing: The name 'keeper' shadows an import name (revive)

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

View workflow job for this annotation

GitHub Actions / lint

import-shadowing: The name 'keeper' shadows an import name (revive)
return &IBCModule{
keeper: keeper,
}
Expand Down Expand Up @@ -52,7 +49,7 @@
return im.keeper.OnSendPacket(ctx, sourceChannel, payload, data, signer)
}

func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, payload types.Payload, relayer sdk.AccAddress) types.RecvPacketResult {
func (im *IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, payload types.Payload, relayer sdk.AccAddress) types.RecvPacketResult {
var (
ackErr error
data transfertypes.FungibleTokenPacketDataV2
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/v2/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack
// Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful.
cacheCtx, writeFn = sdkCtx.CacheContext()
cb := k.Router.Route(pd.DestinationPort)
res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, pd, signer)
res := cb.OnRecvPacket(cacheCtx, msg.Packet.SourceChannel, msg.Packet.DestinationChannel, msg.Packet.Sequence, pd, signer)

if res.Status != channeltypesv2.PacketStatus_Failure {
// write application state changes for asynchronous and successful acknowledgements
Expand Down
4 changes: 2 additions & 2 deletions modules/core/04-channel/v2/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() {
// a failed ack should be returned by the application.
expectedAck.AcknowledgementResults[0].RecvPacketResult = failedRecvResult

path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
return failedRecvResult
}
},
Expand All @@ -162,7 +162,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() {
// an async ack should be returned by the application.
expectedAck.AcknowledgementResults[0].RecvPacketResult = asyncResult

path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
return asyncResult
}
},
Expand Down
1 change: 1 addition & 0 deletions modules/core/api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type IBCModule interface {
ctx context.Context,
sourceChannel string,
destinationChannel string,
sequence uint64,
Copy link
Member

Choose a reason for hiding this comment

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

This should be added to OnAcknowledgementPacket and OnTimeoutPacket as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep makes sense!

data channeltypesv2.Payload,
relayer sdk.AccAddress,
) channeltypesv2.RecvPacketResult
Expand Down
2 changes: 1 addition & 1 deletion testing/mock/v2/ibc_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type IBCApp struct {
OnSendPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error
OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult
OnRecvPacket func(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult
OnTimeoutPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) error
OnAcknowledgementPacket func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, acknowledgement []byte, relayer sdk.AccAddress) error
}
4 changes: 2 additions & 2 deletions testing/mock/v2/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func (im IBCModule) OnSendPacket(ctx context.Context, sourceChannel string, dest
return nil
}

func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
func (im IBCModule) OnRecvPacket(ctx context.Context, sourceChannel string, destinationChannel string, sequence uint64, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult {
if im.IBCApp.OnRecvPacket != nil {
return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, data, relayer)
return im.IBCApp.OnRecvPacket(ctx, sourceChannel, destinationChannel, sequence, data, relayer)
}
return MockRecvPacketResult
}
Expand Down
Loading