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: fix the query for max withdraw #2638

Merged
merged 2 commits into from
Dec 8, 2024
Merged

fix: fix the query for max withdraw #2638

merged 2 commits into from
Dec 8, 2024

Conversation

gsk967
Copy link
Collaborator

@gsk967 gsk967 commented Dec 6, 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
    • Expanded the range of tokens considered for maximum withdrawal and borrowing calculations by removing the blacklist filter.
  • Bug Fixes
    • Maintained consistent error handling during the retrieval of maximum values to ensure reliability.
  • Chores
    • Updated the Go version across various workflows and Dockerfiles to enhance compatibility and performance.

@gsk967 gsk967 requested a review from a team as a code owner December 6, 2024 14:58
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Walkthrough

The changes in this pull request modify the MaxWithdraw and MaxBorrow methods in the Querier struct located in x/leverage/keeper/grpc_query.go. The key alteration is the removal of the filter for blacklisted tokens in the denoms slice, allowing all registered tokens to be considered for maximum withdrawal and borrowing calculations. The error handling remains unchanged, ensuring consistent behavior during value retrieval while maintaining the existing structure and flow of the methods.

Changes

File Path Change Summary
x/leverage/keeper/grpc_query.go Modified MaxWithdraw and MaxBorrow methods to include all registered tokens in denoms, removing the blacklist filter. Error handling remains consistent.
.github/workflows/codeql-analysis.yml Updated go-version from "1.21" to "1.23" for CodeQL analysis workflow.
.github/workflows/debug.yml Updated go-version from "1.22" to "1.23" for debugging workflow.
.github/workflows/lint.yml Updated go-version from "1.22" to "1.23" for linting workflow.
.github/workflows/release-umee.yml Updated go-version from "1.22" to "1.23" for release workflow.
.github/workflows/simulations.yml Updated go-version from "1.22" to "1.23" for various simulation jobs.
.github/workflows/tests.yml Updated go-version from "1.22" to "1.23" across multiple test jobs and introduced merge_group trigger.
contrib/images/umee.e2e.dockerfile Updated base images to golang:1.23-bookworm and ubuntu:24.04.
contrib/images/umeed.dockerfile Updated base images to golang:1.23-bookworm and ubuntu:24.04.

Possibly related PRs

  • fix: fix the account summary grpc #2528: This PR modifies the AccountSummaries function in a related file, which may involve similar logic changes regarding account balances, potentially impacting how maximum amounts are calculated in the context of the MaxWithdraw and MaxBorrow methods.
  • fix: fix the goreleaser #2581: This PR updates the .github/workflows/release-umee.yml file, which is related to the build and release processes that may indirectly affect the deployment of changes made in the main PR, although it does not directly alter the logic in the grpc_query.go file.

Suggested labels

skip-e2e-test

Poem

🐇 In the meadow where tokens play,
All can join without delay.
Withdraw and borrow, come what may,
No blacklist here, hip-hip-hooray!
With every change, we hop and sway! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3407c72 and bd79aa2.

📒 Files selected for processing (1)
  • x/leverage/keeper/grpc_query.go (1 hunks)
🔇 Additional comments (1)
x/leverage/keeper/grpc_query.go (1)

Line range hint 303-359: LGTM on error handling

The error handling in MaxWithdraw is comprehensive and follows good practices:

  • Proper input validation
  • Clear distinction between oracle and non-oracle errors
  • Appropriate handling of edge cases

if !t.Blacklist {
denoms = append(denoms, t.BaseDenom)
}
denoms = append(denoms, t.BaseDenom)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent blacklist filtering between MaxWithdraw and MaxBorrow

There's an inconsistency in how blacklisted tokens are handled:

  • MaxWithdraw now includes all registered tokens
  • MaxBorrow still filters out blacklisted tokens

This divergence in behavior needs clarification:

  1. If blacklisted tokens should be excluded from borrowing but allowed for withdrawal, this is correct but should be documented.
  2. If this is unintentional, one of these methods needs to be updated for consistency.

Would you like me to help document this behavioral difference or align the implementations?

Also applies to: 391-397


💡 Codebase verification

Based on the search results, I can now generate the final response:

Blacklist filtering should be maintained in MaxWithdraw

