-
Notifications
You must be signed in to change notification settings - Fork 751
chore: split out packet handling rpcs #7007
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package keeper | ||
|
|
||
| import ( | ||
| "github.com/cosmos/cosmos-sdk/codec" | ||
|
|
||
| "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" | ||
| ) | ||
|
|
||
| type Keeper struct { | ||
| cdc codec.BinaryCodec | ||
| channelKeeper types.ChannelKeeper | ||
| clientKeeper types.ClientKeeper | ||
| } | ||
|
|
||
| func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper { | ||
| return &Keeper{ | ||
| cdc: cdc, | ||
| channelKeeper: channelKeeper, | ||
| clientKeeper: clientKeeper, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package types | ||
|
|
||
| import ( | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
|
||
| clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" | ||
| "github.com/cosmos/ibc-go/v9/modules/core/exported" | ||
| ) | ||
|
|
||
| type ChannelKeeper interface { | ||
| // SetPacketCommitment writes the commitment hash under the commitment path | ||
| // This is a public path that is standardized by the IBC specification | ||
| SetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64, commitment []byte) | ||
|
|
||
| // GetPacketCommitment returns the packet commitment hash under the commitment path | ||
| GetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) []byte | ||
|
|
||
| // DeletePacketCommitment deletes the packet commitment hash under the commitment path | ||
| DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) | ||
|
|
||
| // SetNextSequenceSend writes the next send sequence under the sequence path | ||
| // This is a public path that is standardized by the IBC specification | ||
| SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64) | ||
|
|
||
| // GetNextSequenceSend returns the next send sequence from the sequence path | ||
| GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) | ||
|
|
||
| // SetPacketReceipt writes the packet receipt under the receipt path | ||
| // This is a public path that is standardized by the IBC specification | ||
| SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) | ||
|
|
||
| // SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path | ||
| // This is a public path that is standardized by the IBC specification | ||
| SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) | ||
| } | ||
|
|
||
| type ClientKeeper interface { | ||
| // VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height. | ||
| VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error | ||
| // VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height. | ||
| VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error | ||
| // GetCounterparty returns the counterparty client given the client ID on | ||
| // the executing chain | ||
| // This is a private path that is only used by the IBC lite module | ||
| GetCounterparty(ctx sdk.Context, clientID string) (clienttypes.Counterparty, bool) | ||
DimitrisJim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package types | ||
|
|
||
| import ( | ||
| commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" | ||
| commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2" | ||
| ) | ||
|
|
||
| // BuildMerklePath takes the merkle path prefix and an ICS24 path | ||
| // and builds a new path by appending the ICS24 path to the last element of the merkle path prefix. | ||
| func BuildMerklePath(prefix *commitmenttypesv2.MerklePath, path []byte) commitmenttypesv2.MerklePath { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. def will add tests, just want to get keeper in branch so we can start working on packet handlers. |
||
| if prefix == nil || len(prefix.KeyPath) == 0 { | ||
| return commitmenttypes.NewMerklePath(path) | ||
| } | ||
| prefixKeys := prefix.KeyPath | ||
| lastElement := prefixKeys[len(prefixKeys)-1] | ||
| // append path to last element | ||
| newLastElement := cloneAppend(lastElement, path) | ||
| prefixKeys[len(prefixKeys)-1] = newLastElement | ||
| return commitmenttypes.NewMerklePath(prefixKeys...) | ||
| } | ||
|
|
||
| func cloneAppend(bz []byte, tail []byte) []byte { | ||
| res := make([]byte, len(bz)+len(tail)) | ||
| copy(res, bz) | ||
| copy(res[len(bz):], tail) | ||
| return res | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can also move to a
packet_msg_server.goif people wanted. didn't since wanted to leave folder organization/shuffling for laterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see this split out eventually and moved to packet-server. But can be done in future PR