Skip to content
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

Conversation

crodriguezvega
Copy link
Contributor

Description

Also found while testing with hermes: a valid MsgRegisterInterchainAccount messages can be constructed and submitted with NONE order. The channel will not be created because an error is returned in ValidateBasic of MsgChannelOpenInit, but I thought it would be nicer to do the same check in the ValidateBasic of MsgRegisterInterchainAccount.

However, I was also thinking that maybe we actually shouldn't do this check at all in ValidateBasic and just set the order to ORDERED if the value passed in registerInterchainAccount is NONE. That way I think we preserve backwards compatibility better, because upstream users don't need to change the existing code they may have creating a MsgRegisterInterchainAccount, 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 in release/v8.1.x we could implement the other solution.

Looking forward to reading people's thoughts.

closes: #XXXX

Commit Message / Changelog Entry

type: commit message

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.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

@@ -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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

@crodriguezvega crodriguezvega Jan 21, 2024

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?

Copy link
Contributor

@DimitrisJim DimitrisJim Jan 22, 2024

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, go for it!

Copy link
Contributor

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-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (59ac9b2) 81.16% compared to head (458e311) 81.17%.
Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           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           
Files Coverage Δ
...ps/27-interchain-accounts/controller/types/msgs.go 100.00% <100.00%> (ø)
modules/core/04-channel/types/channel.go 77.21% <100.00%> (ø)

@@ -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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@crodriguezvega crodriguezvega merged commit 1c1f2fc into main Jan 23, 2024
63 checks passed
@crodriguezvega crodriguezvega deleted the carlos/check-order-msgregisterinterchainaccount-validatebasic branch January 23, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants