header-langage
简体中文
繁體中文
English
Tiếng Việt
Scan to Download the APP
Partnered With:

What is Rust, and which well-known blockchain projects were developed with it?

Read this article in 31 Minutes
What do projects like Parity, Polkadot, Grin, Nervos and others have in common? They were all developed in the Rust language.

Rust is 4 years old today, why are more and more well-known projects using Rust?
Source: blockchain stronghold by Mike Tang


Four years ago today (15 May 2015), the Rust programming language core team officially announced the release of Rust 1.0.

Over the past four years, its elegant ability to solve high concurrency and high security system problems has become increasingly popular with developers. And for the fourth year in a row, he won first place in the Stack Overflow developer's "favorite programming language."


640?wx_fmt=png

Recently, more and more well-known blockchain projects have chosen Rust as their development language, including: Parity, Polkadot, Substrate, Grin, Ethereum classic, Holochain, cardano-rust, Exonum, Lighthouse, Nimiq, Nervos, conflux-rust, Codechain, Witnet and many other well-known projects.

This paper attempts to explore the reasons behind this trend. It also systematically explains the impact of Rust language on block chain development and its advantages.

Rust: a secure and concurrent software system

Rust is a system-level programming language designed to ensure memory and thread safety and prevent segment errors.

As a system-level programming language, its basic philosophy is "zero overhead abstraction." In theory, it's the same speed as C/C++. Rust can be categorized as a generic, multi-paradigm, compiled programming language similar to C/C++.

Unlike these two programming languages, Rust is thread-safe! Its goal is to create a secure and concurrent software system. Rust emphasizes security, concurrency, and memory control. Although Rust borrows C/C++ syntax, it eliminates null and dangling Pointers, which are at the root of system crashes, memory leaks, and insecure code in C/C++.

While Rust is a system-level programming language, that doesn't mean it has to write only the underlying programs (operating systems, drivers, tools, databases, search engines, etc.), its level of abstraction is absolutely amazing, and it's proven to be as good and easy to model as C++/Java/Python/Ruby.

But super-abstract languages like Haskell are not where Rust is headed either. Rust strives to find a balance between abstraction and the real world.

Now, for the fourth year in a row, Rust has won the no. 1 spot in StackOverflow's language of the year award.

The history of the Rust language

Rust was originally a personal project of Mozilla employee Graydon Hoare. It began in 2009 with support from Mozilla research and was announced in 2010.

Bootstrapping implemented between 2010 and 2011. Since then, Rust has undergone significant design changes and iterations (with great difficulty) before finally releasing version 1.0 on May 15, 2015.

In the course of this development, Rust has built a strong and vibrant community with a solid set of project contributions (which is the real scary part). Rust is now maintained by the Rust project developer community.

The following figure describes the Rust gene map:


640?wx_fmt=png

Rust is still a niche language

Rust has come a long way since 1.0 to date (May 2019). But overall, Rust isn't particularly widely used (it's too young, after all) compared to Python, C, C++, and so on.

According to the survey, a large part of the reason for the low usage of Rust is the small number of companies that have chosen Rust.


640?wx_fmt=png

However, Rust is becoming more and more of a work force. Over the past year, Rust has seen surprising growth in commercial applications. Including some well-known companies:

Amazon: build tool with Rust;

Facebook: source control tool;

Google: as part of the Fuchsia project;

Microsoft: use Rust partially in the new Azure iot framework;

Twitter: use Rust as part of building team support.

Domestic baidu, ali, has also been in the internal small scope of the use of Rust. I believe Rust will grow even faster as more companies choose Rust.

Gavin Wood brought Rust to the blockchain

The first to apply Rust to a well-known blockchain project was probably Gavin Wood. Dr. Gavin Wood left the Ethereum community in the second half of 2015 to start Parity Technologies and launch Parity, the Ethereum client, which successfully occupied half of the Ethereum community. The Parity client was written in Rust.


640?wx_fmt=png

The MaidSafe project was around even before Parity. MaidSafe tries a lot with the Rust language. The security emphasis of the Rust language itself, as well as frontier projects such as MaidSafe, may have given Gavin good reason to choose Rust as the parity development language.


640?wx_fmt=png

The language features of Rust itself (security, high performance, concurrent programming) and the features of blockchain (distributed, cryptographic, security-sensitive) inherently overlap considerably.

Not only that, Rust is different as a programming language, not because of how beautiful its syntax is (actually a little ugly for some) or how popular the community is, but because of the confidence gained when writing code with it.

