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

feat!: adding Namespace to remaining endpoints #35

Merged
merged 5 commits into from
Jan 31, 2024
Merged

feat!: adding Namespace to remaining endpoints #35

merged 5 commits into from
Jan 31, 2024

Conversation

distractedm1nd
Copy link
Collaborator

@distractedm1nd distractedm1nd commented Jan 24, 2024

It turns out the previous addition of Namespace to Submit wasn't enough to allow for a native celestia-node implementation of go-da.

GetIDs and Commitment have been extended to use Namespaces for DA layers that support it.

Note that this assumes that namespace would land in the ID, which I'm not so sure about for the following reason:
ID is supposed to represent what uniquely identifies a blob on the DA layer, but adding Namespace means ID represents the data you need to fetch a Blob uniquely from the DA layer. Also, changing the ID means that retrofitting existing op-stack rollups will break.

Whlie porting op-stack back to the blob module though, I realized that this change would only be necessary for using go-da. The id being only (height, commitment) is sufficient for fetching the data because you always know the namespace and can pass it into the blob endpoints directly.

The alternative to making Namespace a part of ID is adding Namespace to Get and Validate as well.

The signature for Submit has been changed again, thanks to a good catch from @tuxcanfly during review. We got rid of SubmitOptions again and pass Namespace as the last parameter, as in the other methods.

Now all methods take an optional Namespace as the last parameter, to avoid needing to modify ID.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced the functionality to support namespaces for ID retrieval and commitment creation.
  • Refactor
    • Updated proxy client and server methods to handle the new namespace parameter.
  • Documentation
    • Updated the DA Interface table in the README.md to reflect changes in method parameters and the addition of a new method.
  • Style
    • Modified the markdown linting configuration to disable a specific rule for tables.

Copy link

coderabbitai bot commented Jan 24, 2024

Walkthrough

The recent updates involve enhancing the functionality related to retrieving IDs, creating commitments for Blobs, and submitting Blobs to the Data Availability layer by integrating a namespace parameter. This additional parameter has been added to the DA interface methods, the GetIDsRequest and CommitRequest messages, as well as to various methods in the proxy/client.go, proxy/server.go, and test/dummy.go files. These changes ensure that the system's operations are now namespace-aware, improving data organization and isolation across different contexts or environments.

Changes

File(s) Change Summary
da.go, proto/da/da.proto Modified the DA interface and GetIDsRequest and CommitRequest messages to include namespace Namespace.
da.go Updated the Submit method to accept an extra parameter gasPrice float64.
proxy/client.go, proxy/server.go, test/dummy.go Modified Get, GetIDs, Commit, Submit, and Validate methods to accept da.Namespace.
test/test_suite.go Added []byte{} as new arguments in function calls of Commit and GetIDs to align with updated logic.
README.md Updated the DA Interface table, added a new Submit method, and modified existing methods to include namespace parameter.
.markdownlint.yaml Updated markdown linting configuration to disable rule MD013 for tables.

Poem

🐇✨
To the code, we hop and skip,
A namespace added, on this tech trip.
Blobs commit with a new ID,
In our digital burrow, we code free. 🌟
🐇💻

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.

@distractedm1nd distractedm1nd changed the title feat!: adding Namespace to GetAll and Commitment feat!: adding Namespace to GetIDs and Commitment Jan 24, 2024
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

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

Comparison is base (d853a41) 79.77% compared to head (c738365) 79.77%.

Files Patch % Lines
proxy/server.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #35   +/-   ##
=======================================
  Coverage   79.77%   79.77%           
=======================================
  Files           3        3           
  Lines         178      178           
=======================================
  Hits          142      142           
  Misses         28       28           
  Partials        8        8           

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

Copy link

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d853a41 and 049a87e.
Files ignored due to path filters (1)
  • types/pb/da/da.pb.go is excluded by: !**/*.pb.go
Files selected for processing (6)
  • da.go (1 hunks)
  • proto/da/da.proto (2 hunks)
  • proxy/client.go (2 hunks)
  • proxy/server.go (3 hunks)
  • test/dummy.go (2 hunks)
  • test/test_suite.go (3 hunks)
Additional comments: 9
da.go (2)
  • 17-17: The GetIDs method now includes a namespace Namespace parameter. Ensure that all implementations of the DA interface are updated to accommodate this change.
  • 20-20: The Commit method now includes a namespace Namespace parameter. Similar to GetIDs, verify that all implementations of the DA interface are updated to reflect this change.
proxy/server.go (2)
  • 41-41: The GetIDs method in proxySrv now correctly passes the namespace parameter to the underlying DA implementation. Ensure that the Namespace type is properly handled in the GetValue method and that it is compatible with the expected type in the GetIDs method of the DA interface.
Verification successful

The GetValue method on the Namespace type has been found, and it correctly returns a []byte, which is consistent with the usage of the Namespace type in the GetIDs method of the DA interface. The review comment has been successfully verified.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Namespace type is handled correctly in the GetValue method.
ast-grep --lang go --pattern $'func ($_ Namespace) GetValue() $_ {
  $$$
}'

Length of output: 76



Script:

#!/bin/bash
# Attempt to find the GetValue method on the Namespace type with a broader pattern
ast-grep --lang go --pattern $'func ($$$) GetValue() $$$'

Length of output: 1292


Script:

#!/bin/bash
# If the above fails, search for any method on the Namespace type
ast-grep --lang go --pattern $'func ($$$ Namespace) $$$'

Length of output: 57


Script:

#!/bin/bash
# Additionally, look for any usage of the Namespace type to understand how its value is retrieved
rg 'Namespace' --type go

Length of output: 5735

* 51-51: The `Commit` method in `proxySrv` also correctly passes the `namespace` parameter. The same verification for the `Namespace` type handling applies here as it did for the `GetIDs` method.
Verification successful

The GetValue method is indeed present in the codebase and is associated with the Namespace type as well as other types. The method checks if the receiver is not nil and returns the Value field, returning nil if the receiver is nil. This is a correct and safe way to handle potentially nil receivers in Go.

Based on the output, the GetValue method for the Namespace type is implemented as follows:

func (m *Namespace) GetValue() []byte {
	if m != nil {
		return m.Value
	}
	return nil
}

This confirms that the GetValue method is correctly implemented for the Namespace type, and thus the review comment is verified as accurate.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Namespace type is handled correctly in the GetValue method.
ast-grep --lang go --pattern $'func ($_ Namespace) GetValue() $_ {
  $$$
}'

Length of output: 76



Script:

#!/bin/bash
# Search for any GetValue method within the Go codebase to verify its handling.
ast-grep --lang go --pattern $'func ($$$) GetValue() $_ {
  $$$
}'

Length of output: 1301

proto/da/da.proto (2)
  • 72-72: The GetIDsRequest message now includes a Namespace field. This is a breaking change and requires all clients and servers that use this message to be updated accordingly.
  • 83-83: The CommitRequest message also includes a Namespace field. As with GetIDsRequest, verify that all usages of CommitRequest are updated to handle the new field.
proxy/client.go (1)
  • 67-68: The GetIDs method in the Client struct now accepts a namespace parameter and correctly constructs the pbda.GetIDsRequest with it. Ensure that all calls to Client.GetIDs are updated to provide the namespace argument.
Verification successful
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for calls to Client.GetIDs to verify they include the namespace argument.
ast-grep --lang go --pattern $'func ($_ *Client) GetIDs($_, $_, $_) $_ {
  $$$
}'

Length of output: 577



Script:

#!/bin/bash
# Search for usages of the Client.GetIDs method to verify if they include the namespace argument.
rg --glob '!proxy/client.go' 'c\.GetIDs\('

Length of output: 44



Script:

#!/bin/bash
# Perform a more general search for usages of the GetIDs method, including within proxy/client.go
rg 'GetIDs\('

Length of output: 1436



Script:

#!/bin/bash
# Verify if the calls in test/test_suite.go are to the Client.GetIDs method and if they include the namespace parameter.
rg 'GetIDs\(ctx, i,' test/test_suite.go

Length of output: 122



Script:

#!/bin/bash
# Determine the type of the variable 'd' in test/test_suite.go to see if it's an instance of 'Client'.
rg '^\s*\w+\s*d\s*=' test/test_suite.go

Length of output: 78



Script:

#!/bin/bash
# Attempt to find the declaration or instantiation of the variable 'd' in test/test_suite.go.
rg 'd\s*[:=]\s*' test/test_suite.go

Length of output: 130



Script:

#!/bin/bash
# Search for the type that 'd' implements or any struct/interface declaration that could give us a hint about 'd's type.
rg -A 3 'type DummyDA' test/dummy.go

Length of output: 163

test/dummy.go (2)
  • 82-82: The GetIDs method in DummyDA now accepts a namespace parameter. This change is consistent with the interface update. Ensure that the namespace parameter is used appropriately within the method if necessary.
  • 94-94: The Commit method in DummyDA also accepts a namespace parameter. As with GetIDs, ensure that the namespace parameter is used appropriately within the method if necessary.

proxy/client.go Show resolved Hide resolved
test/test_suite.go Show resolved Hide resolved
test/test_suite.go Show resolved Hide resolved
test/test_suite.go Show resolved Hide resolved
test/test_suite.go Show resolved Hide resolved
da.go Show resolved Hide resolved
@distractedm1nd distractedm1nd changed the title feat!: adding Namespace to GetIDs and Commitment feat!: adding Namespace to GetIDs and Commitment, fixing in Submit Jan 29, 2024
Copy link

@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 049a87e and 1520e98.
Files selected for processing (5)
  • da.go (1 hunks)
  • proxy/client.go (3 hunks)
  • proxy/server.go (4 hunks)
  • test/dummy.go (3 hunks)
  • test/test_suite.go (5 hunks)
Files skipped from review as they are similar to previous changes (4)
  • da.go
  • proxy/server.go
  • test/dummy.go
  • test/test_suite.go
Additional comments: 2
proxy/client.go (2)
  • 67-68: The implementation of the GetIDs method correctly incorporates the additional namespace parameter as described in the PR objectives. The pbda.GetIDsRequest struct is updated to include the namespace field, aligning with the intended changes.
  • 78-81: The Commit method has been successfully updated to accept an additional namespace parameter, and the pbda.CommitRequest struct is modified accordingly to include this parameter. This change is consistent with the PR's objectives to enhance namespace support in the DA layer's functionality.

@distractedm1nd
Copy link
Collaborator Author

distractedm1nd commented Jan 29, 2024

@nashqueue and I are currently discussing if Validate really needs namespace - currently it is needed as part of the API to verify proofs in node (see: getByCommitment, blob.Included, nmt.Proof.VerifyInclusion). Will update this comment with results

UPDATE:
We decided to leave it in as the lift is too heavy ATM to change the interfaces down the stack. Additionally, we decided to add Namespace to the rest of the endpoints so we can leave it out of ID in celestia-da/celestia-node.

@nashqueue
Copy link
Member

I would rather have get and validate have namespace than id getting namespace.

Copy link

@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 1520e98 and fcce05e.
Files ignored due to path filters (1)
  • types/pb/da/da.pb.go is excluded by: !**/*.pb.go
