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: add keyName #89

Closed
wants to merge 6 commits into from
Closed

feat: add keyName #89

wants to merge 6 commits into from

Conversation

jcstein
Copy link
Member

@jcstein jcstein commented Aug 27, 2024

Overview

Matches rollkit/rollkit#1820
Partially resolves rollkit/rollkit#1821

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

  • New Features

    • Enhanced the submission functionality to accept an optional keyring key name, improving security and access control during data submissions.
    • Introduced a new type to facilitate key management within the submission process.
  • Bug Fixes

    • Adjusted method signatures across various components to accommodate the new keyring key name parameter, ensuring consistency and functionality.
  • Documentation

    • Updated the README to reflect changes in the submission method and its new parameters for better user understanding.

Copy link

coderabbitai bot commented Aug 27, 2024

Walkthrough

The changes involve modifying the Submit method across multiple components to include an additional parameter, keyName. This enhancement allows the submission of a key name, improving data handling related to security and access control. The modifications span various files, including the README.md, Protocol Buffers definitions, and client/server implementations.

Changes

Files Change Summary
README.md, proto/da/da.proto, da.go, proxy/grpc/client.go, proxy/grpc/server.go, proxy/jsonrpc/client.go, test/dummy.go Updated Submit method signatures to include keyName and added KeyName message to SubmitRequest.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant DA

    Client->>Server: Submit(blobs, gasPrice, namespace, keyName)
    Server->>DA: Submit(ctx, blobs, gasPrice, namespace, keyName)
    DA-->>Server: Response(ID, error)
    Server-->>Client: Response(ID, error)
Loading

🐰 In fields so wide and bright,
A key name takes its flight!
With blobs and gas, we play,
Securely, come what may.
Hops of joy, a data dance,
In the code, we take our chance! 🌟

Assessment against linked issues

Objective Addressed Explanation
Add DAKeyringKeyname flag to rollkit and update go-da (1821)

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

@RollkitBot RollkitBot requested review from a team, tuxcanfly, tzdybal and MSevey and removed request for a team August 27, 2024 21:05
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.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e6b934 and 1d6b911.

Files selected for processing (8)
  • README.md (1 hunks)
  • da.go (2 hunks)
  • proto/da/da.proto (1 hunks)
  • proxy/grpc/client.go (1 hunks)
  • proxy/grpc/server.go (1 hunks)
  • proxy/jsonrpc/client.go (2 hunks)
  • test/dummy.go (1 hunks)
  • test/test_suite.go (1 hunks)
Additional context used
GitHub Check: lint / golangci-lint
proxy/grpc/server.go

[failure] 73-73:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 74-74:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname) (typecheck)


[failure] 73-73:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 74-74:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)) (typecheck)

proxy/grpc/client.go

[failure] 116-116:
req.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 116-116:
undefined: pbda.Keyringkeyname


[failure] 116-116:
req.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 116-116:
undefined: pbda.Keyringkeyname

GitHub Check: test / Run Unit Tests
proxy/grpc/server.go

[failure] 73-73:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 74-74:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)

proxy/grpc/client.go

[failure] 116-116:
req.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 116-116:
undefined: pbda.Keyringkeyname

LanguageTool
README.md

[duplication] ~23-~23: Possible typo: you repeated a word
Context: ... | []bool | | Submit | blobs []Blob, gasPrice float64, namespace Namespace, keyringkeyname Keyringkeyname | `[...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~23-~23: Possible typo: you repeated a word
Context: ...gasPrice float64, namespace Namespace, keyringkeyname Keyringkeyname | []ID| NOTE: TheNamespace` pa...

(ENGLISH_WORD_REPEAT_RULE)

Additional comments not posted (10)
da.go (2)

39-42: LGTM!

The new type alias Keyringkeyname is correctly defined.

The code changes are approved.


29-29: Verify impact on existing implementations.

The Submit method signature has been updated to include an additional parameter keyringkeyname. Ensure that all existing implementations of the DA interface are updated accordingly to handle this new parameter.

Run the following script to identify all implementations of the Submit method:

proto/da/da.proto (2)

111-112: LGTM!

The addition of the Keyringkeyname field in the SubmitRequest message enhances the functionality by allowing it to carry additional metadata related to key management.

The code changes are approved.


114-116: LGTM!

The Keyringkeyname message is correctly defined and enhances the Protocol Buffers definitions by allowing the inclusion of keyring key names.

The code changes are approved.

proxy/grpc/client.go (2)

108-108: LGTM!

The Submit function signature is correctly updated to include the new parameter keyringkeyname.

The code changes are approved.


115-117: Verify the keyringkeyname field definition and usage.

The implementation correctly handles the new parameter. However, the static analysis tools indicate that the keyringkeyname field might be undefined.

Run the following script to verify the keyringkeyname field definition and usage:

Verification successful

The keyringkeyname field is correctly defined and used.

The Keyringkeyname field is defined as a message in the proto/da/da.proto file and is used consistently across the codebase, including in the Submit function. The initial concern about it being potentially undefined is unfounded.

  • Definition: proto/da/da.proto
  • Usage: Various function signatures, including Submit in proxy/grpc/client.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the `keyringkeyname` field definition and usage.

# Test: Search for the `keyringkeyname` field definition. Expect: Only valid definitions.
rg --type proto 'Keyringkeyname'

Length of output: 62


Script:

#!/bin/bash
# Description: Search for the `Keyringkeyname` field definition and usage across all files.

# Search for the `Keyringkeyname` field in the entire codebase.
rg 'Keyringkeyname'

Length of output: 1542

Tools
GitHub Check: lint / golangci-lint

[failure] 116-116:
req.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 116-116:
undefined: pbda.Keyringkeyname


[failure] 116-116:
req.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 116-116:
undefined: pbda.Keyringkeyname

GitHub Check: test / Run Unit Tests

[failure] 116-116:
req.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 116-116:
undefined: pbda.Keyringkeyname

proxy/jsonrpc/client.go (2)

29-29: LGTM!

The Submit function signature is correctly updated to include the new parameter keyringkeyname.

The code changes are approved.


64-65: LGTM!

The implementation correctly handles the new parameter keyringkeyname.

The code changes are approved.

test/dummy.go (1)

125-125: Verify the necessity and usage of the new parameter.

The new parameter keyringkeyname is added to the function signature but is not used within the function. Verify if this is intentional or if the parameter should be utilized within the function.

Please confirm if the keyringkeyname parameter is intended to be used within the Submit function. If not, consider removing it to avoid confusion.

test/test_suite.go (1)

43-43: Verify the usage of the new parameter.

The Submit function call now includes an additional parameter, nil. Ensure that this aligns with the intended usage of the Submit function and that nil is an appropriate value for the new parameter.

Please confirm if nil is the intended value for the new parameter in the Submit function call. If not, provide the appropriate value.

Comment on lines 72 to 76
var keyringkeyname *da.Keyringkeyname
if request.Keyringkeyname != nil {
keyringkeyname = (*da.Keyringkeyname)(&request.Keyringkeyname.Value)
}

Copy link

Choose a reason for hiding this comment

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

Fix undefined request.Keyringkeyname.

The request.Keyringkeyname field is undefined. Ensure that the SubmitRequest type in the pbda package includes the Keyringkeyname field.

Apply this diff to define the Keyringkeyname field in the SubmitRequest type:

// In the `pbda` package, update the `SubmitRequest` type definition to include the `Keyringkeyname` field.
type SubmitRequest struct {
	// Other fields...
	Keyringkeyname *Keyringkeyname `protobuf:"bytes,5,opt,name=keyringkeyname" json:"keyringkeyname,omitempty"`
}

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: lint / golangci-lint

[failure] 73-73:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 74-74:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname) (typecheck)


[failure] 73-73:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 74-74:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)) (typecheck)

GitHub Check: test / Run Unit Tests

[failure] 73-73:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)


[failure] 74-74:
request.Keyringkeyname undefined (type *"github.com/rollkit/go-da/types/pb/da".SubmitRequest has no field or method Keyringkeyname)

README.md Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d6b911 and 483f494.

Files selected for processing (1)
  • README.md (1 hunks)
Additional context used
LanguageTool
README.md

