Skip to content

fix(katana): ensure the messaging is not panicking when started in sovereign - #3107

Merged
glihm merged 1 commit into
mainfrom
katana/sovereign-msg
Mar 15, 2025
Merged

fix(katana): ensure the messaging is not panicking when started in sovereign#3107
glihm merged 1 commit into
mainfrom
katana/sovereign-msg

Conversation

@glihm

@glihm glihm commented Mar 15, 2025

Copy link
Copy Markdown
Contributor

Messaging doesn't make sense in the sovereign mode at the moment. However we need this service to start in order to have Katana running as expected.

Summary by CodeRabbit

  • New Features
    • Introduced sovereign chain messaging support, enabling enhanced configuration and handling for sovereign chains.
  • Bug Fixes
    • Improved the messaging service to enforce a valid interval, automatically defaulting to a safe duration and logging warnings for improper settings.

@glihm glihm changed the title fix: ensure the messaging is not panicking when started in sovereign fix(katana): ensure the messaging is not panicking when started in sovereign Mar 15, 2025
@coderabbitai

coderabbitai Bot commented Mar 15, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Ohayo, sensei! This PR adds support for a new messaging configuration for Sovereign chains. The changes update the configuration in the messaging module by introducing a new constant, a variant in the messenger mode enum, and an associated struct. The control flow is modified in both the configuration and the messaging service: instead of panicking, the system now creates a configuration for sovereign chains and logs appropriate warnings, particularly when a messaging interval is zero.

Changes

File(s) Change Summary
crates/katana/.../lib.rs - Added CONFIG_CHAIN_SOVEREIGN constant.
- Introduced SovereignMessaging struct and MessengerMode::Sovereign variant.
- Updated MessagingConfig::from_chain_spec and MessengerMode::from_config to support sovereign chains.
crates/katana/.../service.rs - Added a warning log in interval_from_seconds for zero intervals.
- Modified gather_messages to return (0, 0) for MessengerMode::Sovereign.

Sequence Diagram(s)

sequenceDiagram
    participant CS as ChainSpec
    participant MC as MessagingConfig
    participant MM as MessengerMode
    participant MS as MessagingService

    CS->>MC: from_chain_spec(Sovereign chain)
    MC->>MM: Initialize using CONFIG_CHAIN_SOVEREIGN with interval 60s
    MM->>MS: Handle via from_config (logs unavailability)
    MS->>MS: gather_messages detects Sovereign mode, returns (0, 0)
Loading

Possibly related PRs

Suggested reviewers

  • kariy (sensei)

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this 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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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)
crates/katana/messaging/src/lib.rs (1)

185-186: Simple and sufficient struct definition

The SovereignMessaging struct is appropriately minimal since no actual messaging occurs in sovereign mode. Consider adding a doc comment to explain its purpose.

 #[derive(Debug)]
-pub struct SovereignMessaging {}
+/// Represents messaging for sovereign chains (no actual messaging occurs)
+pub struct SovereignMessaging {}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5451650 and a1e85dd.

📒 Files selected for processing (2)
  • crates/katana/messaging/src/lib.rs (4 hunks)
  • crates/katana/messaging/src/service.rs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (7)
crates/katana/messaging/src/service.rs (3)

12-12: Ohayo! Good addition of warn level logging

You've added the warn import from the tracing crate, which is used later for the interval warning. This is a positive change aligned with good logging practices.


101-101: Elegant handling of Sovereign mode, sensei!

This new match arm for MessengerMode::Sovereign(_) returns (0, 0) indicating no messages gathered, which aligns perfectly with the PR's objective to prevent panics in sovereign mode.


158-164: Nice defensive programming for interval handling!

You've added protection against zero intervals by defaulting to 1 second with a warning message. This prevents potential issues with timer behavior and keeps the messaging service running smoothly.

crates/katana/messaging/src/lib.rs (4)

62-62: Ohayo! Good constant naming convention

Adding the CONFIG_CHAIN_SOVEREIGN constant follows the established pattern for other chain configurations. This maintains consistency in the codebase.


140-146: Well-structured Sovereign chain configuration, sensei!

The new match arm for the Sovereign settlement layer creates an appropriate configuration with sensible defaults. Setting the interval to 60 seconds is reasonable since messaging is not actively used in sovereign mode.


182-182: Clean enum extension

Adding the Sovereign variant to MessengerMode enum is a clean way to represent the new mode. This maintains the pattern used for other messenger modes.


213-216: Clear logging and handling for Sovereign mode

Good job providing clear logging that messaging is not available in Sovereign mode. This properly informs users about the expected behavior instead of causing a panic.

@codecov

codecov Bot commented Mar 15, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 10.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 57.08%. Comparing base (5451650) to head (a1e85dd).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/messaging/src/lib.rs 0.00% 13 Missing ⚠️
crates/katana/messaging/src/service.rs 28.57% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3107      +/-   ##
==========================================
- Coverage   57.14%   57.08%   -0.07%     
==========================================
  Files         442      442              
  Lines       61148    61199      +51     
==========================================
- Hits        34946    34938       -8     
- Misses      26202    26261      +59     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@glihm
glihm merged commit a77d744 into main Mar 15, 2025
@glihm
glihm deleted the katana/sovereign-msg branch March 15, 2025 18:04
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