Skip to content

feat(katana): add support for sovereign mode for init command - #3101

Merged
glihm merged 6 commits into
mainfrom
katana-init-sovereign
Mar 14, 2025
Merged

feat(katana): add support for sovereign mode for init command#3101
glihm merged 6 commits into
mainfrom
katana-init-sovereign

Conversation

@glihm

@glihm glihm commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

Currently, Katana only supports the init command for persistent rollup, which can be cumbersome for users that only wants to send proofs on a DA layer using sovereign mode.

This PR aims at proposing a simplified katana init flow for sovereign rollup, to ensure that Katana can be started in provable mode without providing settlement information.

Summary by CodeRabbit

  • New Features

    • Introduced a sovereign chain option that allows initializing a chain without a settlement layer.
    • Enhanced chain setup by requiring a valid chain identifier and offering additional configuration fields.
    • Updated the outcome display to clearly differentiate between traditional and sovereign chain configurations.
    • Improved safeguards by flagging unsupported configurations for certain messaging features.
  • Documentation

    • Updated guidance to help users understand the enhanced chain initialization options.

@glihm
glihm requested a review from kariy March 14, 2025 01:41
@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

Ohayo, sensei! Below is the updated summary of the changes with the requested sections.

Walkthrough

The changes update the initialization process for chain configuration. The InitArgs struct is refactored with a mandatory id field and several new optional settlement-related fields, alongside a new sovereign flag. The outcome handling is enhanced through new types (SovereignOutcome and PersistentOutcome) consolidated into the AnyOutcome enum. Additionally, the prompt function now returns a broader outcome type and introduces a dedicated slot paymaster collection function. Modifications in the chain-spec, messaging, and node components ensure proper handling of the new sovereign chain type.

Changes

File(s) Change Summary
bin/katana/src/cli/init/mod.rs Updated InitArgs struct: changed id to a non-optional NonEmptyString, added settlement fields and sovereign flag; introduced AnyOutcome enum, PersistentOutcome, and SovereignOutcome.
bin/katana/src/cli/init/prompt.rs Changed return type from Outcome to AnyOutcome; added prompt_slot_paymasters function; updated handling of outcomes with new sovereign variant in settlement chain options.
crates/katana/chain-spec/src/lib.rs Added new Sovereign variant to SettlementLayer enum for future data availability functionality.
crates/katana/messaging/src/lib.rs Introduced a new match arm in from_chain_spec to panic on Sovereign settlement layer, reinforcing unsupported configuration.
crates/katana/node/src/lib.rs Added a match arm in the build function to handle SettlementLayer::Sovereign by using a Starknet-based gas oracle, reflecting uncertainty about fixed gas pricing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Configurator
    participant OutcomeHandler

    User ->> CLI: Provide chain configuration and options
    CLI ->> Configurator: Parse InitArgs (validate id, check sovereign flag)
    Configurator -->> CLI: Process settlement and sovereign options
    CLI ->> OutcomeHandler: Generate outcome (PersistentOutcome or SovereignOutcome)
    OutcomeHandler -->> CLI: Return AnyOutcome result
    CLI -->> User: Display initialization result
Loading

Possibly related PRs

Suggested reviewers

  • kariy

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 9a1ffef and ceeebb6.

📒 Files selected for processing (1)
  • crates/katana/node/src/lib.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/node/src/lib.rs

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

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

139-141: Ohayo sensei, consider returning an error instead of panicking.
Panics can crash the entire node unexpectedly. Handling it gracefully could improve stability.

bin/katana/src/cli/init/prompt.rs (2)

186-186: Ohayo sensei, consider returning a Vec instead of Option<Vec>.
The function always returns Some(...); clarifying the type might simplify usage.


229-229: Ohayo sensei, always returning Some(...) indicates Option isn’t strictly necessary.
Refactoring the function to return Vec could improve readability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e561673 and 3c98cb3.

📒 Files selected for processing (5)
  • bin/katana/src/cli/init/mod.rs (5 hunks)
  • bin/katana/src/cli/init/prompt.rs (6 hunks)
  • crates/katana/chain-spec/src/lib.rs (1 hunks)
  • crates/katana/messaging/src/lib.rs (1 hunks)
  • crates/katana/node/src/lib.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt
🔇 Additional comments (26)
crates/katana/chain-spec/src/lib.rs (1)

104-108: Ohayo sensei, the new Sovereign variant is nicely introduced.
No issues here; it provides a future extension point for DA syncing.

crates/katana/node/src/lib.rs (1)

232-234: Ohayo sensei, consider using a fixed gas approach for sovereign settlement.
Relying on external sampling might be misleading when there’s no actual external settlement chain.

bin/katana/src/cli/init/prompt.rs (7)

17-17: Ohayo sensei, new imports look good.
They correctly reference the updated outcome types.


22-22: Ohayo sensei, the broader AnyOutcome return type looks good.
This flexible approach helps accommodate both persistent and sovereign outcomes.


40-40: Ohayo sensei, adding Sovereign to the enum is consistent.
Smooth integration for the new settlement chain type.


52-52: Ohayo sensei, enumerating Sovereign in options is aligned with new functionality.
No problems spotted here.


65-73: Ohayo sensei, the sovereign flow looks well-structured.
Returning SovereignOutcome is clear and distinct.


173-173: Ohayo sensei, collecting slot paymasters is a helpful addition.
This ensures consistent paymaster logic across setups.


175-184: Ohayo sensei, forming PersistentOutcome here is neat.
It centralizes all necessary state for a persistent chain.

bin/katana/src/cli/init/mod.rs (17)

30-38: Ohayo sensei! Potential contradiction in the id field configuration.
The doc comment states that an empty id is not allowed, but #[arg(default_value = "")] implies it can start empty. This might be intentional for prompting the user, but please confirm if there's a need to enforce a non-empty string before reaching the prompt logic.


40-40: Ohayo sensei! Nice doc clarification.
The description for the settlement chain setup is concise and helps users understand the configuration details.


45-45: Ohayo sensei! Great documentation.
This doc comment clearly states the purpose of the settlement account address.


50-50: Ohayo sensei! Good detail on the private key usage.
The comment clarifies how the private key is used for core contract configuration.


55-57: Ohayo sensei! Clear doc for settlement contract handling.
Explains how the contract might be deployed or reused, which is helpful for new contributors.


62-64: Ohayo sensei! Good explanation of settlement_contract_deployed_block.
Ensures that Katana knows how to gather messages from the correct block onward.


69-78: Ohayo sensei! Well-structured introduction of the sovereign mode.
The #[arg(conflicts_with_all = [...])] approach is concise and prevents invalid usage alongside settlement fields.


98-106: Ohayo sensei! Settlement matching logic is well-handled.
Switching to SettlementLayer::Sovereign when the outcome is sovereign is clear and predictable. Great addition!


109-109: Ohayo sensei! Neat chain ID parsing.
Parsing output's chain ID helps ensure we store the correct chain spec. Looks good.


114-117: Ohayo sensei! Slot paymasters integration is nicely modular.
This block effectively extends the genesis for paymasters without disturbing other logic.


135-137: Ohayo sensei! Cleaner return type for configure_from_args.
Returning Option<anyhow::Result<AnyOutcome>> is a good step to accommodate both persistent and sovereign flows.


138-143: Ohayo sensei! Sovereign outcome initialization is straightforward.
Creating a SovereignOutcome when sovereign is set keeps the logic concise.


193-201: Ohayo sensei! Solid handling of PersistentOutcome.
Unwrapping settlement arguments confidently works well, given Clap’s strict requirement checks.


208-213: Ohayo sensei! Splitting outcomes into AnyOutcome is a neat architectural move.
Having an enum to unify possible outcomes simplifies downstream logic.


215-230: Ohayo sensei! Useful methods on AnyOutcome.
Exposing id() and slot_paymasters() ensures flexible, ergonomic usage for both outcome variants.


232-240: Ohayo sensei! SovereignOutcome struct creation is well-defined.
The separation is clean and clarifies the data needed for a sovereign chain.


242-260: Ohayo sensei! PersistentOutcome struct is well-structured.
All necessary fields for the settlement configuration are logically grouped, promoting clarity.

@glihm glihm changed the title feat: add a proposal to support sovereign rollup Katana init feat(katana): add support for sovereign mode for init command Mar 14, 2025
@codecov

codecov Bot commented Mar 14, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 22.22222% with 63 lines in your changes missing coverage. Please review.

Project coverage is 57.19%. Comparing base (e561673) to head (ceeebb6).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
bin/katana/src/cli/init/mod.rs 32.72% 37 Missing ⚠️
bin/katana/src/cli/init/prompt.rs 0.00% 18 Missing ⚠️
crates/katana/node/src/lib.rs 0.00% 7 Missing ⚠️
crates/katana/messaging/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3101      +/-   ##
==========================================
- Coverage   57.21%   57.19%   -0.03%     
==========================================
  Files         446      446              
  Lines       60618    60685      +67     
==========================================
+ Hits        34685    34709      +24     
- Misses      25933    25976      +43     

☔ 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 commented Mar 14, 2025

Copy link
Copy Markdown
Contributor Author

@kariy thank you sensei for the review and fixes. 🙏

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.

2 participants