ckb-js / topics

4 stars 1 forks source link

Proposal of kuai project #4

Closed Keith-CY closed 1 year ago

Keith-CY commented 1 year ago
felicityin commented 1 year ago

1 Background

Ethereum itself is a server, because it can not only change state, but also store state. Developers only need to implement client. In contrast to CKB, it can only store state. Moreover, the storage on CKB is expensive, so the data should be stored in off-chain as much as possible. In summary, developers need to implement an additional server on top of CKB to change and store state. While CKB uses the UTXO programming model, which is difficult to understand. In addition, developers need to know a lot of details about CKB in the process of implementing the server, such as Cell model. It caused a lot of inconvenience to developers. To make it easier to develop on CKB, Kuai will provide a javascript-based development framework to help developers create high-quality services more efficiently.

2 What is Kuai

Kuai is not a server, but a development framework.

Kuai will provide developers with a more friendly API for off-chain development. It helps developers change and store state in off-chain more conveniently, while only one proof of many state changes is stored in on-chain.

3 Component

Kuai includes kuai-runner, kuai-convention, kuai-runtime, and kuai-testing.

3.1 kuai-runner

At present, it is cumbersome to set up a CKB development environment locally, and developers need to know a lot of details, such as the configuration files of indexer and CKB.

kuai-runner will provide a one-click launch method to help developers to set up a development environment easily, such as:

3.2 kuai-convention(maybe kuai-protocol)

As a framework, Kuai should provide clear boundaries and development standards, and provide a list of best practice tips for developers to follow.

kuai-convention is a convention document for the implementation reference of kuai-runtime and the usage guide of kuai-runtime, such as:

3.3 kuai-runtime

kuai-runtime implements the interface defined by kuai-convention, shielding implementation details for developers and provides easy-to-use APIs.

kuai-runtime provides friendly libraries/modules for building, sending, and managing transactions.

Developers can build services quickly by kuai-runtime.

kuai-runtime drawio (2) (1)

The composition of kuai-runtime is as follows.

runtime-level drawio (2) (1)

3.4 kuai-testing

Testing is an important part of the software development process. And Kuai should provide modules that integrate with common testing frameworks on the market to help developers perform integration testing of the entire business process (dapp → service → CKB → assertion).

kuai-testing will provide a friendly integration testing environment, such as:

3.5 kuai-website

As an open source project, Kuai needs to provide good documentation and examples to attract and guide developers.

kuai-website provides friendly development documentation, such as:

4 Roadmap

yanguoyu commented 1 year ago

Code Run: call a method

Is it means to use a deployed contract? Like for cheque contract, send a cheque, claim, or withdraw?

Data storage Data manipulation

Is it means to get cell data from chain? And we can use data to deploy contracts, call contracts, or get information.

@Keith-CY

yanguoyu commented 1 year ago

kuai-convention

I thought of two ways for kuai-convention to provide for users. We shouldn't limit user development contracts in one way.

I prefer the second method, we can accumulate many useful plugins to improve development efficiency.

felicityin commented 1 year ago

I thought of two ways for kuai-convention to provide for users. We shouldn't limit user development contracts in one way.

You are right, but kuai-convention focuses on off-chain services, rather than on-chain contracts.

Keith-CY commented 1 year ago

Code Run: call a method

Is it means to use a deployed contract? Like for cheque contract, send a cheque, claim, or withdraw?

Yes, Run is used to call a method of the script/contract (Code model). We can use the simple command as the most underlying method to change the state of the Data model from which Code model extends. And derive a contract object with user-friendly APIs from Code model with ABI (TypeChain)

Data storage Data manipulation

Is it means to get cell data from chain? And we can use data to deploy contracts, call contracts, or get information.

@Keith-CY

Data storage and Data manipulation are mentioned in the Unified paradigm for development section, the main idea is to make base APIs uniform so all dapps following the paradigm could interact with each other smoothly.

Say DApp_A has Model A on the chain and it's derived from Code Model/Data Model, then the Model A's data are transparent to all and can be parsed and shown in every other DApp. Besides, if Model A's ABI is public, DApp_B could overlap its own business logic over DApp_A, just like extends ERC 20 Token

Once the rule is omnipresent, all DApps are connected to each other.

Back to question 2

Is it means to get cell data from chain? And we can use data to deploy contracts, call contracts, or get information.

Yes, data storage includes reading/writing data in a prescribed way, and data manipulation means updating data in a well-known way.

Keith-CY commented 1 year ago

The proposal has been drafted by https://github.com/ckb-js/topics/pull/5