It seems that Rust can affect the efficiency and expressiveness of your code, but, quite surprisingly, the opposite is true: it's much easier to write an efficient, customizable Rust program than it is to write a potentially dangerous one.

Here are the Linux kernel bugs found between January and April 2018:


640?wx_fmt=png

For Rust, the 51% portion of the figure on the right can be avoided at the language level. That said, for Rust, none of these issues exist on the right side of the figure.

At present, there are two views: "one only needs to know how to write C" and "one only needs to leave the bottom of the pile for the professionals", neither of which is enough. The Linux kernel is written by strong programmers, probably the top 5 percent of the industry, but still, CVE comes out year after year.

You might not think that 50 bugs in a million lines of code is a big deal. But in some key areas, bugs are a systemic risk (for example, a bug in a heart pacemaker can be life-threatening). Also, those are the 50 bugs we've found, who knows how many bugs we haven't found yet? With Rust, we know the answer beforehand.

The nice thing is that Rust implements memory security and concurrency security without sacrificing performance. Even better, it addresses both memory security and data competition with the same set of abstractions.

Rust's zero-overhead abstraction allows you to enjoy security without losing performance. This is what traditional programmers dream of.

Take Parity, which USES Rust precisely because you don't have to worry about writing complex and high-performance code in Rust. Write programs in Rust, away from undefined behavior, data contention, and memory security issues. Not to mention, Rust is fast, fun to write, easy to read, and has almost no runtime.

Memory security issues are so difficult because you can't easily write tests to catch them. If you don't find a bug before the beta phase, the bug may stay in the code for years, like a ticking time bomb. Of course, there are tools like Valgrind to help you catch these bugs. But if no memory problems are triggered during execution, or if the code generated by such tools is not executed at run time, they will not be caught.

So, by using Rust, we eliminate one of the most complex and unpredictable classes of errors.

Rust has built-in formal proof theories, but only for memory security and concurrency. Rust internally justifies your program with logic. This is why you write Rust code with such confidence. Every time you compile, you have a set of mathematical theories to prove it to.

For a long time, one of the killer features of functional programming languages like Haskell was the ease with which formal proofs could be made, which was impossible with traditional imperative programming languages (due to Shared variability, unsafe pointer manipulation, and uncontrollable side effects).

But Rust changed that, and as an imperative language, it was on the road to being proven. So far, part of the standard library has been proven correct.


640?wx_fmt=png

Well-known blockchain projects developed with Rust

parity

When it comes to well-known blockchain projects written in Rust, Parity is at the forefront. Parity is an ethereum node client called Parity -ethereum.


640?wx_fmt=png

Parity Technologies is the name of their company. Parity now has a suite of clients and libraries, including:

parity-ethereum;

parity-zcash;

parity-bitcoin;

shasper

In other words, Parity Technologies provided a family bucket for developing blockchains using Rust.

polkadot/substrate

Polkadot is a project by the Web3 foundation, developed by Parity Technologies, that aims to do more than connect blockchains.

Polkadot enables developers and enterprises to build block chains, or parachain, using their protocols. As long as these parallel chains are based on Polkadot, they will share the same authoritative proof (PoA) consensus.

Since this type of consensus is embedded in Polkadot, parallel chain developers can focus on the specificity of their respective blockchains. All parallel chains are seamlessly connected to a generic blockchain called the relay chain, which ACTS as the link between all parallel chains.

The Polkadot project, led by Gavin Wood, is actually being developed by the same company as the parity bucket above, but by different teams.

If you follow the progress of Polkadot in real time, you'll probably see the word "Substrate" a lot. It is an important part of the Polkadot project. Parity Substrate is a Polkadot independent project. Polkadot is Substrate based, and other Substrate based projects can also run on the Polkadot network (forming an ecosystem).

So what is a Substrate? You can think of it as a framework similar to Express or other Web applications, but it is a framework for building distributed or decentralized systems, such as cryptocurrency projects, or message bus systems.

Just as most Web applications do not need to re-implement their own HTTP protocol, for each team creating a new chain, there is no need to implement network and consensus code from scratch, which is a waste of effort.

Not to mention that in order to implement business logic, you have to hire cryptographers, security researchers, network engineers, developers (to coordinate updates), and so on. If you're building a new project using a Substrate, you can easily and quickly create a chain by implementing a few function callbacks in your code.

* reference links:

https://github.com/paritytech/polkadot
https://github.com/paritytech/substrate


grin

Grin is the little web celebrity of today's blockchain world. One of the few projects aimed at becoming real money.

Grin is committed to providing a cryptocurrency that is both private and scalable and is scheduled for release in early 2019. Several unique properties: the use of a privacy protected blockchain format called MimbleWimble; It is cheap and easy to run a full node with only a small amount of data stored in the blockchain.

Mimblewimble was developed by anonymous people with teams around the world; There are no pre-dug PoW mechanisms, more equal and decentralized.


640?wx_fmt=png

Grin core developer and Grin Council member D

Grin's emergence heralds a return to bitcoin, which may be the right direction for such projects.

Participating in the development and communication of gin is quite enjoyable.

holochain

Holochain is working on the Dapp landing, that is, building a cloud hosting network.

While people are working on how to improve blockchain performance, Holochain is building cars. Sometimes thinking is not a good thing, a different way of thinking may be able to find a new way to solve the problem. As the Holochain website says: Think outside the blocks.

Holochain is an interesting project. It's not a block chain in the narrow sense. In essence, people are studying blockchain to complete value transmission by solving the trust problem, so as to complete the change of production relations.

In order to achieve the ultimate goal, we do not have to limit our vision to a particular technology. Whether it is blockchain, DAG or Holochain, as long as it can achieve our ultimate goal, it can be regarded as a good technology.

To ensure information consistency in blockchain, each node in the system is a separate ledger that records the same information. Although the distributed ledger technology of blockchain satisfies consistency, it creates huge information redundancy.

Holochain believes that consensus can be divided and that it is not necessary for all events to agree. So it innovatively addresses the consensus problem from another perspective. Holochain divides a ledger into several pieces, hands them over to each participating node, and ensures ledger consistency through DHT technology and cryptography.

In short, we can understand the role of DHT as a picture on a jigsaw puzzle, we can judge whether the jigsaw puzzle is complete through the picture.

The nodes no longer need to keep simultaneous records of multiple accounts, but only need to record the contents related to themselves to reach the consensus of the whole network, which is the innovation of Holochain.

Nerves

First, what is Nervos going to do? According to the website, Nervos is about: building a layered infrastructure for the cryptographic economy of the future. Layer 1 releases native assets, which supports high security and decentralization at the expense of efficiency.

Layer 2 does the capacity expansion. As Layer 1 of the system, Nervos CKB mainly serves the following two purposes: asset storage and protocol enhancement (security and decentralization).

Note that this is also the principle of Nervos CKB economic system design, that asset storage is greater than the exchange of value.

Nervos has a few interesting design highlights:

Tackling deflation and inflation;

One of Nervos CKB's ideas is that the value of the smart contract platform should include the value of other cryptographic assets issued on the platform in addition to the native tokens.

Solving the price problem of resources;

Solve the problem of discovery and adjustment of interest rate.

exonum

Produced by Bitbury. Is a set of license chain development frameworks developed using Rust. Using exonum, it is convenient to build alliance chain.

conclusion

As a 4-year old language (today May 15, 2019 marks the 4th anniversary of the release of Rust language), Rust language is developing rapidly in various fields of the IT industry, and due to the characteristics of the blockchain itself, the blockchain field is one of the early adopters of Rust.

In the blockchain sector, Rust is gaining momentum in the emerging blockchain project market, and many well-known old projects are considering switching to Rust rewriting.

At the same time, the achievements brought by the rapid development of WebAssembly technology are also applied to the block chain in time. Rust provides first-class support for WebAssembly. Probably by far the best of all languages. Please refer to:

https://rustforce.net/article?id=6807cc27-0e6c-4bc9-baa3-8b0c68ae9529

It is believed that with the async/await feature of the Rust language stabilizing this year, it will become easier and more convenient to use Rust for block chain development. More and more blockchain projects will choose to use Rust as the first development language, and we will see a wave of Rust language learning.

This is Rust's 4th birthday present. Happy birthday to Rust!

* about the author:

Mike Tang, senior programmer and Rust language enthusiast, has been with Rust since the second half of 2014 and is the lead author of the Sapper Web framework. Since 2012, I have been focusing on learning and research in the block chain field, and participated in and contributed cita, rust-libp2p, grin and other projects.

References:

https://rustforce.net.cn/section?id=17dd744e-429a-42b1-8d30-01d31d556ab0
https://www.jianshu.com/p/cca7e4f46b86
https://www.parity.io/why-rust/

Text link:mp.weixin.qq.com




Welcome to join the official BlockBeats community:

Telegram Subscription Group: https://t.me/theblockbeats

Telegram Discussion Group: https://t.me/BlockBeats_App

Official Twitter Account: https://twitter.com/BlockBeatsAsia

Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit