A story about abstraction: looking for better CKB development tools.

Time:2020-10-25

Three years ago, we embarked on a journey full of legends and adventures. We started to build a new blockchain platform, a blockchain platform that we, as developers, like very much and hope to rely on for a long time. On this basis, we began to elaborate the foundation of nervos CKB:

  • Security:Can people rest assured that CKB will protect people’s assets?
  • Stability:Will people still be able to use CKB steadily in the coming decades?
  • Performance:Can people believe that CKB can provide the best performance under the premise of meeting the first two objectives?

We have worked very hard to solve all these problems, and we firmly believe that nervos CKB has provided sufficient answers to these problems. However, this puzzle is still not fully solved. In order to make CKB better, there is still a very important link

👇👇👇

Developer experience

Unlike other solutions, you may notice that the developer experience is not something we tried to solve in the first place. That doesn’t mean we don’t care about the developer experience. On the contrary, we believe that developers are the most fundamental and critical part of the entire nervos ecosystem. The contradiction here comes from our understanding ofSoftware abstractionFaith.We believe that the core part of nervos CKB should give priority to security, stability and performance.

There are some aspects that can help improve the developer experience, but we don’t give it a priority because we think adding these extra features could hurt the three foundations we mentioned above. To make up for this lack of functionality, we are adding more nervos CKB development stories by building additional layers and tools. This has been a major concern of the nervos team since the nervos CKB main line last November.

In the computer industry, we are not the only ones to take this path. Take our favorite CPU as an example. Modern CPUs only run complex assembly code. We haven’t heard anyone say that they are eager for a CPU that can run rust or JavaScript. Instead, we build compilers and virtual machines that convert more advanced languages into well tuned assembly code that runs on our CPU. It is with this software abstraction that we have the opportunity to build a complete computer-aided world. We envisage that the future blockchain infrastructure will use exactly the same architecture:The core layer focuses on the foundation, while the surrounding circle layer provides assistance for developers.

We salute all the developers who tried CKB immediately after it was launched, although only a few early tools were available. These pioneers have made great efforts to build demo and Application on the basis of nervos CKB, showing the unique power of nervos CKB to the world.We are also humbled and ashamed that we have not equipped these knights with proper armor and weapons. Therefore, it is a great honor and honor to introduce some of the latest work of nervos team for all developers

We have launched three new tools, capsule, Lumos and Polyjuice, to provide the greatest empowerment for developers on CKB to help them build better dapps on nervos CKB.

  • Capsule:
    https://github.com/nervosnetw…
  • Lumos:
    https://github.com/nervosnetw…
  • Polyjuice:
    https://github.com/nervosnetw…

Capsule

A story about abstraction: looking for better CKB development tools.

The first step in our journey starts with smart contracts, which are scripts in CKB terms. If you have been following our progress, you will know that most of the scripts on CKB are written in normal C language. It’s not because we think C is a smart contract language for everyone, but just because we’re still trying to catch up with the tools. In the early days, when we needed a way to build scripts, C was the only practical solution for us. We are very careful when writing C code, even though we are the creator of the platform. But we limit the use of external libraries and new features. You can see that in the scripts we’re using right now, they’re just emulating C programs for embedded devices.

But we understand that this is not an ideal solution for many people, and if we preach using C to build scripts, we may never win the trust of smart contract developers. The construction of modern advanced intelligent contract is very complex, not to mention the burden of C language. We hope to provide developers with all the most advanced language features and tools to help with the development of CKB scripts.

To solve this problem, we created capsule.The core of capsule is to provide a solution to build CKB scripts using the rust programming language.Rust is a language designed to enable everyone to build reliable and efficient software. Proven type systems and ownership models, healthy communities that invent new things every day, and the widespread use of the blockchain industry make rust the perfect universal language for building scripts on CKB. Capsule combines with the rust tool to provide a seamless experience for nervos CKB to build rust based scripts.

In terms of language,Capsule also provides abstraction (in the form of a rust Library) to help build CKB scripts.The core CKB only provides syscalls that are absolutely necessary to communicate with CKB, which means it can be a little cumbersome to use. In addition, capsule also provides abstraction to simplify communication with CKB blockchain. Here is an example, although file in rust(https://doc.rust-lang.org/std…It’s fun to use, but the correct invocation of the underlying Linux system can be quite complex. In our view, this is another example of the power of abstraction.

Capsule doesn’t stop there. It’s aimed atManage the entire lifecycle of CKB scripts to help you develop, build, test, debug, and deploy scripts.As its name suggests,Capsule encapsulates a very large universe in a tiny shell。 We do envision a world, and in this world,Capsule is everything a script needs from zero to run successfully on the CKB main network.

Lumos

A story about abstraction: looking for better CKB development tools.

Smart contracts are only part of the challenge. For some reasons, such as QoS requirements or in order to better cope with different use cases, we usually need to build a back-end service on the blockchain, which is responsible for processing the user’s request. Nervos CKB is no exception. In fact, because of our abstract design concept, CKB needs the upper layer more than most other blockchains. With this upper layer, developers can build perfect dapps more quickly and easily.

Lumos was born out of this demand.Lumos based on CKB provides a framework based on JavaScript / typescript, which can greatly speed up the development of DAPP。 The name Lumos also reveals the significance of this project:

Although CKB’s Wonderland is vast and fertile, most of the area is still dark. Lumos is flashing, trying to illuminate the land and guide more and more people into this beautiful new world.

In the initial release, Lumos included the following components:

  • A high performance cell indexer that collects chunks from CKB nodes and indexes them, then provides an optimal way to request access to the cell.
  • A transaction manager that processes all pending transactions and makes the output cell available before the transaction is confirmed, which avoids the problem of accepting the previous transaction on the chain before creating the next transaction.
  • A unified configuration manager handles the connection details between the framework and different chains, such as mainnet, testnet, DEVNET, etc. It can also track scripts deployed on the chain to simplify transaction building.
  • A unified workflow for building transactions with many different interaction scripts. We believe that this newly designed workflow can perfectly capture the different needs of dappp developers and script developers. Please refer to the document website for detailed workflow.
  • Built in support of all common scripts currently available.

This is just a quick look at all the possibilities of Lumos. The initial version provides the basis for the build, but is by no means complete. We invite you to join our development community, try Lumos (and capsule) and tell us about your experience. Only with feedback and criticism can we really build abstractions and tools that meet the needs of the nervos CKB world.

Polyjuice

Nervos CKB is based on cell model, which is a general version of utxo model. There seems to be a view in the blockchain community that it is difficult for people to program on the utxo model, while the account model is relatively easy for developers. Although cell model is the evolution of utxo model, it is possible to build an account model on top of cell model. The secret here is still abstraction. At a lower level, utxo style design can help achieve parallelism, while at a higher level, the abstraction layer can be presented as an account model for ordinary developers.

As engineers, we all know a famous saying:Talk is cheap, Show me the code。 Following this principle, we designed and built Polyjuice,This is an Ethereum compatible layer on top of nervos CKB。 Until today, Ethereum is probably the most commonly used and flexible account model-based blockchain.With Polyjuice, we want to show that it is possible to use the account model on nervos CKB.The flexibility here can actually bring countless opportunities.

To make things more interesting, we didn’t build an account layer just tailored for Ethereum, we extracted the core account layer from Polyjuice( https://github.com/nervosnetw… 。 With this universal library, you are free to integrate any account layer you want to integrate. One exciting future we’d like to witness is Libra( https://libra.org/en-US/ )The precise programming model of CKB may also be transplanted to CKB to achieve a very prosperous ecosystem.

New documentation

As all of these exciting projects emerge, our old documentation site( https://docs.nervos.org/ )It has gradually shown the vicissitudes of time. So we also renovated the document website:

👇👇👇

http://docs-new.nervos.org

The new site is divided into several sections designed to help you quickly find what you need:

  • Basics:This is a starting point. If you just want to know about CKB, it will guide you to download and run CKB, how to connect to mainnet or testnet, how to create a new development chain, and how to mine for development. It will also show you how to interact with CKB through a variety of tools, such as CKB cli.
  • reference resources:For developers, this might serve as a dictionary. Want to know how a script works? We will have a reference document. Want to know what components are available in a cell? We got it for you! Want to know the whole transaction verification process? You’re in the right place! We will make sure that this reference document covers all the details you want to know about CKB.
  • laboratory:Relying on reference documents alone does not provide much help. Sometimes, you want to start playing. In this section, we’ll give you detailed steps to show you how to build something with CKB. Whether you want to build a new CKB script or write a DAPP that interacts with CKB, we have a variety of practical labs to cover these operations.
  • Integration:External wallets or exchanges often face unique and different challenges when integrating CKB into their systems. This section provides guidelines and tips for integrating CKB into existing services such as wallets or exchanges.
  • article:Before that, our developers have been writing different articles about CKB. Here, we also provide a space for developers to write articles. Whether it’s about debugging CKB scripts, serialization formats, or even RPC best practices, we hope that this can be a place where you can freely share your opinions.

Finally, we hope that this new documentation site will answer all your questions about nervos CKB.

future

We believe that CKB has the potential to develop into a prosperous ecosystem. The project shown here is just a microcosm of many new ideas and patterns supported by nervos CKB. We hope that these projects will improve your efficiency in building CKB dappp and inspire new directions that only nervos CKB can achieve. In other words, we have looked into the future, and some more promising projects are under construction

  • In the field of blockchain, people begin to use web assembly more and more( https://webassembly.org/ )。 Although we think risc-v is more suitable for nervos CKB, it doesn’t mean that we can’t provide first-class web assembly support. We are now building a project that can take any Wasi( https://wasi.dev/ )The supported web assembly programs are compiled into CKB scripts. In addition to new programming language support, such as assembly script( https://assemblyscript.org/ )We believe that this can also open up new potential, such as cross chain interoperability.
  • We have demonstrated the common language support on CKB above, but our journey is not over. In the depth of the CKB VM model, there are some potential that can only be revealed through custom-designed programming languages. In this spirit, we are also exploring the possibility of creating script development for special purpose languages on CKB. Once these attempts are ready, they will release more energy inspired by CKB’s unique design.
  • At present, the project is mainly released to meet the needs of back-end developers. There are many front-end or application developers who are also eager to join CKB’s Wonderland. We are also trying to provide Nocode(https://www.nocode.tech/)Tool, so that those who are curious can build a complete dappp experience on nervos CKB.

We believe that CKB has unlimited potential. In addition to the above, we are also trying more ideas and developing more tools on CKB. We sincerely hope to share with you in the future.