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

ignore validation failed error for the genesis block #1499

Merged
merged 3 commits into from
Jan 27, 2024

Conversation

gupadhyaya
Copy link
Member

@gupadhyaya gupadhyaya commented Jan 21, 2024

Fixes #969

This PR fixes the validation failed error that is thrown by header and block sync, which happens when the sequencer calls Broadcast which also does publish the header/block locally for updating the store. This happens because the sequencer before broadcasting, for the genesis header, already does the store initialization and double store update causes this error. The prior initialization is required to start the syncer and there is no easier way to skip one of the two initializations. In future, can refactor the code to move syncer start to its own thread. But for now, ignoring the error is easier solution without adding any safety concerns.

Summary by CodeRabbit

  • Refactor
    • Improved handling of genesis blocks and headers during synchronization, enhancing the app's stability and reducing unnecessary error logs.

Copy link
Contributor

coderabbitai bot commented Jan 21, 2024

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 109de72 and ba691bb.

Walkthrough

The recent updates have streamlined error handling in the synchronization services for blocks and headers. A new isGenesis check has been introduced to determine if a block or header is the genesis one. If so, broadcasting errors are ignored, considering the initialization of the store has already been set for the syncer to begin its work. This refinement simplifies the logic and reduces unnecessary redundancy when dealing with genesis blocks and headers.

Changes

File(s) Change Summary
block/block_sync.go Improved readability and redundancy reduction with isGenesis check
block/header_sync.go Added isGenesis check for better error handling of genesis headers

Assessment against linked issues

Objective Addressed Explanation
Ensure genesis block header broadcast errors do not halt synchronization ([#969])

🐇
In the code's warren, beneath the moon's glow,
A genesis check was added, errors now bow low.
Syncers dance with glee, in binary ballet,
For blocks and headers sync, in a much smoother way. 🌙
🐇

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.

@gupadhyaya gupadhyaya marked this pull request as ready for review January 21, 2024 15:32
@gupadhyaya gupadhyaya added the T:bug Something isn't working label Jan 21, 2024
Copy link
Contributor

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between de98a94 and 06a62fc.
Files selected for processing (2)
  • block/block_sync.go (2 hunks)
  • block/header_sync.go (2 hunks)
Additional comments: 1
block/header_sync.go (1)
  • 113-125: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [102-122]

The implementation of the isGenesis check and the conditional error handling in the WriteToHeaderStoreAndBroadcast method is consistent with the PR's objectives and the changes made in the block_sync.go file. The logic is sound and the approach to handle the genesis header is appropriate given the context.

block/block_sync.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 21, 2024

Codecov Report

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

Comparison is base (109de72) 50.36% compared to head (7f01ffa) 50.20%.

❗ Current head 7f01ffa differs from pull request most recent head ba691bb. Consider uploading reports for the commit ba691bb to get more accurate results

Files Patch % Lines
block/block_sync.go 0.00% 9 Missing ⚠️
block/header_sync.go 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1499      +/-   ##
==========================================
- Coverage   50.36%   50.20%   -0.17%     
==========================================
  Files          52       52              
  Lines        6731     6743      +12     
==========================================
- Hits         3390     3385       -5     
- Misses       3000     3016      +16     
- Partials      341      342       +1     

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

Copy link
Contributor

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 06a62fc and 583b889.
Files selected for processing (1)
  • block/block_sync.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/block_sync.go

@MSevey MSevey self-requested a review January 24, 2024 14:16
@MSevey
Copy link
Contributor

MSevey commented Jan 24, 2024

Is there a regression test we can write for this?
This took a long time to debug and resolve, so I'd hate for us to inadvertently re-introduce this as a failure mode in the future.

Copy link
Contributor

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

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

Copy link
Contributor

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0a3001b and 7f01ffa.
Files selected for processing (2)
  • block/block_sync.go (2 hunks)
  • block/header_sync.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • block/block_sync.go
  • block/header_sync.go

@gupadhyaya
Copy link
Member Author

gupadhyaya commented Jan 26, 2024

Is there a regression test we can write for this? This took a long time to debug and resolve, so I'd hate for us to inadvertently re-introduce this as a failure mode in the future.

tightened the error skip logic to skip only ValidationFailed. this is the best we can do given that exact reason for validation failure (known header: '1' <= current '1') is not propagated. however this would still help not skip many useful errors.

i did not want to add additional efforts into this as we are tackling #1501 in v1 and it should totally remove this error skipping logic.

let me know if this works.

@Manav-Aggarwal Manav-Aggarwal added this pull request to the merge queue Jan 27, 2024
Merged via the queue into rollkit:main with commit 6f93820 Jan 27, 2024
15 of 17 checks passed
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
Status: Done
Development

Successfully merging this pull request may close these issues.

header exchange throws failed to broadcast block header error validation ignored
4 participants