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

feat(auction) msgs interfaces and validation #2475

Merged
merged 11 commits into from
Mar 28, 2024
Merged

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Mar 26, 2024

Description

  • sdk.Msg implementation for auction messages
  • added new checkers
  • updated tests

Summary by CodeRabbit

  • New Features
    • Introduced new validation functions for numerical inputs, enhancing input data integrity.
  • Changes
    • Updated the auction system to use a custom type for representing bid amounts, improving precision.
  • Bug Fixes
    • Removed an obsolete field related to revenue collection in the auction system, streamlining the data model.
  • Tests
    • Enhanced testing suite with parallel execution and new test cases for numerical validations and auction system functionalities.

@robert-zaremba robert-zaremba requested a review from a team as a code owner March 26, 2024 14:39
@robert-zaremba robert-zaremba added the skip-e2e-test Skip the e2e tests label Mar 26, 2024
Copy link
Contributor

coderabbitai bot commented Mar 26, 2024

Walkthrough

The recent updates involve modifications to the auction system in a blockchain protocol. A specific field related to revenue collection has been removed from reward parameters, and the type for bid amounts in auction bids has been switched to a custom type for better representation. Additionally, new utility functions for number checking have been introduced, alongside tests for these functions and auction-related messages, enhancing validation and efficiency in the system.

Changes

Files Change Summary
proto/umee/auction/v1/auction.proto Removed revenu_collection_shift from RewardsParams
proto/umee/auction/v1/tx.proto Replaced cosmos.base.v1beta1.Coin with cosmossdk.io/math.Int for bid_amount in MsgRewardsBid
proto/umee/auction/v1/genesis.proto Updated fields in GenesisState message, added highest_bid, adjusted indices
util/checkers/number.go
util/checkers/number_test.go
Added functions and tests for number checking, updated error messages
util/coin/fixtures.go Added global variable UmeeDenom initialized with value umee
x/auction/msgs.go
x/auction/msgs_test.go
Added message types and tests for auction system operations

🐰✨
In the realm of code, where changes abound,
A rabbit hopped, leaving footprints on the ground.
Fields were removed, types transformed with care,
New checks were made, with precision rare.
"To improve, to enhance," the rabbit did declare,
With every line of code, a meticulous affair.
🌟🐾

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-tests 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@robert-zaremba robert-zaremba requested a review from gsk967 March 26, 2024 14:39
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 820a6f2 and 19ea1b9.
Files ignored due to path filters (2)
  • x/auction/auction.pb.go is excluded by: !**/*.pb.go
  • x/auction/tx.pb.go is excluded by: !**/*.pb.go
Files selected for processing (6)
  • proto/umee/auction/v1/auction.proto (1 hunks)
  • proto/umee/auction/v1/tx.proto (2 hunks)
  • util/checkers/number.go (1 hunks)
  • util/checkers/number_test.go (4 hunks)
  • x/auction/msgs.go (1 hunks)
  • x/auction/msgs_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • proto/umee/auction/v1/auction.proto
Additional comments: 11
proto/umee/auction/v1/tx.proto (1)
  • 46-46: The change from cosmos.base.v1beta1.Coin to cosmossdk.io/math.Int for the bid_amount field in MsgRewardsBid is noted. Ensure that the new type is consistently used across the system and is well-documented to avoid confusion.
x/auction/msgs.go (2)
  • 21-30: The implementation of ValidateBasic and GetSigners for MsgGovSetRewardsParams correctly uses the new validation checkers and aligns with best practices for message validation in the SDK.
  • 42-58: The implementation of ValidateBasic and GetSigners for MsgRewardsBid effectively uses the new validation checkers for comprehensive input validation, adhering to SDK standards.
x/auction/msgs_test.go (2)
  • 13-42: The tests for MsgGovSetRewardsParams are comprehensive, covering a range of scenarios to ensure the message's validation logic works as expected. The use of t.Parallel() for parallel test execution is a good practice.
  • 44-74: The tests for MsgRewardsBid effectively validate the message's validation logic under various scenarios, ensuring robustness. The consistent use of t.Parallel() enhances test execution efficiency.
util/checkers/number.go (3)
  • 30-35: The NumberMin function correctly checks if a number meets a specified minimum value, enhancing validation capabilities. The implementation is generic and the error message is clear.
  • 37-42: The NumberPositive function effectively ensures a number is positive, contributing to the system's robust validation mechanisms. The implementation is generic, making it versatile for various use cases.
  • 44-46: The BigNumPositive function extends validation capabilities to complex numeric types with an IsPositive method, ensuring versatility in validation checks. The implementation is clear and the error message is appropriate.