Files selected for processing (7)
  • README.md (1 hunks)
  • da.go (1 hunks)
  • proto/da/da.proto (4 hunks)
  • proxy/client.go (5 hunks)
  • proxy/server.go (4 hunks)
  • test/dummy.go (5 hunks)
  • test/test_suite.go (6 hunks)
Files skipped from review as they are similar to previous changes (3)
  • da.go
  • proto/da/da.proto
  • test/test_suite.go
Additional comments: 16
proxy/server.go (5)
  • 36-36: The addition of request.Namespace.GetValue() as a parameter in the Get method aligns with the PR objectives to enhance namespace support. This change correctly extends the method's functionality to include namespace handling.
  • 41-41: The GetIDs method correctly incorporates the Namespace parameter, adhering to the PR's goal of improving data availability layer's interface with namespace support.
  • 51-51: The Commit method's update to include request.Namespace.GetValue() as a parameter is consistent with the PR's objectives to enhance namespace functionality across the data availability layer.
  • 62-62: The Submit method's modification to accept request.Namespace.GetValue() as a parameter is in line with the PR's aim to extend namespace support, enhancing the data availability layer's capabilities.
  • 84-84: The Validate method now correctly includes request.Namespace.GetValue() as a parameter, aligning with the PR's objectives to improve namespace handling in the data availability layer.
