hyperledger-labs / perun-node

State channel node of the blockchain-agnostic state channels framework Perun.
https://labs.hyperledger.org/perun-doc/
Apache License 2.0
18 stars 12 forks source link

Development status? #227

Open MatthiasLohr opened 3 years ago

MatthiasLohr commented 3 years ago

Hi,

what is the current status of this project? Is development still in progress? Any ETA, when app channels will be supported? I'm about to create an app using state channels and using an gRPC API instead of using directly the Go API would be highly desirable in my opinion.

Best regards Matthias

manoranjith commented 3 years ago

Hi @MatthiasLohr

Yes, it is still being actively developed. In the past couple of months, we were focusing on adding features to our core library (go-perun) used by perun-node. That is why you see less activity in this repository.

App channels are already supported by the core package (session). However, whether you want to use the App channels directly using our core library (go-perun) or using our node (perun-node) would depend on your use case.

  1. go-perun is the core library that implements the perun protocols and provides Go APIs for the core protocol operations of opening, transacting on and closing the state channels.
  2. perun-node can be used as library (Go API) or command line program (accessed via remote API like gRPC), which on top of the go-perun, provides a session for managing

    • all the channels of a user,
    • the keys (used for on-chain and off-chain transactions),
    • the off-chain identities of the entities the user wants to transact with.

    Additionaly it provides the option to create app specific APIs for convenience (in Go, gRPC or any other protocol of your choice).

Adding new channel apps

To add a new app,

  1. You will need a smart contract which implements a set of functions for that app.
  2. You will then have to add functions that define how to encode/decode the App data and how to validate an off-chain transaction for this app in the go-perun/apps.

An example for adding a simple tic tac toe app can be found in the go-samples repository.

Using the app with perun-node

As described above, perun-node provides a set of functionalities and the option to add convenience APIs specific to your App. Currently, there is no tutorial which describes how to add these APIs. But, you could use the payment API as an reference, because in perun-node payment API is also treated as an App.

  1. Implementing Go API: In perun-node/app package, you will have to create a new package for your app. In that, you will have to write thin wrappers which translate the generic state channel data into your app specific data and vice verse.

  2. Implementing gRPC API: This is just another abstraction, which makes the Go API accessible via gRPC or any other remote interface of your choice. For these, you need to add gRPC adapter for your Go API.

    To add gRPC wrappers,

    1. You will have to define the messages and services for your app in a .proto file. Eg: Proto file for payment API.
    2. You will have to then write a thin wrapper that maps the structs in your application to those defined in the generated code of proto buff.

    Now, you should be able to use the gRPC API.

    Note: You can also add these app specific packages in a separate repository and then use it from there.

  3. Examples for using the gRPC API: There are multiple examples, that showcase how to use the gRPC client stubs. The shortest one is in the payment_test. You can also find a more comprehensive example in the reference implementation for using client stubs: perunnodecli.

Feel free to ask if you have more questions !