-
Notifications
You must be signed in to change notification settings - Fork 30
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
bump up mods.irisnet.org/modules/mt to cosmos-sdk v0.50.10 #447
Conversation
Warning Rate limit exceeded@wangjiulian has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 37 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes in this pull request involve significant updates to the Go modules and dependencies across various files. The Go version is upgraded from 1.19 to 1.21, and a new toolchain version 1.23.1 is introduced. Multiple dependencies are updated to their latest versions, including core libraries and indirect dependencies. Additionally, there are modifications to import paths, particularly shifting from Changes
Poem
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (4)
modules/mt/simulation/genesis.go (1)
Line range hint
1-132
: Consider Go 1.21 improvements and optimizations.Since this PR includes an upgrade to Go 1.21, consider these potential improvements:
- The
genMTs
,genCollections
, andgenOwners
functions could benefit from usingslices
package introduced in Go 1.21 for cleaner slice operations- Consider using
rand.Float64
withmath.Round
for more uniform distribution in balance calculationsExample optimization for balance distribution:
func genDenomBalances(r *rand.Rand, denomId string, mts []mt.MT, accounts []simtypes.Account) []mt.DenomBalance { denomBalances := make([]mt.DenomBalance, len(accounts)) for i := 0; i < len(accounts); i++ { balances := make([]mt.Balance, len(mts)) // amount evenly distributed and sum-up not exceeding the total supply for j := 0; j < len(mts); j++ { - balances[j] = mt.Balance{ - MtId: mts[j].Id, - Amount: mts[j].Supply / uint64(len(accounts)), - } + // More random distribution while maintaining total supply + ratio := math.Round(r.Float64() * 100) / 100 + amount := uint64(float64(mts[j].Supply) * ratio / float64(len(accounts))) + balances[j] = mt.Balance{ + MtId: mts[j].Id, + Amount: amount, + } }e2e/go.mod (1)
Line range hint
214-241
: Consider tracking the TODO comments for replace directives.The replace directives contain important security fixes, but there are TODO comments that should be tracked:
- cosmos-sdk#13134: Remove deprecated jwt-go
- cosmos-sdk#10409: Remove gin-gonic/gin fix after upstream fix
Would you like me to create GitHub issues to track these TODOs?
modules/mt/simulation/operations.go (1)
Line range hint
513-513
: Fix unsafe integer conversion in SimulateMsgBurnMTThe comment indicates an unsafe conversion from
int
touint64
. This could lead to potential issues if the random value is negative.Apply this fix:
-amt = uint64(simtypes.RandIntBetween(r, 1, int(amt))) // unsafe conversion +amt = uint64(simtypes.RandIntBetween(r, 1, int(math.MaxInt64))) +if amt > k.GetBalance(ctx, denomID, mtr.Id, sender.Address) { + amt = k.GetBalance(ctx, denomID, mtr.Id, sender.Address) +}modules/mt/go.mod (1)
Line range hint
162-164
: Address the Deprecated jwt-go DependencyThe package
github.com/dgrijalva/jwt-go
is deprecated and has been replaced withgithub.aaakk.us.kg/golang-jwt/jwt/v4 v4.4.2
. There's a TODO to remove the deprecated dependency: cosmos-sdk issue #13134. Consider addressing this to enhance security and reduce reliance on deprecated libraries.Would you like assistance in updating the codebase to fully migrate away from the deprecated dependency?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (2)
e2e/go.sum
is excluded by!**/*.sum
modules/mt/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (12)
e2e/go.mod
(6 hunks)modules/mt/depinject.go
(1 hunks)modules/mt/go.mod
(1 hunks)modules/mt/handler.go
(1 hunks)modules/mt/keeper/balance.go
(2 hunks)modules/mt/keeper/denom.go
(2 hunks)modules/mt/keeper/grpc_query.go
(1 hunks)modules/mt/keeper/keeper.go
(1 hunks)modules/mt/keeper/mt.go
(2 hunks)modules/mt/module.go
(1 hunks)modules/mt/simulation/genesis.go
(1 hunks)modules/mt/simulation/operations.go
(7 hunks)
✅ Files skipped from review due to trivial changes (3)
- modules/mt/depinject.go
- modules/mt/keeper/grpc_query.go
- modules/mt/keeper/keeper.go
🔇 Additional comments (16)
modules/mt/handler.go (1)
Line range hint 13-45
: LGTM! Improved type safety in handler signature.
The updated NewHandler
function now returns a more explicit function signature instead of the generic sdk.Handler
. This change:
- Improves type safety and code clarity
- Maintains proper error handling and result wrapping
- Follows current Cosmos SDK best practices for message handling
modules/mt/keeper/denom.go (2)
8-8
: LGTM: Import update aligns with SDK namespace migration
The change from cosmos-sdk to cosmossdk.io namespace is consistent with the module's modernization efforts.
55-55
: LGTM: Iterator implementation properly updated
The switch to storetypes.KVStorePrefixIterator
maintains the same functionality while aligning with the new import structure. The iterator is properly managed with defer Close()
.
modules/mt/keeper/mt.go (1)
8-8
: LGTM: Import path update aligns with Cosmos SDK migration
The change from github.com/cosmos/cosmos-sdk
to cosmossdk.io
for store types follows the recommended migration path for Cosmos SDK modules.
modules/mt/keeper/balance.go (3)
8-8
: LGTM: Import update aligns with SDK modularization
The update to use storetypes
from cosmossdk.io/store/types
follows the new SDK convention and is part of the broader dependency updates.
66-66
: LGTM: Store iterator update maintains functionality
The update to storetypes.KVStorePrefixIterator
is a direct consequence of the SDK modularization and maintains the same functionality. The iterator is properly managed with defer it.Close()
.
66-66
: Verify consistent store types usage across the module
Let's ensure that all store iterator usages in the MT module have been updated to use the new storetypes
package.
✅ Verification successful
Let me verify the actual implementation details in those files to ensure complete consistency.
Store iterator usage is consistent across the module
All instances of KVStorePrefixIterator
in the MT module are using the new storetypes
package consistently. The verification shows uniform implementation across mt.go
, denom.go
, and balance.go
, with no remaining usage of the old sdk.KVStorePrefixIterator
pattern.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining usage of the old store iterator pattern
# across the MT module to ensure consistent updates.
echo "Checking for old store iterator usage patterns..."
rg -l "sdk\.KVStorePrefixIterator" "modules/mt/"
echo "Verifying new store types usage..."
rg -l "storetypes\.KVStorePrefixIterator" "modules/mt/"
Length of output: 372
Script:
#!/bin/bash
# Check the actual implementation of KVStorePrefixIterator in these files
echo "Checking mt.go implementation:"
rg "KVStorePrefixIterator" "modules/mt/keeper/mt.go" -B 2 -A 2
echo -e "\nChecking denom.go implementation:"
rg "KVStorePrefixIterator" "modules/mt/keeper/denom.go" -B 2 -A 2
echo -e "\nChecking balance.go implementation:"
rg "KVStorePrefixIterator" "modules/mt/keeper/balance.go" -B 2 -A 2
Length of output: 934
modules/mt/module.go (1)
161-163
: LGTM: Parameter type update for RegisterStoreDecoder
The change from sdk.StoreDecoderRegistry
to simtypes.StoreDecoderRegistry
is correct and aligns with the module simulation framework's type system. This change maintains the same functionality while using a more specific and appropriate type.
e2e/go.mod (2)
Line range hint 32-212
: LGTM! Security and stability improvements in indirect dependencies.
The updates to indirect dependencies include important security and stability improvements, particularly in:
- Cloud platform dependencies
- Monitoring tools (Prometheus)
- Cryptographic libraries
8-16
: Verify compatibility between major version upgrades.
The updates include significant version jumps in core dependencies:
cosmossdk.io/api
→ v0.7.5cosmossdk.io/core
→ v0.11.1github.aaakk.us.kg/cometbft/cometbft
→ v0.38.12github.aaakk.us.kg/cosmos/cosmos-sdk
→ v0.50.10
Let's verify compatibility between these versions:
modules/mt/simulation/operations.go (2)
39-39
: LGTM: Parameter removal is consistent with module updates
The removal of the cdc
parameter from GetOrGenerate
calls maintains the core functionality while aligning with the broader changes in the module.
Also applies to: 46-46, 53-53, 60-60, 67-67, 73-73
173-173
: LGTM: Return statement simplification
The removal of redundant nil
arguments from NewOperationMsg
calls improves code clarity while maintaining functionality.
Also applies to: 268-268, 356-356, 461-461, 545-545, 635-635
modules/mt/go.mod (4)
3-5
: Ensure Build and CI Environments Support Updated Go Versions
The Go version has been updated to 1.21
, and the toolchain is now set to go1.23.1
. Please verify that all development, build, and CI/CD environments are configured to use these versions to prevent any compatibility issues.
8-24
: Verify Compatibility with Updated Dependencies
Several dependencies have been updated to newer versions. Ensure that these updates do not introduce any breaking changes or deprecated APIs that could affect the module's functionality.
Line range hint 165-167
: Review Replacement of gin-gonic/gin Dependency
The replacement of github.com/gin-gonic/gin
with version v1.9.0
aims to fix the GHSA-h395-qcrw-5vmq
vulnerability. Verify if the latest version of gin-gonic/gin
has resolved this issue, and consider updating to it directly to benefit from the latest features and security patches.
Line range hint 167-169
: Re-evaluate Downgrade of goleveldb Dependency
The github.com/syndtr/goleveldb
dependency has been downgraded to avoid bugs causing simulations to fail. Check if these issues have been resolved in newer versions so you can upgrade and take advantage of improvements and fixes.
#440