Skip to content

Commit

Permalink
feat(ics20): implement on receive packet (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: srdtrk <[email protected]>
  • Loading branch information
gjermundgaraba and srdtrk authored Aug 7, 2024
1 parent 43ce11c commit 298254c
Show file tree
Hide file tree
Showing 21 changed files with 960 additions and 86 deletions.
53 changes: 52 additions & 1 deletion abi/ICS20Transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"name": "onRecvPacket",
"inputs": [
{
"name": "",
"name": "msg_",
"type": "tuple",
"internalType": "struct IIBCAppCallbacks.OnRecvPacketCallback",
"components": [
Expand Down Expand Up @@ -430,6 +430,46 @@
],
"anonymous": false
},
{
"type": "event",
"name": "ICS20ReceiveTransfer",
"inputs": [
{
"name": "packetData",
"type": "tuple",
"indexed": false,
"internalType": "struct ICS20Lib.PacketDataJSON",
"components": [
{
"name": "denom",
"type": "string",
"internalType": "string"
},
{
"name": "sender",
"type": "string",
"internalType": "string"
},
{
"name": "receiver",
"type": "string",
"internalType": "string"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "memo",
"type": "string",
"internalType": "string"
}
]
}
],
"anonymous": false
},
{
"type": "event",
"name": "ICS20Timeout",
Expand Down Expand Up @@ -599,6 +639,17 @@
}
]
},
{
"type": "error",
"name": "ICS20InvalidReceiver",
"inputs": [
{
"name": "receiver",
"type": "string",
"internalType": "string"
}
]
},
{
"type": "error",
"name": "ICS20InvalidSender",
Expand Down
171 changes: 171 additions & 0 deletions abi/ICS26Router.json
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,103 @@
}
]
},
{
"type": "error",
"name": "IBCMembershipProofVerificationFailed",
"inputs": [
{
"name": "packet",
"type": "tuple",
"internalType": "struct IICS26RouterMsgs.Packet",
"components": [
{
"name": "sequence",
"type": "uint32",
"internalType": "uint32"
},
{
"name": "timeoutTimestamp",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "sourcePort",
"type": "string",
"internalType": "string"
},
{
"name": "sourceChannel",
"type": "string",
"internalType": "string"
},
{
"name": "destPort",
"type": "string",
"internalType": "string"
},
{
"name": "destChannel",
"type": "string",
"internalType": "string"
},
{
"name": "version",
"type": "string",
"internalType": "string"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
}
]
},
{
"name": "membershipMsg",
"type": "tuple",
"internalType": "struct ILightClientMsgs.MsgMembership",
"components": [
{
"name": "proof",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "proofHeight",
"type": "tuple",
"internalType": "struct IICS02ClientMsgs.Height",
"components": [
{
"name": "revisionNumber",
"type": "uint32",
"internalType": "uint32"
},
{
"name": "revisionHeight",
"type": "uint32",
"internalType": "uint32"
}
]
},
{
"name": "path",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "value",
"type": "bytes",
"internalType": "bytes"
}
]
},
{
"name": "reason",
"type": "bytes",
"internalType": "bytes"
}
]
},
{
"type": "error",
"name": "IBCPacketAcknowledgementAlreadyExists",
Expand Down Expand Up @@ -869,6 +966,64 @@
}
]
},
{
"type": "error",
"name": "IBCPacketHandlingFailed",
"inputs": [
{
"name": "packet",
"type": "tuple",
"internalType": "struct IICS26RouterMsgs.Packet",
"components": [
{
"name": "sequence",
"type": "uint32",
"internalType": "uint32"
},
{
"name": "timeoutTimestamp",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "sourcePort",
"type": "string",
"internalType": "string"
},
{
"name": "sourceChannel",
"type": "string",
"internalType": "string"
},
{
"name": "destPort",
"type": "string",
"internalType": "string"
},
{
"name": "destChannel",
"type": "string",
"internalType": "string"
},
{
"name": "version",
"type": "string",
"internalType": "string"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
}
]
},
{
"name": "reason",
"type": "bytes",
"internalType": "bytes"
}
]
},
{
"type": "error",
"name": "IBCPacketReceiptAlreadyExists",
Expand Down Expand Up @@ -918,6 +1073,22 @@
"name": "ReentrancyGuardReentrantCall",
"inputs": []
},
{
"type": "error",
"name": "SafeCastOverflowedUintDowncast",
"inputs": [
{
"name": "bits",
"type": "uint8",
"internalType": "uint8"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
}
]
},
{
"type": "error",
"name": "StringsInsufficientHexLength",
Expand Down
2 changes: 1 addition & 1 deletion e2e/artifacts/genesis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"trustedClientState": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000012754500000000000000000000000000000000000000000000000000000000001baf800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673696d642d310000000000000000000000000000000000000000000000000000",
"trustedConsensusState": "0000000000000000000000000000000000000000000000000000000066b0b92862093024debc13c1fab2cce33d04895624033edca5cc22f7266085eca4c6461606c79e13ccd4e467cae775cbc073ccca2735947069c0255e78337c50dcdee823",
"trustedConsensusState": "0000000000000000000000000000000000000000000000000000000066b24dfc0a376dcfbf32aa896d68958779c5d6ef4c73b5f0eb8c55e74eaeb1399a9f8250b29f00b95808b8b596d78d77bbb1f263250537c5561baf2dc879ae5226c9ccd7",
"updateClientVkey": "0x0068b9d316aced51c5923b2d50692f4a6a9bfefcd89392914b90e77545727fbe",
"membershipVkey": "0x00a4245d249b5c35c9782cc899c8e370a35d5d928187dc9e7acbab7096764b72",
"ucAndMembershipVkey": "0x00cea834e3408d45d29080a3146e4fb1fd0c06503d655bd787219caac86cf59c"
Expand Down
23 changes: 23 additions & 0 deletions e2e/interchaintestv8/e2esuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
msgv1 "cosmossdk.io/api/cosmos/msg/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
)

Expand Down Expand Up @@ -40,6 +42,27 @@ func populateQueryReqToPath(ctx context.Context, chain *cosmos.CosmosChain) erro
return nil
}

func ABCIQuery(ctx context.Context, chain *cosmos.CosmosChain, req *abci.RequestQuery) (*abci.ResponseQuery, error) {
// Create a connection to the gRPC server.
grpcConn, err := grpc.Dial(
chain.GetHostGRPCAddress(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return &abci.ResponseQuery{}, err
}

defer grpcConn.Close()

resp := &abci.ResponseQuery{}
err = grpcConn.Invoke(ctx, "cosmos.base.tendermint.v1beta1.Service/ABCIQuery", req, resp)
if err != nil {
return &abci.ResponseQuery{}, err
}

return resp, nil
}

// Queries the chain with a query request and deserializes the response to T
func GRPCQuery[T any](ctx context.Context, chain *cosmos.CosmosChain, req proto.Message, opts ...grpc.CallOption) (*T, error) {
path, ok := queryReqToPath[proto.MessageName(req)]
Expand Down
2 changes: 1 addition & 1 deletion e2e/interchaintestv8/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
cosmossdk.io/x/tx v0.13.3
cosmossdk.io/x/upgrade v0.1.2
github.com/CosmWasm/wasmd v0.50.0
github.com/cometbft/cometbft v0.38.7
github.com/cosmos/cosmos-sdk v0.50.7
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/v8 v8.3.0
Expand Down Expand Up @@ -71,7 +72,6 @@ require (
github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.7 // indirect
github.com/cometbft/cometbft-db v0.10.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
Expand Down
Loading

0 comments on commit 298254c

Please sign in to comment.