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 CL pool valid key length check #1634

Merged
merged 1 commit into from
May 29, 2024
Merged

Conversation

joe-bowman
Copy link
Contributor

1. Summary

Fixes issue in checking CL pool key validity in updateosmosisclpool callback.

CL pool keys are formed by prefix + []byte(pool_id.(string))

vs.

Gamm pool keys which are prefix + encode(uint64)

Gamm pool keys are always 9 bytes in length
CL pool keys are 2 bytes for pools 1-9, 3 bytes for pools 10-99, etc.

Key length check should reflect this.

Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quicksilver ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2024 9:56pm

Copy link
Contributor

coderabbitai bot commented May 28, 2024

Walkthrough

The recent update to the OsmosisClPoolUpdateCallback function in callbacks.go modifies the validation logic for the length of query.Request. The new condition checks for a minimum length of 2 bytes, specifically looking for the byte 0x03 followed by poolID, whereas the previous version required at least 5 bytes. This change likely aims to streamline and simplify the validation process.

Changes

File Path Change Summary
x/participationrewards/keeper/callbacks.go Updated validation logic for query.Request length in OsmosisClPoolUpdateCallback function.

Poem

In bytes we trust, a change so neat,
From five to two, a code retreat.
With 0x03 and poolID in tow,
The simpler path is now the flow.
A rabbit's hop through lines of code,
To streamline checks, a lighter load.
🐇✨


Tip

Early Access Features
  • gpt-4o model for chat

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 full the 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.

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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 82c2146 and 9544ac3.
Files selected for processing (1)
  • x/participationrewards/keeper/callbacks.go (1 hunks)
Additional comments not posted (1)
x/participationrewards/keeper/callbacks.go (1)

174-175: The updated key length and prefix checks align with the PR's objectives to handle variable CL pool key lengths and ensure correct prefixes.

Verification successful

The function OsmosisClPoolUpdateCallback is used in several places, including the main implementation file and test files. To ensure the changes are correct, we need to review the function's implementation and the test cases that cover it.


The implementation of the OsmosisClPoolUpdateCallback function and its corresponding test cases have been retrieved. The function includes checks for the length of query.Request and the prefix, ensuring they meet the expected criteria. The test cases in callbacks_test.go cover various scenarios, including the unmarshalling of responses and validation of protocol data.

The changes made to the function appear to be correctly implemented and are adequately tested.

  • The function checks if query.Request is at least 2 bytes long.
  • It verifies that the first byte of query.Request is 0x03.
  • The test cases validate these checks and ensure the function behaves as expected.

Based on the retrieved information, the changes are correctly implemented and tested.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the behavior of the updated key length and prefix checks.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type go $'OsmosisClPoolUpdateCallback'

Length of output: 1085



Script:

#!/bin/bash
# Description: Retrieve the implementation of the OsmosisClPoolUpdateCallback function and relevant test cases.

# Retrieve the implementation of the OsmosisClPoolUpdateCallback function
ast-grep --lang go --pattern $'func OsmosisClPoolUpdateCallback($_, $_, $_, $_) $_' 

# Retrieve the test cases for OsmosisClPoolUpdateCallback
ast-grep --lang go --pattern $'func (suite *KeeperTestSuite) TestOsmosisClPoolUpdateCallback() $_'

Length of output: 9639

Copy link

codecov bot commented May 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 63.72%. Comparing base (82c2146) to head (9544ac3).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1634   +/-   ##
=======================================
  Coverage   63.72%   63.72%           
=======================================
  Files         194      194           
  Lines       13740    13740           
=======================================
  Hits         8756     8756           
  Misses       4130     4130           
  Partials      854      854           
Flag Coverage Δ
unittests 63.72% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
x/participationrewards/keeper/callbacks.go 52.01% <0.00%> (ø)

@joe-bowman joe-bowman merged commit 0d4322f into main May 29, 2024
20 of 21 checks passed
@joe-bowman joe-bowman deleted the cl-pool-valid-key-check branch May 29, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants