Skip to content

Commit b8d1fba

Browse files
committed
fix: Use seconds instead of nanoseconds for IBCv2 msg
1 parent 867de24 commit b8d1fba

File tree

8 files changed

+22
-8
lines changed

8 files changed

+22
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/CosmWasm/wasmd
33
go 1.23.6
44

55
require (
6-
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250311142732-2684ad434449
6+
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250328101044-d6dfa29f9935
77
github.com/cosmos/cosmos-proto v1.0.0-beta.5
88
github.com/cosmos/cosmos-sdk v0.50.12
99
github.com/cosmos/gogogateway v1.2.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25
227227
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
228228
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
229229
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
230-
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250311142732-2684ad434449 h1:7dFOzheG+3HatTz/OmbPaudVCweJMz0dn2+8/eQPMcw=
231-
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250311142732-2684ad434449/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
230+
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250328101044-d6dfa29f9935 h1:Vcn1k7PUiV1wyz+d1aEZEVQfbwzPO3B8DA6rnE5bhok=
231+
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250328101044-d6dfa29f9935/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
232232
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
233233
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
234234
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=

tests/e2e/ibc2_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package e2e_test
22

33
import (
4+
"encoding/json"
45
"testing"
56
"time"
67

@@ -22,6 +23,14 @@ type QueryMsg struct {
2223
// ibc2 contract response type
2324
type State struct {
2425
IBC2PacketReceiveCounter uint32 `json:"ibc2_packet_receive_counter"`
26+
LastChannelID string `json:"last_channel_id"`
27+
LastPacketSeq uint64 `json:"last_packet_seq"`
28+
}
29+
30+
// Message sent to the ibc2 contract over IBCv2 channel
31+
type IbcPayload struct {
32+
ResponseWithoutAck bool `json:"response_without_ack"`
33+
SendAsyncAckForPrevMsg bool `json:"send_async_ack_for_prev_msg"`
2534
}
2635

2736
func TestIBC2SendMsg(t *testing.T) {
@@ -56,11 +65,14 @@ func TestIBC2SendMsg(t *testing.T) {
5665

5766
// IBC v2 Payload from contract on Chain B to contract on Chain A
5867
payload := mockv2.NewMockPayload(contractPortB, contractPortA)
68+
var err error
69+
payload.Value, err = json.Marshal(IbcPayload{ResponseWithoutAck: false, SendAsyncAckForPrevMsg: false})
70+
require.NoError(t, err)
5971

6072
// Message timeout
6173
timeoutTimestamp := uint64(chainB.GetContext().BlockTime().Add(time.Minute * 5).Unix())
6274

63-
_, err := path.EndpointB.MsgSendPacket(timeoutTimestamp, payload)
75+
_, err = path.EndpointB.MsgSendPacket(timeoutTimestamp, payload)
6476
require.NoError(t, err)
6577

6678
// First message send through test

tests/e2e/testdata/ibc2.wasm

5.62 KB
Binary file not shown.

x/wasm/keeper/handler_plugin.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keeper
33
import (
44
"errors"
55
"fmt"
6+
"time"
67

78
wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"
89
channeltypesv2 "github.com/cosmos/ibc-go/v10/modules/core/04-channel/v2/types"
@@ -302,7 +303,7 @@ func (h IBC2RawPacketHandler) DispatchMsg(ctx sdk.Context,
302303
}
303304
ibcGoMsg := &channeltypesv2.MsgSendPacket{
304305
SourceClient: msg.IBC2.SendPacket.ChannelID,
305-
TimeoutTimestamp: msg.IBC2.SendPacket.Timeout,
306+
TimeoutTimestamp: uint64(time.Unix(0, int64(msg.IBC2.SendPacket.Timeout)).Unix()),
306307
Payloads: payloads,
307308
Signer: contractAddr.String(),
308309
}

x/wasm/keeper/handler_plugin_encoders.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keeper
33
import (
44
"encoding/json"
55
"fmt"
6+
"time"
67

78
wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"
89
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
@@ -360,7 +361,7 @@ func EncodeIBCv2Msg(sender sdk.AccAddress, msg *wasmvmtypes.IBC2Msg) ([]sdk.Msg,
360361
}
361362
msg := &channeltypesv2.MsgSendPacket{
362363
SourceClient: msg.SendPacket.ChannelID,
363-
TimeoutTimestamp: msg.SendPacket.Timeout,
364+
TimeoutTimestamp: uint64(time.Unix(0, int64(msg.SendPacket.Timeout)).Unix()),
364365
Payloads: payloads,
365366
Signer: sender.String(),
366367
}

x/wasm/keeper/handler_plugin_encoders_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ func TestEncodeIBCv2Msg(t *testing.T) {
928928
Value: []byte{},
929929
},
930930
},
931-
Timeout: 1000,
931+
Timeout: 1000000000000,
932932
},
933933
},
934934
},

x/wasm/keeper/ibc2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (module IBC2Handler) OnRecvPacket(
5252
}
5353

5454
em := sdk.NewEventManager()
55-
msg := wasmvmtypes.IBC2PacketReceiveMsg{Payload: newIBC2Payload(payload), Relayer: relayer.String(), SourceClient: sourceClient}
55+
msg := wasmvmtypes.IBC2PacketReceiveMsg{Payload: newIBC2Payload(payload), Relayer: relayer.String(), SourceClient: sourceClient, PacketSequence: sequence}
5656

5757
ack := module.keeper.OnRecvIBC2Packet(ctx.WithEventManager(em), contractAddr, msg)
5858

0 commit comments

Comments
 (0)