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

[EPIC] Celestia-Node API #944

Closed
30 tasks done
renaynay opened this issue Jul 25, 2022 · 3 comments
Closed
30 tasks done

[EPIC] Celestia-Node API #944

renaynay opened this issue Jul 25, 2022 · 3 comments
Assignees
Labels
architecture Architecture / design-related issues area:api Related to celestia-node API area:rpc

Comments

@renaynay
Copy link
Member

renaynay commented Jul 25, 2022

Context

This issue supersedes and encompasses #169, serving as the canonical tracking issue for work related to celestia-node API.

Current design

Simple HTTP server with endpoints accessing certain methods mounted on the servemux. See here.

Desired design

An RPC client that provides modules based on the services provided by the node.

Goals

  • eliminate need for go-cnc and DALC
  • automated documentation of methods

Issue breakdown

Related issues

@renaynay renaynay added area:rpc architecture Architecture / design-related issues area:api Related to celestia-node API labels Jul 25, 2022
@renaynay renaynay self-assigned this Jul 25, 2022
@Bidon15
Copy link
Member

Bidon15 commented Jul 26, 2022

Added #709 after grooming

@Wondertan
Copy link
Member

Ok, so the main reason I would like to use JSON/Open RPC is the ability to do the following. Imagine we have a simplified DA interface:

type DataAvailability interface {
  GetByNamespace(context.Context, namespace.ID, Root) ([][]byte, error)
  SubmitData(context.Context, namespace.ID, [][]byte) Root 
}

and its implementation:

// implements actual logic to read and write from node network
type availabilityService struct {}

// performs network ops to get the data
func (availability) GetByNamespace(context.Context, namespace.ID, Root) ([][]byte, error) 
// sends PFD
func (availability) SubmitData(context.Context, namespace.ID, [][]byte) (Root, error) 

With Open/JSONRPC tooling we are aware of, we can do this:

server := jsonrpc.NewServer(...)
server.Register(new(DataAvailability), &availabilityService{})
server.Serve()

This is almost all you need to do to set up your own RPC server. The tooling parses the given interface and automagically setups the endpoint for each existing method.

Similarly on the client side:

client := jsonrpc.NewClient(serverAddr, new(DataAvailability))

client.GetByNamespace() // does request to the remote server instance of DataAvailabiliy interface and returns the results

Simple, powerful, and composable.

With regular Rest APIs there is a lot of boilerplate code that you cannot avoid. GRPC is somewhat similar to RPC, but it generates interfaces for you, which I personally hate. Interfaces have to be handwritten with care and succinctness and cohesionin mind

@renaynay
Copy link
Member Author

🚀

@renaynay renaynay unpinned this issue Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture Architecture / design-related issues area:api Related to celestia-node API area:rpc
Projects
Archived in project
Development

No branches or pull requests

4 participants