Skip to content
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

ICS27 cleanup #639

Closed
wants to merge 1 commit into from
Closed

Conversation

AdityaSripal
Copy link
Member

  • Minor cleanups and fixes to keep consistent with implementation

@AdityaSripal AdityaSripal changed the base branch from master to aditya/ics27-updates January 17, 2022 18:17
@@ -118,10 +118,11 @@ function AuthenticateTx(msgs []Any, portId string) error {
Executes each message sent by the owner account on the controller chain.

```typescript
function ExecuteTx(sourcePort: string, destPort: string, destChannel: string, msgs []Any) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields are not used

return ack
switch data.Type {
case types.EXECUTE_TX:
msgs, err := types.DeserializeTx(data.Data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the norm "throwing exceptions" in this ics spec "pseudo code".

It seems modelled heavily on TypeScript

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to throw an exception in this case and abort the transaction, we want to write an error acknowledgement and commit the state changes

Copy link
Contributor

@ethanfrey ethanfrey Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. But the idiom msg, err := fn() is very go. The rest of the ibc specs are modelled on TypeScript.

I would say:

try {
  const msg = deserializeTx(data.data)
  // ... other stuff
} catch (err) {
  return newErrorAcknowledgement(err)
}

would look more in line with the other specs (but still needs some adjustment).

I believe the specs were intentionally not written in Go to keep a clear distinction between them and the implementation. Whether that was a good decision I will leave to you and @cwgoes to discuss. I just like consistency in the style.

case types.EXECUTE_TX:
msgs, err := types.DeserializeTx(data.Data)
if err != nil {
return NewErrorAcknowledgement(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the spec discuss the implication of returning the error in the acknowledgement? That is, including the error string in the acknowledgement makes error strings state machine breaking

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be optional, as we will not include the error in the ibc-go implementation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the spec discuss the implication of returning the error in the acknowledgement? That is, including the error string in the acknowledgement makes error strings state machine breaking

Very good point.
That has proved to be the case for CosmWasm with submessages and we did hit a case where one node included the stack trace and fell out of consensus.

I like to include error message, but this is a very good thing to think through (and check code paths)

}

// return acknowledgement containing the transaction result after executing on host chain
return NewAcknowledgement(result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for implications of including the result

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of a transaction is currently hashed and included in the the Tendermint block header (DataHash I believe). The data field and the code (u32) are the only fields currently consensus breaking (not events). I think including Data is fully acceptable, where errors and events may need more consideration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great insight! I did not know the data field is included in consensus. I agree, if the result is already included in consensus then it is fully acceptable to include in the acknowledgement

Copy link
Contributor

@seantking seantking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Agree with @ethanfrey about the state of the pseudo-code in general. We should have a standard for this.

@AdityaSripal
Copy link
Member Author

Superceded by #643

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants