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

Bugfix deadlock in the code #269

Merged
merged 1 commit into from
May 28, 2024
Merged

Bugfix deadlock in the code #269

merged 1 commit into from
May 28, 2024

Conversation

devbugging
Copy link
Contributor

@devbugging devbugging commented May 28, 2024

Closes: #260

Description

This fixes a deadlock, thanks to @janezpodhostnik and @peterargue.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • Refactor
    • Improved handling of EVM height caching for better performance and reliability.

@devbugging devbugging self-assigned this May 28, 2024
Copy link
Contributor

coderabbitai bot commented May 28, 2024

Walkthrough

The changes in storage/pebble/blocks.go involve refactoring the Blocks struct to replace the latestEVMHeight field with latestEVMHeightCache. This includes updating corresponding methods and adding a new method latestEVMHeight() to access the cached height value. The refactor aims to address potential deadlock issues when retrieving the latest block.

Changes

Files Change Summary
storage/pebble/blocks.go Refactored latestEVMHeight to latestEVMHeightCache and updated methods. Introduced latestEVMHeight() method.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant Client
    participant Blocks
    Client->>Blocks: getBlockByNumber(latest)
    activate Blocks
    Blocks->>Blocks: latestEVMHeight()
    deactivate Blocks
    Blocks-->>Client: Return latest block
Loading

Assessment against linked issues

Objective Addressed Explanation
Investigate and resolve possible deadlock on getting latest block (#260)

In the realm of code, a change so bright,
To fix the blocks and set things right.
No more waits in endless plight,
Cached heights now bring swift light.
A rabbit's cheer for code's new flight! 🐇✨

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 full the 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.

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

@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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 21a0600 and 2c5bf5c.
Files selected for processing (1)
  • storage/pebble/blocks.go (4 hunks)
Additional comments not posted (4)
storage/pebble/blocks.go (4)

23-23: Refactor latestEVMHeight to latestEVMHeightCache to improve clarity and manage caching.


80-80: Update the cache after storing the block to ensure the cache is always in sync with the latest stored value.


88-88: Ensure error handling is robust when fetching the latest EVM height.


Line range hint 142-156: Optimized retrieval of the latest EVM height by checking the cache first before accessing the store. This reduces unnecessary data fetches and potential delays.

Comment on lines +139 to +140
return b.latestEVMHeight()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should be private as it directly accesses the cache which is an internal mechanism.

- func (b *Blocks) LatestEVMHeight() (uint64, error) {
+ func (b *Blocks) latestEVMHeight() (uint64, error) {

Committable suggestion was skipped due low confidence.

@devbugging devbugging merged commit 0e5f7f0 into main May 28, 2024
2 checks passed
@m-Peter m-Peter deleted the gregor/fix-deadlock branch July 29, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Timeout issues on getting a block
2 participants