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

refactor: expose CreateShareToRowRootProofs for downstream use #3739

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Jul 26, 2024

Overview

Exposes that functionality so that we don't end up copy-pasting that code in Celestia-node.

@rach-id rach-id added chore optional label for items that follow the `chore` conventional commit backport:v1.x PR will be backported automatically to the v1.x branch upon merging backport:v2.x PR will be backported automatically to the v2.x branch upon merging labels Jul 26, 2024
@rach-id rach-id self-assigned this Jul 26, 2024
@rach-id rach-id requested a review from a team as a code owner July 26, 2024 09:06
@rach-id rach-id requested review from staheri14 and evan-forbes and removed request for a team July 26, 2024 09:06
Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Walkthrough

Walkthrough

The recent changes introduce significant refactoring to the NewShareInclusionProofFromEDS function, enhancing modularity by delegating share proof creation to a new function, CreateShareToRowRootProofs. This new function processes a set of shares and their roots, returning multiple values for improved error handling and clarity. Overall, these modifications improve code maintainability and clarity, streamlining the generation of share proofs.

Changes

File Change Summary
pkg/proof/proof.go Refactored NewShareInclusionProofFromEDS to delegate share proof creation to new function CreateShareToRowRootProofs, enhancing modularity. Added CreateShareToRowRootProofs to generate NMT inclusion proofs from row shares and roots, returning slices of proofs, raw shares, and error. Updated error handling for clarity.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ProofGenerator
    participant ShareProofHandler

    Client->>ProofGenerator: NewShareInclusionProofFromEDS(...)
    ProofGenerator->>ShareProofHandler: CreateShareToRowRootProofs(...)
    ShareProofHandler-->>ProofGenerator: Return proofs, raw shares, error
    ProofGenerator-->>Client: Return results
Loading

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 do a full 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 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.

@celestia-bot celestia-bot requested a review from a team July 26, 2024 09:07
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: 0

Outside diff range, codebase verification and nitpick comments (1)
pkg/proof/proof.go (1)

124-140: Add test cases for NewShareInclusionProofFromEDS

The function NewShareInclusionProofFromEDS is not currently tested. Please add test cases to ensure the refactored logic is properly validated.

  • Add unit tests for NewShareInclusionProofFromEDS to cover different scenarios and edge cases.
Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to NewShareInclusionProofFromEDS are tested with the refactored logic.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `NewShareInclusionProofFromEDS` are tested with the refactored logic.

# Test: Search for the function usage. Expect: Only occurances of the new logic.
rg --type go -A 5 $'NewShareInclusionProofFromEDS'

Length of output: 787


Script:

#!/bin/bash
# Description: Verify if `NewShareInclusionProofFromEDS` is tested.

# Test: Search for test cases related to `NewShareInclusionProofFromEDS`.
rg --type go 'NewShareInclusionProofFromEDS' --tests

Length of output: 484


Script:

#!/bin/bash
# Description: Verify if `NewShareInclusionProofFromEDS` is tested.

# Test: Search for test cases related to `NewShareInclusionProofFromEDS` within test files.
rg 'NewShareInclusionProofFromEDS' --type-add 'test:*.go' --type test

Length of output: 292

@rach-id rach-id enabled auto-merge (squash) July 26, 2024 10:34
@rach-id rach-id merged commit 8536727 into main Jul 26, 2024
33 of 34 checks passed
@rach-id rach-id deleted the refactor-prove-shares branch July 26, 2024 14:38
mergify bot pushed a commit that referenced this pull request Jul 26, 2024
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Exposes that functionality so that we don't end up copy-pasting that
code in Celestia-node.

(cherry picked from commit 8536727)

# Conflicts:
#	pkg/proof/proof.go
mergify bot pushed a commit that referenced this pull request Jul 26, 2024
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Exposes that functionality so that we don't end up copy-pasting that
code in Celestia-node.

(cherry picked from commit 8536727)
rach-id added a commit that referenced this pull request Jul 26, 2024
…ort #3739) (#3740)

## Overview

Exposes that functionality so that we don't end up copy-pasting that
code in Celestia-node.<hr>This is an automatic backport of pull request
#3739 done by [Mergify](https://mergify.com).

---------

Co-authored-by: sweexordious <chamirachid1@gmail.com>
rach-id added a commit that referenced this pull request Jul 30, 2024
…ort #3739) (#3741)

## Overview

Exposes that functionality so that we don't end up copy-pasting that
code in Celestia-node.<hr>This is an automatic backport of pull request
#3739 done by [Mergify](https://mergify.com).

Co-authored-by: CHAMI Rachid <chamirachid1@gmail.com>
ninabarbakadze pushed a commit that referenced this pull request Aug 7, 2024
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Exposes that functionality so that we don't end up copy-pasting that
code in Celestia-node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:v1.x PR will be backported automatically to the v1.x branch upon merging backport:v2.x PR will be backported automatically to the v2.x branch upon merging chore optional label for items that follow the `chore` conventional commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants