Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Binary / gRPC server #7

Merged
merged 19 commits into from
Oct 30, 2023
Merged

Binary / gRPC server #7

merged 19 commits into from
Oct 30, 2023

Conversation

tzdybal
Copy link
Member

@tzdybal tzdybal commented Oct 16, 2023

Overview

  • execution of DA test suite from go-da, using local-celestia-devnet
  • binary that expose DA interface via gRPC

Resolves #5.
Resolves #9.

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

Refactor:

  • Simplified the CI/CD process by removing the proto job from the release workflow and eliminating Dockerfile and protobuf linting jobs.
  • Updated the CelestiaDA struct and related functions in celestia.go for improved data handling.

New Features:

  • Introduced a new Go package that implements a gRPC server for the Celestia DA layer in cmd/celestia-da/main.go.

Tests:

  • Enhanced the celestia_test package with new imports, test functions, and a test suite struct for more comprehensive testing.

Style:

  • Adjusted linter settings in .golangci.yml and .markdownlint.yaml for more specific code and markdown linting.

Documentation:

  • Updated references in the Celestia DA documentation (specs/src/celestia-da.md) to reflect the new API documentation location.

@codecov
Copy link

codecov bot commented Oct 20, 2023

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

@tzdybal tzdybal marked this pull request as ready for review October 20, 2023 08:10
@tzdybal
Copy link
Member Author

tzdybal commented Oct 20, 2023

I added auto-merge with merge instead of squash, as this PR contains many little fixes, and commit history is detailed.

@Manav-Aggarwal Manav-Aggarwal added the enhancement New feature or request label Oct 24, 2023
Copy link
Member

@Manav-Aggarwal Manav-Aggarwal left a comment

Choose a reason for hiding this comment

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

Looks good! Left some minor comments/questions.

celestia.go Show resolved Hide resolved
celestia.go Outdated Show resolved Hide resolved
celestia.go Outdated Show resolved Hide resolved
celestia.go Show resolved Hide resolved
celestia.go Show resolved Hide resolved
celestia.go Outdated Show resolved Hide resolved
celestia.go Outdated Show resolved Hide resolved
tuxcanfly
tuxcanfly previously approved these changes Oct 24, 2023
celestia.go Show resolved Hide resolved
celestia.go Outdated Show resolved Hide resolved
Manav-Aggarwal
Manav-Aggarwal previously approved these changes Oct 25, 2023
nashqueue
nashqueue previously approved these changes Oct 30, 2023
Copy link
Member

@nashqueue nashqueue left a comment

Choose a reason for hiding this comment

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

utAck , some conflicts in go.mod

@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2023

Walkthrough

The changes primarily focus on streamlining the CI/CD process by modifying the workflow and linter configurations, and updating the Celestia DA layer's implementation and its corresponding tests. The changes also include updates to the documentation references.

Changes

File(s) Summary
.github/workflows/ci_release.yml,
.github/workflows/lint.yml
Removed certain jobs from the workflows, indicating a shift in the CI/CD process.
.golangci.yml,
.markdownlint.yaml
Updated linter configurations to refine the code quality checks.
celestia.go,
cmd/celestia-da/main.go
Implemented changes in the Celestia DA layer and added a new gRPC server package.
celestia_test.go Added new tests and a test suite for the Celestia DA layer.
specs/src/celestia-da.md Updated documentation references to reflect the new location.

Poem

🍂 As the autumn leaves fall, so do old ways, 🍁

In the world of code, it's a brand new day! 🌞

Linting rules refined, workflows streamlined, 🚀

Celestia DA layer, redefined! 🔄

Tests are running, servers humming, 🖥️

With every change, progress is coming! 📈

So here's to the devs, in their coding den, 🐇

Making magic with their keyboard and pen! 🎩✨

As Halloween 🎃 nears, no need for fears,

For every bug 🐞, a solution appears!


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

Copy link
Member

@nashqueue nashqueue left a comment

Choose a reason for hiding this comment

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

Thank you !

@tzdybal tzdybal merged commit 14907fd into main Oct 30, 2023
7 checks passed
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: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8da293c and 59f76e2.
Files ignored due to filter (2)
  • go.mod
  • go.sum
Files selected for processing (8)
  • .github/workflows/ci_release.yml (1 hunks)
  • .github/workflows/lint.yml (2 hunks)
  • .golangci.yml (1 hunks)
  • .markdownlint.yaml (1 hunks)
  • celestia.go (3 hunks)
  • celestia_test.go (1 hunks)
  • cmd/celestia-da/main.go (1 hunks)
  • specs/src/celestia-da.md (2 hunks)
Files skipped from review due to trivial changes (5)
  • .github/workflows/ci_release.yml
  • .github/workflows/lint.yml
  • .golangci.yml
  • .markdownlint.yaml
  • specs/src/celestia-da.md
Additional comments: 21
celestia_test.go (6)
  • 1-23: The import section looks fine. All the imported packages are being used in the code.

  • 25-32: The TestSuite struct is well defined with necessary fields for the test suite.

  • 86-90: The TearDownSuite function is correctly purging the Docker resource and handling errors.

  • 92-94: The TestIntegrationTestSuite function is correctly running the test suite.

  • 96-105: The TestCelestiaDA function is correctly setting up the RPC client, initializing the blob namespace, and running the DA test suite. It also handles errors and context timeouts properly.

  • 107-109: The getRPCAddress function is correctly returning the RPC address.

