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

fix: ibc transfer memo and receiver length check #2551

Merged
merged 6 commits into from
Jun 18, 2024

Conversation

gsk967
Copy link
Collaborator

@gsk967 gsk967 commented Jun 17, 2024

Description

closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features

    • Added validation to the ibc-transfer message receiver and memo fields to reduce spam transactions.
    • Implemented a new function to generate random strings of specified lengths.
  • Bug Fixes

    • Improved error handling in the SendIBC function for transaction hash outputs.
    • Removed redundant lint directive in error handling for historical median calculations.
  • Tests

    • Enhanced end-to-end tests for IBC token transfers to include address and memo validation checks.

Copy link
Contributor

coderabbitai bot commented Jun 17, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The v6.5.0 update focuses on enhancing message validation and handling within the ibc-transfer module. It includes new validation checks for receiver addresses and memos to mitigate spam transactions, upgrades registration in UmeeApp, and improvements in error handling and testing. A new utility function is also introduced to generate random strings, aiding in testing.

Changes

Files Changes Summary
CHANGELOG.md, RELEASE_NOTES.md Documented bug fixes and validation updates for ibc-transfer message receiver.
app/upgrades.go Registered upgrade handlers for version v6.5.
tests/e2e/e2e_ibc_test.go, tests/e2e/setup/utils.go Enhanced tests to include receiver address length checks and updated error handling.
util/ibc/ibc.go, util/ibc/ibc_test.go Added constants and functions for validation; updated test cases for validation checks.
util/sdkutil/string.go Introduced function to generate random strings.
x/oracle/keeper/historic_price.go Improved error handling by removing //nolint: goconst directive.

Poem

In the code’s vast land, a bug was found,
Transfers spamming without a bound.
But with version six point five,
New checks arrive, spam won’t thrive.
Changes clean and tests robust,
Umee’s safeguards now adjust. 🐇🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gsk967 gsk967 marked this pull request as ready for review June 17, 2024 16:53
@gsk967 gsk967 requested review from a team as code owners June 17, 2024 16:53
tests/e2e/e2e_ibc_test.go Outdated Show resolved Hide resolved
x/oracle/keeper/historic_price.go Show resolved Hide resolved
util/sdkutil/string.go Outdated Show resolved Hide resolved
RELEASE_NOTES.md Outdated Show resolved Hide resolved
Copy link
Contributor

coderabbitai bot commented Jun 17, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hoffmabc
Copy link

  • Need to update those explorer links in the markdown noted in CI.
  • Check on the govulncheck issues

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (1)
util/ibc/ibc.go (1)

14-30: The constants MaximumReceiverLength and MaximumMemoLength are set to very high values. Consider whether these limits are practical or if they should be reduced to prevent potential abuse.

It might be beneficial to consult with the network security team or check the typical lengths used in the industry to set these constants appropriately.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8f493e8 and 6d7c8c2.

Files selected for processing (9)
  • CHANGELOG.md (1 hunks)
  • RELEASE_NOTES.md (1 hunks)
  • app/upgrades.go (1 hunks)
  • tests/e2e/e2e_ibc_test.go (2 hunks)
  • tests/e2e/setup/utils.go (1 hunks)
  • util/ibc/ibc.go (2 hunks)
  • util/ibc/ibc_test.go (2 hunks)
  • util/sdkutil/string.go (2 hunks)
  • x/oracle/keeper/historic_price.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
util/sdkutil/string.go

[warning] 35-35: util/sdkutil/string.go#L35
Added line #L35 was not covered by tests


[warning] 37-40: util/sdkutil/string.go#L37-L40
Added lines #L37 - L40 were not covered by tests


[warning] 42-42: util/sdkutil/string.go#L42
Added line #L42 was not covered by tests

util/ibc/ibc.go

[warning] 50-50: util/ibc/ibc.go#L50
Added line #L50 was not covered by tests

x/oracle/keeper/historic_price.go

[warning] 48-48: x/oracle/keeper/historic_price.go#L48
Added line #L48 was not covered by tests

LanguageTool
RELEASE_NOTES.md

[typographical] ~11-~11: It appears that a comma is missing. (DURING_THAT_TIME_COMMA)
Context: ...rocedure) document. ## v6.5.0 In this release we are adding validations to ibc-transf...


[uncategorized] ~15-~15: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...se updates our dependencies and applies latest patches to the v6.4.x line. All validat...


[grammar] ~47-~47: The auxiliary verb ‘do’ requires the base form of the verb. (DID_BASEFORM)
Context: ...ved that Price Feeder doesn't correctly re-established a connection after the chain upgrade. ...


[uncategorized] ~51-~51: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...ld the binary from source on the server machine you probably don't need any change. How...


[uncategorized] ~60-~60: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: .... ### Upgrade instructions - Download latest binary or build from source. - Make sur...


