-
Notifications
You must be signed in to change notification settings - Fork 579
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
items from first channel upgrades security audit session #5664
Changes from all commits
cec32d1
ef28df7
0b76ef2
24cdd1d
d9abb10
5807f05
5d98593
fcb8aac
edc8f99
ac1ca8c
63f05fd
e13a382
76b7ec9
52542e5
2dc7ebd
ff35306
31cbfde
dbd8a28
9242b05
aa9a71b
a0705e6
20db85c
b781477
61bfcd5
87c5344
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,8 +119,17 @@ func (u *UpgradeError) GetErrorReceipt() ErrorReceipt { | |
} | ||
} | ||
|
||
// IsUpgradeError returns true if err is of type UpgradeError, otherwise false. | ||
// IsUpgradeError returns true if err is of type UpgradeError or contained | ||
// in the error chain of err and false otherwise. | ||
func IsUpgradeError(err error) bool { | ||
_, ok := err.(*UpgradeError) | ||
return ok | ||
for { | ||
_, ok := err.(*UpgradeError) | ||
if ok { | ||
return true | ||
} | ||
|
||
if err = errors.Unwrap(err); err == nil { | ||
return false | ||
} | ||
} | ||
Comment on lines
+125
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the presence of this function, means we can actually update the // Unwrap returns the base error that caused the upgrade to fail.
func (u *UpgradeError) Unwrap() error {
return errors.Unwrap(u.err)
} And the corresponding test can be updated to // TestUpgradeErrorUnwrap tests that the underlying error is not modified when Unwrap is called.
func (suite *TypesTestSuite) TestUpgradeErrorUnwrap() {
baseUnderlyingError := errorsmod.Wrap(types.ErrInvalidChannel, "base error")
wrappedErr := errorsmod.Wrap(baseUnderlyingError, "wrapped error")
upgradeError := types.NewUpgradeError(1, wrappedErr)
originalUpgradeError := upgradeError.Error()
unWrapped := errors.Unwrap(upgradeError)
postUnwrapUpgradeError := upgradeError.Error()
suite.Require().Equal(baseUnderlyingError, unWrapped, "unwrapped error was not equal to base underlying error")
suite.Require().Equal(originalUpgradeError, postUnwrapUpgradeError, "original error was modified when unwrapped")
} I think I like this better since it becomes more of a direct passthrough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, |
||
} |
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.
Hmm, I guess the reason we had to the logger at the bottom is that
startFlushing
might move the channel state from OPEN to FLUSHING, but, the previous channel state also could have been FLUSHING. A bit of a rock and a hard place