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

Resolve multiple BB audit issues #1478

Merged
merged 5 commits into from
Jan 23, 2024
Merged

Conversation

Manav-Aggarwal
Copy link
Member

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

Overview

Resolves #1477, resolves #1475, resolves #1474

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

  • Bug Fixes
    • Improved timer management to prevent potential memory leaks.
    • Enhanced error handling during block publishing to handle context cancellation gracefully.
    • Added a validation check for block signatures to ensure data integrity.

Copy link
Contributor

coderabbitai bot commented Jan 17, 2024

Walkthrough

The changes encompass various improvements in the codebase. They include adding deferred calls to stop timers for proper resource management, restructuring logic for publishing data with error handling, consolidating cleanup logic to reduce code duplication, and introducing validation checks for data integrity. These changes aim to enhance the reliability and robustness of the system.

Changes

File Path Change Summary
block/manager.go Deferred timer.Stop() added for proper resource cleanup. Restructured logic for publishing data.
store/store.go Consolidated bb.Discard(ctx) calls with defer to reduce duplication.
types/block.go Introduced validation check for the first signature in Commit.
types/signed_header.go Added new error variables to handle cases related to signatures.
types/signed_header_test.go Added test cases for validating absence of signatures and empty signature values.

Assessment against linked issues

Objective Addressed Explanation
Incomplete Validation of Commit (#1477)
Garbage collect Timer in Aggregation Loop (#1475)
Remove unused doneBuildingBlock channel (#1474)

Poem

In the code where bugs did creep,
A rabbit hopped, no time to sleep.
With every fix and tweak so clever,
Ensured the code ran smooth as ever. 🐇💻

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.

@Manav-Aggarwal Manav-Aggarwal added T:code-hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. bb-audit-issue T:bug Something isn't working labels Jan 17, 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: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3c3a3a7 and f33a6dd.
Files selected for processing (3)
  • block/manager.go (2 hunks)
  • store/store.go (1 hunks)
  • types/block.go (1 hunks)
Additional comments: 3
types/block.go (1)
  • 105-107: The added validation logic in ValidateBasic method of Commit struct correctly checks if the first signature is empty and returns an error if it is. This change aligns with the PR objectives to enhance signature validation.
store/store.go (1)
  • 80-80: The introduction of defer bb.Discard(ctx) before error checks is a good practice to ensure resources are cleaned up properly. This change reduces code duplication and ensures that bb.Discard(ctx) is always called, even if an error occurs or a return statement is reached before the end of the function.
block/manager.go (1)
  • 265-265: The addition of defer timer.Stop() in the AggregationLoop method is a good practice to prevent potential resource leaks by ensuring that the timer is stopped when the function exits, regardless of the exit path.

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

codecov bot commented Jan 17, 2024

Codecov Report

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

Comparison is base (de98a94) 50.87% compared to head (32c3d8b) 51.09%.

Files Patch % Lines
block/manager.go 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1478      +/-   ##
==========================================
+ Coverage   50.87%   51.09%   +0.22%     
==========================================
  Files          52       52              
  Lines        6717     6717              
==========================================
+ Hits         3417     3432      +15     
+ Misses       2951     2939      -12     
+ Partials      349      346       -3     

☔ 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 f33a6dd and b29a450.
Files selected for processing (1)
  • block/manager.go (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/manager.go

Copy link

@testinginprod testinginprod left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

nashqueue
nashqueue previously approved these changes Jan 17, 2024
Copy link
Member

@nashqueue nashqueue left a comment

Choose a reason for hiding this comment

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

ProxyUtAck

Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

Can we discuss the select statement changes offline?
Those are reverting back to conditions that previously caused test failures.
Let's make sure we aren't re-introducing those or if the other updates, like the shutdown coordination, has resolved the underlying issue.

block/manager.go Outdated Show resolved Hide resolved
types/block.go Show resolved Hide resolved
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 b29a450 and 94d79ba.
Files selected for processing (1)
  • block/manager.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • block/manager.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 de98a94 and 32c3d8b.
Files selected for processing (5)
  • block/manager.go (4 hunks)
  • store/store.go (1 hunks)
  • types/block.go (1 hunks)
  • types/signed_header.go (1 hunks)
  • types/signed_header_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • block/manager.go
  • store/store.go
  • types/block.go
Additional comments: 4
types/signed_header.go (2)
  • 101-105: Added new error variables ErrNoSignatures and ErrSignatureEmpty to handle cases when there are no signatures or the signature is empty. This is a good practice for explicit error handling and improves the clarity of error conditions.
  • 100-105: The new error variables ErrNoSignatures and ErrSignatureEmpty should be used in the ValidateBasic method to handle the respective error conditions. Ensure that the logic in ValidateBasic is updated to return these errors when appropriate.
types/signed_header_test.go (2)
  • 238-259: New test cases have been added to validate the absence of signatures and empty signature values. This is a good practice to ensure that the new error conditions are properly tested.
  • 238-259: The new test cases for ErrNoSignatures and ErrSignatureEmpty are correctly set up to expect these errors when the conditions are met. This ensures that the error handling is properly tested.

block/manager.go Outdated Show resolved Hide resolved
@gupadhyaya gupadhyaya added this pull request to the merge queue Jan 23, 2024
Merged via the queue into main with commit 4098eba Jan 23, 2024
19 checks passed
@gupadhyaya gupadhyaya deleted the manav/resolve_bb_audit_issues branch January 23, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bb-audit-issue T:bug Something isn't working T:code-hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
Status: Done
5 participants