Skip to content

Commit

Permalink
fix: allow OnRecvPacket to return ack bytes of nil
Browse files Browse the repository at this point in the history
This bypasses the synchronous call to PacketExecuted and allows
the module to call it at a later time.
  • Loading branch information
michaelfig committed Aug 29, 2020
1 parent 5ee4fad commit e00a1e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ invalid or incomplete requests.
* (x/genutil) [\#5938](https://github.com/cosmos/cosmos-sdk/pull/5938) Fix `InitializeNodeValidatorFiles` error handling.
* (x/staking) [\#5949](https://github.com/cosmos/cosmos-sdk/pull/5949) Skip staking `HistoricalInfoKey` in simulations as headers are not exported.
* (client) [\#5964](https://github.com/cosmos/cosmos-sdk/issues/5964) `--trust-node` is now false by default - for real. Users must ensure it is set to true if they don't want to enable the verifier.
* (x/ibc) [\#7200](https://github.com/cosmos/cosmos-sdk/pull/7200) an `OnRecvPacket` callback can declare that it will do its own `PacketExecuted` if the callback returns an acknowledgment of `[]byte(nil)`.

### State Machine Breaking

Expand Down
9 changes: 6 additions & 3 deletions x/ibc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
return nil, sdkerrors.Wrap(err, "receive packet callback failed")
}

// Set packet acknowledgement
if err = k.ChannelKeeper.PacketExecuted(ctx, cap, msg.Packet, ack); err != nil {
return nil, err
// If the caller returned a nil ack, it intends to do its own PacketExecuted.
if ack != nil {
// Set packet acknowledgement
if err = k.ChannelKeeper.PacketExecuted(ctx, cap, msg.Packet, ack); err != nil {
return nil, err
}
}

return res, nil
Expand Down

0 comments on commit e00a1e2

Please sign in to comment.