[duplication] ~23-~23: Possible typo: you repeated a word
Context: ... | []bool | | Submit | blobs []Blob, gasPrice float64, namespace Namespace, keyringkeyname Keyringkeyname | `[...

(ENGLISH_WORD_REPEAT_RULE)

Additional comments not posted (1)
README.md (1)

23-23: Fix possible typo.

There is a possible typo in the Submit method signature documentation. Ensure that the method signature is correctly documented.

Apply this diff to fix the typo:

- | `Submit`      | `blobs []Blob, gasPrice float64, namespace Namespace, keyringkeyname Keyringkeyname`    | `[]ID` |
+ | `Submit`      | `blobs []Blob, gasPrice float64, namespace Namespace, keyringkeyname Keyringkeyname`    | `[]ID` |

Likely invalid or redundant comment.

Tools
LanguageTool

[duplication] ~23-~23: Possible typo: you repeated a word
Context: ... | []bool | | Submit | blobs []Blob, gasPrice float64, namespace Namespace, keyringkeyname Keyringkeyname | `[...

(ENGLISH_WORD_REPEAT_RULE)

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 78.26%. Comparing base (02a78bb) to head (de917c7).
Report is 11 commits behind head on main.

Files Patch % Lines
proxy/grpc/client.go 33.33% 1 Missing and 1 partial ⚠️
proxy/grpc/server.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
+ Coverage   75.54%   78.26%   +2.71%     
==========================================
  Files           5        5              
  Lines         274      230      -44     
==========================================
- Hits          207      180      -27     
+ Misses         52       35      -17     
  Partials       15       15              

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 483f494 and de917c7.

Files ignored due to path filters (1)
  • types/pb/da/da.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • proto/da/da.proto (1 hunks)
  • test/test_suite.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • proto/da/da.proto
  • test/test_suite.go

Copy link
Contributor

@tuxcanfly tuxcanfly left a comment

Choose a reason for hiding this comment

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

Since node's jsonrpc library doesn't support optional params, older jsonrpc clients go-da <= 0.5.0 will not be compatible as they'll break with:

RPC error (-32602): wrong param count (method 'da.Submit'): 3 != 4

One alternative might be to add a new method SubmitWithOptions which includes an opaque []byte SubmitOptions.

type SubmitOptions = []byte

type DA interface {
...
	SubmitWithOptions(ctx context.Context, blobs []Blob, namespace Namespace, options SubmitOptions) ([]ID, error)
...
}

In celestia-node we can pass this directly to TxConfig.UnmarshalJSON to support all other txconfig options such as signer_address, fee_granter_address as well e.g.:

func (s *Service) SubmitWithOptions(
	ctx context.Context,
	daBlobs []da.Blob,
	options da.SubmitOptions)
) ([]da.ID, error) {
	blobs, _, err := s.blobsAndCommitments(daBlobs, namespace)
	if err != nil {
		return nil, err
	}

	opts := state.NewTxConfig()
	err = opts.UnmarshalJSON(options)

This allows older clients to continue working while newer clients can support new features such as multiple accounts, fee granter etc.

proto/da/da.proto Outdated Show resolved Hide resolved
proxy/grpc/client.go Show resolved Hide resolved
da.go Outdated
@@ -36,6 +36,10 @@ type DA interface {
// posted to, for DA layers supporting the functionality.
type Namespace = []byte

// Keyringkeyname is an optional parameter used to set the keyring keyname for
// the DA service.
type Keyringkeyname = []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

KeyName sounds less repetitive.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I was just trying to match UX on node.

da.go Outdated Show resolved Hide resolved
proxy/grpc/server.go Outdated Show resolved Hide resolved
@jcstein
Copy link
Member Author

jcstein commented Aug 28, 2024

Got it! I understand, and thank you for the review.

Confirming my understanding, that []byte SubmitOptions would handle the struct from 3349 celestiaorg/celestia-node#3349?

Co-authored-by: Javed Khan <tuxcanfly@gmail.com>
README.md Outdated Show resolved Hide resolved
da.go Outdated Show resolved Hide resolved
da.go Outdated Show resolved Hide resolved
proto/da/da.proto Outdated Show resolved Hide resolved
proto/da/da.proto Outdated Show resolved Hide resolved
proxy/grpc/client.go Outdated Show resolved Hide resolved
proxy/grpc/client.go Outdated Show resolved Hide resolved
proxy/grpc/client.go Outdated Show resolved Hide resolved
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.

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between de917c7 and 3f7312e.

Files selected for processing (4)
  • da.go (2 hunks)
  • proto/da/da.proto (1 hunks)
  • proxy/grpc/client.go (1 hunks)
  • proxy/grpc/server.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/da/da.proto
Additional context used
GitHub Check: test / Run Unit Tests
da.go

[failure] 29-29:
undefined: keyName

GitHub Check: lint / golangci-lint
da.go

[failure] 29-29:
undefined: keyName (typecheck)


[failure] 29-29:
undefined: keyName) (typecheck)


[failure] 29-29:
undefined: keyName) (typecheck)