The removal of blacklist filtering in MaxWithdraw appears to be incorrect based on the codebase analysis:

  • Blacklisted tokens are consistently filtered out across the codebase:
    • In MaxBorrow query, blacklisted tokens are filtered (if !t.Blacklist)
    • Oracle hooks skip blacklisted tokens (if token.Blacklist { return })
    • Token validation requires AssertNotBlacklisted()
    • The protocol documentation states blacklisted assets should be "treated as though its oracle price is zero, and thus ignored by calculations"

The change introduces inconsistency with the rest of the codebase's treatment of blacklisted tokens and should maintain the blacklist filtering.

🔗 Analysis chain

Verify the removal of blacklist filtering

The change removes the blacklist filtering for tokens in MaxWithdraw, allowing all registered tokens to be considered. While this aligns with fixing the max withdraw query, we should verify if this is the intended behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if blacklist filtering is consistently applied across the codebase

# Search for blacklist usage in token filtering
rg -A 5 'Blacklist' 

# Search for MaxWithdraw related tests
ast-grep --pattern 'func TestMaxWithdraw($$$)'

Length of output: 19089

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

🧹 Outside diff range and nitpick comments (1)
.github/workflows/release-umee.yml (1)

Line range hint 1-50: PR scope mismatch: Go version updates vs. max withdraw query fix

This PR's title and description indicate it's meant to fix the query for max withdraw, but these changes are updating Go versions across workflows. This seems to be outside the scope of the original PR objective.

Consider:

  1. Splitting these Go version updates into a separate PR
  2. Updating the PR title and description if these changes are intentional
  3. Removing these changes if they were accidentally included
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bd79aa2 and 6e30706.

📒 Files selected for processing (8)
  • .github/workflows/codeql-analysis.yml (1 hunks)
  • .github/workflows/debug.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/release-umee.yml (1 hunks)
  • .github/workflows/simulations.yml (5 hunks)
  • .github/workflows/tests.yml (4 hunks)
  • contrib/images/umee.e2e.dockerfile (2 hunks)
  • contrib/images/umeed.dockerfile (2 hunks)
🔇 Additional comments (3)
.github/workflows/codeql-analysis.yml (1)

30-30: ⚠️ Potential issue

Caution: Go 1.23 is not yet officially released

The workflow is being updated to use Go 1.23, which hasn't been officially released yet. This could potentially cause instability in the CodeQL security analysis process. Consider keeping the current stable version until Go 1.23 is officially released.

Let's verify the latest stable Go version:

.github/workflows/simulations.yml (1)

18-18: Verify Go 1.23 compatibility and stability

The workflow has been updated to use Go 1.23 across all jobs. Since this is a relatively new Go version, please ensure:

  1. All dependencies are compatible with Go 1.23
  2. The version is production-ready and stable
  3. The upgrade aligns with the project's Go version policy

Also applies to: 43-43, 68-68, 98-98, 127-127

.github/workflows/tests.yml (1)

18-18: Changes align with simulations.yml updates

The Go version updates are consistent with the changes in simulations.yml.

Also applies to: 55-55, 81-81, 113-113

@@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid Go version specified

The specified Go version "1.23" is not yet released. The latest stable version is Go 1.22.x. Using an unreleased version will cause CI failures.

Apply this diff to fix the Go version:

-          go-version: "1.23"
+          go-version: "1.22"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go-version: "1.23"
go-version: "1.22"

@@ -1,7 +1,7 @@
# Docker for e2e testing
# Creates dynamic binaries, by building from the latest version of umeed

FROM golang:1.22-bookworm AS builder
FROM golang:1.23-bookworm AS builder
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid Go version in base image

The specified Go version "1.23" in the base image is not yet released. The latest stable version is Go 1.22.x.

Apply this diff to fix the base image:

-FROM golang:1.23-bookworm AS builder
+FROM golang:1.22-bookworm AS builder
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM golang:1.23-bookworm AS builder
FROM golang:1.22-bookworm AS builder

@@ -18,7 +18,7 @@
RUN make install

## Prepare the final clear binary
FROM ubuntu:23.04
FROM ubuntu:24.04
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid Ubuntu version in base image

Ubuntu 24.04 is not yet released. Consider using Ubuntu 22.04 LTS for better stability and long-term support.