README.md (1)
  • 18-22: The README.md file accurately reflects the changes made to the DA Interface, including the addition of the namespace parameter to the Get, GetIDs, Commit, Validate methods, and the introduction of a new Submit method. This documentation update is crucial for users to understand the new interface requirements.
proxy/client.go (5)
  • 51-54: The Get method in proxy/client.go has been correctly updated to include a namespace parameter, aligning with the PR's objectives to enhance namespace support in the data availability layer.
  • 68-69: The GetIDs method now correctly accepts a namespace parameter, reflecting the PR's aim to improve namespace functionality within the data availability layer.
  • 79-82: The Commit method's update to include a namespace parameter is consistent with the PR's objectives. However, based on the existing comments, there's a need to verify that all calls to Client.Commit in other parts of the codebase have been updated accordingly.
  • 94-98: The Submit method's modification to accept a namespace parameter, along with gasPrice, is in line with the PR's aim to extend namespace support, enhancing the data availability layer's capabilities.
  • 117-121: The Validate method now correctly includes a namespace parameter, aligning with the PR's objectives to improve namespace handling in the data availability layer.
test/dummy.go (5)
  • 58-58: The Get method in test/dummy.go has been updated to accept a namespace parameter. This change is consistent with the PR's objectives to enhance namespace support across the data availability layer.
  • 82-82: The GetIDs method now correctly incorporates a namespace parameter, adhering to the PR's goal of improving data availability layer's interface with namespace support.
  • 94-94: The Commit method's update to include a namespace parameter is in line with the PR's objectives to enhance namespace functionality across the data availability layer.
  • 103-103: The Submit method's modification to accept a namespace parameter, along with gasPrice, reflects the PR's aim to extend namespace support, enhancing the data availability layer's capabilities.
  • 120-120: The Validate method now correctly includes a namespace parameter, aligning with the PR's objectives to improve namespace handling in the data availability layer.

@distractedm1nd distractedm1nd changed the title feat!: adding Namespace to GetIDs and Commitment, fixing in Submit feat!: adding Namespace to remaining endpoints Jan 29, 2024
Copy link

@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 fcce05e and 9f197f8.
Files selected for processing (1)
  • README.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • README.md

Copy link

@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 9f197f8 and c738365.
Files selected for processing (1)
  • .markdownlint.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .markdownlint.yaml

@nashqueue nashqueue merged commit 58fb4d0 into main Jan 31, 2024
14 checks passed
@nashqueue nashqueue deleted the namespace branch January 31, 2024 09:36
distractedm1nd added a commit that referenced this pull request Jan 31, 2024
* adding namespaces

* changing submitoptions to gasprice,ns

* adding namespace to remaining endpoints

* updating readme w note

* nit: lint md013 - skip tables

---------

Co-authored-by: Javed Khan <tuxcanfly@gmail.com>

updating readme w note

feat: GetProofs introduction

updating readme
distractedm1nd added a commit that referenced this pull request Jan 31, 2024
* adding namespaces

* changing submitoptions to gasprice,ns

* adding namespace to remaining endpoints

* updating readme w note

* nit: lint md013 - skip tables

---------

Co-authored-by: Javed Khan <tuxcanfly@gmail.com>

updating readme w note

feat: GetProofs introduction

updating readme
nashqueue pushed a commit that referenced this pull request Feb 1, 2024
* feat!: adding Namespace to remaining endpoints (#35)

* adding namespaces

* changing submitoptions to gasprice,ns

* adding namespace to remaining endpoints

* updating readme w note

* nit: lint md013 - skip tables

---------

Co-authored-by: Javed Khan <tuxcanfly@gmail.com>

updating readme w note

feat: GetProofs introduction

updating readme

* nit

* making GetProofs take da.ID slice instead of height
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.

3 participants