Skip to content

Handle duplicate block submission - #1471

Merged
MSevey merged 26 commits into
mainfrom
manav/fix_block_submission
Feb 8, 2024
Merged

Handle duplicate block submission#1471
MSevey merged 26 commits into
mainfrom
manav/fix_block_submission

Conversation

@Manav-Aggarwal

@Manav-Aggarwal Manav-Aggarwal commented Jan 17, 2024

Copy link
Copy Markdown
Member

Overview

Closes: #1472

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features
    • Enhanced block submission functionality to track the number of blocks submitted and improve error handling.
  • Tests
    • Added comprehensive test cases for block submission scenarios, including tests for block sizes and submission attempts.
  • Refactor
    • Introduced a new utility function for creating a minimalistic block manager for testing.

@coderabbitai

coderabbitai Bot commented Jan 17, 2024

Copy link
Copy Markdown
Contributor

Warning

Rate Limit Exceeded

@Manav-Aggarwal has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 48 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 88f8ecf and 80fd272.

Walkthrough

The recent updates involve enhancing the submitBlocksToDA function in the block/manager.go file to support multiple block submissions and improved error handling, alongside the introduction of comprehensive test cases in block/manager_test.go for various submission scenarios. Additionally, a new utility file, block/utils.go, has been added to facilitate testing by providing a simplified block manager setup.

Changes

File(s) Change Summary
block/manager.go Modified to return the number of blocks submitted and an error, with improved handling of multiple block submissions.
block/manager_test.go Added test cases for block submission scenarios, including handling of block sizes and submission attempts.
block/utils.go Introduced to provide a simplified block manager for testing purposes.

Assessment against linked issues