cmd/celestia-da/main.go (3)
  • 21-59: The main function is well-structured and uses the cobra library for command-line flag handling. However, the TODO comments indicate that there are plans to extract the configuration and main command from the main function and read the configuration from a file. This would be a good improvement for maintainability and flexibility.

  • 61-90: The serve function sets up the Celestia DA instance and the gRPC server, and serves it on a network listener. It handles errors appropriately by logging them and terminating the program when necessary. However, the TODO comment on line 78 indicates that there are plans to add configuration options for encryption. This is a crucial aspect for security and should be implemented as soon as possible.

  • 81-81: The network listener is set up to listen on a random port because the port is not specified in the net.Listen function. If a specific port is required, it should be specified here.

- lis, err := net.Listen("tcp", "")
+ lis, err := net.Listen("tcp", ":8080") // replace 8080 with the desired port
celestia.go (12)
  • 2-16: The import section looks clean and organized. All the necessary packages are imported for the implementation of the CelestiaDA struct and its methods.

  • 18-23: The CelestiaDA struct has been updated to remove the height field. This is in line with the changes mentioned in the summary.

  • 25-32: The NewCelestiaDA function has been updated to remove the height parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 34-42: The Get function now takes a list of da.ID instead of []byte. This change is in line with the summary. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 48-62: The GetIDs function now takes the height parameter. This change is in line with the summary. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 64-68: The Commit function now returns []da.Commitment instead of []byte. This change is in line with the summary. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 70-96: The Submit function now returns []da.ID and []da.Proof instead of []byte. This change is in line with the summary. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 98-116: The blobsAndCommitments function is well implemented and handles the conversion of []da.Blob to []*blob.Blob and generates corresponding []da.Commitment.

  • 128-160: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [118-139]

The Validate function now takes []da.ID and []da.Proof instead of [][]byte. This change is in line with the summary. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 146-151: The makeID function has been added. It combines height and commitment into a single da.ID.

  • 153-158: The splitID function has been added. It splits a da.ID into height and commitment.

  • 160-160: The CelestiaDA struct is confirmed to implement the da.DA interface. This is a good practice to ensure that the struct meets the interface requirements.

Comment on lines +34 to +84
func (t *TestSuite) SetupSuite() {
pool, err := dockertest.NewPool("")
if err != nil {
t.Failf("Could not construct docker pool", "error: %v\n", err)
}
t.pool = pool

// uses pool to try to connect to Docker
err = pool.Client.Ping()
if err != nil {
t.Failf("Could not connect to Docker", "error: %v\n", err)
}

// pulls an image, creates a container based on it and runs it
resource, err := pool.Run("ghcr.io/rollkit/local-celestia-devnet", "4ecd750", []string{})
if err != nil {
t.Failf("Could not start resource", "error: %v\n", err)
}
t.resource = resource

// exponential backoff-retry, because the application in the container might not be ready to accept connections yet
pool.MaxWait = 60 * time.Second
if err := pool.Retry(func() error {
resp, err := http.Get(fmt.Sprintf("http://localhost:%s/balance", resource.GetPort("26659/tcp")))
if err != nil {
return err
}
bz, err := io.ReadAll(resp.Body)
_ = resp.Body.Close()
if err != nil {
return err
}
if strings.Contains(string(bz), "error") {
return errors.New(string(bz))
}
return nil
}); err != nil {
log.Fatalf("Could not start local-celestia-devnet: %s", err)
}

opts := dockertest.ExecOptions{}
buf := new(bytes.Buffer)
opts.StdOut = buf
opts.StdErr = buf
_, err = resource.Exec([]string{"/bin/celestia", "bridge", "auth", "admin", "--node.store", "/home/celestia/bridge"}, opts)
if err != nil {
t.Failf("Could not execute command", "error: %v\n", err)
}

t.token = buf.String()
}
Copy link

Choose a reason for hiding this comment

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

The SetupSuite function is setting up the Docker pool and resource correctly. It also handles errors properly. However, it's recommended to use t.Fatalf instead of t.Failf followed by log.Fatalf to fail the test immediately when an error occurs.


da := celestia.NewCelestiaDA(client, namespace, ctx)
// TODO(tzdybal): add configuration options for encryption
srv := proxy.NewServer(da, grpc.Creds(insecure.NewCredentials()))
Copy link

Choose a reason for hiding this comment

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

The gRPC server is set up with insecure credentials. This is a security risk and should be replaced with secure credentials as soon as possible.

- srv := proxy.NewServer(da, grpc.Creds(insecure.NewCredentials()))
+ // replace with secure credentials
+ creds, _ := credentials.NewServerTLSFromFile("cert.pem", "key.pem")
+ srv := proxy.NewServer(da, grpc.Creds(creds))

Commitable suggestion (Beta)
Suggested change
srv := proxy.NewServer(da, grpc.Creds(insecure.NewCredentials()))
// replace with secure credentials
creds, _ := credentials.NewServerTLSFromFile("cert.pem", "key.pem")
srv := proxy.NewServer(da, grpc.Creds(creds))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Expose gRPC server [Feature Request]: Add Tests to CelestiaDA Implemenation
4 participants