[uncategorized] ~65-~65: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...hain upgrade. - Swap binaries. - Ensure latest Price Feeder (see [compatibility matrix...

CHANGELOG.md

[grammar] ~107-~107: Using ‘plenty’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: .../pull/2368) Fix inflow amount calculation. Previously, the inflow amount of the t...


[grammar] ~209-~209: Did you mean “limiting”? Or maybe you should add a pronoun? In active voice, ‘allow’ + ‘to’ takes an object, usually a pronoun. (ALLOW_TO)
Context: ...veragedLiquidate.MaxRepay` which allows to limit the liquidation size using the leverage...


[grammar] ~342-~342: The singular proper name ‘Bridge’ must be used with a third-person or a past tense verb. (HE_VERB_AGR)
Context: ...-network/umee/pull/1967) Gravity Bridge phase out phase-2: disable Umee -> Ethereum t...


[grammar] ~343-~343: The singular proper name ‘Bridge’ must be used with a third-person or a past tense verb. (HE_VERB_AGR)
Context: ...-network/umee/pull/1967) Gravity Bridge phase out phase-2: disable Umee -> Ethereum t...


[grammar] ~393-~393: Make sure that the singular noun after the number ‘4.1’ is correct. (CD_POINT_CD_NN)
Context: ...e/pull/1807) Fixes BNB ibc denom in 4.1 migration - [1812](https://github.com/umee-networ...


[style] ~411-~411: In contexts where ‘if’ is followed by ‘or’, using ‘whether’ may be more appropriate (and formal). (IF_WHETHER)
Context: ...rowandMsgRepay` won't return errors if there is nothing to withdraw, borrow or...


[duplication] ~462-~462: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...e/pull/1555) Updates IBC to v5.1.0 that adds adds optional memo field to `FungibleTokenPa...


[uncategorized] ~519-~519: A comma may be missing after the conjunctive/linking adverb ‘Also’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
Context: ...ableLend, docs, and internal functions. Also QueryLoaned similar queries to QuerySup...


[misspelling] ~523-~523: This word is normally spelled as one. (EN_COMPOUNDS_PROTO_TYPES)
Context: ...roto getters in x/leverage and x/oracle proto types. - [1126](https://github.com/umee-netwo...


[uncategorized] ~544-~544: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...umee/pull/1157) Added PrintOrErr util function optimizing the CLI code flow. - [1118](...


[duplication] ~642-~642: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...k/umee/pull/1358/files) Disable Gravity Bridge bridge messages. ### Improvements - [#1355](...

Additional comments not posted (5)
util/ibc/ibc.go (1)

40-50: The error handling in GetFundsFromPacket is correctly implemented. However, ensure that the error messages are consistent and informative.

Tools
GitHub Check: codecov/patch

[warning] 50-50: util/ibc/ibc.go#L50
Added line #L50 was not covered by tests

app/upgrades.go (1)

54-54: The registration of the upgrade handler for v6.5 follows established patterns and uses the encapsulated function correctly.

x/oracle/keeper/historic_price.go (1)

48-48: The removal of the //nolint: goconst directive and the addition of error wrapping enhance error clarity and maintainability.

Tools
GitHub Check: codecov/patch

[warning] 48-48: x/oracle/keeper/historic_price.go#L48
Added line #L48 was not covered by tests

tests/e2e/setup/utils.go (1)

145-148: The enhancements in error handling and logging when IBC transfer quotas are exceeded improve the robustness and clarity of the SendIBC function.

CHANGELOG.md (1)

51-51: The entry for PR 2551 in the changelog correctly links to the pull request and briefly describes the change. However, the description could be more specific about what the validation checks for, such as length restrictions or format validations.

util/sdkutil/string.go Outdated Show resolved Hide resolved
tests/e2e/e2e_ibc_test.go Outdated Show resolved Hide resolved
util/ibc/ibc_test.go Outdated Show resolved Hide resolved
RELEASE_NOTES.md Outdated Show resolved Hide resolved
Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

pre-approving.

CHANGELOG.md Outdated Show resolved Hide resolved
tests/e2e/e2e_ibc_test.go Show resolved Hide resolved
util/sdkutil/string.go Outdated Show resolved Hide resolved
util/sdkutil/string.go Outdated Show resolved Hide resolved
x/oracle/keeper/historic_price.go Show resolved Hide resolved
RELEASE_NOTES.md Outdated Show resolved Hide resolved
RELEASE_NOTES.md Show resolved Hide resolved
@robert-zaremba robert-zaremba changed the title fix: fix ibc transfer msg recv legnth check fix: fix ibc transfer msg recv length check Jun 17, 2024
@robert-zaremba robert-zaremba changed the title fix: fix ibc transfer msg recv length check fix: ibc transfer memo and receiver length check Jun 17, 2024
@faddat
Copy link
Contributor

faddat commented Jun 18, 2024

I think that this is a really good way of addressing the issue, I think that it's important that any transaction size management is actually not done in the relay software, but instead enforced by the chain.

The sizes that you have chosen here make sense to me, I do just want to caution that I think that it's possible that someone wanting to interrupt chain functionality in a timed way may Just send lots of little transactions, but this is way better than nothing.

Thank you!

Are you guys able to let me know the longest block times experienced while two wallets were attempting to do IBC transactions with them?

Is the hub Channel currently working?

@gsk967 gsk967 requested a review from hoffmabc June 18, 2024 09:41
@hoffmabc hoffmabc merged commit fb7df57 into release/v6.5 Jun 18, 2024
25 of 27 checks passed
@hoffmabc hoffmabc deleted the sai/add_ibc_transfer_msg_recv_legnth_check branch June 18, 2024 11:03
@robert-zaremba
Copy link
Member

Are you guys able to let me know the longest block times experienced while two wallets were attempting to do IBC transactions with them?

Hi @faddat . Thanks for looking into it , and your work and precautious to alarm the community.
I remember we have already limited the block size last year. But it looks it was not enough.

We don't have information about "longest block times experienced..."

robert-zaremba added a commit that referenced this pull request Jun 18, 2024
* fix: ibc transfer memo and receiver length check (#2551)

* fix

* lint

* lint

---------

Co-authored-by: Sai Kumar <17549398+gsk967@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants