Skip to content

fix(da): add jsonrpc da client #1587

Merged
gupadhyaya merged 38 commits into
mainfrom
tux/jsonrpc
Mar 18, 2024
Merged

fix(da): add jsonrpc da client #1587
gupadhyaya merged 38 commits into
mainfrom
tux/jsonrpc

Conversation

@tuxcanfly

@tuxcanfly tuxcanfly commented Mar 6, 2024

Copy link
Copy Markdown
Collaborator

Overview

This PR adds jsonrpc da client.

Depends on evstack/go-da#54

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
    • Added a new flag for specifying a data availability layer (DA) auth token.
    • Introduced support for connecting via gRPC or JSON-RPC transports with configuration options including DA address, auth token, and namespace.
  • Bug Fixes
    • Updated default DA address format and protocol to ensure consistency and correct connection handling.
  • Refactor
    • Simplified DA client initialization with default timeout values and new client creation methods.
    • Renamed and restructured timeout constants and fields within the DAClient struct.
    • Replaced direct gRPC server setup with simplified proxy server initialization for both gRPC and JSONRPC.
    • Updated references and variable names across various tests to align with new addressing and namespace configurations.
  • Chores
    • Removed unused imports across multiple files to clean up the codebase.
  • Documentation
    • Updated documentation to reflect new DA connection options and configurations.

@coderabbitai

coderabbitai Bot commented Mar 6, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent updates represent a significant shift towards enhancing connectivity and configuration flexibility within the system. Key changes include the adoption of JSON-RPC alongside gRPC for data availability (DA) client-server communication, streamlined client initialization with new default settings, and improved configuration options including authentication tokens and namespace adjustments. This evolution underscores a broader strategy to accommodate diverse network protocols and enhance security measures, ensuring a more adaptable and robust framework.

Changes

Files Change Summary
block/manager_test.go Modified dalc initialization to use da.NewDAClient.
cmd/rollkit/.../run_node.go, node/full.go Removed unused imports, updated DA connection to use JSON-RPC, adjusted daClient initialization.
cmd/rollkit/docs/rollkit_start.md, config/... Added DA auth token configuration, updated DA address defaults.
da/da.go, da/da_test.go, node/... Renamed timeout constants, added new NewDAClient function, refactored block submission, updated namespace and address references.
da/mock/cmd/main.go, rpc/json/helpers_test.go Simplified server setup to use JSON-RPC, updated address parsing.
test/mocks/util.go Introduced mock addresses and namespace for testing purposes.

"In the realm of code, where data streams flow,
A rabbit hopped, with changes in tow.
🌐 From gRPC to JSON-RPC, it leapt with grace,
🛡️ Adding tokens for security's embrace.
🚀 With namespaces refined and addresses keen,
This rabbit's work, a tech marvel unseen."
🐰💻 - @coderabbitai

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

@tuxcanfly tuxcanfly changed the title fix(da): switch to jsonrpc da client fix(da): add jsonrpc da client Mar 8, 2024
@tuxcanfly
tuxcanfly marked this pull request as ready for review March 13, 2024 07:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 b708321 and e6b5a38.
Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum
Files selected for processing (9)
  • cmd/rollkit/commands/run_node.go (4 hunks)
  • cmd/rollkit/docs/rollkit_start.md (1 hunks)
  • config/config.go (4 hunks)
  • da/da.md (2 hunks)
  • da/da_test.go (6 hunks)
  • da/mock/cmd/main.go (2 hunks)
  • node/full.go (3 hunks)
  • node/node_test.go (1 hunks)
  • rpc/json/helpers_test.go (1 hunks)
Check Runs (5)
lint / hadolint / hadolint completed (1)
lint / markdown-lint completed (1)
lint / yamllint completed (1)
lint / golangci-lint completed (1)
test / Run Unit Tests completed (1)
Files skipped from review as they are similar to previous changes (6)
  • cmd/rollkit/commands/run_node.go
  • config/config.go
  • da/mock/cmd/main.go
  • node/full.go
  • node/node_test.go
  • rpc/json/helpers_test.go
