-
Notifications
You must be signed in to change notification settings - Fork 637
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
imp: check order in validate basic of MsgRegisterInterchainAccount
#5671
Conversation
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty to make this small improvement.
{ | ||
"order is not valid", | ||
func() { | ||
msg.Order = channeltypes.NONE |
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.
Small nit I just realised: in the protos we called this field order
for MsgRegisterInterchainAccount
, while in MsgChannelOpenInit
is called ordering
. Should we rename order
to ordering
for consistency?
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.
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 comment
The 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 comment
The 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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5671 +/- ##
=======================================
Coverage 81.16% 81.17%
=======================================
Files 199 199
Lines 15278 15281 +3
=======================================
+ Hits 12401 12404 +3
Misses 2408 2408
Partials 469 469
|
@@ -41,6 +42,10 @@ func (msg MsgRegisterInterchainAccount) ValidateBasic() error { | |||
return errorsmod.Wrap(err, "invalid connection ID") | |||
} | |||
|
|||
if !slices.Contains([]channeltypes.Order{channeltypes.ORDERED, channeltypes.UNORDERED}, msg.Order) { |
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.
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!
Description
Also found while testing with hermes: a valid
MsgRegisterInterchainAccount
messages can be constructed and submitted withNONE
order. The channel will not be created because an error is returned inValidateBasic
ofMsgChannelOpenInit
, but I thought it would be nicer to do the same check in theValidateBasic
ofMsgRegisterInterchainAccount
.However, I was also thinking that maybe we actually shouldn't do this check at all in
ValidateBasic
and just set the order toORDERED
if the value passed inregisterInterchainAccount
isNONE
. That way I think we preserve backwards compatibility better, because upstream users don't need to change the existing code they may have creating aMsgRegisterInterchainAccount
, otherwise, they will have to change their code and set a valid ordering.We could leave the
ValidateBasic
check of this PR and merge it to main, but not backport; and then inrelease/v8.1.x
we could implement the other solution.Looking forward to reading people's thoughts.
closes: #XXXX
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.