proxy/grpc/server.go

[failure] 77-77:
request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)

proxy/grpc/client.go

[failure] 113-113:
undefined: pbda.KeyName (typecheck)

golangci-lint
proxy/grpc/server.go

77-77: request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)

proxy/grpc/client.go

113-113: undefined: pbda.KeyName

(typecheck)

Additional comments not posted (1)
da.go (1)

39-41: LGTM!

The type alias Keyringkeyname is correctly defined.

The code changes are approved.

Comment on lines 72 to 77
var keyringkeyname *da.Keyringkeyname
if request.Keyringkeyname != nil {
keyringkeyname = (*da.Keyringkeyname)(&request.Keyringkeyname.Value)
}

ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), request.KeyName.GetValue())
Copy link

Choose a reason for hiding this comment

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

Fix undefined KeyName.

The request.KeyName field is undefined. Ensure that the correct field name is used.

Apply this diff to fix the issue:

	ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), keyringkeyname)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var keyringkeyname *da.Keyringkeyname
if request.Keyringkeyname != nil {
keyringkeyname = (*da.Keyringkeyname)(&request.Keyringkeyname.Value)
}
ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), request.KeyName.GetValue())
var keyringkeyname *da.Keyringkeyname
if request.Keyringkeyname != nil {
keyringkeyname = (*da.Keyringkeyname)(&request.Keyringkeyname.Value)
}
ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), keyringkeyname)
Tools
golangci-lint

77-77: request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)

GitHub Check: lint / golangci-lint

[failure] 77-77:
request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)

Comment on lines 108 to 117
func (c *Client) Submit(ctx context.Context, blobs []da.Blob, gasPrice float64, namespace da.Namespace, keyringkeyname *da.Keyringkeyname) ([]da.ID, error) {
req := &pbda.SubmitRequest{
Blobs: blobsDA2PB(blobs),
GasPrice: gasPrice,
Namespace: &pbda.Namespace{Value: namespace},
Namespace: &pbda.KeyName{Value: keyName},
}

if keyringkeyname != nil {
req.Keyringkeyname = &pbda.Keyringkeyname{Value: *keyringkeyname}
Copy link

Choose a reason for hiding this comment

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

Fix undefined KeyName.

The KeyName field is undefined. Ensure that the correct field name is used.

Apply this diff to fix the issue:

		Namespace: &pbda.Namespace{Value: namespace},
		Keyringkeyname: &pbda.Keyringkeyname{Value: *keyringkeyname},

Committable suggestion was skipped due to low confidence.

Tools
golangci-lint

113-113: undefined: pbda.KeyName

(typecheck)

GitHub Check: lint / golangci-lint

[failure] 113-113:
undefined: pbda.KeyName (typecheck)

proxy/grpc/server.go Outdated Show resolved Hide resolved
proxy/grpc/server.go Outdated Show resolved Hide resolved
proxy/grpc/server.go Outdated Show resolved Hide resolved
proxy/jsonrpc/client.go Outdated Show resolved Hide resolved
proxy/jsonrpc/client.go Outdated Show resolved Hide resolved
proxy/jsonrpc/client.go Outdated Show resolved Hide resolved
test/dummy.go Outdated Show resolved Hide resolved
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.

Actionable comments posted: 6

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3f7312e and f22f875.

Files selected for processing (7)
  • README.md (1 hunks)
  • da.go (2 hunks)
  • proto/da/da.proto (1 hunks)
  • proxy/grpc/client.go (1 hunks)
  • proxy/grpc/server.go (1 hunks)
  • proxy/jsonrpc/client.go (2 hunks)
  • test/dummy.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • proxy/jsonrpc/client.go
  • test/dummy.go
Additional context used
GitHub Check: test / Run Unit Tests
da.go

[failure] 29-29:
undefined: keyName

GitHub Check: lint / golangci-lint
da.go

[failure] 29-29:
undefined: keyName (typecheck)


[failure] 29-29:
undefined: keyName) (typecheck)

proxy/grpc/server.go

[failure] 73-73:
request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)


[failure] 77-77:
request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)

proxy/grpc/client.go

[failure] 113-113:
undefined: pbda.KeyName (typecheck)


[failure] 117-117:
req.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)

golangci-lint
proxy/grpc/server.go

73-73: request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)


77-77: request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)

proxy/grpc/client.go

113-113: undefined: pbda.KeyName

(typecheck)


117-117: req.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)

LanguageTool
README.md