Objective Addressed Explanation
Prevent duplicate block submission in submitBlocksToDA (#1472)
Update blocks variable correctly after submission attempts to avoid re-submitting (#1472)
Change code to manage block submission duplication effectively (#1472)
Add test cases for submitBlocksToDA function to enhance testing coverage (#1530) It's unclear if all specific scenarios mentioned are covered due to the summary's brevity.

Related issues

🐇🎉
Changes are here, oh what a sight,
Submitting blocks, left and right.
No more dupes, tests run tight,
CodeRabbit hops in delight! 🚀🐾

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e4a5e07 and 804778f.
Files selected for processing (1)
  • block/manager.go (1 hunks)

Comment thread block/manager.go Outdated
@Manav-Aggarwal Manav-Aggarwal changed the title Fix block submission Handle duplicate block submission Jan 17, 2024
@Manav-Aggarwal Manav-Aggarwal added va T:bug Something isn't working labels Jan 17, 2024
@codecov

codecov Bot commented Jan 17, 2024

Copy link
Copy Markdown

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (c9d8467) 50.23% compared to head (38c330c) 51.27%.
Report is 9 commits behind head on main.

❗ Current head 38c330c differs from pull request most recent head 80fd272. Consider uploading reports for the commit 80fd272 to get more accurate results

Files Patch % Lines
block/manager.go 70.58% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1471      +/-   ##
==========================================
+ Coverage   50.23%   51.27%   +1.04%     
==========================================
  Files          52       52              
  Lines        6762     6726      -36     
==========================================
+ Hits         3397     3449      +52     
+ Misses       3024     2929      -95     
- Partials      341      348       +7     

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

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 804778f and bd52850.
Files selected for processing (1)
  • block/manager.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/manager.go

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between bd52850 and 6982ed6.
Files selected for processing (1)
  • block/manager.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/manager.go

@Manav-Aggarwal
Manav-Aggarwal force-pushed the manav/fix_block_submission branch from 6982ed6 to e93dfe3 Compare January 18, 2024 18:37

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between de98a94 and e93dfe3.
Files selected for processing (1)
  • block/manager.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/manager.go

Comment thread block/manager.go Outdated

@MSevey MSevey 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.

This needs an update to testing.

Test cases I can thinking of that we should understand how they execute.
Assuming starting with Blocks a b c

  1. happy case, all are submitted on first round
  2. a and b are submitted first because including c triggers size limit. C is then submitted on second round.
  3. C is too big on it's own, never submitted but a and b are
  4. C has a marshal issue. A and b should still be submitted ( I think this case currently isn't possible with the code based on SubmitBlocks)
  5. A is too big on its own
  6. A has a marshal issue

for cases 5 and 6, what should be the desired outcome? Do we never submit any blocks if the current next block is bad? Based on SubmitBlocks that appears to be the case.

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e93dfe3 and aac52a7.
Files selected for processing (1)
  • block/manager.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/manager.go

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between aac52a7 and 38c330c.
Files selected for processing (1)
  • block/manager_test.go (1 hunks)

Comment thread block/manager_test.go Outdated
@Manav-Aggarwal
Manav-Aggarwal force-pushed the manav/fix_block_submission branch from 38c330c to bd78dbd Compare January 24, 2024 16:05

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d2bfbc3 and bd78dbd.
Files selected for processing (2)
  • block/manager.go (1 hunks)
  • block/manager_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • block/manager.go
  • block/manager_test.go

@Manav-Aggarwal
Manav-Aggarwal force-pushed the manav/fix_block_submission branch from bd78dbd to b6a2808 Compare February 1, 2024 22:48
@Manav-Aggarwal
Manav-Aggarwal marked this pull request as draft February 2, 2024 17:10
@Manav-Aggarwal
Manav-Aggarwal force-pushed the manav/fix_block_submission branch 2 times, most recently from bb3185a to e489f68 Compare February 7, 2024 21:39
@Manav-Aggarwal

Copy link
Copy Markdown
Member Author

This needs an update to testing.

Test cases I can thinking of that we should understand how they execute. Assuming starting with Blocks a b c

  1. happy case, all are submitted on first round
  2. a and b are submitted first because including c triggers size limit. C is then submitted on second round.
  3. C is too big on it's own, never submitted but a and b are
  4. C has a marshal issue. A and b should still be submitted ( I think this case currently isn't possible with the code based on SubmitBlocks)
  5. A is too big on its own
  6. A has a marshal issue

for cases 5 and 6, what should be the desired outcome? Do we never submit any blocks if the current next block is bad? Based on SubmitBlocks that appears to be the case.

Added test cases for 1, 2, 3. Follow up issue for the rest: #1530

@Manav-Aggarwal
Manav-Aggarwal requested a review from MSevey February 7, 2024 23:21
@Manav-Aggarwal
Manav-Aggarwal marked this pull request as ready for review February 7, 2024 23:21
@RollkitBot
RollkitBot requested a review from tuxcanfly February 7, 2024 23:21
@Manav-Aggarwal
Manav-Aggarwal force-pushed the manav/fix_block_submission branch from fded548 to dc532a8 Compare February 8, 2024 15:21
@Manav-Aggarwal
Manav-Aggarwal requested a review from MSevey February 8, 2024 15:22
MSevey
MSevey previously approved these changes Feb 8, 2024
Comment thread block/manager.go Outdated
Comment thread block/manager.go Outdated
Comment thread block/manager.go Outdated

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 76a199a and 88f8ecf.
Files selected for processing (2)
  • block/manager.go (1 hunks)
  • block/manager_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • block/manager.go
  • block/manager_test.go

@gupadhyaya

Copy link
Copy Markdown
Contributor

should we also optimize this

case da.StatusError, da.StatusNotFound:
			m.logger.Error("DA layer submission failed", "error", res.Message, "attempt", attempt)
			time.Sleep(backoff)
			backoff = m.exponentialBackoff(backoff)
		default:
			m.logger.Error("DA layer submission failed", "error", res.Message, "attempt", attempt)
			time.Sleep(backoff)
			backoff = m.exponentialBackoff(backoff)

to

		default:
			m.logger.Error("DA layer unknown status response", "error", res.Message, "attempt", attempt)
			time.Sleep(backoff)
			backoff = m.exponentialBackoff(backoff)

as there is not much difference and lot of duplicate code.

Comment thread block/manager.go
@Manav-Aggarwal

Copy link
Copy Markdown
Member Author

should we also optimize this

case da.StatusError, da.StatusNotFound:
			m.logger.Error("DA layer submission failed", "error", res.Message, "attempt", attempt)
			time.Sleep(backoff)
			backoff = m.exponentialBackoff(backoff)
		default:
			m.logger.Error("DA layer submission failed", "error", res.Message, "attempt", attempt)
			time.Sleep(backoff)
			backoff = m.exponentialBackoff(backoff)

to

		default:
			m.logger.Error("DA layer unknown status response", "error", res.Message, "attempt", attempt)
			time.Sleep(backoff)
			backoff = m.exponentialBackoff(backoff)

as there is not much difference and lot of duplicate code.

This was introduced in https://github.com/rollkit/rollkit/pull/1466/files. I think we can optimize.

@gupadhyaya
gupadhyaya self-requested a review February 8, 2024 16:04

@tzdybal tzdybal 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.

LGTM. This is even better than mock.

@MSevey
MSevey added this pull request to the merge queue Feb 8, 2024
Merged via the queue into main with commit 254e958 Feb 8, 2024
@MSevey
MSevey deleted the manav/fix_block_submission branch February 8, 2024 16:46
@tac0turtle tac0turtle removed this from Evolve Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle duplicate block submission in submitBlocksToDA

5 participants