-
Notifications
You must be signed in to change notification settings - Fork 642
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
Move channel back to counterparty #7842
Conversation
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.
Thanks! This is going to be very nice! 🙌
The general structure and logic seems straightforward and understandable. I have some questions on naming that I left in comments.
// resolveV2Identifiers returns the client identifier and the counterpartyInfo for the client given the packetId | ||
// Note: For fresh eureka channels, the client identifier and packet identifier are the same. | ||
// For aliased channels, the packet identifier will be the original channel ID and the counterpartyInfo will be constructed from the channel | ||
func (k *Keeper) resolveV2Identifiers(ctx context.Context, portId string, packetId string) (string, clienttypes.CounterpartyInfo, error) { |
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.
I think maybe the name could be better here. If I have to read the comment to understand what the function does for me, I consider it a code smell :)
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.
After seeing it used further down I am even more confused. Is it taking in packetId or a client id?
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.
Yea this was because it could also be an original channelID for aliasing, in which case I still need to retrieve the original clientiD
@@ -14,9 +14,9 @@ message Packet { | |||
// with a later sequence number. | |||
uint64 sequence = 1; | |||
// identifies the sending chain. | |||
string source_channel = 2; | |||
string source_id = 2; |
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.
It will be the last time I bring this up (I hope), but what is the reason we don't want to name source and destination identifier client_id (as in source_client_id)? Can it be anything else?
return 0, "", errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel) | ||
} | ||
// lookup counterparty and clientid from packet identifiers | ||
clientID, counterparty, err := k.resolveV2Identifiers(ctx, payloads[0].SourcePort, sourceId) |
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.
I thought this function was taking in a packet identifier? But it is taking in the source (client) identifier?
transfertypes.NewHop(transfertypes.ModuleName, pathv2.EndpointB.ClientID), | ||
transfertypes.NewHop(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), |
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.
First hop used IBC Classic, second hop used IBC Eureka
return nil, status.Error(codes.InvalidArgument, err.Error()) | ||
} | ||
|
||
if req.Sequence == 0 { | ||
return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0") | ||
} | ||
|
||
if !q.HasChannel(ctx, req.ChannelId) { |
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.
This was a pain to find the analog of especially in a world with aliasing. Just decided to remove it since if client (or aliased client) doesn't exist, none of these other auxilliary state will exist either
} | ||
}, | ||
status.Error(codes.InvalidArgument, "packet sequence cannot be 0"), | ||
}, | ||
{ | ||
"channel not found", |
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.
Removed these cases. They still error but now equivalent to the queried key not existing
// NextSequenceSend returns the next send sequence for a given channel. | ||
rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { | ||
option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; | ||
option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/next_sequence_send"; |
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.
There rpc urls are very ugly since they still contain channel/v2. Should we pull this whole thing back out to its own package packetserver
? 🫣
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.
I think that would be cleaner, yes.
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.
I don't mind the urls but up to you
// CounterpartyInfo defines the key that the counterparty will use to message our client | ||
message CounterpartyInfo { | ||
// merkle prefix key is the prefix that ics provable keys are stored under | ||
repeated bytes merkle_prefix = 1; |
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.
I decided to just make this repeated bytes
rather than importing ics23.commitment MerklePath
I think the inclusion of ics23 into the required external structs has caused more confusion than anything else. It is also an unnecessary import here
I convert to ics23 commitment MerklePath internally
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.
I think it is ok to have this be ics23.commitment.MerklePath
but use repeated bytes
in MsgRegisterCounterparty
since CounterpartyInfo
is used internally anyway?
But this is also good :)
Now that we have channel completely removed should we move |
I think that would make sense and keep things much cleaner. Not sure what the best name is, but separate package for sure. |
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.
I like where this is going! Left some mostly nit comments :)
// NextSequenceSend returns the next send sequence for a given channel. | ||
rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { | ||
option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; | ||
option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/next_sequence_send"; |
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.
I think that would be cleaner, yes.
// identifies the receiving chain. | ||
string destination_channel = 3; | ||
// identifies the sending client on the sending chain. | ||
string source_client = 2; |
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.
nit: but why not source_client_id? Since we use client_id everywhere else?
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.
I will leave this out for now, since this is analogous to what has existed in ibc-go forever. We can make a decision to change in a different PR/issue
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.
Created an issue to track this here #7854
func() {}, | ||
func() { | ||
packet.SourceChannel = ibctesting.InvalidID | ||
packet.SourceClient = ibctesting.InvalidID |
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.
This is a bit of a nit, but I don't get why we don't just add the ID to all these names? If we're dealing with the ID, and we use that name in most other contexts, why not keep it consistent and always refer to it as SourceClientID and so on?
@@ -19,50 +20,40 @@ import ( | |||
// in order for the packet to be sent to the counterparty. | |||
func (k *Keeper) sendPacket( | |||
ctx context.Context, | |||
sourceChannel string, | |||
sourceClient string, |
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.
Same here with the naming. It's a bit of a nit, but the more I see it, the more I feel like we should just use ClientID in all names where it that is really what it is.
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.
lgtm. Surprised so many lines were deleted. This is the right way it seems.
// it must be called by the same relayer that called CreateClient | ||
func (k *Keeper) RegisterCounterparty(ctx context.Context, msg *clienttypes.MsgRegisterCounterparty) (*clienttypes.MsgRegisterCounterpartyResponse, error) { | ||
creator := k.ClientKeeper.GetClientCreator(ctx, msg.ClientId) | ||
if !creator.Equals(sdk.AccAddress(msg.Signer)) { |
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.
Should you instead have the creator become a string? Should be consistent with how we do these comparisons elsewhere?
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.
Left as is now, since it that case, we may as well just have the keeper return a string. Maybe we can do later as a small followup if really necessary
// NextSequenceSend returns the next send sequence for a given channel. | ||
rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { | ||
option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; | ||
option (google.api.http).get = "/ibc/core/channel/v2/clients/{client_id}/next_sequence_send"; |
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.
I don't mind the urls but up to you
// CounterpartyInfo defines the key that the counterparty will use to message our client | ||
message CounterpartyInfo { | ||
// merkle prefix key is the prefix that ics provable keys are stored under | ||
repeated bytes merkle_prefix = 1; |
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.
I think it is ok to have this be ics23.commitment.MerklePath
but use repeated bytes
in MsgRegisterCounterparty
since CounterpartyInfo
is used internally anyway?
But this is also good :)
Quality Gate passed for 'ibc-go'Issues Measures |
Description
closes: #7739
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.