-
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
imp: check order in validate basic of MsgRegisterInterchainAccount
#5671
Changes from 1 commit
458e311
51b29f3
25b69bf
664701a
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 |
---|---|---|
|
@@ -72,6 +72,13 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { | |
}, | ||
false, | ||
}, | ||
{ | ||
"order is not valid", | ||
func() { | ||
msg.Order = channeltypes.NONE | ||
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. Small nit I just realised: in the protos we called this field 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. yea, think we should! can push directly here if you want me to. 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, go for it! 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. ah, would be nice to backport that change and just saw about BP this PR. can open as separate instead to have it backport cleanly |
||
}, | ||
false, | ||
}, | ||
} | ||
|
||
for i, tc := range testCases { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package types | ||
|
||
import ( | ||
"slices" | ||
|
||
errorsmod "cosmossdk.io/errors" | ||
|
||
host "github.com/cosmos/ibc-go/v8/modules/core/24-host" | ||
|
@@ -68,7 +70,7 @@ func (ch Channel) ValidateBasic() error { | |
if ch.State == UNINITIALIZED { | ||
return ErrInvalidChannelState | ||
} | ||
if !(ch.Ordering == ORDERED || ch.Ordering == UNORDERED) { | ||
if !slices.Contains([]Order{ORDERED, UNORDERED}, ch.Ordering) { | ||
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. I took the liberty to make this small improvement. |
||
return errorsmod.Wrap(ErrInvalidChannelOrdering, ch.Ordering.String()) | ||
} | ||
if len(ch.ConnectionHops) != 1 { | ||
|
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.
I asked about this in security audit and though it does indeed get handled later on I do think having explicit ordering check here also makes sense. Only worry is something like #5668 occurring again, maybe we can add these checks in spec too?
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.
Sounds good to include it in the spec as well. I have this PR with ICS 27 updates, so I can include it there.