-
Notifications
You must be signed in to change notification settings - Fork 170
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
Conversation
WalkthroughThe 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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
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
tocosmossdk.io/math.Int
for thebid_amount
field inMsgRewardsBid
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
andGetSigners
forMsgGovSetRewardsParams
correctly uses the new validation checkers and aligns with best practices for message validation in the SDK.- 42-58: The implementation of
ValidateBasic
andGetSigners
forMsgRewardsBid
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 oft.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 oft.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 anIsPositive
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
andBigNumPositive
are comprehensive, covering a range of scenarios to ensure the validation functions work as expected. The consistent use oft.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 oft.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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-approving
There was a problem hiding this 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
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 withcosmos.AddressString
scalar type is correctly implemented and follows protobuf conventions.- 22-22: The
highest_bid
field is correctly defined using thecosmos.base.v1beta1.Coin
type and is appropriately marked as non-nullable.- 25-25: The
current_rewards
field is correctly defined as a repeated field ofcosmos.base.v1beta1.Coin
and is non-nullable, following protobuf best practices for representing multiple coin types.- 28-29: The
next_rewards
andcurrent_rewards_auction_end
fields are correctly defined with their respective types and marked as non-nullable. The use ofgogoproto.stdtime
for the timestamp field is a good practice.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ 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
|
There was a problem hiding this 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
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
// Umee creates a BondDenom sdk.Coin with the given amount | ||
func Umee(amount int64) sdk.Coin { | ||
return sdk.NewInt64Coin(umee, amount) | ||
} |
There was a problem hiding this comment.
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.
// UmeeCoins creates an Umee (uumee) sdk.Coins with the given amount | ||
func UmeeCoins(amount int64) sdk.Coins { | ||
return sdk.NewCoins(sdk.NewInt64Coin(umee, amount)) |
There was a problem hiding this comment.
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.
Description
Summary by CodeRabbit