Additional comments: 8
da/da.md (2)
  • 7-7: The transition from gRPC to JSON-RPC for the DAClient is well-documented here. It's important to ensure that all references and links related to JSON-RPC and the json-rpc-proxy are accurate and accessible.
  • 32-37: The addition of [json-rpc-proxy] in the references section is a good practice for documentation clarity. Ensure that the URL provided (https://github.com/rollkit/go-da/tree/main/proxy) is correct and that the repository is publicly accessible.
cmd/rollkit/docs/rollkit_start.md (1)
  • 34-34: The addition of the --rollkit.da_auth_token flag is a crucial update for supporting authentication with the DA layer. Ensure that the documentation clearly explains how to obtain and use this token for users unfamiliar with the authentication process.
da/da_test.go (5)
  • 18-18: Renaming the proxy package to proxy-jsonrpc aligns with the transition to JSON-RPC. Ensure that all references to this package are updated across the entire codebase to prevent import errors.
Verification successful

The renaming of the proxy package to proxy-jsonrpc has been correctly applied across the codebase, as indicated by the absence of the old package name and the presence of the new one in several files. This aligns with the transition to JSON-RPC and ensures consistency in package references, preventing import errors.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for old package name usage across the codebase. Expecting no results.
rg --type go 'github.com/rollkit/go-da/proxy'

Length of output: 298

* 72-76: The initialization of the `rpcClient` using `startMockDAClient` demonstrates the transition to JSON-RPC for testing. Verify that the mock DA client correctly mimics the behavior of the actual JSON-RPC DA client to ensure test reliability. * 98-100: Starting the mock DA server with `proxy.NewServer` is a key part of testing the JSON-RPC integration. Ensure that the server address (`localhost:7980`) does not conflict with other services during testing. * 124-126: The temporary adjustment of `submitTimeout` for testing the submit timeout behavior is a good practice. However, ensure that this modification is thread-safe if tests are run in parallel. * 273-278: The tests for submitting large blocks and handling overflow are critical for ensuring the DA client behaves correctly under various conditions. Verify that these tests cover all edge cases, including partial submissions and retries.

Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 e6b5a38 and 1227545.
Files selected for processing (2)
  • da/da_test.go (6 hunks)
  • node/full.go (3 hunks)
Check Runs (5)
lint / hadolint / hadolint completed (1)
test / Run Unit Tests completed (1)
lint / yamllint completed (1)
lint / golangci-lint completed (1)
lint / markdown-lint completed (1)
Files skipped from review as they are similar to previous changes (2)
  • da/da_test.go
  • node/full.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 1227545 and a8b7580.
Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum
Files selected for processing (1)
  • node/full.go (3 hunks)
Check Runs (5)
lint / hadolint / hadolint completed (1)
test / Run Unit Tests completed (1)
lint / golangci-lint completed (1)
lint / yamllint completed (1)
lint / markdown-lint completed (1)
Files skipped from review as they are similar to previous changes (1)
  • node/full.go

Comment thread cmd/rollkit/commands/run_node.go Outdated
Comment thread da/da.md Outdated
Comment thread da/da.md Outdated
Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread node/node_test.go Outdated
Comment thread rpc/json/helpers_test.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 a8b7580 and 3873082.
Files selected for processing (1)
  • node/full.go (3 hunks)
Check Runs (5)
lint / hadolint / hadolint completed (1)
test / Run Unit Tests completed (1)
lint / yamllint completed (1)
lint / golangci-lint completed (1)
lint / markdown-lint completed (1)
Files skipped from review as they are similar to previous changes (1)
  • node/full.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 3873082 and 3fdee75.
Files selected for processing (2)
  • config/defaults.go (1 hunks)
  • da/da.md (2 hunks)
Additional comments: 2
config/defaults.go (1)
  • 29-29: The update to DAAddress to include "grpc://" seems inconsistent with the PR's objective of transitioning to JSON-RPC for DA interactions. Please verify if this is the intended protocol and address format, especially since the PR aims to move away from gRPC.
da/da.md (1)
  • 7-11: The documentation updates accurately reflect the PR's objectives by mentioning support for both gRPC and JSON-RPC transports. However, the default DA address is prefixed with "grpc://", which might be misleading given the focus on JSON-RPC. Consider clarifying the intended default protocol and address format for users.

Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread da/da_test.go Outdated
Comment thread da/mock/cmd/main.go
Comment thread node/full.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 3fdee75 and b94d4d4.
Files selected for processing (10)
  • cmd/rollkit/commands/run_node.go (5 hunks)
  • da/da_test.go (6 hunks)
  • da/mock/cmd/main.go (1 hunks)
  • node/full.go (3 hunks)
  • node/full_client_test.go (7 hunks)
  • node/full_node_integration_test.go (3 hunks)
  • node/full_node_test.go (2 hunks)
  • node/helpers_test.go (1 hunks)
  • node/node_test.go (2 hunks)
  • rpc/json/helpers_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • cmd/rollkit/commands/run_node.go
  • da/mock/cmd/main.go
  • node/full.go
  • rpc/json/helpers_test.go
Additional comments: 19
node/helpers_test.go (1)
  • 21-22: The update from MockNamespace to MockDANamespace aligns with the PR's objectives to enhance JSON-RPC DA client integration. This change is clear and straightforward.
node/node_test.go (2)
  • 20-23: The updates to MockDAAddress and MockDANamespace are consistent with the PR's objectives to enhance JSON-RPC DA client integration. These changes properly reflect the transition from gRPC to JSON-RPC.
  • 68-68: Ensure that the updated MockDAAddress and MockDANamespace are consistently used throughout the test suite to avoid any connectivity or namespace resolution issues.
da/da_test.go (4)
  • 21-22: Transitioning from proxy-grpc to proxy-jsonrpc aligns with the PR's objectives to enhance JSON-RPC DA client integration. This change is a key part of moving away from gRPC towards a JSON-RPC based approach.
  • 114-124: The setup for the mock DA server using gRPC has been correctly replaced with a JSON-RPC implementation. This change is crucial for testing the new JSON-RPC client functionality.
  • 127-133: The initialization of the mock DA client for gRPC has been correctly updated to reflect the transition to JSON-RPC. This ensures consistency with the new DA interaction method.
  • 311-316: Consider revisiting the removal of assertions regarding resp.Code in the test functions. Ensuring that the response code is as expected is important for validating the behavior of the DA client.
node/full_node_test.go (2)
  • 197-197: Updating the namespace reference from MockNamespace to MockDANamespace in the DAClient struct aligns with the PR's objectives to enhance JSON-RPC DA client integration. This change is appropriate and reflects the transition from gRPC to JSON-RPC.
  • 284-285: Ensure that the updated MockDANamespace is consistently used throughout the test suite to avoid any namespace resolution issues.
node/full_node_integration_test.go (3)
  • 63-63: The DAAddress and DANamespace fields have been updated to MockDAAddress and MockDANamespace respectively. This change aligns with the PR's objective to transition from gRPC to JSON-RPC for DA interactions. Ensure that MockDAAddress and MockDANamespace are correctly defined and represent valid JSON-RPC endpoints and namespaces for testing purposes.
  • 186-187: Similar to the previous comment, the DAAddress and DANamespace fields are updated here for the lazy aggregator test scenario. It's crucial to verify that these mock values are appropriately set up for integration testing, reflecting the new JSON-RPC DA client's requirements.
  • 651-652: In the createNode function, the DAAddress and DANamespace fields are updated, which is consistent with the changes across the test file. This function is pivotal for setting up nodes in various test scenarios, so it's essential to ensure that the mock values used here are correctly initialized and represent the intended JSON-RPC endpoints and namespaces.
node/full_client_test.go (7)
  • 72-73: The update of DAAddress and DANamespace to MockDAAddress and MockDANamespace respectively in the getRPC function aligns with the PR's objective to shift towards JSON-RPC for DA interactions. This change ensures that the tests are configured to use the new mock addresses and namespaces for data availability, reflecting the transition from gRPC to JSON-RPC.
  • 175-175: The same update in the TestGenesisChunked function ensures consistency across test configurations, aligning with the new JSON-RPC based approach for data availability.
  • 547-548: The updates in the TestTx function to use MockDAAddress and MockDANamespace are consistent with the overall shift towards JSON-RPC for DA interactions. This change is crucial for ensuring that the tests reflect the new method of interaction with the data availability layer.
  • 806-807: In the TestMempool2Nodes function, updating the DA configurations to use mock values is appropriate for testing the functionality in a controlled environment. This change is part of the broader update to accommodate the new JSON-RPC DA client.
  • 818-819: Similarly, the update in the TestMempool2Nodes function for the second node's configuration ensures that both nodes in the test are aligned with the new data availability interaction method. This consistency is key for accurate and relevant testing.
  • 881-882: The update in the TestStatus function to use MockDAAddress and MockDANamespace ensures that the status checks and related functionalities are tested against the new JSON-RPC based DA client. This change is aligned with the PR's objectives and ensures that the tests are relevant to the new implementation.
  • 1017-1018: Finally, the update in the TestFutureGenesisTime function to use MockDAAddress and MockDANamespace is consistent with the shift towards JSON-RPC for DA interactions. This ensures that the tests accurately reflect the new method of interaction with the data availability layer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 b94d4d4 and e1eae33.
Files selected for processing (2)
  • cmd/rollkit/docs/rollkit_start.md (1 hunks)
  • da/da_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • da/da_test.go
Additional comments: 3
cmd/rollkit/docs/rollkit_start.md (3)
  • 33-34: The addition of the --rollkit.da_auth_token string flag is clearly documented, enhancing the user's ability to provide a DA auth token when starting Rollkit. This is a valuable addition for users needing to authenticate with a data availability layer.
  • 30-37: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [9-9]

Consider clarifying the description for --p2p.laddr string to ensure it's understood that this is the address the node listens on. For example, "node listen address" could be expanded to "node listen address (specify the IP and port for the node to listen on for incoming connections)."

  • 30-37: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [50-50]

For the --log_level string option, consider using a hyphen in "set the log-level" to clarify that "log-level" is a compound adjective modifying "default."

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 e1eae33 and 039149c.
Files selected for processing (2)
  • da/da.md (2 hunks)
  • da/mock/cmd/main.go (1 hunks)
Additional comments: 7
da/mock/cmd/main.go (4)
  • 4-11: Unused imports such as net and syscall have been correctly removed, aligning with the PR's objectives to clean up dependencies. However, ensure that the removal of syscall does not impact the handling of interrupt signals for graceful shutdown.
  • 13-13: The transition to proxy-jsonrpc from proxy (previously likely proxy-grpc) is a key change that aligns with the PR's objective of moving from gRPC to JSON-RPC. This change is correctly implemented.
  • 27-29: Parsing the address using url.Parse and extracting the host and port is a good practice for flexibility. However, ensure that the default address (MockDAAddress) is correctly updated to a JSON-RPC endpoint if necessary, as mentioned in a previous comment.
  • 38-42: Handling interrupt signals for graceful shutdown is correctly implemented. This addresses the previous comment by tzdybal regarding gentle shutdown of the proxy server.
da/da.md (3)
  • 7-11: The documentation correctly highlights the DAClient's ability to connect via both gRPC and JSON-RPC transports. This is a significant update that aligns with the PR's objectives. Ensure that the example URLs and flags are consistent with the actual implementation and default values in the code.
  • 4-14: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [13-24]

The explanation of the SubmitBlocks and RetrieveBlocks methods is clear and informative. However, consider adding a note about the transition from gRPC to JSON-RPC and its impact on these methods, if any, to provide readers with a complete understanding of the changes.

Consider adding a section or note about the transition from gRPC to JSON-RPC and its impact on the SubmitBlocks and RetrieveBlocks methods for completeness.

  • 36-44: The references section is correctly updated to include both proxy-grpc and proxy-jsonrpc, reflecting the dual support for gRPC and JSON-RPC transports. Ensure that the URLs provided are accurate and lead to the correct resources.

Comment thread da/mock/cmd/main.go
Comment thread da/mock/cmd/main.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 039149c and d7405cc.
Files selected for processing (6)
  • block/manager_test.go (1 hunks)
  • da/da.go (4 hunks)
  • da/da_test.go (5 hunks)
  • node/full.go (3 hunks)
  • node/full_node_test.go (2 hunks)
  • node/helpers_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • node/full.go
  • node/full_node_test.go
  • node/helpers_test.go
Additional comments: 11
da/da.go (5)
  • 20-24: The renaming and restructuring of timeout constants to defaultSubmitTimeout and defaultRetrieveTimeout improve clarity and maintainability by providing default values for timeouts in a centralized location.
  • 98-105: The addition of SubmitTimeout and RetrieveTimeout fields to the DAClient struct allows for customizable timeouts for submitting and retrieving blocks, enhancing flexibility and adaptability to different network conditions.
  • 107-117: The NewDAClient function provides a clear and concise way to initialize a DAClient with default timeout values, ensuring that all necessary fields are properly set. This approach enhances code readability and maintainability.
  • 151-151: Using context.WithTimeout in SubmitBlocks method ensures that the block submission process respects the specified timeout, preventing potential hangs in network communication. This is a good practice for handling external calls with unpredictable response times.
  • 218-218: Similarly, the use of context.WithTimeout in RetrieveBlocks method is commendable for ensuring that block retrieval operations are bounded by the specified timeout, enhancing the robustness of the data retrieval process.
da/da_test.go (5)
  • 21-22: Renaming the proxy package to proxy-grpc and proxy-jsonrpc and adjusting imports accordingly improves clarity and better reflects the underlying protocol used by each proxy implementation. This change enhances code readability and maintainability.
  • 114-124: The startMockDAServGRPC function demonstrates a good practice by creating a new gRPC server with the appropriate credentials and serving it asynchronously. This setup is essential for testing gRPC-related functionality in isolation.
  • 127-133: The startMockDAClientGRPC function correctly initializes a gRPC client and connects it to the mock server, ensuring that the client is ready for testing. The use of grpc.WithTransportCredentials for secure communication is a good practice.
  • 136-142: The startMockDAServJSONRPC function effectively starts a mock JSON-RPC server, showcasing a straightforward approach to testing JSON-RPC server functionality. The use of context.TODO() here is acceptable given the test context, but it's generally good to use more specific contexts.
  • 146-151: The startMockDAClientJSONRPC function demonstrates a clear and concise way to initialize a JSON-RPC client for testing purposes. The separation of client initialization into its own function enhances test code organization and reusability.
block/manager_test.go (1)
  • 32-32: The modification in the getManager function to use da.NewDAClient for initializing dalc with specific parameters enhances code clarity and ensures that the DAClient is correctly configured for testing. This change improves the test setup process by making it more explicit and maintainable.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d7405cc and 6c43946.
Files selected for processing (1)
  • da/da_test.go (5 hunks)
Additional comments: 7
da/da_test.go (7)
  • 21-22: Renaming the proxy package to proxy-grpc and proxy-jsonrpc is a good practice for clarity and specificity. This change helps in distinguishing between the two different protocol implementations.
  • 28-37: The constants defined for mock DA addresses and namespace are well-structured and clearly named. However, ensure that the port numbers (7980 for gRPC and 7988 for JSONRPC) do not conflict with any commonly used ports or other services in your environment to avoid potential issues during testing.
  • 65-65: The instantiation of NewDAClient with negative timeout values (-1) in the test functions TestMockDAErrors is concerning. While this might be intentional to simulate certain conditions, using negative values for timeouts is unconventional and could lead to confusion or unintended behavior. If this is a deliberate choice for testing specific scenarios, consider adding a comment to clarify the rationale behind using negative values.

Also applies to: 83-83

  • 91-101: The setup for testing different DA clients (dummy, jsonrpc, grpc) is comprehensive and well-organized. This approach ensures that each client type is tested under the same conditions, enhancing the test coverage for the new JSONRPC functionality alongside the existing gRPC functionality. Good job on structuring these tests to cover multiple scenarios.
  • 145-151: The startMockDAServJSONRPC function demonstrates good practice by starting a mock JSONRPC server and handling potential startup errors. This approach ensures robustness and reliability in the test setup phase for JSONRPC-related tests.
  • 171-171: Setting a specific SubmitTimeout value (50 * time.Millisecond) in the doTestSubmitTimeout function is a good practice for testing timeout behavior. However, ensure that this value is representative of realistic scenarios and does not lead to flaky tests, especially in environments with variable network latency or processing power.
  • 220-220: The use of rand.Int63() % MockDABlockTime.Milliseconds() to introduce variability in block submission timing is an interesting approach to simulate real-world conditions. However, be cautious with the use of randomness in tests as it can introduce non-determinism and potentially make tests flaky. Consider if there's a more deterministic way to achieve the desired test coverage.

Comment thread da/da_test.go
Comment thread da/da_test.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6c43946 and 4db000e.
Files selected for processing (10)
  • cmd/rollkit/commands/run_node.go (5 hunks)
  • da/da_test.go (5 hunks)
  • da/mock/cmd/main.go (1 hunks)
  • node/full_client_test.go (7 hunks)
  • node/full_node_integration_test.go (3 hunks)
  • node/full_node_test.go (2 hunks)
  • node/helpers_test.go (1 hunks)
  • node/node_test.go (2 hunks)
  • rpc/json/helpers_test.go (2 hunks)
  • test/mocks/util.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • test/mocks/util.go
Files skipped from review as they are similar to previous changes (8)
  • cmd/rollkit/commands/run_node.go
  • da/mock/cmd/main.go
  • node/full_client_test.go
  • node/full_node_integration_test.go
  • node/full_node_test.go
  • node/helpers_test.go
  • node/node_test.go
  • rpc/json/helpers_test.go
Additional comments: 2
da/da_test.go (2)
  • 150-155: In the startMockDAClientJSONRPC function, handling the error from proxyjsonrpc.NewClient is done correctly. However, consider adding a comment explaining the choice of an empty string for the second parameter of NewClient, as it's not immediately clear what this represents (presumably, an authentication token or API key). This would improve code readability and maintainability.

Consider adding a comment to clarify the purpose of the empty string parameter in the proxyjsonrpc.NewClient call for future maintainability.

  • 215-215: Using rand.Int63() % MockDABlockTime.Milliseconds() to introduce variability in block submission timing is a clever way to simulate real-world conditions. However, using rand.Int63() without a seed can lead to predictable sequences of random numbers, which might not be desirable in tests where randomness is expected to introduce variability in test execution. Consider seeding the random number generator (e.g., with rand.Seed(time.Now().UnixNano())) at the beginning of the test or test suite to ensure more unpredictable sequences.

Consider seeding the random number generator at the beginning of the test suite to ensure unpredictable sequences of random numbers.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between bb27d27 and bb1b4ed.
Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum
Files selected for processing (17)
  • block/manager_test.go (1 hunks)
  • cmd/rollkit/commands/run_node.go (5 hunks)
  • cmd/rollkit/docs/rollkit_start.md (1 hunks)
  • config/config.go (4 hunks)
  • config/defaults.go (1 hunks)
  • da/da.go (4 hunks)
  • da/da.md (2 hunks)
  • da/da_test.go (5 hunks)
  • da/mock/cmd/main.go (1 hunks)
  • node/full.go (3 hunks)
  • node/full_client_test.go (7 hunks)
  • node/full_node_integration_test.go (3 hunks)
  • node/full_node_test.go (2 hunks)
  • node/helpers_test.go (1 hunks)
  • node/node_test.go (2 hunks)
  • rpc/json/helpers_test.go (2 hunks)
  • test/mocks/util.go (1 hunks)
Files skipped from review as they are similar to previous changes (14)
  • block/manager_test.go
  • cmd/rollkit/commands/run_node.go
  • config/config.go
  • config/defaults.go
  • da/da.go
  • da/mock/cmd/main.go
  • node/full.go
  • node/full_client_test.go
  • node/full_node_integration_test.go
  • node/full_node_test.go
  • node/helpers_test.go
  • node/node_test.go
  • rpc/json/helpers_test.go
  • test/mocks/util.go
Additional comments: 4
da/da.md (2)
  • 7-11: The documentation clearly explains the new configuration options for connecting to the DA service using either gRPC or JSON-RPC. This addition enhances the flexibility of the DAClient.
  • 36-44: References to the proxy-grpc and proxy-jsonrpc implementations are correctly linked, providing useful resources for further exploration. It's good practice to ensure these links remain up-to-date.
Verification successful

The links to proxy-grpc and proxy-jsonrpc implementations are valid and lead to the correct resources, as confirmed by the HTTP/2 200 responses. This ensures that the references are correctly linked, providing useful resources for further exploration.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the links to proxy-grpc and proxy-jsonrpc are valid and lead to the correct resources.
curl --head https://github.com/rollkit/go-da/tree/tux/jsonrpc/proxy-grpc
curl --head https://github.com/rollkit/go-da/tree/tux/jsonrpc/proxy-jsonrpc

Length of output: 9044

cmd/rollkit/docs/rollkit_start.md (1)
  • 33-34: The addition of the --rollkit.da_auth_token string flag is well-documented, providing clear instructions for users on how to supply the DA auth token when starting Rollkit. This enhances the security and flexibility of DA connections.
da/da_test.go (1)
  • 21-22: Renaming the proxy package to proxy-grpc and proxy-jsonrpc is a good practice for clarity and specificity. This change makes it easier to distinguish between the two implementations.

Comment thread da/da_test.go
Comment thread da/da_test.go
Comment thread da/da_test.go
Comment thread da/da_test.go

@tzdybal tzdybal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, except using grpc with 26650 (which seems like an error)

Comment thread cmd/rollkit/commands/run_node.go Outdated
Comment thread cmd/rollkit/docs/rollkit_start.md Outdated
Comment thread da/da.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e2f60bc and 51b6d7f.
Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum
Files selected for processing (16)
  • block/manager_test.go (1 hunks)
  • cmd/rollkit/commands/run_node.go (6 hunks)
  • cmd/rollkit/docs/rollkit_start.md (1 hunks)
  • config/config.go (4 hunks)
  • config/defaults.go (1 hunks)
  • da/da.go (4 hunks)
  • da/da.md (2 hunks)
  • da/da_test.go (5 hunks)
  • da/mock/cmd/main.go (1 hunks)
  • node/full.go (3 hunks)
  • node/full_client_test.go (7 hunks)
  • node/full_node_integration_test.go (3 hunks)
  • node/full_node_test.go (2 hunks)
  • node/helpers_test.go (1 hunks)
  • node/node_test.go (4 hunks)
  • rpc/json/helpers_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (13)
  • block/manager_test.go
  • cmd/rollkit/commands/run_node.go
  • config/config.go
  • config/defaults.go
  • da/da.go
  • da/mock/cmd/main.go
  • node/full.go
  • node/full_client_test.go
  • node/full_node_integration_test.go
  • node/full_node_test.go
  • node/helpers_test.go
  • node/node_test.go
  • rpc/json/helpers_test.go
Additional comments: 4
da/da.md (2)
  • 7-11: The configuration options are clearly outlined, but it's important to ensure that the default value for --rollkit.da_address is consistent with the actual implementation. Given the previous comments about a potential proto/port mismatch and the suggestion to use Celestia node's endpoint as default, please verify that the default value and the protocol (grpc://) are correctly set and match the implementation.
  • 43-44: The documentation provides a helpful overview of the DAClient's capabilities and configuration. However, it would be beneficial to include examples or more detailed explanations of how to use the DAClient with both gRPC and JSON-RPC transports, especially for users unfamiliar with these protocols.
cmd/rollkit/docs/rollkit_start.md (1)
  • 33-34: The addition of the --rollkit.da_auth_token flag is clearly documented. It's important to ensure that the documentation also mentions any requirements or constraints related to the DA auth token, such as format or length, to assist users in correctly configuring Rollkit.
da/da_test.go (1)
  • 161-166: The startMockDAClientJSONRPC function correctly handles errors from proxyjsonrpc.NewClient. This is a good practice, ensuring that the test setup is robust and can gracefully handle initialization failures.

Comment thread da/da_test.go
Comment thread da/da_test.go
Comment thread da/da_test.go
gupadhyaya
gupadhyaya previously approved these changes Mar 18, 2024
@gupadhyaya
gupadhyaya enabled auto-merge March 18, 2024 15:40
Comment thread cmd/rollkit/commands/run_node.go Outdated
Comment thread da/da.md Outdated
Comment thread node/node_test.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 51b6d7f and 49fcd5e.
Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum
Files selected for processing (1)
  • da/da.md (2 hunks)
Additional comments: 4
da/da.md (4)
  • 7-11: The configuration options introduced for the DAClient are clear and well-documented. However, it's important to ensure that the default value for --rollkit.da_address is aligned with the project's standards and the feedback from previous comments regarding the use of a more appropriate default endpoint.
  • 9-9: Based on previous comments, there was a suggestion to use Celestia node's endpoint as the default for --rollkit.da_address. It's crucial to verify if this change has been implemented to ensure consistency and alignment with project standards.
Verification successful

The verification process confirms that the Celestia node's endpoint, "grpc://localhost:26650", has been set as the default for --rollkit.da_address in the da/da.md file. This aligns with the expectations set in the review comment, ensuring consistency and alignment with project standards.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check for the presence of Celestia node's endpoint as the default DA address.
grep "grpc://localhost:26650" da/da.md

Length of output: 130

* 4-14: > 📝 **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [13-24]

The descriptions of SubmitBlocks and RetrieveBlocks methods are detailed and informative. However, it would be beneficial to include examples or code snippets to illustrate how these methods are used in practice. This addition would enhance the documentation's usefulness to developers and improve clarity.

Consider adding example usage code snippets for SubmitBlocks and RetrieveBlocks to provide practical guidance to developers.

  • 33-44: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [28-44]

The references section is well-organized, providing easy access to related resources. However, ensure that all links are functional and lead to the intended destinations. Broken links can significantly hinder the usefulness of documentation.

Verification successful

The verification process confirms that all links in the references section are functional, leading to the intended destinations as indicated by the HTTP status code 200 for each link.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the functionality of links in the references section.
curl -o /dev/null --silent --head --write-out '%{http_code}\n' https://github.com/rollkit/go-da
curl -o /dev/null --silent --head --write-out '%{http_code}\n' https://github.com/rollkit/celestia-da
curl -o /dev/null --silent --head --write-out '%{http_code}\n' https://github.com/rollkit/go-da/tree/main/proxy/grpc
curl -o /dev/null --silent --head --write-out '%{http_code}\n' https://github.com/rollkit/go-da/tree/main/proxy/jsonrpc

Length of output: 458

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 49fcd5e and b489ea9.
Files selected for processing (1)
  • cmd/rollkit/commands/run_node.go (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • cmd/rollkit/commands/run_node.go

@gupadhyaya
gupadhyaya added this pull request to the merge queue Mar 18, 2024
Merged via the queue into main with commit 1a6b03d Mar 18, 2024
@gupadhyaya
gupadhyaya deleted the tux/jsonrpc branch March 18, 2024 16:36
@tac0turtle tac0turtle removed this from Evolve Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants