Skip to content

Conversation

hawkadrian
Copy link
Contributor

@hawkadrian hawkadrian commented Aug 30, 2025

Description

Fixes the slashing simulation operation weight issue where MsgUnjail was almost always skipped.

Summary by CodeRabbit

  • Chores

    • Adjusted simulation parameters to significantly reduce how often the “unjail” operation is selected during simulations, aligning simulation behavior with real-world validator states. No impact on production behavior or user workflows.
  • Documentation

    • Clarified comments in the simulation to explain why the “unjail” operation is frequently skipped and the rationale for lowering its selection frequency, improving maintainability and reviewer understanding.

Copy link
Contributor

coderabbitai bot commented Aug 30, 2025

📝 Walkthrough

Walkthrough

Reduces DefaultWeightMsgUnjail from 100 to 5 in slashing simulation operations and updates comments in SimulateMsgUnjail to note frequent skip behavior when validators aren’t jailed. No functional changes to runtime behavior; non-jailed path still returns a NoOpMsg.

Changes

Cohort / File(s) Summary of Changes
Slashing simulation parameters
x/slashing/simulation/operations.go
Lowered exported constant DefaultWeightMsgUnjail from 100 to 5, reducing selection weight in WeightedOperations. Updated comments in SimulateMsgUnjail clarifying skip frequency and rationale. No code-path/logic change; still returns NoOpMsg when validator is not jailed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
x/slashing/simulation/operations.go (1)

164-166: Potential nil dereference on error path (res may be nil).

If SimDeliver returns err with a nil res, accessing res.Log will panic.

-		if err != nil {
-			return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, errors.New(res.Log)
-		}
+		if err != nil {
+			if res != nil && len(res.Log) > 0 {
+				return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, errors.New(res.Log)
+			}
+			return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err
+		}
🧹 Nitpick comments (1)
x/slashing/simulation/operations.go (1)

90-92: Avoid hardcoding the weight value in comments.

Refer to the constant to prevent drift if it changes again.

-			// This operation is often skipped because validators are rarely jailed in simulations.
-			// The weight has been reduced to 5 to reflect this reality.
+			// Often skipped because validators are rarely jailed in sims; see DefaultWeightMsgUnjail for the current weight rationale.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between b6b58e4 and 9fc08d7.

📒 Files selected for processing (1)
  • x/slashing/simulation/operations.go (2 hunks)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (1)
x/slashing/simulation/operations.go (1)

25-25: Good call lowering the default weight to 5.

Aligns with actual sim behavior and avoids wasting cycles on an op that usually skips.

@aljo242 aljo242 enabled auto-merge September 12, 2025 18:12
@aljo242 aljo242 added this pull request to the merge queue Sep 12, 2025
Merged via the queue into cosmos:main with commit 1a5c57b Sep 12, 2025
39 checks passed
warpbuild-benchmark-bot bot added a commit to WarpBuilds/cosmos-sdk that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants