-
Notifications
You must be signed in to change notification settings - Fork 202
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
Sdk v0.46.* and ibc-go v5.1.0 #349
Conversation
Is upgrade code also required here? |
Yes, we'll add upgrade handler after all bug is fixed |
x/icacallbacks/module_ibc.go
Outdated
@@ -92,7 +94,11 @@ func (im IBCModule) NegotiateAppVersion( | |||
} | |||
|
|||
// GetTxMsgData returns the msgs from an ICA transaction and can be reused across authentication modules | |||
func GetTxMsgData(ctx sdk.Context, ack channeltypes.Acknowledgement, logger log.Logger) (*sdk.TxMsgData, error) { | |||
func GetTxMsgData(ctx sdk.Context, ack channeltypes.Acknowledgement, logger log.Logger) (*types.ICATxResponse, 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.
If you're on board with moving the ack unmarshaling out, I think we should add it to the top of this function and rename it to something more generic like UnpackICAAcknowledgement
(I'm sure you can think of a much better name)
And then each callback would take types.ICATxResponse as the argument instead of the Ack packet type
) | ||
type ICATxResponse struct { | ||
Status ICATxResponseStatus // enum of SUCCESS, TIMEOUT, FAILURE | ||
Data sdk.TxMsgData // TxMsgData |
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.
And then I think you want data to be a byte array here
x/icacallbacks/module_ibc.go
Outdated
// if ack is nil, a timeout occurred | ||
if &ack == nil { | ||
if &acknowledgement == nil { |
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.
Since we removed logging in x/records/module_ibc.go
, should we add a log here so that it's easy to see how acks are being parsed?
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.
yup, I was thinking that as well. Might make sense to add them in after testing though cause it's still a little unclear to me which branch will wind up being timeout, error, success, etc.
I'll add a TODO for the time being
x/icacallbacks/module_ibc.go
Outdated
// | ||
// It's also unclear to me whether this timeout case below is possible | ||
// In any case, we should just test this thoughly with the following cases: | ||
// Success |
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 think this sequence is possible, because the host chain should process either a timeout or an error, but not both
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.
Yeah my biggest question is what a timeout looks like. It seems odd that we were identifying it by a nil ack. Fortunately, should be easy enough to test
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.
We identify it with a nil ack out of convenience here https://github.com/notional-labs/stride/blob/acd8c57188652ce42c53a09c82a2d5bbe49b83af/x/stakeibc/module_ibc.go#L174
The timeout actually flows down a different code path (OnTimeout
), so it probably makes sense to stop using a nil ack to identify timeouts and instead pass in an ICATxResponse
with a timeout status. Sorry, should have caught this in the review - I'll push this up now.
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.
Ah that's right, good call out!
x/icacallbacks/module_ibc.go
Outdated
// so Acknowledgement_Result should only be returned if the transaction was successful | ||
// However, I recall seeing a case where the acknowledgement type was Acknowledgement_Result but the transaction failed | ||
// | ||
// -> If my memory's correct, I think a failure on the host could come back as either an AcknowledgementError |
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.
also recall this - I think the way we tested it (as you mentioned below) was delegating to a non-existent validator?
For testing, we can add logging at each step in the Unpack function. And then we can test the following cases:
@asalzmann What am I forgetting? I think there might be two failure cases on the host - one that's rejected early by validate basic and one that's rejected after reading state from the store. And then for transfer I think the example above would be a validate basic failure - not sure how to invoke a state failure. |
The above test plan makes sense - thoughts on doing this in a separate PR? This one is getting a bit hairy I think we should probably write integration tests for these, wdyt? |
Agreed, I don't think we should push any changes related to those tests, I think we can just do it locally. But I think we should avoid merging this to main until the integration tests pass. Maybe we get the acks working for the current v3 hosts, merge, then test a v5 host (evmos) and make relevant changes in another PR?
I think as far as the individual success/failure test cases, we should just determine the Ack packet format and then make unit tests. And then wrt integration tests, I think adding a v5 host is adequate. |
@asalzmann Integration tests are working. I'm trying to test restoring the channel but looks like there's some bugs in the relayer we might have to solve first. Also I don't see any lint errors anymore, but lmk if there was something you saw that I might be missing. |
// ICA transactions have associated messages responses. IBC transfer do not. | ||
// With ICA transactions, the schema of the response differs depending on the version of ibc-go used, | ||
// however, this function unifies the format into a common response (a slice of byte arrays) | ||
func UnpackAcknowledgementResponse(ctx sdk.Context, logger log.Logger, ack []byte, isICA bool) (*types.AcknowledgementResponse, 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.
Not needed here, in the future we might want to encode the ack type as an enum (ICA, Transfer, etc.) so that we can support more IBC apps
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.
That's a great idea, much cleaner! I'll actually make a quick PR for that soon
LGTM |
Co-authored-by: Son Trinh <sontrinh@Sons-MacBook-Pro.local> Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com> Co-authored-by: Aidan Salzmann <aidan@stridelabs.co> Co-authored-by: DongLieu <duongduydongtq@gmail.com> Co-authored-by: Nguyen Thanh Nhan <thanhnhan98qh@gmail.com> Co-authored-by: sampocs <sam.pochyly@gmail.com> Co-authored-by: sampocs <sam@stridelabs.co>
Closes: #347
Context and purpose of the change
This PR updates cosmos-sdk to v0.46.*. It shouldn't be considered ready for production until the release of v0.46.7, which deprecates all prior sdk releases.
Brief Changelog
Author's Checklist
I have...
If skipped any of the tests above, explain.
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Documentation and Release Note
Unreleased
section inCHANGELOG.md
?How is the feature or change documented?
XXX
x/<module>/spec/
)