-
Notifications
You must be signed in to change notification settings - Fork 596
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
imp: create and reuse errors in core channel upgrades handlers #5389
Conversation
Hi, it looks like there's some compiler errors here from a redeclared function. I would also suggest naming the errors - invalidupgraderoute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
+ err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module) |
cleaned the history up since it was bringing in 350 commits with a 25k diff 😅. should ideally look clean and reviewable now ✨ |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #5389 +/- ##
==========================================
- Coverage 81.27% 81.20% -0.08%
==========================================
Files 197 197
Lines 15234 15235 +1
==========================================
- Hits 12382 12372 -10
- Misses 2391 2400 +9
- Partials 461 463 +2
|
It is uneeded if the if guard fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @vishal-kanna
@@ -856,19 +856,22 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh | |||
|
|||
app, ok := k.Router.GetRoute(module) | |||
if !ok { | |||
ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) | |||
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) | |||
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could reinitialise new errors here as they'd be within the scope of the if
, but I don't really feel super strong on it and happy to reuse err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will push it in as is for now, can't say I have a strong pref either way too (slight preference for yours since it scopes values nicely but not enough pref to make the change)
} | ||
|
||
err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) | ||
if err != nil { | ||
ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel upgrade ack failed")) | ||
errChanUpgradeFailed := errorsmod.Wrap(err, "channel upgrade ack failed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not to reuse err
here instead of creating a new var with a different name?
err = errorsmod.Wrap(err, "channel upgrade ack failed")
should work fine too, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damiannolan Using the err works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah it won't. IsUpgradeError
is a direct cast to UpgradeError
, wrapping causes it to fail. (I think Cian mentioned this in a call at some point).
do we backport to 8.1? cc @crodriguezvega |
imp: create and reuse errors in core channel upgrades handlers --------- Co-authored-by: DimitrisJim <[email protected]> Co-authored-by: Cian Hatton <[email protected]> (cherry picked from commit b68c4aa)
#5557) imp: create and reuse errors in core channel upgrades handlers --------- Co-authored-by: DimitrisJim <[email protected]> Co-authored-by: Cian Hatton <[email protected]> (cherry picked from commit b68c4aa) Co-authored-by: Vishal Potpelliwar <[email protected]>
closes #5378