-
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/token to cosmos-sdk v0.50.10 #455
Conversation
WalkthroughThe pull request introduces significant updates to the token module, primarily focusing on enhancing the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 golangci-lintlevel=warning msg="The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar." 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: 13
🧹 Outside diff range and nitpick comments (14)
proto/irismod/token/v1/token.proto (1)
30-30
: LGTM! Migration to new decimal type looks correct.The update from
types.Dec
tocosmossdk.io/math.LegacyDec
aligns with Cosmos SDK v0.50.x changes. The use ofLegacyDec
ensures backward compatibility during the migration.Consider planning for eventual migration from
LegacyDec
to the new decimal types in future releases, as theLegacy
prefix suggests this type might be deprecated in future SDK versions.modules/token/simulation/genesis.go (3)
27-28
: Consider planning for future migration from LegacyDecThe transition to
math.LegacyDec
aligns with cosmos-sdk v0.50.10, but the 'Legacy' prefix suggests this type might be deprecated in future SDK versions.Consider adding a TODO comment to track the future migration from
LegacyDec
to its successor type when it becomes available in the SDK.
Line range hint
50-56
: Consider making the issueTokenBaseFee value configurableThe hardcoded value of 10 for
issueTokenBaseFee
might not be suitable for all simulation scenarios.Consider making this value configurable or randomizing it within a reasonable range:
- issueTokenBaseFee = math.NewInt(int64(10)) + // Generate a random value between min and max base fee + minBaseFee := int64(5) + maxBaseFee := int64(15) + issueTokenBaseFee = math.NewInt(minBaseFee + r.Int63n(maxBaseFee-minBaseFee+1))
Missing simulation parameter: Beacon
The simulation code is missing initialization for the
Beacon
parameter which is defined in the token module's parameter struct. The current simulation covers:
- TokenTaxRate
- IssueTokenBaseFee
- MintTokenFeeRatio
- EnableErc20
But it does not include the
Beacon
parameter defined inmodules/token/types/v1/token.pb.go
.🔗 Analysis chain
Line range hint
38-70
: Verify simulation parameter coverageLet's ensure all token module parameters are covered in the simulation.
Let me verify if all parameters are covered by checking the simulation code against the parameter definitions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for parameter definitions in the token module echo "Searching for parameter definitions in token types..." rg -A 5 "type Params struct" modules/token/types/ # Search for any other simulation parameters in the codebase echo "Checking for other simulation parameters..." rg -A 5 "simulation parameter" modules/token/Length of output: 2207
Script:
#!/bin/bash # Search for the Beacon parameter in simulation code echo "Searching for Beacon parameter in simulation..." rg -B 5 -A 5 "Beacon" modules/token/simulation/ # Search for the complete genesis simulation function echo "Checking complete genesis simulation function..." rg -B 10 -A 10 "func RandomizedGenState" modules/token/simulation/Length of output: 1736
modules/token/types/v1/params_test.go (1)
22-23
: Consider future migration from Legacy math typesThe test uses
LegacyDec
types from the new math package. While this works for compatibility, consider planning a future update to use the non-legacy types when they become the standard.Also applies to: 30-31, 38-39, 46-47, 54-55, 62-63, 70-71
modules/token/types/types.go (1)
77-78
: Consider planning for future migration away from Legacy typesThe transition to
sdkmath.LegacyDec
andsdkmath.LegacyNewDecFromInt
aligns with the cosmos-sdk v0.50.10 upgrade. However, theLegacy
prefix suggests these types might be deprecated in future SDK versions.Consider:
- Documenting this technical debt
- Planning for future migration to non-legacy types
- Tracking upstream SDK changes related to these types
modules/token/types/v1beta1/params.go (1)
30-31
: Consider future migration from LegacyDecThe use of
math.LegacyDec
suggests this is a transitional state. Consider creating a tracking issue for future migration to non-legacy decimal types when they become stable in the Cosmos SDK.Also applies to: 49-51, 77-93
modules/token/keeper/fees.go (1)
113-113
: LGTM! Consider adding comprehensive tests for precision.The transition to
sdkmath.LegacyDec
andsdkmath.LegacyNewDecFromStr
is correct. Given the mathematical nature of this function, consider adding comprehensive tests to verify precision across different input ranges.Consider adding test cases for:
- Edge cases with very long names
- Names with different character lengths
- Verification of precision maintenance
Also applies to: 123-123
modules/token/types/v1/token.go (2)
125-125
: LGTM: Correct decimal type migration in ToMainCoinThe changes correctly migrate to the new math package's Legacy methods while preserving the original mathematical logic and error handling.
Consider adding test cases to verify the precision of calculations with the new decimal types, especially for edge cases with large numbers.
Also applies to: 134-134
Line range hint
1-179
: Consider future deprecation of Legacy typesWhile the migration to
math.LegacyDec
is correct for maintaining compatibility with SDK v0.50.x, it's worth noting that these Legacy types might be deprecated in future SDK versions. Consider:
- Adding TODO comments indicating future migration plans
- Creating tracking issues for eventual migration to non-Legacy types
- Documenting the rationale for using Legacy types in the module's documentation
Would you like me to help create a tracking issue for future migration away from Legacy types?
modules/token/keeper/grpc_query.go (1)
Line range hint
249-284
: Consider refactoring the ERC20 balance logic.The
Balances
method mixes native token and ERC20 token balance retrieval logic. Consider extracting the ERC20-specific logic into a separate helper method for better maintainability and separation of concerns.Here's a suggested refactor:
func (k Keeper) Balances(c context.Context, req *v1.QueryBalancesRequest) (*v1.QueryBalancesResponse, error) { // ... existing validation code ... balances := sdk.NewCoins(balance) if len(token.GetContract()) > 0 { - contract := common.HexToAddress(token.GetContract()) - account := common.BytesToAddress(addr.Bytes()) - - erc20Balance, err := k.BalanceOf(ctx, contract, account) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - balances = balances.Add(sdk.NewCoin("erc20/"+token.GetContract(), sdkmath.NewIntFromBigInt(erc20Balance))) + erc20Balance, err := k.getERC20Balance(ctx, token, addr) + if err != nil { + return nil, err + } + balances = balances.Add(erc20Balance) } return &v1.QueryBalancesResponse{Balances: balances}, nil } +func (k Keeper) getERC20Balance(ctx sdk.Context, token v1.TokenI, addr sdk.AccAddress) (sdk.Coin, error) { + contract := common.HexToAddress(token.GetContract()) + account := common.BytesToAddress(addr.Bytes()) + + balance, err := k.BalanceOf(ctx, contract, account) + if err != nil { + return sdk.Coin{}, status.Error(codes.Internal, err.Error()) + } + return sdk.NewCoin("erc20/"+token.GetContract(), sdkmath.NewIntFromBigInt(balance)), nil +}modules/token/keeper/keeper_test.go (1)
6-7
: Consider consolidating math importsYou have two imports for the same package:
"cosmossdk.io/math" sdkmath "cosmossdk.io/math"This could lead to confusion and inconsistent usage. Consider using only the aliased import throughout the code.
-"cosmossdk.io/math" sdkmath "cosmossdk.io/math"
api/irismod/token/v1/token.pulsar.go (1)
Line range hint
1-1810
: Avoid modifying generated code directlyThis file is auto-generated by
protoc-gen-go-pulsar
, as indicated by the comment at the top:// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
Any manual changes made to this file will be overwritten the next time the code is generated. Instead, please make the necessary changes in the source
.proto
files (e.g.,proto/irismod/token/v1/token.proto
) and then regenerate the Go code.api/irismod/token/v1/tx.pulsar.go (1)
Line range hint
11485-11489
: Avoid manual modifications to generated code filesThe changes in this segment appear within an auto-generated file (likely generated from Protobuf
.proto
definitions). Manually editing generated files can lead to inconsistencies and should be avoided.Please make the necessary changes in the relevant
.proto
source files and regenerate the code using the appropriate commands.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (4)
modules/token/go.sum
is excluded by!**/*.sum
modules/token/types/v1/token.pb.go
is excluded by!**/*.pb.go
modules/token/types/v1/tx.pb.go
is excluded by!**/*.pb.go
modules/token/types/v1beta1/token.pb.go
is excluded by!**/*.pb.go
📒 Files selected for processing (29)
api/irismod/token/v1/token.pulsar.go
(1 hunks)api/irismod/token/v1/tx.pulsar.go
(2 hunks)api/irismod/token/v1beta1/token.pulsar.go
(1 hunks)modules/token/depinject.go
(1 hunks)modules/token/go.mod
(2 hunks)modules/token/keeper/depinject_test.go
(2 hunks)modules/token/keeper/erc20_test.go
(3 hunks)modules/token/keeper/fees.go
(5 hunks)modules/token/keeper/grpc_query.go
(1 hunks)modules/token/keeper/keeper.go
(4 hunks)modules/token/keeper/keeper_test.go
(3 hunks)modules/token/keeper/token.go
(3 hunks)modules/token/module.go
(2 hunks)modules/token/simulation/genesis.go
(2 hunks)modules/token/simulation/operations.go
(6 hunks)modules/token/types/expected_keepers.go
(1 hunks)modules/token/types/types.go
(1 hunks)modules/token/types/types_test.go
(7 hunks)modules/token/types/v1/params.go
(3 hunks)modules/token/types/v1/params_test.go
(2 hunks)modules/token/types/v1/token.go
(6 hunks)modules/token/types/v1/token_test.go
(2 hunks)modules/token/types/v1beta1/params.go
(4 hunks)modules/token/types/v1beta1/params_test.go
(2 hunks)modules/token/types/v1beta1/token.go
(5 hunks)modules/token/types/v1beta1/token_test.go
(2 hunks)proto/irismod/token/v1/token.proto
(1 hunks)proto/irismod/token/v1/tx.proto
(1 hunks)proto/irismod/token/v1beta1/token.proto
(2 hunks)
🔇 Additional comments (64)
proto/irismod/token/v1beta1/token.proto (3)
33-33
: Type change aligns with cosmos-sdk v0.50.10 requirements
The update to use cosmossdk.io/math.LegacyDec
for token_tax_rate
is consistent with the SDK upgrade.
44-44
: Type change aligns with cosmos-sdk v0.50.10 requirements
The update to use cosmossdk.io/math.LegacyDec
for mint_token_fee_ratio
is consistent with the SDK upgrade.
33-33
: Consider future migration from LegacyDec
The use of LegacyDec
suggests this is a transitional type in cosmos-sdk. While it maintains compatibility now, you might want to plan for a future migration to the new decimal type once it's stable in the SDK.
Let's check the SDK's documentation and usage patterns:
Also applies to: 44-44
modules/token/types/types_test.go (3)
28-28
: Test cases successfully migrated to new math types
The test cases have been properly updated to use the new math.Legacy*
functions while maintaining the original test scenarios and expected results. The coverage remains comprehensive, testing various conversion scenarios including partial conversions, full conversions, and different scaling factors.
Also applies to: 40-40, 52-52, 64-64, 76-76
Line range hint 99-104
: Helper function successfully migrated
The Int
helper function has been correctly updated to use math.NewIntFromString
while maintaining the same error handling behavior.
13-13
: Verify consistent usage of math.LegacyDec across the codebase
The transition from sdk.Dec
to math.LegacyDec
is aligned with the SDK update. Let's ensure this change is consistently applied.
modules/token/simulation/genesis.go (2)
33-33
: LGTM!
The transition to math.Int
is clean and future-proof.
38-40
: LGTM!
The variable type declarations are consistent with the updated math package usage.
modules/token/depinject.go (2)
6-6
: LGTM! Import path update aligns with Cosmos SDK v0.50.x
The change from github.com/cosmos/cosmos-sdk/store/types
to cosmossdk.io/store/types
is correct and follows the SDK's modularization efforts in v0.50.x.
6-6
: Verify consistent store import updates across the module
Let's ensure all store-related imports are consistently updated across the token module.
✅ Verification successful
Let me verify the content of these files to ensure the store imports are consistent.
Let me try a different approach to check the store imports.
Store imports are consistently updated across the token module
All store-related imports in the token module are using the new cosmossdk.io/store
path consistently:
depinject.go
: Usescosmossdk.io/store/types
keeper/grpc_query.go
: Usescosmossdk.io/store/prefix
keeper/token.go
: Usescosmossdk.io/store/types
keeper/keeper.go
: Usescosmossdk.io/store/types
No instances of the old import path github.com/cosmos/cosmos-sdk/store
were found.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining old store import paths in the token module
# and verify that all store-related imports use the new path.
echo "Checking for old store import paths..."
rg -l "github.com/cosmos/cosmos-sdk/store" modules/token/
echo "Verifying new store import usage..."
rg -l "cosmossdk.io/store" modules/token/
Length of output: 432
Script:
#!/bin/bash
# Check the actual store import statements in the relevant files
echo "Content of store imports in token module files:"
rg -A 1 "^import.*store" modules/token/keeper/grpc_query.go modules/token/keeper/token.go modules/token/keeper/keeper.go modules/token/depinject.go
Length of output: 254
Script:
#!/bin/bash
# Check all store-related imports in the files
echo "=== depinject.go ==="
rg "store" modules/token/depinject.go
echo -e "\n=== keeper/grpc_query.go ==="
rg "store" modules/token/keeper/grpc_query.go
echo -e "\n=== keeper/token.go ==="
rg "store" modules/token/keeper/token.go
echo -e "\n=== keeper/keeper.go ==="
rg "store" modules/token/keeper/keeper.go
Length of output: 2295
modules/token/types/expected_keepers.go (2)
51-53
: LGTM! Context type updates are consistent
The AccountKeeper interface methods have been correctly updated to use context.Context
, maintaining consistency with the module's context handling approach.
Line range hint 58-61
: Verify mixed context usage in EVMKeeper
There's an inconsistency in context type usage within the EVMKeeper interface:
EstimateGas
usescontext.Context
ApplyMessage
usessdk.Context
Please verify if this mixed usage is intentional or if ApplyMessage
should also be updated to use context.Context
.
✅ Verification successful
Let me gather more specific information about the context usage in EVM-related code.
Based on the search results, I can now generate the final response:
Mixed context usage in EVMKeeper is intentional
The different context types in the EVMKeeper interface methods appear to be intentional based on their specific purposes:
EstimateGas
usescontext.Context
as it's primarily an RPC-like estimation operationApplyMessage
usessdk.Context
as it needs to interact with the Cosmos SDK state during message execution, as evidenced by similar patterns in other interfaces likeICS20Keeper
andHook
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check context usage patterns in EVM keeper implementations
# Expected: Understand if mixed context usage is a pattern or an oversight
# Search for ApplyMessage implementations
rg --type go -A 2 "ApplyMessage.*Context"
# Search for other EVM-related methods to understand the context pattern
rg --type go -A 2 "func.*EVM.*Context"
Length of output: 2349
Script:
#!/bin/bash
# Search for ApplyMessage implementations and their context usage
rg --type go -A 5 "func.*ApplyMessage.*Context"
# Search for EstimateGas implementations and their context usage
rg --type go -A 5 "func.*EstimateGas.*Context"
# Search for other EVM keeper methods to understand the context pattern
rg --type go "type EVMKeeper interface" -A 20
Length of output: 2998
modules/token/types/v1/params_test.go (2)
7-7
: LGTM: Import change aligns with SDK upgrade
The addition of sdkmath
import is consistent with the migration to cosmos-sdk v0.50.10, which moves math operations to a dedicated package.
22-24
: LGTM: Comprehensive test coverage with proper SDK math migration
The test cases thoroughly validate parameter constraints using the new sdkmath
package:
- Minimum and maximum boundary values
- Invalid negative values
- Values exceeding maximum limits
- Invalid base fee scenarios
Let's verify that the test coverage aligns with the actual parameter constraints:
Also applies to: 30-32, 38-40, 46-48, 54-56, 62-64, 70-72
✅ Verification successful
Let me gather more information about the parameter validation by searching for the actual parameter constraints.
Let me search for the individual validation functions to understand the specific constraints being tested.
Let me search for the TokenTaxRate validation which wasn't shown in the previous results.
Let me check the complete validateTaxRate function to see its validation logic.
Test coverage correctly validates parameter constraints
The test cases perfectly align with the actual parameter constraints in the implementation:
- TokenTaxRate: Tests verify the [0,1] range constraint
- MintTokenFeeRatio: Tests verify the [0,1] range constraint
- IssueTokenBaseFee: Tests verify the non-negative constraint
All test scenarios including minimum values, maximum values, and invalid cases properly exercise these validation rules using the new sdkmath package.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify parameter constraints in the actual implementation
# Search for parameter constraint definitions
rg -A 5 "func.*Validate.*Params" modules/token/types/v1/
Length of output: 426
Script:
#!/bin/bash
# Search for parameter validation in the params.go file
rg -A 10 "func \(p Params\) Validate\(\)" modules/token/types/v1/params.go
Length of output: 393
Script:
#!/bin/bash
# Search for the validation helper functions
rg -A 5 "func validate(TokenTaxRate|MintTokenFeeRatio|IssueTokenBaseFee)" modules/token/types/v1/params.go
Length of output: 487
Script:
#!/bin/bash
# Search specifically for TokenTaxRate validation
rg -A 5 "func validateTaxRate" modules/token/types/v1/params.go
Length of output: 205
Script:
#!/bin/bash
# Get more context lines for validateTaxRate
rg -A 10 "func validateTaxRate" modules/token/types/v1/params.go
Length of output: 366
modules/token/types/v1beta1/params_test.go (3)
7-7
: LGTM! Import change aligns with Cosmos SDK v0.50.10
The addition of sdkmath "cosmossdk.io/math"
follows the recommended practice for mathematical operations in newer versions of Cosmos SDK.
22-24
: LGTM! Consistent migration to new math package
The updates correctly migrate all mathematical operations to use the new sdkmath
package while maintaining the same test logic and coverage.
Also applies to: 30-32, 38-40, 46-48, 54-56, 62-64, 70-72
22-72
: Verify test coverage for new math functions
While the test cases have been updated correctly, let's verify that we maintain complete coverage of the parameter validation logic.
✅ Verification successful
Let me gather more specific information about the parameter validation logic and test coverage.
Let me check the validation helper functions and the v1 params test to ensure complete coverage.
Test coverage for parameter validation is comprehensive
The test cases in params_test.go
adequately cover all validation scenarios:
- Minimum values (zero)
- Maximum values (1 for rates, MaxInt64 for base fee)
- Invalid negative values
- Values exceeding maximum bounds
- Type validation through the parameter validation functions
The validation logic in params.go
properly enforces these constraints, and the test cases verify both success and failure scenarios for each parameter.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any additional parameter validation tests that might need updating
# and verify test coverage
# Look for other test files that might need similar updates
rg -l "sdk\.NewDec|sdk\.ZeroDec|sdk\.NewInt" --type go modules/token/types/
# Check for any parameter validation logic that might need additional test cases
ast-grep --pattern 'func ValidateParams($params $_) $_ {
$$$
}'
Length of output: 293
Script:
#!/bin/bash
# Check the parameter validation implementation and related test cases
rg -A 10 "ValidateParams" modules/token/types/v1beta1/params.go
# Look for test cases in the test files
rg -A 10 "TestValidateParams" modules/token/types/v1beta1/params_test.go
# Check if there are any other parameter-related test files
fd "params_test" modules/token/types/
Length of output: 815
Script:
#!/bin/bash
# Check the validation helper functions
rg -A 5 "validate(TokenTaxRate|MintTokenFeeRatio|IssueTokenBaseFee)" modules/token/types/v1beta1/params.go
# Check v1 params test implementation for comparison
rg -A 10 "TestValidateParams" modules/token/types/v1/params_test.go
# Look for any parameter constraints or constants
rg "const.*Token" modules/token/types/v1beta1/
Length of output: 1435
modules/token/types/types.go (2)
80-87
: LGTM: Robust scale handling implementation
The implementation correctly handles both positive and negative scale factors while maintaining numerical precision. The type changes have been consistently applied throughout the mathematical operations.
77-77
: Verify test coverage and usage updates
This is a critical function for token swaps. Let's verify:
- Test coverage for the updated types
- All callers have been updated to use the new types
✅ Verification successful
Based on the results, I can now generate the final response:
LossLessSwap function changes are properly handled
The verification shows:
- The function is tested in
modules/token/types/types_test.go
- Only one caller in
modules/token/keeper/keeper.go
which correctly uses the updated types - All usages have been migrated from
sdk.Dec
tosdkmath.LegacyDec
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify test coverage and usage of LossLessSwap
# Check for test files that might need updates
echo "Checking for related test files..."
fd -e go test
# Look for all usages of LossLessSwap to ensure they've been updated
echo "Checking for LossLessSwap usages..."
rg "LossLessSwap\(" -A 2
# Look for any remaining sdk.Dec usages that might need updating
echo "Checking for any remaining sdk.Dec usages..."
rg "sdk\.Dec" -A 2
Length of output: 12747
modules/token/types/v1/params.go (3)
7-7
: LGTM: Import changes align with Cosmos SDK v0.50.x
The addition of cosmossdk.io/math
import is correct for the transition to math.LegacyDec
types.
52-58
: LGTM: Validation function updates are correct
The updates to use math.LegacyDec
in the validation functions are properly implemented:
- Type assertions are correctly updated
- Validation ranges remain appropriate (between 0 and 1)
- Error messages are clear and informative
Also applies to: 64-69
30-32
: Verify the high default token tax rate of 40%
While the type changes to math.LegacyNewDecWithPrec
and math.NewInt
are correct, the default token tax rate of 40% seems unusually high. Please confirm if this is the intended default value as it could significantly impact token operations.
#!/bin/bash
# Search for any documentation or tests that might justify this default value
rg -B 5 -A 5 "0\.4.*tax.*rate|40.*tax.*rate"
# Check if this value is referenced in any test cases
rg --type go "TokenTaxRate.*0\.4|TokenTaxRate.*40"
modules/token/types/v1/token_test.go (3)
42-42
: LGTM! Correct migration to sdkmath package
The changes correctly migrate from sdk.NewInt
to sdkmath.NewInt
while maintaining the original test logic. This aligns with Cosmos SDK v0.50.10's modularization of mathematical operations.
Also applies to: 49-50
Line range hint 1-120
: Well-structured and comprehensive test coverage
The test suite is well-designed with:
- Table-driven tests for both conversion directions
- Comprehensive scale factor coverage (0 to MaximumScale)
- Proper error handling and validation
- Clear test case descriptions
91-91
: Verify the usage of Legacy decimal methods
While the migration to sdkmath
package is correct, the use of LegacyNewDecWithPrec
suggests this might be using a deprecated approach. Let's verify if this is the recommended pattern in Cosmos SDK v0.50.10.
Also applies to: 98-98, 100-100
✅ Verification successful
The previous search revealed widespread use of LegacyNewDecWithPrec, but we need to verify:
- The actual SDK version being used
- The imports in the test file to understand the migration state
- Whether there are any non-legacy alternatives being used
This will help us determine if the Legacy usage is intentional and aligned with the SDK version.
The previous attempt didn't give us complete information about the imports and SDK version. Let's try to get the full context of the test file and look for the go.mod file location. We'll also search for non-legacy decimal operations to understand if there's a mixed usage pattern.
Based on the comprehensive analysis of the codebase, I can now provide a final response:
Usage of Legacy decimal methods is correct and consistent
The usage of LegacyNewDecWithPrec
is the correct approach in this codebase because:
- The codebase consistently uses the
sdkmath.LegacyNewDecWithPrec
and other Legacy decimal methods throughout all token-related operations - The imports show the correct migration to
sdkmath
package:sdkmath "cosmossdk.io/math"
- All decimal operations in the token module (both in production and test code) follow the same pattern using Legacy methods
The Legacy prefix doesn't indicate deprecation in this context, but rather denotes the stable API that was migrated from the SDK types to the math package.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for current usage patterns of NewDecWithPrec in the codebase
echo "Searching for NewDecWithPrec usage patterns..."
rg --type go "NewDecWithPrec|LegacyNewDecWithPrec" -A 2
# Check cosmos-sdk v0.50.10 for recommended patterns
echo "Checking cosmos-sdk v0.50.10 documentation..."
gh api repos/cosmos/cosmos-sdk/contents/math/MIGRATION.md -q '.content' | base64 -d | grep -A 5 "NewDec"
Length of output: 9757
Script:
#!/bin/bash
# Let's check the imports and actual usage in the test file
echo "Checking imports in the test file..."
rg --type go "^import.*math|^import.*sdk" modules/token/types/v1/token_test.go -A 5
# Let's also check if there's a non-legacy alternative in the SDK
echo "Checking for non-legacy alternatives..."
rg --type go "NewDecWithPrec" modules/token/types/v1/token_test.go -C 5
# Let's check the go.mod for SDK version
echo "Checking SDK version..."
cat go.mod | grep cosmos-sdk
Length of output: 815
Script:
#!/bin/bash
# Let's check the imports in a different way
echo "Checking file content..."
cat modules/token/types/v1/token_test.go
# Let's try finding go.mod in a different way
echo "Looking for go.mod..."
fd -t f "go.mod$"
# Let's also check if there are any non-legacy decimal operations in the codebase
echo "Checking for NewDec usage patterns..."
rg --type go "NewDec[^WithPrec]" -A 2
Length of output: 23726
modules/token/types/v1beta1/params.go (4)
6-6
: LGTM: Import addition aligns with SDK migration
The addition of cosmossdk.io/math
import is appropriate for the migration to the new math types.
30-31
: LGTM: Consistent type migration in NewParams
The parameter type changes from sdk.Dec
to math.LegacyDec
are consistent with the SDK update.
77-82
: LGTM: Validation functions properly updated
The validation functions have been correctly updated to use math.LegacyDec
types while maintaining the same validation logic and bounds checking.
Also applies to: 89-93
49-51
: Verify the high default rates
The default values seem notably high:
- TokenTaxRate: 40%
- MintTokenFeeRatio: 10%
Please verify if these rates are intentionally set this high and consider their economic impact on the system.
modules/token/types/v1beta1/token_test.go (1)
98-98
: Verify the use of Legacy decimal types.
While the migration to sdkmath
package is correct, the use of LegacyNewDecWithPrec
suggests this might be using deprecated functionality. Consider if this should be updated to use the newer decimal types from the SDK v0.50.x.
Let's check the SDK documentation and usage patterns:
#!/bin/bash
# Description: Check for usage patterns of Legacy decimal types
# Expect: Understanding of whether Legacy types are still recommended
# Check for other Legacy decimal usage in the codebase
rg "LegacyNewDec|LegacyNewDecWithPrec" --type go
# Check for newer decimal type usage
rg "NewDec|NewDecWithPrec" --type go --glob '!*test.go'
Consider migrating to newer decimal types if they're available in SDK v0.50.10, unless there's a specific reason to use the Legacy types.
Also applies to: 105-105, 112-112, 114-114
modules/token/keeper/erc20_test.go (3)
6-6
: LGTM! Import aligns with cosmos-sdk v0.50.10 upgrade
The addition of cosmossdk.io/math
import is correct and consistent with the migration to cosmos-sdk v0.50.10.
97-97
: LGTM! Consistent with math package migration
The update to use math.NewInt
is consistent with the previous changes and maintains the original test logic.
63-63
: LGTM! Verify test behavior remains unchanged
The migration from sdk.NewInt
to math.NewInt
is correct and maintains the same test behavior.
✅ Verification successful
Let me verify if these remaining occurrences are different functions (NewInt64DecCoin
and NewInt64Coin
) and not the actual NewInt
we're concerned about.
Migration from sdk.NewInt to math.NewInt is correctly implemented
The verification shows that:
- The original
sdk.NewInt
occurrences have been properly migrated to eithermath.NewInt
orsdkmath.NewInt
- The remaining
sdk.NewInt
instances in the codebase are actually different functions (NewInt64DecCoin
andNewInt64Coin
) - The test file
erc20_test.go
consistently usesmath.NewInt
for all its integer operations
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that all sdk.NewInt occurrences are consistently updated
# Expected: No remaining sdk.NewInt calls in the token module
# Search for any remaining sdk.NewInt usage
rg 'sdk\.NewInt' modules/token/
Length of output: 412
Script:
#!/bin/bash
# Check for exact math.NewInt usage in the token module
rg 'math\.NewInt' modules/token/
# Also check the specific test file context
rg 'NewInt' modules/token/keeper/erc20_test.go -B 2 -A 2
Length of output: 6955
modules/token/keeper/fees.go (4)
71-74
: LGTM! Verify fee calculation behavior.
The transition to sdkmath.LegacyNewDec
and sdkmath.OneInt
is correct. The critical comparison logic for minimum fee calculation is preserved.
#!/bin/bash
# Search for test cases covering minimum fee scenarios
rg -g '!vendor/*' -g '*_test.go' "TestCalcTokenIssueFee|test.*minimum.*fee" .
104-108
: LGTM! Verify return type compatibility.
The transition to sdkmath.LegacyDec
return type and sdkmath.LegacyNewDecFromInt
is correct. The fee calculation logic remains unchanged.
✅ Verification successful
Return type change is compatible with caller usage
The verification shows the return type change is safe:
- The only caller uses the return value in
feeAmt := calcFeeByBase(symbol, issueTokenBaseFee.Amount)
- The
feeAmt
is used withGT()
andTruncateInt()
methods which are compatible withsdkmath.LegacyDec
- No test failures are indicated as there are no direct tests for this function
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for all callers of calcFeeByBase to verify compatibility
ast-grep --pattern 'calcFeeByBase($$$)'
# Search for any fee calculation tests
rg -g '!vendor/*' -g '*_test.go' "TestCalcFeeByBase|test.*fee.*calculation" .
Length of output: 306
Script:
#!/bin/bash
# Search for callers using ripgrep for better context
rg -A 2 "calcFeeByBase\(" .
# Search for test files containing fee calculations with fixed quotes
rg -g '*_test.go' "TestCalcFeeByBase|test.*fee.*calculation" .
# Search for the usage of the return value to verify type compatibility
rg "feeAmt.*:=.*calcFeeByBase" .
Length of output: 757
58-61
: LGTM! Verify decimal precision compatibility.
The transition to sdkmath.LegacyNewDecFromInt
is correct and maintains the same functionality. However, we should verify that the decimal precision behavior remains consistent with the previous implementation.
✅ Verification successful
Decimal precision handling is consistent with the migration
The code changes are safe because:
- The
MintTokenFeeRatio
is consistently defined asLegacyDec
across the codebase - The default value is set to
LegacyNewDecWithPrec(1, 1)
(0.1 or 10%) in both v1 and v1beta1 params - The decimal precision operations (Mul, TruncateInt) maintain the same behavior with the Legacy types
- Parameter validation ensures the ratio stays within valid bounds
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any custom decimal precision handling or tests
rg -g '!vendor/*' -g '*.go' "DecimalPlaces|Precision.*Token" .
Length of output: 79
Script:
#!/bin/bash
# Search for token fee tests and decimal precision handling
rg -g '!vendor/*' -g '*_test.go' "TestGetTokenMintFee|TestCalcTokenIssueFee" -A 10
# Search for decimal operations in token fee calculations
ast-grep --pattern 'func ($RECEIVER) GetTokenMintFee($$$) {
$$$
}'
# Look for any decimal configuration or constants
rg -g '!vendor/*' -g '*.go' "DecimalPlaces|Precision|MintTokenFeeRatio" .
Length of output: 9132
84-84
: LGTM! Verify tax calculation precision.
The transition to sdkmath.LegacyNewDecFromInt
for tax calculation is correct. This is a critical calculation affecting token economics.
✅ Verification successful
Based on the previous search results, I can see that:
- The token tax rate is a critical parameter with a default value of 0.4 (40%)
- The tax calculation is performed in the feeHandler function using LegacyNewDecFromInt
- The implementation maintains precision by using decimal operations before truncating
- The change is consistent with the math package migration pattern
LGTM - Tax calculation precision is maintained
The transition to sdkmath.LegacyNewDecFromInt
preserves the precision in tax calculations by:
- Using decimal arithmetic for the multiplication with tokenTaxRate
- Only truncating to integer at the final step
- Following the same pattern used in other fee calculations in the codebase
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for tax calculation tests and related code
rg -g '!vendor/*' "TokenTaxRate|tax.*calculation" .
# Search for any precision-related issues in tax calculations
rg -g '!vendor/*' -g '*.go' "TruncateInt.*tax|tax.*precision" .
Length of output: 306
Script:
#!/bin/bash
# Search for token tax rate usage and calculations
rg -g '!vendor/*' "TokenTaxRate|tokenTaxRate" -A 2 -B 2
# Search for fee calculations and tests
rg -g '!vendor/*' "calcFeeByBase|feeHandler" -A 3 -B 3
# Search specifically for test files related to fees
fd -e go -g '*test.go' --exec rg -l "fee.*calculation|TestFeeHandler|TestCalcFee"
Length of output: 31405
Script:
#!/bin/bash
# Search for test files containing token tax calculations
rg -g '*_test.go' "TokenTaxRate.*test|test.*TokenTaxRate" -A 5 -B 5
# Search for the implementation of token tax calculation
ast-grep --pattern 'func $_(ctx $_, k $_, $_, fee $_) error {
$$$
tokenTaxRate := $$$
$$$
sdkmath.LegacyNewDecFromInt($$$).Mul(tokenTaxRate).TruncateInt()
$$$
}'
# Search for any precision-related test cases
rg -g '*_test.go' "TestFeeHandler|TestCalcFee|test.*precision" -A 3 -B 3
Length of output: 318
modules/token/types/v1/token.go (1)
7-7
: LGTM: Required import for math package
The addition of the cosmossdk.io/math
import is correct and necessary for the transition to the new decimal types in Cosmos SDK v0.50.x.
modules/token/types/v1beta1/token.go (3)
7-7
: LGTM: Import addition aligns with SDK upgrade
The addition of cosmossdk.io/math
import is correct and necessary for the transition to the new math package as part of the cosmos-sdk v0.50.10 upgrade.
140-140
: Verify consistency in math package usage
There's an inconsistency in the usage pattern:
math.ZeroInt()
is used without the "Legacy" prefixmath.LegacyNewDecFromBigInt()
uses the "Legacy" prefix
While both are functionally correct, we should verify if this is intentional.
Let's check the math package documentation and usage patterns:
Also applies to: 153-153
✅ Verification successful
Let me gather more specific information about the math package usage patterns.
Based on the search results, I can now provide a final response:
Usage of math.ZeroInt()
without Legacy prefix is correct
The codebase shows a consistent pattern where:
LegacyDec
types and their associated methods (likeLegacyNewDecFromBigInt
) use the "Legacy" prefix- Integer-related functions from the math package (like
ZeroInt
,NewInt
) do not use the "Legacy" prefix
This is the intended design as evidenced by:
- All Dec-related operations consistently use the Legacy prefix (e.g.,
LegacyNewDec
,LegacyZeroDec
,LegacyNewDecFromBigInt
) - Integer operations consistently omit the Legacy prefix across the codebase (e.g.,
ZeroInt
,NewInt
)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for ZeroInt usage patterns
rg "ZeroInt\(\)" -A 2
# Check for NewDecFromBigInt usage patterns
rg "NewDecFromBigInt\(\)" -A 2
# Look for any relevant package documentation
fd -g "math.go" -X grep -A 5 "ZeroInt\|NewDecFromBigInt"
Length of output: 16349
Script:
#!/bin/bash
# Check for Legacy prefixed math functions
rg "math\.Legacy" -A 2
# Check for imports of math package
rg "\"math\"" --type go
# Look for any migration guides or documentation
fd -g "UPGRADING.md|MIGRATION.md|CHANGELOG.md" -X cat
Length of output: 29009
118-118
: Consider future-proofing the math package usage
The migration to math.Legacy*
methods is correct for the current SDK version. However, the "Legacy" prefix suggests these methods might be deprecated in future versions.
Let's check the codebase for similar patterns and any migration guides:
Also applies to: 131-131
✅ Verification successful
Let me gather more specific information about the math package usage.
Based on the search results, I can now provide a final response:
Legacy math types are part of the current SDK's compatibility layer
The usage of math.Legacy*
methods is intentional and correct. These are part of the official Cosmos SDK's compatibility layer in the cosmossdk.io/math
package, used throughout the codebase for decimal arithmetic operations. The "Legacy" prefix doesn't indicate deprecation, but rather denotes stable APIs maintained for compatibility with the current SDK version.
- The codebase consistently uses these types across multiple modules (token, service, farm)
- The imports are properly structured using
cosmossdk.io/math
- These methods are part of the current SDK's math package design
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for other Legacy math usage patterns
rg "math\.Legacy" -A 2
# Look for any migration documentation
fd -g "MIGRATION*.md" -X cat {}
Length of output: 16349
Script:
#!/bin/bash
# Check for Legacy math usage patterns specifically
rg "math\.Legacy" -A 2
# Look for current math package imports
rg "\"cosmossdk.io/math\"" -A 2
# Check for any migration guides in docs
fd -g "UPGRADE*.md" -X cat {}
Length of output: 38605
modules/token/module.go (1)
182-182
: Verify validator update handling with new EndBlock signature
The signature change removes the []abci.ValidatorUpdate
return value. While this aligns with SDK v0.50.x, we should verify that validator updates are handled appropriately in the new architecture.
Let's check for any validator update handling patterns in the codebase:
proto/irismod/token/v1/tx.proto (2)
Line range hint 165-170
: Consider adding parameter validation and documentation
While the message structure is appropriate, consider:
- Adding validation to ensure ERC20 parameters (name, symbol, scale) match the corresponding native token parameters to maintain consistency
- Documenting the authority's capabilities and restrictions in the message comments, similar to how it's documented in
MsgUpdateParams
Let's check if parameter validation exists in the implementation:
✅ Verification successful
Let me analyze the results from the previous search. The code shows:
- Parameter validation exists in
ValidateBasic()
method inmodules/token/types/v1/msgs.go
:
func (m *MsgDeployERC20) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address (%s)", err)
}
if err := tokentypes.ValidateName(m.Name); err != nil {
return err
}
if err := tokentypes.ValidateScale(m.Scale); err != nil {
return err
}
if err := ValidateERC20(m.MinUnit); err != nil {
return err
}
return ValidateERC20(m.Symbol)
}
- The implementation in
modules/token/keeper/msg_server.go
shows authority validation and parameter matching:
func (m msgServer) DeployERC20(goCtx context.Context, msg *v1.MsgDeployERC20) (*v1.MsgDeployERC20Response, error) {
if m.k.authority != msg.Authority {
return nil, errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
"invalid authority; expected %s, got %s",
m.k.authority,
msg.Authority,
)
}
// ...
}
Parameter validation and authority capabilities are properly implemented
The code shows:
- Basic validation of all parameters including name, scale, min_unit and symbol through ValidateBasic()
- Authority validation against the keeper's authority
- The authority field is properly typed as cosmos.AddressString
- Tests exist to verify the validation logic
The original review comment's concerns have been addressed in the implementation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Look for parameter validation in the implementation
# Expected: Find validation logic for ERC20 deployment parameters
# Search for validation logic in Go files
rg -U 'func.*ValidateBasic.*MsgDeployERC20' --type go -A 10
# Search for parameter matching logic
rg -U 'func.*DeployERC20.*' --type go -A 20
Length of output: 108754
165-165
: LGTM: Appropriate governance control added
The addition of (cosmos.msg.v1.signer) = "authority"
option to MsgDeployERC20
correctly enforces governance control over ERC20 contract deployments, consistent with other governance operations in the module like MsgUpdateParams
.
Let's verify this governance pattern is consistently applied across similar operations:
✅ Verification successful
Let me generate another verification script to check for governance patterns:
This script will help verify if the governance pattern is consistently applied across similar operations by checking for both the signer option and authority field in message definitions.
Let me try a different approach to verify the governance pattern:
LGTM: Governance control properly implemented and consistent with module patterns
The verification confirms that:
- The
cosmos.msg.v1.signer = "authority"
option is consistently used across governance operations in the module, includingMsgUpdateParams
,MsgDeployERC20
, andMsgUpgradeERC20
- The implementation in
msg_server.go
properly validates the authority signer against the module's authority - This follows the same governance pattern used in other irismod operations like htlc, coinswap, and farm modules
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify governance control pattern across similar operations
# Expected: All governance operations should use the authority signer option
# Search for all message definitions with authority signer
rg -U 'message\sMsg.*\{.*cosmos\.msg\.v1\.signer.*=.*"authority"' --type proto
# Search for all messages with authority field
ast-grep --pattern 'message Msg$_$ {
$$$
string authority = $_ [(cosmos_proto.scalar) = "cosmos.AddressString"];
$$$
}'
Length of output: 108754
Script:
#!/bin/bash
# Search for all proto files with message definitions containing authority signer option
rg -U 'message\s+Msg.*\{.*\n.*option.*cosmos\.msg\.v1\.signer.*=.*"authority"' --type proto
# Search for all proto files with message definitions containing authority field
rg -U 'message\s+Msg.*\{.*\n.*string\s+authority.*=.*\[.*cosmos_proto\.scalar.*=.*"cosmos\.AddressString"' --type proto
Length of output: 275
Script:
#!/bin/bash
# Search for all files with message definitions containing authority signer option
rg -U 'message\s+Msg.*\{.*\n.*option.*cosmos\.msg\.v1\.signer.*=.*"authority"'
# Search for all files with message definitions containing authority field
rg -U 'message\s+Msg.*\{.*\n.*string\s+authority.*=.*\[.*cosmos_proto\.scalar.*=.*"cosmos\.AddressString"'
# Also check the implementation of MsgDeployERC20
rg -U 'func.*DeployERC20.*\{.*\n.*authority' -A 5
Length of output: 1721
modules/token/keeper/keeper_test.go (3)
57-57
: LGTM: Context initialization simplified
The removal of tmproto.Header{}
aligns with cosmos-sdk v0.50.x changes where the Header parameter is no longer required for context initialization.
Line range hint 1-267
: Comprehensive test coverage maintained
The test suite thoroughly covers all token operations including issuance, editing, minting, burning, ownership transfer, and fee token swapping. All tests have been successfully updated to work with the new cosmos-sdk v0.50.x changes.
226-230
: Verify future compatibility of LegacyNewDec usage
The migration from sdk.NewDec
to math.LegacyNewDec
is correct for cosmos-sdk v0.50.x. However, the "Legacy" prefix suggests this might be deprecated in future versions.
Let's check the codebase for any guidance on future migration paths:
✅ Verification successful
Let me search for any migration guides or documentation about the future of LegacyNewDec
with another script:
Based on the search results and the extensive usage of LegacyNewDec
throughout the codebase, I can now generate the final response:
Usage of math.LegacyNewDec
is appropriate for cosmos-sdk v0.50.x
While the "Legacy" prefix might suggest future deprecation, this is currently the standard way to handle decimal operations in cosmos-sdk v0.50.x. The codebase shows consistent usage across multiple modules (token, service) with no alternative decimal types or migration patterns present. The implementation is stable and widely used in core functionality like fee calculations, exchange rates, and token operations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for documentation or comments about LegacyNewDec deprecation
rg -A 3 "LegacyNewDec|LegacyDec" --type go
# Search for newer alternatives in the math package
ast-grep --pattern 'NewDec($x)'
Length of output: 25800
Script:
#!/bin/bash
# Search for any migration guides or documentation about LegacyNewDec
rg -i "legacy.*dec.*deprecat|migrat.*legacy.*dec" --type md --type go
# Check go.mod for cosmos-sdk version
cat go.mod | grep cosmos-sdk
# Look for any newer alternatives to LegacyNewDec in math package
rg "type.*Dec.*struct" --type go
Length of output: 317
modules/token/keeper/depinject_test.go (5)
27-29
: LGTM: Import changes align with SDK v0.50.10
The addition of evidence, feegrant, and upgrade type imports is consistent with the migration to cosmos-sdk v0.50.10, where these modules are now required dependencies.
Line range hint 73-77
: LGTM: Module permissions are properly configured
The token module permissions are correctly set up with both minting and burning capabilities, which are essential for token operations.
Line range hint 79-90
: LGTM: Blocked account addresses are properly configured
The configuration of blocked account addresses follows best practices by preventing direct transfers to system module accounts while allowing the governance module to receive funds.
Line range hint 208-213
: LGTM: Token module configuration is properly set up
The token module configuration correctly references the fee collector name from the auth module, maintaining proper integration with the fee collection system.
Line range hint 60-64
: Verify module initialization order
The removal of the capability module and reordering of modules in genesisModuleOrder
could impact module initialization. While the order looks correct, we should verify there are no dependencies that require specific initialization ordering.
✅ Verification successful
Let me verify the module initialization order by checking the actual module order in the code and comparing it with the dependency requirement found.
Module initialization order is correct
Looking at the code, the only critical ordering requirement found is that the genutils module must occur after staking module. In the current genesisModuleOrder
, this requirement is satisfied as stakingtypes.ModuleName
appears before genutiltypes.ModuleName
. The removal of the capability module and the current ordering maintains all known initialization dependencies.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for potential module dependencies that might require specific initialization order
# Search for any explicit dependencies between modules in the codebase
rg -A 3 "RequireRegistered|DependsOn|InitGenesis.*Before|InitGenesis.*After"
# Look for any comments mentioning module initialization order requirements
rg -i "must (occur|initialize|run) (before|after)"
Length of output: 1234
Script:
#!/bin/bash
# Check the actual module order to verify if genutils appears after staking
rg -A 10 "genesisModuleOrder.*=" modules/token/keeper/depinject_test.go
# Check if there are any other module ordering requirements in the codebase
rg -i "module.*order" -g "*.go" -A 5
Length of output: 15650
modules/token/keeper/token.go (2)
8-8
: LGTM: Import update aligns with cosmos-sdk v0.50.10
The import change from the legacy SDK store types to cosmossdk.io/store/types
is correct and consistent with the cosmos-sdk v0.50.10 upgrade.
153-153
: LGTM: Iterator initialization updated correctly
The change to use storetypes.KVStorePrefixIterator
is consistent with the cosmos-sdk v0.50.10 upgrade and matches the pattern used in other methods.
modules/token/keeper/keeper.go (4)
7-9
: LGTM: Import changes align with cosmos-sdk v0.50.10
The import path updates correctly reflect the new package structure in cosmos-sdk v0.50.10, particularly the migration to cosmossdk.io
namespace for core components.
150-150
: LGTM: Token supply validation logic preserved
The migration to sdkmath.NewIntFromUint64
maintains the critical validation that prevents setting maxSupply below the currently issued amount.
240-240
: LGTM: Mintable amount calculation maintains precision and safety
The migration to sdkmath
for calculating mintable amount preserves the mathematical precision and overflow protection crucial for token minting operations.
108-108
: Verify consistent usage of sdkmath across token supply calculations
The change from sdk.NewIntFromUint64
to sdkmath.NewIntFromUint64
is correct, but we should verify consistent usage across all token supply calculations.
✅ Verification successful
Let me analyze the token supply calculations more deeply by checking the context around the remaining sdk.NewIntFromUint64
instances.
Migration to sdkmath package is consistent for token supply calculations
The remaining instances of sdk.NewIntFromUint64
are only in coinswap
module test files, while all token supply calculations in the token
module correctly use sdkmath.NewIntFromUint64
. The token module's math operations are consistent with the migration.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining instances of sdk.NewIntFromUint64 to ensure complete migration
# Expected: No instances of sdk.NewIntFromUint64 should remain in token-related files
# Search for any remaining instances of the old math function
rg "sdk\.NewIntFromUint64" --type go
# Search for the new math function to verify proper migration
rg "sdkmath\.NewIntFromUint64" --type go
Length of output: 1378
Script:
#!/bin/bash
# Get context around the remaining sdk.NewIntFromUint64 usages
rg "sdk\.NewIntFromUint64" --type go -B 2 -A 2
# Check if there are any other math operations in token-related files
rg "sdk\.(NewInt|NewDec|Int|Dec)" modules/token/ --type go
Length of output: 4447
modules/token/simulation/operations.go (2)
41-69
: LGTM! Weight distribution looks appropriate.
The weight distribution across different operations is well-balanced:
- Lower weight (10) for token issuance, which is typically less frequent
- Equal weights (50) for edit, mint, transfer, and burn operations, which are more common
175-175
: LGTM! Consistent updates to operation messages.
The removal of the unnecessary nil
parameter from simtypes.NewOperationMsg
calls is consistent across all simulation functions.
Also applies to: 254-254, 333-333, 415-415
modules/token/go.mod (2)
21-21
:
Verify the 'google.golang.org/genproto/googleapis/api' dependency version
The version v0.0.0-20240318140521-94a12d6c2237
appears to reference a commit date in the future (March 18, 2024). This might be unintended and could lead to build or compatibility issues. Please confirm that this is the correct version.
Run the following script to list available versions and check for anomalies:
#!/bin/bash
# Description: List available versions of 'google.golang.org/genproto/googleapis/api' and check for future dates.
# Expected: No versions should have future commit dates.
go list -m -versions google.golang.org/genproto/googleapis/api
# Check the timestamp of the specified version.
go list -m -json google.golang.org/[email protected] | jq '.Version, .Time'
205-205
:
Verify the 'google.golang.org/genproto' indirect dependency version
The version v0.0.0-20240227224415-6ceb2ff114de
seems to have a commit date in the future (February 27, 2024). This could cause unexpected issues during builds. Please verify that this is the intended version.
Run the following script to list available versions and check for anomalies:
api/irismod/token/v1beta1/token.pulsar.go (1)
1575-1608
:
Verify proper handling of LegacyDec
types in Params
The fields TokenTaxRate
and MintTokenFeeRatio
in the Params
message have been updated to use cosmossdk.io/math.LegacyDec
. Ensure all parts of the codebase that interact with these fields are updated to handle the new type to prevent type mismatches or runtime errors.
Run the following script to identify any instances where TokenTaxRate
or MintTokenFeeRatio
are incorrectly used as string
:
✅ Verification successful
Let me try with corrected ast-grep commands to verify the usage of these fields.
Let me search for actual usages of these fields to verify if there are any type mismatches.
Based on the search results, I can now provide a definitive response about the token tax rate and mint token fee ratio fields.
No issues found with LegacyDec
types in Params
The codebase correctly handles TokenTaxRate
and MintTokenFeeRatio
as LegacyDec
types:
- The core implementation in
modules/token/types/v1/token.pb.go
andmodules/token/types/v1beta1/token.pb.go
properly defines both fields ascosmossdk_io_math.LegacyDec
- All parameter validation functions in
params.go
correctly check formath.LegacyDec
type - The keeper code in
fees.go
properly handles these fields as decimal values - Test files demonstrate correct usage with
sdkmath.LegacyDec
values
The string types seen in the pulsar-generated code (token.pulsar.go
) are just serialization wrappers and do not affect the actual type handling in the core implementation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find usages of 'TokenTaxRate' and 'MintTokenFeeRatio' that are still using 'string' instead of 'LegacyDec'.
# Search for field declarations in 'Params' struct with incorrect types.
ast-grep --pattern '
type Params struct {
$_
TokenTaxRate string
$_
}' -t go
ast-grep --pattern '
type Params struct {
$_
MintTokenFeeRatio string
$_
}' -t go
# Search for assignments to 'TokenTaxRate' and 'MintTokenFeeRatio' using string literals.
ast-grep --pattern '
$_ := Params {
$_
TokenTaxRate: "$_",
$_
}' -t go
ast-grep --pattern '
$_ := Params {
$_
MintTokenFeeRatio: "$_",
$_
}' -t go
Length of output: 1073
Script:
#!/bin/bash
# Search for field declarations and usages of TokenTaxRate and MintTokenFeeRatio
# Search for Params struct definition and field types
ast-grep --pattern 'type Params struct {
$$$
}'
# Search for any direct string assignments or conversions
rg -l "TokenTaxRate|MintTokenFeeRatio" --type go
# Check proto definitions
fd -e proto | xargs cat
Length of output: 133302
Script:
#!/bin/bash
# Search for TokenTaxRate and MintTokenFeeRatio usages
rg -A 5 "TokenTaxRate|MintTokenFeeRatio" --type go
# Search for any string to LegacyDec conversions or assignments
rg -A 2 "LegacyDec|NewDecFromStr" --type go
Length of output: 58529
api/irismod/token/v1/tx.pulsar.go (1)
Line range hint 11495-11499
: Ensure that changes are reflected in the source .proto
files
Any changes in the generated code should correspond to modifications in the .proto
files. Verify that the source .proto
files have been updated accordingly.
You can verify this by regenerating the code and checking for differences:
✅ Verification successful
The generated code matches the proto definition
The generated code at api/irismod/token/v1/tx.pulsar.go
correctly reflects the message definition from proto/irismod/token/v1/tx.proto
. The MsgSwapToERC20
message structure with its fields (amount, sender, receiver) is properly defined in the proto file and corresponds to the binary encoding in the generated file.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Regenerate Protobuf code and check for differences.
make proto-gen
git diff api/irismod/token/v1/tx.pulsar.go
Length of output: 133
Script:
#!/bin/bash
# Let's first find the corresponding proto file
fd -e proto -x rg -l "MsgSwapToERC20" {}
# Then examine its content
fd -e proto -x cat {} | grep -A 5 -B 5 "MsgSwapToERC20"
Length of output: 1254
(gogoproto.nullable) = false | ||
]; | ||
|
||
cosmos.base.v1beta1.Coin issue_token_base_fee = 2 | ||
[ (gogoproto.nullable) = false ]; | ||
|
||
string mint_token_fee_ratio = 3 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", |
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.
💡 Codebase verification
Decimal type updates need attention in farm and coinswap modules
The verification reveals inconsistent decimal type usage across the codebase:
- Token and Service modules use the new
cosmossdk.io/math.LegacyDec
- Farm and Coinswap modules still use the old
github.com/cosmos/cosmos-sdk/types.Dec
Locations requiring updates:
proto/irismod/farm/farm.proto
: 2 instancesproto/irismod/coinswap/coinswap.proto
: 3 instances
🔗 Analysis chain
LGTM! Consistent type update across decimal fields.
The change to cosmossdk.io/math.LegacyDec
is consistent with the previous field, maintaining uniform decimal handling throughout the Params message.
Let's verify that all decimal types have been consistently updated across the codebase:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining old decimal type references
# and ensure consistent usage of the new type
# Search for any remaining old decimal type references
echo "Checking for any remaining old github.com/cosmos/cosmos-sdk/types.Dec references:"
rg "github.com/cosmos/cosmos-sdk/types.Dec"
# Search for new decimal type usage to ensure consistency
echo -e "\nVerifying consistent usage of new decimal type:"
rg "cosmossdk.io/math.LegacyDec"
Length of output: 5339
MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error | ||
BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error | ||
|
||
GetSupply(ctx sdk.Context, denom string) sdk.Coin | ||
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin | ||
GetSupply(ctx context.Context, denom string) sdk.Coin | ||
GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin | ||
|
||
SendCoinsFromModuleToAccount( | ||
ctx sdk.Context, | ||
ctx context.Context, | ||
senderModule string, | ||
recipientAddr sdk.AccAddress, | ||
amt sdk.Coins, | ||
) error | ||
SendCoinsFromAccountToModule( | ||
ctx sdk.Context, | ||
ctx context.Context, | ||
senderAddr sdk.AccAddress, | ||
recipientModule string, | ||
amt sdk.Coins, | ||
) error | ||
SendCoinsFromModuleToModule( | ||
ctx sdk.Context, | ||
ctx context.Context, | ||
senderModule, recipientModule string, | ||
amt sdk.Coins, | ||
) error | ||
|
||
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins | ||
SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins | ||
|
||
SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) | ||
GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) | ||
SetDenomMetaData(ctx context.Context, denomMetaData banktypes.Metadata) | ||
GetDenomMetaData(ctx context.Context, denom string) (banktypes.Metadata, bool) |
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.
💡 Codebase verification
Based on the search results, I can now generate a final response as we have sufficient information about the context usage patterns.
Migration to context.Context
is incomplete and inconsistent
The codebase shows an inconsistent state of context type usage:
- The BankKeeper interface in
modules/token/types/expected_keepers.go
usescontext.Context
- However, many implementations and other parts of the token module still use
sdk.Context
:- The keeper implementation (
modules/token/keeper/*.go
) extensively usessdk.Context
- The EVMKeeper interface in the same file still uses
sdk.Context
- Other modules' BankKeeper interfaces (e.g., htlc, coinswap, farm) are still using
sdk.Context
- The keeper implementation (
This suggests that the interface change to context.Context
is premature and needs to be coordinated with the actual implementations and other dependent modules.
🔗 Analysis chain
Verify context type alignment with Cosmos SDK v0.50.10
The migration from sdk.Context
to context.Context
in the BankKeeper interface appears correct. However, let's verify this aligns with Cosmos SDK v0.50.10's bank keeper implementation.
Let me gather more information about the context usage patterns across the codebase to better understand the migration status.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify context type usage in Cosmos SDK v0.50.10 bank keeper
# Expected: Methods should use context.Context in their signatures
# Search for bank keeper method signatures in cosmos-sdk
rg --type go -A 1 "type BankKeeper interface"
# Verify specific method signatures
rg --type go "MintCoins.*context\.Context"
rg --type go "BurnCoins.*context\.Context"
Length of output: 2349
Script:
#!/bin/bash
# Check for any remaining sdk.Context usage in the token module
rg --type go "sdk\.Context" modules/token/
# Check for context.Context usage in other critical keeper methods
rg --type go "GetSupply.*context\.Context"
rg --type go "GetBalance.*context\.Context"
rg --type go "SendCoinsFromModuleToAccount.*context\.Context"
# Look for any migration patterns or documentation
fd README.md | xargs rg -i "context.*migration"
Length of output: 7948
func NewParams(tokenTaxRate math.LegacyDec, issueTokenBaseFee sdk.Coin, | ||
mintTokenFeeRatio math.LegacyDec, enableErc20 bool, beacon string, |
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.
💡 Codebase verification
Inconsistent decimal type usage detected across modules
The verification reveals mixed usage of decimal types across the codebase:
token
module has been updated to usemath.LegacyDec
service
module usesmath.LegacyDec
- However,
farm
andcoinswap
modules still use the oldsdk.Dec
type
Locations requiring updates:
modules/farm/types/params.go
: Usessdk.Dec
for tax rate parametermodules/farm/migrations/v2/migrate.go
: Usessdk.Dec
in migration codemodules/coinswap/types/params.go
: Usessdk.Dec
for fee and tax rate parametersmodules/coinswap/migrations/v3/migrate.go
andv4/migrate.go
: Usessdk.Dec
in migration code
🔗 Analysis chain
Verify consistent usage of math.LegacyDec across the codebase
The transition from sdk.Dec
to math.LegacyDec
is correct for Cosmos SDK v0.50.x compatibility. However, we should ensure this change is consistently applied across all related code.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining sdk.Dec usages that might need updating
rg --type go 'sdk\.Dec'
# Search for math.LegacyDec usage to verify consistency
rg --type go 'math\.LegacyDec'
Length of output: 304
Script:
#!/bin/bash
# Search for any remaining sdk.Dec usages that might need updating
rg --type go 'sdk\.Dec'
# Search for math.LegacyDec usage to verify consistency
rg --type go 'math\.LegacyDec'
Length of output: 7912
@@ -39,22 +39,22 @@ func TestToken_ToMinCoin(t *testing.T) { | |||
{ | |||
name: fmt.Sprintf("Main Coin to Min Coin,scale=%d", i), | |||
wantErr: false, | |||
args: args{coin: sdk.NewDecCoin(token.Symbol, sdk.NewInt(10))}, | |||
args: args{coin: sdk.NewDecCoin(token.Symbol, sdkmath.NewInt(10))}, |
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.
💡 Codebase verification
Migration to sdkmath package needs additional changes
The verification reveals that while sdk.NewInt
has been correctly migrated to sdkmath.NewInt
, there are still several instances of sdk.NewDec
, sdk.NewDecWithPrec
, and related decimal types that need to be migrated to their sdkmath
equivalents. Here are the key locations that need attention:
modules/farm/simulation/genesis.go
: Usessdk.NewDecWithPrec
modules/farm/types/params.go
: Usessdk.NewDecWithPrec
modules/farm/keeper/pool.go
: Usessdk.NewDecFromInt
modules/coinswap/types/params.go
: Usessdk.NewDecWithPrec
modules/coinswap/migrations/v4/migrate.go
: Usessdk.NewDecWithPrec
modules/coinswap/migrations/v3/migrate.go
: Usessdk.NewDecWithPrec
modules/coinswap/keeper/fees.go
: Usessdk.NewDecFromInt
modules/coinswap/simulation/genesis.go
: Usessdk.NewDecWithPrec
🔗 Analysis chain
LGTM! Migration to sdkmath package is correct.
The changes appropriately migrate from sdk.NewInt
to sdkmath.NewInt
while maintaining the original test coverage and scenarios. The test cases effectively verify token conversion behavior across different scales.
Let's verify that all integer-related SDK types have been migrated:
Also applies to: 49-50, 56-57
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining old SDK integer types
# Expect: No matches as all should be migrated to sdkmath
rg "sdk\.NewInt|sdk\.Int|sdk\.NewDec|sdk\.Dec" --type go
Length of output: 14573
@@ -139,7 +140,7 @@ func (t Token) ToMinCoin(coin sdk.DecCoin) (newCoin sdk.Coin, err error) { | |||
if t.Symbol != coin.Denom { | |||
return sdk.NewCoin( | |||
coin.Denom, | |||
sdk.ZeroInt(), | |||
math.ZeroInt(), |
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.
Fix inconsistent usage of Legacy methods
There's an inconsistency in the usage of Legacy methods:
- Line 143 uses
math.ZeroInt()
while other changes use Legacy variants - Line 152 correctly uses
math.LegacyNewDecFromBigInt()
For consistency with other changes and to prevent potential compatibility issues, use the Legacy variant:
- math.ZeroInt(),
+ math.LegacyZeroInt(),
Also applies to: 152-152
@@ -5,8 +5,8 @@ import ( | |||
"fmt" | |||
|
|||
sdkmath "cosmossdk.io/math" | |||
"cosmossdk.io/store/prefix" |
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.
💡 Codebase verification
Update required: Found inconsistent import paths for prefix
package
The verification revealed inconsistent import paths across the codebase:
-
Files still using old import
github.com/cosmos/cosmos-sdk/store/prefix
:- modules/oracle/keeper/grpc_query.go
- modules/farm/keeper/grpc_query.go
- modules/coinswap/keeper/grpc_query.go
-
Files using new import
cosmossdk.io/store/prefix
:- modules/token/keeper/grpc_query.go
- modules/service/keeper/grpc_query.go
- modules/nft/migrations/v2/keeper.go
- modules/mt/keeper/grpc_query.go
Please update all remaining files to use the new import path cosmossdk.io/store/prefix
for consistency with Cosmos SDK v0.50.x.
🔗 Analysis chain
LGTM! Verify import consistency across the codebase.
The import path change from cosmos/cosmos-sdk/store
to cosmossdk.io/store/prefix
aligns with Cosmos SDK's modularization efforts in v0.50.x.
Let's verify that all files have been updated to use the new import path:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining old import paths
# Expected: No files should still use the old import path
echo "Checking for old import path usage..."
rg --type go "cosmos/cosmos-sdk/store/prefix" || echo "No old imports found ✓"
echo "Checking for new import path usage..."
rg --type go "cosmossdk.io/store/prefix"
Length of output: 755
var it storetypes.Iterator | ||
|
||
// 获取迭代器 | ||
if owner == nil { | ||
it = sdk.KVStorePrefixIterator(store, types.PrefixTokenForSymbol) | ||
it = storetypes.KVStorePrefixIterator(store, types.PrefixTokenForSymbol) | ||
} else { | ||
it = sdk.KVStorePrefixIterator(store, types.KeyTokens(owner, "")) | ||
it = storetypes.KVStorePrefixIterator(store, types.KeyTokens(owner, "")) |
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.
💡 Codebase verification
Iterator updates needed in multiple modules
Several modules still use the deprecated sdk.Iterator
and sdk.KVStorePrefixIterator
. Similar updates are needed in:
modules/oracle/keeper/feed.go
: Using deprecatedsdk.KVStorePrefixIterator
modules/htlc/keeper/htlc.go
andasset.go
: Using deprecatedsdk.Iterator
andsdk.KVStorePrefixIterator
modules/farm/keeper/*.go
: Multiple files using deprecated iterator typesmodules/coinswap/keeper/pool.go
: Using deprecated iterator initialization
The iterator type should be updated to storetypes.Iterator
and initialization should use storetypes.KVStorePrefixIterator
for cosmos-sdk v0.50.10 compatibility.
🔗 Analysis chain
LGTM: Iterator type update is consistent
The change from sdk.Iterator
to storetypes.Iterator
and corresponding initialization updates are correct for cosmos-sdk v0.50.10 compatibility.
Let's verify if similar iterator changes are needed in other files:
Let me check the actual iterator usage in these files to provide a more accurate assessment.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining sdk.Iterator or sdk.KVStorePrefixIterator usage
rg -l "sdk\.(Iterator|KVStorePrefixIterator)" --type go
# Search for potential iterator usage patterns that might need updating
ast-grep --pattern 'var $_ sdk.Iterator'
Length of output: 343
Script:
#!/bin/bash
# Check the context of sdk.Iterator usage in the identified files
rg "sdk\.Iterator" -B 2 -A 2 --type go
# Also check for KVStorePrefixIterator usage
rg "KVStorePrefixIterator" -B 2 -A 2 --type go
Length of output: 17267
@@ -512,7 +512,7 @@ func SimulateBurnToken( | |||
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil | |||
} | |||
|
|||
return simtypes.NewOperationMsg(msg, true, "simulate mint token", nil), nil, nil | |||
return simtypes.NewOperationMsg(msg, true, "simulate mint token"), nil, nil |
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.
Fix incorrect operation message in SimulateBurnToken.
The operation message incorrectly states "simulate mint token" for a burn operation.
Apply this fix:
- return simtypes.NewOperationMsg(msg, true, "simulate mint token"), nil, nil
+ return simtypes.NewOperationMsg(msg, true, "simulate burn token"), nil, nil
📝 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.
return simtypes.NewOperationMsg(msg, true, "simulate mint token"), nil, nil | |
return simtypes.NewOperationMsg(msg, true, "simulate burn token"), nil, nil |
@@ -512,7 +512,7 @@ | |||
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil | |||
} | |||
|
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.
Fix inconsistent error handling in SimulateBurnToken.
The error from app.SimDeliver
is silently ignored. This is inconsistent with other simulation functions that properly propagate the error.
Apply this fix:
- return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil
+ return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err
Committable suggestion skipped: line range outside the PR's diff.
modules/token/go.mod
Outdated
@@ -208,4 +224,8 @@ replace ( | |||
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0 | |||
// Downgraded to avoid bugs in following commits which caused simulations to fail. | |||
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 | |||
|
|||
// todo replace version |
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.
🛠️ Refactor suggestion
Address the TODO: Replace version in module replacements
There's a TODO comment indicating that a version needs to be specified in the replace
directive:
// todo replace version
mods.irisnet.org/api => ../../api
mods.irisnet.org/simapp => ../../simapp
Please update the replace
directives with the appropriate version numbers for mods.irisnet.org/api
and mods.irisnet.org/simapp
to ensure proper module resolution.
Would you like assistance in determining and updating the correct versions for these replacements? I can help generate the appropriate replace
directives.
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: 0
🧹 Outside diff range and nitpick comments (1)
modules/token/go.mod (1)
Update jwt-go replacement to address new security advisory
The jwt-go replacement is still needed as multiple modules depend on it, but the current replacement version (v4.4.2) should be updated to v4.5.1 to address a recently published security advisory (GHSA-29wx-vh33-7x7r / CVE-2024-51744).
- The original issue (#13134) for removing the replacement is closed, but the replacement is still required as the dependency is used across 12 modules
- Current replacement uses v4.4.2 which is vulnerable to a low-severity issue related to error handling
- Recommend updating to v4.5.1 which includes the security fix
🔗 Analysis chain
Line range hint
215-227
: Address TODO comment for jwt-go replacementWhile the current replacement of
dgrijalva/jwt-go
withgolang-jwt/jwt/v4
addresses the security concern, there's a TODO referencing cosmos-sdk issue #13134 for its removal.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check the status of the referenced issue echo "Checking status of jwt-go removal issue..." gh issue view 13134 --repo cosmos/cosmos-sdk # Check for any dependencies still using the old jwt-go echo "Checking for remaining uses of deprecated jwt-go..." rg "github.com/dgrijalva/jwt-go" --type goLength of output: 1978
Script:
#!/bin/bash # Let's check if there are any remaining direct or indirect dependencies on jwt-go echo "Checking go.mod files for jwt-go dependencies..." fd "go.mod$" --exec grep -l "jwt-go" # Check if the replacement is actually being used echo "Checking for golang-jwt/jwt usage..." rg "github.com/golang-jwt/jwt" --type go # Check for any security advisories echo "Checking for any security advisories..." gh api /repos/golang-jwt/jwt/security-advisoriesLength of output: 5946
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
modules/token/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (1)
modules/token/go.mod
(1 hunks)
🔇 Additional comments (3)
modules/token/go.mod (3)
3-3
: LGTM: Go version upgrade is appropriate
The upgrade to Go 1.21 aligns well with cosmos-sdk v0.50.10 requirements and brings important security updates and performance improvements.
28-213
: LGTM: Indirect dependencies include important security updates
The indirect dependency updates include several security-related improvements, particularly in:
- cloud.google.com/go and related packages
- golang.org/x/crypto
- Various prometheus packages
6-25
: Verify compatibility between core dependencies
The upgrade includes significant version bumps for core dependencies. While the individual versions look appropriate, let's verify their compatibility:
- cosmos-sdk v0.50.10 with cometbft v0.38.12
- cosmossdk.io/math v1.3.0 with the new cosmos-sdk version
✅ Verification successful
Based on the verification results from checking both cosmos-sdk v0.50.10 and cometbft v0.38.12 go.mod files, I can now provide a final response:
Core dependencies are compatible
The dependency versions in your go.mod are compatible:
- cosmos-sdk v0.50.10 directly requires cometbft v0.38.12
- cosmossdk.io/math v1.3.0 is the correct version used by cosmos-sdk v0.50.10
No compatibility issues were found between the core dependencies. The versions are aligned with the official releases and their requirements.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check dependency compatibility in cosmos-sdk v0.50.10
echo "Checking cosmos-sdk v0.50.10 go.mod for dependency versions..."
curl -s "https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.50.10/go.mod" | grep -E "cometbft|cosmossdk.io/math"
# Check for any known issues with these versions
echo "Checking for known issues..."
gh api graphql -f query='
{
repository(owner: "cosmos", name: "cosmos-sdk") {
issues(first: 5, states: OPEN, labels: ["bug"], searchQuery: "v0.50.10 compatibility") {
nodes {
title
url
labels(first: 5) {
nodes {
name
}
}
}
}
}
}'
Length of output: 1978
Script:
#!/bin/bash
# Let's try a different approach to verify compatibility
# Check cosmos-sdk's go.mod directly
echo "Checking cosmos-sdk v0.50.10 dependencies..."
curl -s "https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.50.10/go.mod"
# Check if there are any compatibility requirements in README or UPGRADING docs
echo -e "\nChecking upgrade docs for compatibility notes..."
curl -s "https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.50.10/UPGRADING.md"
# Let's also check CometBFT's requirements
echo -e "\nChecking CometBFT v0.38.12 dependencies..."
curl -s "https://raw.githubusercontent.com/cometbft/cometbft/v0.38.12/go.mod"
Length of output: 46862
Closed: #445
Summary by CodeRabbit
Release Notes
New Features
token_tax_rate
andmintable
in theMsgIssueToken
message.MsgMintToken
,MsgBurnToken
, andMsgDeployERC20
.Improvements
Bug Fixes
Refactor
Documentation