Skip to content

Conversation

@randy-cro
Copy link
Contributor

@randy-cro randy-cro commented Nov 19, 2025

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • Tests

    • Added comprehensive integration tests for the mint module's BlocksPerYear parameter covering zero, valid, boundary, and overflow cases.
    • Introduced a dedicated test marker for mint-related tests to enable targeted execution.
  • Chores

    • Updated the cosmos-sdk dependency to a newer pinned version.
    • Expanded CI test workflow to include mint module tests in the integration matrix.

…mos-sdk (backport #25562) (crypto-org-chain#1918)

* update cosmos-sdk (backport #26652) - improve mint params validation

* add integration tests

* fix python lint

* remove comment

Signed-off-by: randy-cro <[email protected]>

---------

Signed-off-by: randy-cro <[email protected]>
@randy-cro randy-cro requested a review from a team as a code owner November 19, 2025 09:09
@randy-cro randy-cro requested review from calvinaco and thomas-nguy and removed request for a team November 19, 2025 09:09
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Walkthrough

Adds mint integration tests and a pytest marker, updates the cosmos-sdk dependency (go.mod and gomod2nix.toml), and includes mint in the GitHub Actions integration test matrix.

Changes

Cohort / File(s) Summary
GitHub Actions workflow
\.github/workflows/test.yml
Added mint to the integration test matrix.
Go module dependencies
go.mod, gomod2nix.toml
Updated github.com/cosmos/cosmos-sdk pseudo-version from v0.50.6-0.20250424063720-28ea58ae20d8 to v0.50.6-0.20251119062431-8d0a31ef043d; updated corresponding sha256 in gomod2nix.toml.
Integration test config
integration_tests/conftest.py
Registered a new pytest marker mint for mint-module tests.
Mint integration tests
integration_tests/test_mint_blocks_per_year.py
Added end-to-end tests exercising governance updates to BlocksPerYear, including zero, valid, MaxInt64, MaxInt64+1, and UINT64_MAX cases plus helper utilities and block-waiting verification.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Mint Test
    participant CLI as Cronos CLI
    participant Gov as Gov Module
    participant Chain as Blockchain

    Test->>CLI: Query current mint params
    CLI-->>Test: Return current BlocksPerYear

    rect rgb(200,220,255)
    Note over Test,Gov: Proposal submission flow
    Test->>Test: Normalize decimal fields
    Test->>CLI: Submit gov proposal (update BlocksPerYear)
    CLI->>Gov: Create proposal
    Gov->>Chain: Store proposal
    Chain-->>CLI: Confirm submission
    CLI-->>Test: Submission result
    end

    rect rgb(220,255,220)
    Note over Test,Chain: Verification flow
    Test->>Test: Wait for blocks / proposal enactment
    Test->>CLI: Query mint params again
    CLI->>Chain: Fetch state
    Chain-->>CLI: Return updated params
    CLI-->>Test: New BlocksPerYear
    Test->>Test: Assert expected outcome
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review dependency replace/version and checksum consistency across go.mod and gomod2nix.toml.
  • Inspect new tests for correctness around big-integer boundaries and waiting/assertion logic (integration_tests/test_mint_blocks_per_year.py).
  • Confirm GitHub Actions matrix change introduces expected CI runs; verify pytest marker name consistency.

Possibly related PRs

Suggested reviewers

  • calvinaco
  • thomas-nguy

Poem

🐰 A tiny test hops into the night,
BlocksPerYear counted, boundaries in sight,
Proposals proposed, the chain keeps its pace,
Dependencies updated, the logs leave a trace,
Hooray for mint — a carrot-shaped case!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title is partially related to the changeset as it mentions 'x/mint params validation and test' which aligns with the new mint module tests and related updates, but it doesn't clearly highlight that the primary changes include cosmos-sdk dependency updates in go.mod and gomod2nix.toml alongside the new integration tests.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the ci label Nov 19, 2025
@socket-security
Copy link

socket-security bot commented Nov 19, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​crypto-org-chain/​cosmos-sdk@​v0.50.6-0.20250424063720-28ea58ae20d8 ⏵ v0.50.6-0.20251119062431-8d0a31ef043d76 +1100100100100

View full report

@randy-cro randy-cro enabled auto-merge November 19, 2025 09:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
integration_tests/test_mint_blocks_per_year.py (2)

27-46: Consider validating decimal values instead of returning them as-is.

Lines 34-35 return values containing "." without validation. This could accept malformed decimals (e.g., wrong number of decimal places). Consider normalizing existing decimal values or adding validation to ensure they conform to the 18-decimal-place LegacyDec format.

 def normalize_legacy_dec(value: str) -> str:
     """
     Ensure math.LegacyDec strings have an explicit decimal point (scale 18).
     This matches the Cosmos SDK's LegacyDec format.
     """
     if not value:
         return "0.000000000000000000"
     if "." in value:
-        return value
+        # Validate and normalize existing decimal values
+        parts = value.split(".")
+        if len(parts) != 2:
+            raise ValueError(f"Invalid decimal format: {value}")
+        int_part = parts[0] or "0"
+        frac_part = parts[1].ljust(18, "0")[:18]
+        return f"{int_part}.{frac_part}"
     sign = ""
     if value[0] == "-":
         sign = "-"
         value = value[1:]
     stripped = value.lstrip("0")
     if not stripped:
         return "0.000000000000000000"
     padded = stripped.rjust(19, "0")
     int_part = padded[:-18] or "0"
     frac_part = padded[-18:]
     return f"{sign}{int_part}.{frac_part}"

86-101: Improve exception handling specificity.

The current implementation catches all exceptions broadly and returns False, which can hide unexpected errors and make debugging difficult. Consider catching specific exceptions or re-raising unexpected errors.

Based on learnings

     try:
         submit_gov_proposal(
             cronos,
             msg,
             messages=[
                 {
                     "@type": msg,
                     "authority": authority,
                     "params": params,
                 }
             ],
         )
-        return True
-    except (AssertionError, Exception) as e:
+    except AssertionError as e:
+        # Expected validation failure
         print(f"Proposal failed as expected: {e}")
         return False
+    except Exception as e:
+        # Unexpected error - log and re-raise for debugging
+        print(f"Unexpected error during proposal submission: {e}")
+        raise
+    else:
+        return True
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 984097c and 8c389fb.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • .github/workflows/test.yml (1 hunks)
  • go.mod (1 hunks)
  • gomod2nix.toml (1 hunks)
  • integration_tests/conftest.py (1 hunks)
  • integration_tests/test_mint_blocks_per_year.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
integration_tests/test_mint_blocks_per_year.py (3)
integration_tests/utils.py (1)
  • wait_for_new_blocks (133-141)
integration_tests/cosmoscli.py (1)
  • query_params (1115-1126)
integration_tests/conftest.py (1)
  • cronos (63-72)
🪛 Ruff (0.14.5)
integration_tests/test_mint_blocks_per_year.py

98-98: Consider moving this statement to an else block

(TRY300)


99-99: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: unittest
  • GitHub Check: build (macos-latest)
  • GitHub Check: gomod2nix
  • GitHub Check: build (macos-14)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (mint)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: Run golangci-lint
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
integration_tests/conftest.py (1)

26-26: LGTM!

The new pytest marker for mint module tests follows the established pattern and is properly documented.

.github/workflows/test.yml (1)

22-22: LGTM!

The mint test suite is properly integrated into the CI workflow matrix, ensuring the new tests run alongside existing integration tests.

gomod2nix.toml (1)

216-217: LGTM!

The cosmos-sdk version and hash are correctly updated to match the go.mod changes. The verification requested for go.mod applies here as well.

integration_tests/test_mint_blocks_per_year.py (4)

1-24: LGTM!

The module documentation clearly describes the test scenarios, imports are appropriate, and the constants are correctly defined for boundary testing.


49-52: LGTM!

Simple and clear helper function for querying mint module parameters.


104-129: LGTM!

The test correctly verifies that blocks_per_year = 0 is rejected and that the parameter remains unchanged after the failed proposal.


206-256: LGTM!

Both overflow test cases correctly verify that values exceeding MAX_INT64 (both MAX_INT64+1 and UINT64_MAX) are properly rejected and that the parameter remains unchanged.

go.mod (1)

284-284: No issues found.

The commit 8d0a31ef043d exists in the forked repository and contains the expected mint parameter validation changes ("chore: cleanup and improve x/mint params validation and test"). The pseudo-version reference is valid.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.25%. Comparing base (a3c2f70) to head (543bb56).
⚠️ Report is 121 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1919       +/-   ##
===========================================
+ Coverage   16.87%   37.25%   +20.38%     
===========================================
  Files          72      127       +55     
  Lines        6163     9730     +3567     
===========================================
+ Hits         1040     3625     +2585     
- Misses       5000     5682      +682     
- Partials      123      423      +300     

see 121 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
integration_tests/test_mint_blocks_per_year.py (1)

86-101: Tighten exception handling in submit_mint_param_update to avoid masking unexpected errors

Catching (AssertionError, Exception) and unconditionally treating any exception as an expected proposal failure both trips Ruff (BLE001/TRY300) and can hide genuinely unexpected issues (e.g., coding errors, I/O problems) behind a False return.

Consider narrowing the expected-failure path and letting unexpected exceptions surface, and optionally using an else for the success case, e.g.:

-    try:
-        submit_gov_proposal(
-            cronos,
-            msg,
-            messages=[
-                {
-                    "@type": msg,
-                    "authority": authority,
-                    "params": params,
-                }
-            ],
-        )
-        return True
-    except (AssertionError, Exception) as e:
-        print(f"Proposal failed as expected: {e}")
-        return False
+    try:
+        submit_gov_proposal(
+            cronos,
+            msg,
+            messages=[
+                {
+                    "@type": msg,
+                    "authority": authority,
+                    "params": params,
+                }
+            ],
+        )
+    except AssertionError as e:
+        # Expected failure path in tests where the proposal should be rejected
+        print(f"Proposal failed as expected: {e}")
+        return False
+    else:
+        return True

Adjust the caught exception type(s) to whatever submit_gov_proposal actually raises on expected failures so that unexpected exceptions still bubble up with full tracebacks.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c389fb and 543bb56.

📒 Files selected for processing (1)
  • integration_tests/test_mint_blocks_per_year.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
integration_tests/test_mint_blocks_per_year.py (3)
integration_tests/utils.py (1)
  • wait_for_new_blocks (133-141)
integration_tests/cosmoscli.py (1)
  • query_params (1115-1126)
integration_tests/conftest.py (1)
  • cronos (63-72)
🪛 Ruff (0.14.5)
integration_tests/test_mint_blocks_per_year.py

98-98: Consider moving this statement to an else block

(TRY300)


99-99: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: integration_tests (mint)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: Run golangci-lint
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: unittest
  • GitHub Check: gomod2nix
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
integration_tests/test_mint_blocks_per_year.py (1)

104-256: Boundary coverage for blocks_per_year looks solid

The tests exercise zero, a small valid value, MaxInt64, MaxInt64 + 1, and UINT64_MAX, and they verify both parameter persistence and continued block production. This is a good, focused set of integration checks around the mint params update path.

@randy-cro randy-cro added this pull request to the merge queue Nov 19, 2025
@randy-cro randy-cro changed the title chore: cleanup and improve x/mint params validation and test in cosmos-sdk (backport #25562) chore: cleanup and improve x/mint params validation and test in cosmos-sdk (backport #25562) Nov 19, 2025
Merged via the queue into crypto-org-chain:main with commit 47a2ae0 Nov 19, 2025
44 checks passed
@randy-cro randy-cro deleted the backport/improve-mint-params-validation-25562 branch November 19, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants