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

feat(katana-messaging): remove sending messages to settlement layer #3035

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

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Feb 14, 2025

The feature of sending message to settlement layer was done mainly to test messaging in the early days of Starknet.

Now that app chains are here, there is no need of such feature.

This PR aims at removing all the code related to send a message to the settlement layout from Katana operated as a Rollup sequencer. Module documentation has been updated and types simplified when possible.

We also had some errors of type Send where it should have been Gather, confusing me during some tests on Katana. Those errors have been fixed to Gather instead.

In the current setup, we still have the blockifier limitation for the to_address field as mentioned in comment into the messaging crate doc. But this can be resolved by a simple application logic with the MSG_MAGIC as it was implemented in Katana before trimming this code.

Ideally @kariy as we have discussed, if the blockifier changes to remove this constraint aren't big, it will be beneficial to have to_address of type felt.

Summary by CodeRabbit

  • Refactor
    • Streamlined the messaging workflow to focus on gathering messages and executing them via a proof-generation process.
    • Simplified the MessagingService and StarknetMessaging structures by removing unnecessary fields and methods.
  • Chores
    • Removed outdated dependency configurations and eliminated redundant parameters from the messaging setup.
  • Documentation
    • Updated explanations to provide clearer insight into the revised messaging execution process.
  • Tests
    • Adjusted related test configurations to align with the simplified messaging approach, including the removal of unnecessary fields.

@glihm glihm requested a review from kariy February 14, 2025 23:08
Copy link

coderabbitai bot commented Feb 14, 2025

Ohayo, sensei! Here are the updated details for this pull request:

Walkthrough

This pull request refactors the messaging subsystem. The changes remove the katana-provider dependency and eliminate the send_messages method (along with related functions) across various modules. The MessagingService and MessagingTask have been simplified by dropping generic provider parameters and updating method signatures. The configuration for messaging has also been streamlined by removing specific fields. Overall, the changes adjust the control flow to focus on message gathering and proof generation rather than direct message sending.

Changes

File(s) Change Summary
crates/katana/messaging/Cargo.toml Removed dependency declaration for katana-provider with { workspace = true, default-features = false }.
crates/katana/messaging/src/{ethereum.rs, lib.rs, service.rs, starknet.rs}
crates/katana/sync/stage/src/sequencing.rs
Removed message-sending methods (send_messages, send_invoke_tx, parse_messages); dropped logging and provider-based logic; refactored MessagingService and MessagingTask by removing generic parameters and the provider dependency, and updated method signatures.
crates/katana/rpc/rpc/tests/messaging.rs Removed configuration fields (sender_address and private_key) from the MessagingConfig structure used in tests.

Sequence Diagram(s)

sequenceDiagram
    participant MT as Messaging Task
    participant MS as Messaging Service
    participant SO as StarknetOS
    participant SC as Settlement Chain

    MT->>MS: Gather messages from settlement chain
    MS->>SO: Execute proof generation (STARK proof)
    SO-->>MS: Return generated proof
    MS->>SC: Send proof for verification
Loading

Possibly related PRs

Suggested labels

contributor

Suggested reviewers

  • kariy

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c93fdb and ad6cd46.

📒 Files selected for processing (1)
  • crates/katana/rpc/rpc/tests/messaging.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/rpc/rpc/tests/messaging.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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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: 0

🧹 Nitpick comments (3)
crates/katana/messaging/src/service.rs (1)

105-109: Ohayo sensei! There's a small nitpick on naming.
The field is spelled lastest_block, but you might want latest_block to avoid confusion.

- pub lastest_block: u64,
+ pub latest_block: u64,
crates/katana/messaging/src/starknet.rs (2)

98-98: Consider improving error handling.

Ohayo sensei! While the error handling change from SendError to GatherError aligns with the removal of sending functionality, consider adding more context to help with debugging:

-                return Err(Error::GatherError);
+                return Err(Error::GatherError.with_context("Failed to fetch settlement chain block number"));

118-118: Consider adding error context.

Similar to above, consider adding more context to the error:

-            .map_err(|_| Error::GatherError)
+            .map_err(|e| Error::GatherError.with_context(format!("Failed to fetch events: {}", e)))
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between de7eddd and 5581171.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • crates/katana/messaging/Cargo.toml (0 hunks)
  • crates/katana/messaging/src/ethereum.rs (1 hunks)
  • crates/katana/messaging/src/lib.rs (4 hunks)
  • crates/katana/messaging/src/service.rs (4 hunks)
  • crates/katana/messaging/src/starknet.rs (4 hunks)
  • crates/katana/rpc/rpc/tests/messaging.rs (1 hunks)
  • crates/katana/sync/stage/src/sequencing.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • crates/katana/messaging/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ensure-windows
  • GitHub Check: test
🔇 Additional comments (19)
crates/katana/messaging/src/service.rs (6)

20-20: Ohayo sensei! Nice simplification by dropping the generic parameter.
This makes the MessagingService more straightforward and aligns well with the removal of direct message sending.


33-33: Ohayo sensei!
No concerns here—removing the generic bounds from impl MessagingService keeps the code maintainable.


53-53: Ohayo sensei!
Initializing msg_gather_fut as None is an elegant way to defer gathering until needed. Good job.


112-112: Ohayo sensei!
Good usage of Stream here. This improves clarity by consistently polling for new messaging outcomes.


118-124: Ohayo sensei! Consider verifying the interval scheduling.
If gathering takes longer than the interval, ensure we don’t queue extra futures. This code is likely fine, but keep an eye on possible repeated scheduling.


133-133: Ohayo sensei!
Returning Poll::Ready(Some(MessagingOutcome { ... })) is a neat approach to publish the new block’s outcome. Nicely handled.

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

5-8: Ohayo sensei!
These doc lines clearly reflect the new focus on message gathering and proof-based sending. Good clarity.


11-11: Ohayo sensei!
Mentioning Anvil usage is helpful for local dev context. Thumbs up!


18-21: Ohayo sensei!
Great job highlighting the collecting of messages and proof generation steps. This clarifies how messages reach the settlement chain.


25-27: Ohayo sensei!
Thanks for documenting the to_address limitation. This warns devs to use an applicative workaround.


29-31: Ohayo sensei!
Again, good doc about carrying the real address in payload. This offers a straightforward approach to circumvent Blockifier constraints.


100-101: Ohayo sensei!
Documenting the interval with thorough comments is beneficial. No issues here.


122-122: Ohayo sensei!
Specifically pulling rpc_url and core_contract from the chain spec ensures consistency with settlement-layer config. Nice synergy.

Also applies to: 131-131


211-212: Ohayo sensei!
Making MessagingTask more concise without generics is consistent with the refactoring. Looks good.


215-216: Ohayo sensei!
A simple constructor with only the needed parameter is a good step towards clarity.


228-235: Ohayo sensei!
Nice logging approach. Conditionally logging message collection is helpful for debugging and verifying flows.

crates/katana/sync/stage/src/sequencing.rs (1)

44-44: Ohayo sensei!
Using the updated MessagingService::new signature with fewer parameters is neat and aligns with the new design.

crates/katana/messaging/src/ethereum.rs (1)

21-21: LGTM! Simplified imports.

Ohayo! The import cleanup looks good, removing unused warn while keeping necessary logging levels.

crates/katana/rpc/rpc/tests/messaging.rs (1)

67-73: LGTM! Configuration simplified.

Ohayo sensei! The MessagingConfig has been correctly simplified by removing the unused sender_address and private_key fields, aligning with the removal of settlement layer messaging functionality.

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 76.19048% with 5 lines in your changes missing coverage. Please review.

Project coverage is 56.21%. Comparing base (de7eddd) to head (ad6cd46).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/messaging/src/starknet.rs 0.00% 3 Missing ⚠️
crates/katana/messaging/src/lib.rs 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3035      +/-   ##
==========================================
- Coverage   56.31%   56.21%   -0.10%     
==========================================
  Files         437      437              
  Lines       59013    58757     -256     
==========================================
- Hits        33232    33031     -201     
+ Misses      25781    25726      -55     

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

Comment on lines +6 to +7
//! execute them, and send messages to a settlement chain via a provable mechanism (STARK proof in
//! the case of Starknet).
Copy link
Member

Choose a reason for hiding this comment

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

STARK proof in the case of Starknet

I'd imagine it's same case as well when settling to Ethereum - that the messages would be settled by the proof (or to be exact, on the call to updateState function on the settlement contract, no?

Comment on lines +232 to +233
// Send message from L2 to L1 testing must be done using Saya or part of
// it to ensure the settlement contract is test on piltover and its `update_state` method.
Copy link
Member

Choose a reason for hiding this comment

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

We definitely need katana <> saya e2e tests.

I know, to some extent, parts of the settlement process can be already be mocked. But we should think how we can make the whole katana to saya flow in a way where each part can be easily mocked for testing purposes.

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