[duplication] ~23-~23: Possible typo: you repeated a word
Context: ... | []bool | | Submit | blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName | []ID | NOTE: ...

(ENGLISH_WORD_REPEAT_RULE)

buf
proto/da/da.proto

111-111: Field name "keyName" should be lower_snake_case, such as "key_name".

(FIELD_LOWER_SNAKE_CASE)

Additional comments not posted (3)
da.go (1)

39-42: LGTM!

The type alias KeyName is correctly defined as a byte slice.

proto/da/da.proto (1)

114-115: LGTM!

The KeyName message is correctly defined and enhances the functionality.

The code changes are approved.

proxy/grpc/client.go (1)

108-108: LGTM!

The addition of the keyName parameter enhances the functionality of the Submit function.

The code changes are approved.

@@ -26,7 +26,7 @@
//
// This method is synchronous. Upon successful submission to Data Availability layer, it returns the IDs identifying blobs
// in DA.
Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace) ([]ID, error)
Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName) ([]ID, error)
Copy link

Choose a reason for hiding this comment

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

Fix undefined keyName.

The keyName parameter is undefined. Ensure that the parameter name matches the type alias KeyName.

Apply this diff to fix the issue:

-	Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName) ([]ID, error)
+	Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace, keyName KeyName) ([]ID, error)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName) ([]ID, error)
Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace, keyName KeyName) ([]ID, error)
Tools
GitHub Check: test / Run Unit Tests

[failure] 29-29:
undefined: keyName

GitHub Check: lint / golangci-lint

[failure] 29-29:
undefined: keyName (typecheck)


[failure] 29-29:
undefined: keyName) (typecheck)

Comment on lines +72 to +77
var keyName da.KeyName
if request.KeyName != nil {
keyName = (da.KeyName)(&request.KeyName.Value)
}

ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), request.KeyName.GetValue())
Copy link

Choose a reason for hiding this comment

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

Fix undefined request.KeyName.

The request.KeyName field is undefined. Ensure that the SubmitRequest type in the pbda package includes the KeyName field.

Apply this diff to define the KeyName field in the SubmitRequest type:

// In the `pbda` package, update the `SubmitRequest` type definition to include the `KeyName` field.
type SubmitRequest struct {
	// Other fields...
	KeyName *KeyName `protobuf:"bytes,5,opt,name=keyName" json:"keyName,omitempty"`
}

Committable suggestion was skipped due to low confidence.

Tools
golangci-lint

73-73: request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)


77-77: request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)

GitHub Check: lint / golangci-lint

[failure] 73-73:
request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)


[failure] 77-77:
request.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)

@@ -20,7 +20,7 @@ go-da defines a generic Data Availability interface for modular blockchains.
| `GetProofs` | `ids []id, namespace Namespace` | `[]Proof` |
| `Commit` | `blobs []Blob, namespace Namespace` | `[]Commitment` |
| `Validate` | `ids []Blob, proofs []Proof, namespace Namespace` | `[]bool` |
| `Submit` | `blobs []Blob, gasPrice float64, namespace Namespace` | `[]ID` |
| `Submit` | `blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName` | `[]ID` |
Copy link

Choose a reason for hiding this comment

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

Fix possible typo.

There is a possible typo in the Submit method signature documentation. Ensure that the method signature is correctly documented.

Apply this diff to fix the typo:

- | `Submit`      | `blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName`    | `[]ID` |
+ | `Submit`      | `blobs []Blob, gasPrice float64, namespace Namespace, keyName KeyName`    | `[]ID` |
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `Submit` | `blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName` | `[]ID` |
| `Submit` | `blobs []Blob, gasPrice float64, namespace Namespace, keyName KeyName` | `[]ID` |
Tools
LanguageTool

[duplication] ~23-~23: Possible typo: you repeated a word
Context: ... | []bool | | Submit | blobs []Blob, gasPrice float64, namespace Namespace, keyName keyName | []ID | NOTE: ...

(ENGLISH_WORD_REPEAT_RULE)

Comment on lines +108 to +112
repeated Blob blobs = 1;
double gas_price = 2;
Namespace namespace = 3;
KeyName keyName = 4;
}
Copy link

@coderabbitai coderabbitai bot Aug 28, 2024

Choose a reason for hiding this comment

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

Use lower_snake_case for field names.

The field name keyName should be in lower_snake_case to follow protobuf naming conventions. Change it to key_name.

Apply this diff to fix the naming convention:

message SubmitRequest {
    repeated Blob blobs = 1;
    double gas_price = 2;
    Namespace namespace = 3;
-   KeyName keyName = 4;
+   KeyName key_name = 4;
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
repeated Blob blobs = 1;
double gas_price = 2;
Namespace namespace = 3;
KeyName keyName = 4;
}
repeated Blob blobs = 1;
double gas_price = 2;
Namespace namespace = 3;
KeyName key_name = 4;
Tools
buf

111-111: Field name "keyName" should be lower_snake_case, such as "key_name".

(FIELD_LOWER_SNAKE_CASE)

Copy link
Member

Choose a reason for hiding this comment

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

This is perfectly valid point and should be reworked.

Copy link

Choose a reason for hiding this comment

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

@tzdybal, thanks for confirming! The change to lower_snake_case for the field name will ensure consistency with protobuf naming conventions. Let's proceed with reworking it as suggested.

Comment on lines +116 to +117
if keyName != nil {
req.KeyName = &pbda.KeyName{Value: *keyName}
Copy link

Choose a reason for hiding this comment

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

Fix incorrect field usage.

The field req.KeyName is incorrectly used, causing type errors and undefined field issues. Use the correct field name key_name.

Apply this diff to fix the issue:

if keyName != nil {
-   req.KeyName = &pbda.KeyName{Value: *keyName}
+   req.key_name = &pbda.KeyName{Value: *keyName}
}

Committable suggestion was skipped due to low confidence.

Tools
golangci-lint

117-117: req.KeyName undefined (type *da.SubmitRequest has no field or method KeyName)

(typecheck)

GitHub Check: lint / golangci-lint

[failure] 117-117:
req.KeyName undefined (type *da.SubmitRequest has no field or method KeyName) (typecheck)

Comment on lines +113 to +114
Namespace: &pbda.KeyName{Value: keyName},
}
Copy link

Choose a reason for hiding this comment

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

Fix incorrect field usage.

The field Namespace is incorrectly used for KeyName, causing type errors and undefined field issues. Use the correct field name KeyName.

Apply this diff to fix the issue:

req := &pbda.SubmitRequest{
    Blobs:     blobsDA2PB(blobs),
    GasPrice:  gasPrice,
    Namespace: &pbda.Namespace{Value: namespace},
-   Namespace: &pbda.KeyName{Value: keyName},
+   KeyName:   &pbda.KeyName{Value: keyName},
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Namespace: &pbda.KeyName{Value: keyName},
}
req := &pbda.SubmitRequest{
Blobs: blobsDA2PB(blobs),
GasPrice: gasPrice,
Namespace: &pbda.Namespace{Value: namespace},
KeyName: &pbda.KeyName{Value: keyName},
}
Tools
golangci-lint

113-113: undefined: pbda.KeyName

(typecheck)

GitHub Check: lint / golangci-lint

[failure] 113-113:
undefined: pbda.KeyName (typecheck)

@jcstein jcstein changed the title feat: add keyringkeyname feat: add keyName Aug 29, 2024
Copy link
Member

@tzdybal tzdybal left a comment

Choose a reason for hiding this comment

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

I'm trying to be aggressively neutral here.

Key name seems to be something quite specific to celestia-node. It probably could be translated to other implementations as well, but I can also imagine system where you can specify actual key (not nick-name).

And to be even more generic, maybe we should pass just some bytes, that could be passed by rollkit via go-da and interpreted by specific da implementations?

@@ -36,6 +36,10 @@ type DA interface {
// posted to, for DA layers supporting the functionality.
type Namespace = []byte

// KeyName is an optional parameter used to set the keyring keyname for
Copy link
Member

Choose a reason for hiding this comment

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

TBH it's not "optional" as you have to pass something in Go call.

Copy link
Member

Choose a reason for hiding this comment

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

To make it actually optional, we should implement Option pattern and accept them using ... in functions.

Comment on lines +108 to +112
repeated Blob blobs = 1;
double gas_price = 2;
Namespace namespace = 3;
KeyName keyName = 4;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is perfectly valid point and should be reworked.

@tzdybal
Copy link
Member

tzdybal commented Sep 9, 2024

Replaced by #95

@tzdybal tzdybal closed this Sep 9, 2024
@jcstein
Copy link
Member Author

jcstein commented Sep 10, 2024

worth a shot! thank you for making #95 and apologies for letting this go stale

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.

[Feature Request]: add support for MultiAccounts on celestia-node
3 participants