Repository navigation
Conversation
fix docker
fix docker
|
@greptile review |
Greptile SummaryThis PR upgrades rate-limiting, async-icq, packet-forward-middleware, and ibc-hooks to cosmos-sdk v0.54.x and ibc-go v11, removing the capability module, switching store and log imports to their v2 paths, and implementing the new
Confidence Score: 4/5The migration is mechanically thorough and follows the ibc-go v11 and cosmos-sdk v0.54 guides closely; the only rough edges are two inconsistencies in how SetUnderlyingApplication is guarded across middleware implementations. The core migration work across all four modules looks correct. Two related issues stand out: SetUnderlyingApplication in rate-limiting has no nil guard and silently overwrites a previously-set underlying application, while the packet-forward middleware panics unconditionally even when app was already set via the constructor. Neither is likely to trigger in normal usage given the current simapp wiring, but they represent a fragile divergence from the intended interface contract. modules/rate-limiting/ibc_middleware.go (SetUnderlyingApplication missing nil guard) and middleware/packet-forward-middleware/packetforward/ibc_middleware.go (SetUnderlyingApplication always panics when app is already set via constructor). Important Files Changed
|
| func (im *IBCMiddleware) SetUnderlyingApplication(app porttypes.IBCModule) { | ||
| im.app = app | ||
| } |
There was a problem hiding this comment.
Missing nil guard in
SetUnderlyingApplication
SetUnderlyingApplication silently overwrites im.app even when it was already set by the constructor — unlike the packet-forward middleware, which panics in the same situation. If the IBC framework (or a developer) calls SetUnderlyingApplication after NewIBCMiddleware, the explicitly wired underlying transfer module is replaced without any warning, leading to the middleware silently forwarding to the wrong application.
| // SetUnderlyingApplication sets the underlying IBC application. This function | ||
| // may be used after the middleware's initialization to set the IBC module which | ||
| // is below this middleware. | ||
| func (im *IBCMiddleware) SetUnderlyingApplication(app porttypes.IBCModule) { | ||
| if im.app != nil { | ||
| panic("underlying application already set") | ||
| } | ||
| im.app = app | ||
| } |
There was a problem hiding this comment.
The
SetUnderlyingApplication guard correctly panics when im.app is already set, but im.app is always set via the constructor — so this guard will always fire for any caller trying to use the ibc-go v11 programmatic wiring pattern. Consider allowing it to be set only when im.app is nil so the middleware can support both construction patterns.
| // SetUnderlyingApplication sets the underlying IBC application. This function | |
| // may be used after the middleware's initialization to set the IBC module which | |
| // is below this middleware. | |
| func (im *IBCMiddleware) SetUnderlyingApplication(app porttypes.IBCModule) { | |
| if im.app != nil { | |
| panic("underlying application already set") | |
| } | |
| im.app = app | |
| } | |
| // SetUnderlyingApplication sets the underlying IBC application. This function | |
| // may be used after the middleware's initialization to set the IBC module which | |
| // is below this middleware. | |
| func (im *IBCMiddleware) SetUnderlyingApplication(app porttypes.IBCModule) { | |
| if app == nil { | |
| panic("underlying IBC application cannot be nil") | |
| } | |
| im.app = app | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| // BindPort stores the provided portID and binds to it, returning the associated capability | ||
| func (k Keeper) BindPort(ctx sdk.Context, portID string) error { | ||
| capability := k.portKeeper.BindPort(ctx, portID) | ||
| return k.ClaimCapability(ctx, capability, host.PortPath(portID)) | ||
| } | ||
|
|
||
| // IsBound checks if the interchain query already bound to the desired port | ||
| func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { | ||
| _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) | ||
| return ok | ||
| // WithICS4Wrapper sets the ICS4Wrapper. This function may be used after the | ||
| // keeper's creation to set the middleware which is above this module in the | ||
| // IBC application stack. |
There was a problem hiding this comment.
WithICS4Wrapper naming differs from the rest of the codebase
All other middlewares in this PR name the equivalent setter SetICS4Wrapper (rate-limiting keeper.go, packet-forward keeper.go). Using WithICS4Wrapper here is inconsistent and forces IBCModule.SetICS4Wrapper to dispatch through a differently-named method, making the call graph harder to follow. Renaming to SetICS4Wrapper would align with the pattern across modules.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
This PR is not needed since we are going to release rate-limiting for v11 in ibc-go. And have already released pfm for v11 in ibc-go. We updated ibc-hooks here already. And we have no plans for async-icq or polytone |
cosmossdk.io/storetostore/v2,cosmossdk.io/logtolog/v2SetICS4Wrapper/SetUnderlyingApplicationon middleware