Apply this diff to fix the base image:

-FROM ubuntu:24.04
+FROM ubuntu:22.04
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM ubuntu:24.04
FROM ubuntu:22.04

@@ -14,7 +14,7 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=badgerdb make install

# Stage-2: copy binary and required artifacts to a fresh image
# we need to use debian compatible system.
FROM ubuntu:23.04
FROM ubuntu:24.04
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid Ubuntu version in base image

Ubuntu 24.04 is not yet released. Consider using Ubuntu 22.04 LTS for better stability and long-term support.

Apply this diff to fix the base image:

-FROM ubuntu:24.04
+FROM ubuntu:22.04
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM ubuntu:24.04
FROM ubuntu:22.04

@@ -1,7 +1,7 @@
# Stage-1: build
# We use Debian Bullseye rather then Alpine because Alpine has problem building libwasmvm
# - requires to download libwasmvm_muslc from external source. Build with glibc is straightforward.
FROM golang:1.22-bookworm AS builder
FROM golang:1.23-bookworm AS builder
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid Go version in base image

The specified Go version "1.23" in the base image is not yet released. The latest stable version is Go 1.22.x.

Apply this diff to fix the base image:

-FROM golang:1.23-bookworm AS builder
+FROM golang:1.22-bookworm AS builder
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM golang:1.23-bookworm AS builder
FROM golang:1.22-bookworm AS builder

@@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: "1.22"
go-version: "1.23"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Go 1.23 is not yet supported by golangci-lint

The golangci-lint tool currently uses Go 1.22.1 as specified in its go.mod file. Using Go 1.23 in the workflow could lead to compatibility issues since:

  • The linter hasn't been tested or updated for Go 1.23
  • New language features in Go 1.23 might not be properly analyzed
  • This could result in unreliable linting results or workflow failures

Please update the Go version in the workflow to 1.22 to ensure compatibility with golangci-lint.

🔗 Analysis chain

Verify golangci-lint compatibility with Go 1.23

Using an unreleased Go version (1.23) could cause compatibility issues with golangci-lint. Additionally:

  1. The linter might not fully support Go 1.23 features yet
  2. This could lead to false positives or missed issues in the lint process

Let's check golangci-lint's Go compatibility:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check golangci-lint's supported Go versions
curl -s https://raw.githubusercontent.com/golangci/golangci-lint/master/go.mod | grep -A 1 "go "

Length of output: 390

@@ -22,7 +22,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 6, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Avoid using unreleased Go version for production releases

Using Go 1.23 (unreleased) for building release binaries poses significant risks:

  1. Potential instability in production builds
  2. Lack of security patches and updates for an unreleased version
  3. Possible compatibility issues with dependencies

Consider maintaining the current stable Go version for production releases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you check again, it is already released
https://tip.golang.org/doc/go1.23

Copy link
Contributor

Choose a reason for hiding this comment

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

@gsk967, thank you for the clarification. You're absolutely right; Go 1.23 has been released. The update is appropriate.

(A curious rabbit tilts its head, ears perked up)


✏️ Learnings added
Learnt from: gsk967
PR: umee-network/umee#2638
File: .github/workflows/release-umee.yml:25-25
Timestamp: 2024-12-06T18:52:26.187Z
Learning: Go 1.23 has been officially released and is acceptable for production releases.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.00%. Comparing base (7f05ad4) to head (6e30706).
Report is 554 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2638       +/-   ##
===========================================
- Coverage   75.38%   62.00%   -13.39%     
===========================================
  Files         100      275      +175     
  Lines        8025    19627    +11602     
===========================================
+ Hits         6050    12170     +6120     
- Misses       1589     6685     +5096     
- Partials      386      772      +386     
Files with missing lines Coverage Δ
x/leverage/keeper/grpc_query.go 64.66% <100.00%> (-2.55%) ⬇️

... and 215 files with indirect coverage changes

@gsk967 gsk967 enabled auto-merge December 8, 2024 05:21
@gsk967 gsk967 disabled auto-merge December 8, 2024 05:21
@gsk967 gsk967 merged commit f3a428c into main Dec 8, 2024
24 of 27 checks passed
@gsk967 gsk967 deleted the sai/fix_maxwithdraw_query branch December 8, 2024 05:22
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.

2 participants