Skip to content

OnRecv changes to revert state on failed acknowledgement #91

Closed
@colin-axner

Description

Summary

Currently if partial application logic occurs in the OnRecvPacket callback and a failed acknowledgement is returned, these partial state changes persist. See #68

There are two potential solutions:

  • add a 4th return argument to the callback to indicate if the application state should be reverted
  • revert all application logic callback if an error is returned

Adding a 4th argument allows the most flexibility since the application developer can revert application state on a failed acknowledgement and still decide to revert the entire transaction in a unique situation.

Reverting all application logic on an error returned makes the most sense if there exists no use case to revert the entire transaction. Note, a panic in the callback will result in a reverted transaction. Returning an error which results in a successful SDK transaction is semantically different than the other callbacks. Returning an error in all the other callbacks results in the entire transaction failing

The 1st case might look like this at the application level

    revert = true
    return result, failedAck, revert, nil // failed ack, revert app state

or

    revert = false
    return result, successAck, revert, nil // successful ack, write app state

or

    return result, nil, revert, err // failed transaction, revert all state changes (including in core IBC)

where true indicates to revert the application state and the error indicates if the transaction should be reverted.

The 2nd case might look like this at the application level

    return result, failedAck, err // failed ack, revert app state

or

    return result, successAck, nil // successful ack, write app state

NOTE: using the following is a non-atomic failed callback, this could be potentially dangerous if the developer is not aware of these concerns.

    return result, failedAck, nil // failed ack, write app state

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions