Skip to content

Conversation

TropicalDog17
Copy link
Contributor

@TropicalDog17 TropicalDog17 commented Jul 18, 2025

Overview

Closes #2385

Summary by CodeRabbit

  • Refactor
    • Improved the submission process for headers and data, streamlining how items are prepared and submitted.
    • Enhanced error handling for submission failures.
    • Optimized the retry logic and internal control flow for more efficient processing.

Copy link
Contributor

coderabbitai bot commented Jul 18, 2025

Walkthrough

The submission logic was refactored to separate marshaling from data submission. The submitToDA function now directly receives pre-marshaled byte slices and a callback that operates by count, not item value. Related methods were updated to marshal data upfront, handle marshaling errors, and adjust their post-submission logic accordingly.

Changes

File(s) Change Summary
block/submitter.go Refactored submitToDA to accept marshaled byte slices and a count-based callback; updated submitHeadersToDA and submitDataToDA to marshal data before submission, handle marshaling errors, and adjust post-submit logic.

Suggested reviewers

  • tac0turtle
  • julienrbrt

Poem

In the warren, code refines its flow,
Marshaled bytes now swiftly go.
Headers, data—prepped with care,
Submitted with logic, light as air.
Rabbits cheer the streamlined way,
Fewer hops, less hay—
A byte-sized leap for DA today! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7a74bd and c6d536d.

📒 Files selected for processing (1)
  • block/submitter.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • block/submitter.go
⏰ 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). (6)
  • GitHub Check: test / Run Integration Tests
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: test / Build All Rollkit Binaries
  • GitHub Check: test / Build Rollkit Docker Image
  • GitHub Check: test / Build Rollkit EVM Single Docker Image
  • GitHub Check: Summary
✨ Finishing Touches
  • 📝 Generate Docstrings

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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

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
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @TropicalDog17, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on refactoring the submitToDA helper function to improve its clarity and separation of concerns. By moving the data marshalling responsibility out of submitToDA and into its callers, the function becomes more focused on the submission logic itself, leading to a cleaner and potentially more reusable design.

Highlights

  • Refactored submitToDA Signature: The submitToDA function has been refactored to no longer be generic and now directly accepts [][]byte (pre-marshaled data) instead of raw items and a marshalling function. This shifts the responsibility of marshalling to the caller.
  • Updated postSubmit Callback: The postSubmit callback within submitToDA was updated to pass only the count of successfully submitted items (int) rather than the actual slice of submitted items. This simplifies the submitToDA function's internal state management.
  • Caller Adaptations: Functions like submitHeadersToDA and submitDataToDA were updated to perform the marshalling of their respective data types before calling submitToDA. Their post-submission logic was also adjusted to use the original item lists in conjunction with the new submittedCount from the postSubmit callback.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the submitToDA function to simplify its logic by moving marshaling responsibility to its callers. While the refactoring of submitToDA itself is sound, the changes in the calling functions, submitHeadersToDA and submitDataToDA, have introduced a critical bug. The logic for handling partial submissions is incorrect, which could lead to data loss as some headers or data blocks might not be submitted to the DA layer. I've provided detailed comments and suggestions to fix these issues.

Copy link

codecov bot commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 80.64516% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.33%. Comparing base (265ff50) to head (c2d1da7).

Files with missing lines Patch % Lines
block/submitter.go 80.64% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2474      +/-   ##
==========================================
- Coverage   74.52%   74.33%   -0.20%     
==========================================
  Files          70       70              
  Lines        6537     6550      +13     
==========================================
- Hits         4872     4869       -3     
- Misses       1276     1287      +11     
- Partials      389      394       +5     
Flag Coverage Δ
combined 74.33% <80.64%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@tac0turtle tac0turtle requested review from alpe and julienrbrt July 22, 2025 10:53
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm! somewhat more readable that way, i left some suggestions to help the reader.

julienrbrt
julienrbrt previously approved these changes Jul 24, 2025
@TropicalDog17
Copy link
Contributor Author

can you review @alpe

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

Nice work. The changes look good.

marshalFn func(T) ([]byte, error),
postSubmit func([]T, *coreda.ResultSubmit, float64),
marshaled [][]byte,
onSuccessfulSubmission func(int, *coreda.ResultSubmit, float64),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 better naming

for i, header := range headersToSubmit {
headerPb, err := header.ToProto()
if err != nil {
return fmt.Errorf("failed to transform header to proto: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

personal preference: "failed to " is some prefix that can always be dropped from error messages. It is obvious that something failed when an error is returned. It also reads odd when error messages are chained and you end up with failed to ... : failed to ... : failed to ...


return submitToDA(m, ctx, marshaledHeaders,
func(submittedCount int, res *coreda.ResultSubmit, currentGasPrice float64) {
for i := 0; i < submittedCount; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This can be simplified with Go 1.24

Suggested change
for i := 0; i < submittedCount; i++ {
for i := range submittedCount {

func(submittedCount int, res *coreda.ResultSubmit, currentGasPrice float64) {
for i := 0; i < submittedCount; i++ {
headerIdx := submissionOffset + i
if headerIdx < len(headersToSubmit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

personal preference: if you want to get the if out of the loop, you can do:

maxOffset := min(submissionOffset+submittedCount, len(headersToSubmit))
for i := submissionOffset; i < maxOffset; i++ {
	m.headerCache.SetDAIncluded(headersToSubmit[i].Hash().String(), res.Height)
}

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

argh, CI is failing. This is the only blocker, now

@alpe
Copy link
Contributor

alpe commented Aug 4, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the submitToDA function to be non-generic and operate on pre-marshaled data. This change simplifies the core submission logic by moving type-specific marshaling to the caller functions, submitHeadersToDA and submitDataToDA, which improves the separation of concerns. The implementation correctly handles partial submissions using a submissionOffset. My review includes suggestions to remove a couple of redundant checks to enhance code clarity.

Comment on lines 187 to 189
if headerIdx < len(headersToSubmit) {
m.headerCache.SetDAIncluded(headersToSubmit[headerIdx].Hash().String(), res.Height)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This check if headerIdx < len(headersToSubmit) appears to be redundant. The submittedCount is derived from the number of items successfully submitted from the remaining slice in submitToDA. The length of remaining is managed to be len(headersToSubmit) - submissionOffset. Therefore, headerIdx should never exceed the bounds of headersToSubmit. Removing this unnecessary check will make the code slightly cleaner.

                    m.headerCache.SetDAIncluded(headersToSubmit[headerIdx].Hash().String(), res.Height)

Comment on lines 231 to 233
if dataIdx < len(signedDataToSubmit) {
m.dataCache.SetDAIncluded(signedDataToSubmit[dataIdx].Data.DACommitment().String(), res.Height)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This check if dataIdx < len(signedDataToSubmit) appears to be redundant. The submittedCount is derived from the number of items successfully submitted from the remaining slice in submitToDA. The length of remaining is managed to be len(signedDataToSubmit) - submissionOffset. Therefore, dataIdx should never exceed the bounds of signedDataToSubmit. Removing this unnecessary check will make the code slightly cleaner.

                    m.dataCache.SetDAIncluded(signedDataToSubmit[dataIdx].Data.DACommitment().String(), res.Height)

@tac0turtle
Copy link
Contributor

@TropicalDog17 can you help resolve conflicts then ci should be fixed

@alpe
Copy link
Contributor

alpe commented Aug 28, 2025

@mergify rebase

@TropicalDog17 TropicalDog17 force-pushed the chore/refactor-submit-toda branch from 74626e6 to 3c28a77 Compare September 1, 2025 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Cleanup: Explore moving marshaling out of submitToDA method in DA Submitter
4 participants