From 3602bb878899f69ea35e3a5f896d7e42bb8a7901 Mon Sep 17 00:00:00 2001 From: Justin Tieri <37750742+jtieri@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:02:41 -0500 Subject: [PATCH 1/3] refactor: remove processed key and handling code --- .../packetforward/ibc_middleware.go | 11 ----------- .../packetforward/types/keys.go | 3 --- 2 files changed, 14 deletions(-) diff --git a/middleware/packet-forward-middleware/packetforward/ibc_middleware.go b/middleware/packet-forward-middleware/packetforward/ibc_middleware.go index c10f6de2..db77d1eb 100644 --- a/middleware/packet-forward-middleware/packetforward/ibc_middleware.go +++ b/middleware/packet-forward-middleware/packetforward/ibc_middleware.go @@ -196,7 +196,6 @@ func (im IBCMiddleware) OnRecvPacket( metadata := m.Forward goCtx := ctx.Context() - processed := getBoolFromAny(goCtx.Value(types.ProcessedKey{})) nonrefundable := getBoolFromAny(goCtx.Value(types.NonrefundableKey{})) disableDenomComposition := getBoolFromAny(goCtx.Value(types.DisableDenomCompositionKey{})) @@ -212,16 +211,6 @@ func (im IBCMiddleware) OnRecvPacket( return newErrorAcknowledgement(fmt.Errorf("failed to construct override receiver: %w", err)) } - // if this packet has been handled by another middleware in the stack there may be no need to call into the - // underlying app, otherwise the transfer module's OnRecvPacket callback could be invoked more than once - // which would mint/burn vouchers more than once - if !processed { - if err := im.receiveFunds(ctx, packet, data, overrideReceiver, relayer); err != nil { - logger.Error("packetForwardMiddleware OnRecvPacket error receiving packet", "error", err) - return newErrorAcknowledgement(fmt.Errorf("error receiving packet: %w", err)) - } - } - // if this packet's token denom is already the base denom for some native token on this chain, // we do not need to do any further composition of the denom before forwarding the packet denomOnThisChain := data.Denom diff --git a/middleware/packet-forward-middleware/packetforward/types/keys.go b/middleware/packet-forward-middleware/packetforward/types/keys.go index 13479e9a..072702c6 100644 --- a/middleware/packet-forward-middleware/packetforward/types/keys.go +++ b/middleware/packet-forward-middleware/packetforward/types/keys.go @@ -13,12 +13,9 @@ const ( QuerierRoute = ModuleName ) -var ParamsKey = []byte{0x00} - type ( NonrefundableKey struct{} DisableDenomCompositionKey struct{} - ProcessedKey struct{} ) func RefundPacketKey(channelID, portID string, sequence uint64) []byte { From 08a1ec59566b4cadc5f97327b7dee547060eadc2 Mon Sep 17 00:00:00 2001 From: Justin Tieri <37750742+jtieri@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:08:22 -0500 Subject: [PATCH 2/3] refactor: ensure the underlying apps `OnRecvPacket` callback is invoked --- .../packetforward/ibc_middleware.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/middleware/packet-forward-middleware/packetforward/ibc_middleware.go b/middleware/packet-forward-middleware/packetforward/ibc_middleware.go index db77d1eb..b370b69a 100644 --- a/middleware/packet-forward-middleware/packetforward/ibc_middleware.go +++ b/middleware/packet-forward-middleware/packetforward/ibc_middleware.go @@ -211,6 +211,11 @@ func (im IBCMiddleware) OnRecvPacket( return newErrorAcknowledgement(fmt.Errorf("failed to construct override receiver: %w", err)) } + if err := im.receiveFunds(ctx, packet, data, overrideReceiver, relayer); err != nil { + logger.Error("packetForwardMiddleware OnRecvPacket error receiving packet", "error", err) + return newErrorAcknowledgement(fmt.Errorf("error receiving packet: %w", err)) + } + // if this packet's token denom is already the base denom for some native token on this chain, // we do not need to do any further composition of the denom before forwarding the packet denomOnThisChain := data.Denom From ee0dd8feb17a656be94fe039a889d5483c6b00d2 Mon Sep 17 00:00:00 2001 From: Justin Tieri <37750742+jtieri@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:21:11 -0500 Subject: [PATCH 3/3] docs: fix broken link to Defund-Labs interquery. I cannot find a link to the code so this now links to the spec --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6362410..d741cd86 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Modules and middleware developed by other awesome teams in the ecosystem: | Name | Type | Stakeholders | Description | | ---- | ---- | ------------ | ----------- | | [Interchain KV Queries](https://github.com/ingenuity-build/interchain-queries) | Module | [Ingenuity](https://github.com/ingenuity-build) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. | -| [query](https://github.com/defund-labs/defund/tree/main/x/query) | Module | [Defund Labs](https://github.com/defund-labs) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. Similar to the interchain-queries application in the row above but without callbacks. | +| [query](https://github.com/defund-labs/interquery) | Module | [Defund Labs](https://github.com/defund-labs) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. Similar to the interchain-queries application in the row above but without callbacks. | | [NFT Transfer (ICS 721)](https://github.com/bianjieai/nft-transfer) | Module | [Bianjieai](https://github.com/bianjieai) | An application that enables cross chain NFT transfer. | | [CosmWasm NFT Transfer (ICS 721)](https://github.com/public-awesome/cw-ics721) | Wasm Contract | [Public Awesome (Stargaze)](https://github.com/public-awesome), [Ark Protocol](https://x.com/ArkProtocol) | An application that enables cross chain NFT transfer. CosmWasm implementation of the above, written in Rust. | | [recovery](https://github.com/evmos/evmos/tree/v15.0.0/x/recovery) | Middleware | [Evmos](https://github.com/evmos) | Middleware enabling the recovery of tokens sent to unsupported addresses. |