util/checkers/number_test.go (3)
  • 98-127: The tests for NumberPositive and BigNumPositive are comprehensive, covering a range of scenarios to ensure the validation functions work as expected. The consistent use of t.Parallel() enhances test execution efficiency.
  • 129-147: The tests for NumberMin effectively validate the function's ability to check minimum values under various scenarios, ensuring robustness. The consistent use of t.Parallel() enhances test execution efficiency.
  • 33-39: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [12-90]

The inclusion of t.Parallel() in all tests contributes to the efficiency of the test suite, ensuring that the validation logic is thoroughly tested across various scenarios.

Copy link
Collaborator

@gsk967 gsk967 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

x/auction/msgs.go Outdated Show resolved Hide resolved
proto/umee/auction/v1/tx.proto Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 19ea1b9 and 3f5d854.
Files ignored due to path filters (2)
  • x/auction/genesis.pb.go is excluded by !**/*.pb.go
  • x/auction/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (5)
  • proto/umee/auction/v1/genesis.proto (1 hunks)
  • proto/umee/auction/v1/tx.proto (2 hunks)
  • util/coin/fixtures.go (1 hunks)
  • x/auction/msgs.go (1 hunks)
  • x/auction/msgs_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • proto/umee/auction/v1/tx.proto
  • x/auction/msgs.go
  • x/auction/msgs_test.go
Additional comments (4)
proto/umee/auction/v1/genesis.proto (4)
  • 21-21: The addition of the highest_bidder field with cosmos.AddressString scalar type is correctly implemented and follows protobuf conventions.
  • 22-22: The highest_bid field is correctly defined using the cosmos.base.v1beta1.Coin type and is appropriately marked as non-nullable.
  • 25-25: The current_rewards field is correctly defined as a repeated field of cosmos.base.v1beta1.Coin and is non-nullable, following protobuf best practices for representing multiple coin types.
  • 28-29: The next_rewards and current_rewards_auction_end fields are correctly defined with their respective types and marked as non-nullable. The use of gogoproto.stdtime for the timestamp field is a good practice.

util/coin/fixtures.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

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

Project coverage is 69.25%. Comparing base (7f05ad4) to head (31998a5).
Report is 427 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2475      +/-   ##
==========================================
- Coverage   75.38%   69.25%   -6.14%     
==========================================
  Files         100      189      +89     
  Lines        8025    10968    +2943     
==========================================
+ Hits         6050     7596    +1546     
- Misses       1589     2742    +1153     
- Partials      386      630     +244     
Files Coverage Δ
util/checkers/number.go 84.09% <100.00%> (ø)
util/coin/fixtures.go 16.66% <0.00%> (ø)
x/auction/msgs.go 45.45% <45.45%> (ø)

... and 178 files with indirect coverage changes

@robert-zaremba robert-zaremba added this pull request to the merge queue Mar 28, 2024
Merged via the queue into main with commit 740718f Mar 28, 2024
23 of 26 checks passed
@robert-zaremba robert-zaremba deleted the robert/auction-msgs branch March 28, 2024 09:32
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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3f5d854 and 31998a5.
Files selected for processing (2)
  • util/coin/fixtures.go (1 hunks)
  • x/auction/msgs_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/auction/msgs_test.go

Comment on lines +44 to +47
// Umee creates a BondDenom sdk.Coin with the given amount
func Umee(amount int64) sdk.Coin {
return sdk.NewInt64Coin(umee, amount)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The Umee function correctly creates a sdk.Coin with the umee denomination. However, it's important to ensure that new functions are covered by tests to verify their correctness and behavior under various conditions.

Consider adding unit tests for the Umee function to cover different amounts, including edge cases.

Comment on lines +49 to 51
// UmeeCoins creates an Umee (uumee) sdk.Coins with the given amount
func UmeeCoins(amount int64) sdk.Coins {
return sdk.NewCoins(sdk.NewInt64Coin(umee, amount))
Copy link
Contributor

Choose a reason for hiding this comment

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

The UmeeCoins function correctly creates sdk.Coins with the umee denomination. As with any new functionality, it's crucial to have test coverage to ensure the function behaves as expected under various scenarios.

Consider adding unit tests for the UmeeCoins function, focusing on different amounts and edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-e2e-test Skip the e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants