Today webank blockchain released a white paper on “New Exploration of Liquid Smart Contract Programming Language”. Patract official account responds to Liquid backstage and downloads the white paper.

Patract CTO Aten spoke highly of this:

Liquid is a new rust-based Wasm contract language framework proposed by FISCO-BCOS. This contract language is based on Parity’s Wasm contract language framework ink! And incorporates many of the contractual properties of ISCO-BCOS. On this basis, adaptive customization capabilities of linear asset model (LAM) and programmable distributed collaboration (PDC) are designed according to common scenarios to reduce the burden of developers in the same scenario. Further features related to privacy and cross-chain properties are in development. In general, Liquid proves that INK! + feasibility of Wasm contract model in alliance chain.

01 Existing challenges of smart contract programming languages

The increasingly diverse and complex application scenarios present new challenges for smart contract programming languages:

More attention should be paid to data privacy, and the ownership of data under smart contracts should be clear.

Distributed and immutable execution environment requires stronger robustness of smart contract.

The increasing scale of services requires smart contracts to operate more efficiently;

To be effective, the development process needs to be more developer-friendly;

The emerging new computing paradigms such as cross-chain require the ability to provide native abstractions directly.

Common smart contract programming languages have different degrees of limitations in these aspects, which restrict the further development of distributed applications.

Webank blockchain focuses on the existing challenges, combined with the exploration and practice of the core technology at the bottom of the blockchain and the implementation of distributed commercial applications, The design specification of “SPEC” intelligent contract programming language is proposed, which covers four aspects: Security, Performance, Experience and Customization.

Based on the design specification of “SPEC”, Webank blockchain has launched a new smart contract programming language Liquid.

02 Linear asset model

When using smart contracts on blockchain to manage assets, we want the contract language to ensure that assets can be managed flexibly and transferred safely. Liquid provides a secure asset model that allows users to define asset types. Asset types simulate the behavior of assets in real life and provide a number of security features, including that user declared asset types cannot be copied in the Liquid contract and that asset instances in code blocks must be stored in an account until the end of their life cycle. Assets are stored in the user’s account and have overflow checks.

Developers expect better experiences

The user experience of smart contract programming languages can be understood from narrow and broad perspectives respectively. In a narrow sense, user experience depends on whether the integrated development environment (IDE), intellisense tools, debuggers and testing tools are perfect and easy to use. Broadly speaking, the user experience depends on whether the community built around the language and the resources surrounding it, such as documentation and courses, are active and abundant. In the narrow sense, user experience is responsible for “hard”, which can help developers improve development efficiency and gracefully complete development tasks. The broad user experience is responsible for “soft”, helping to lower the learning barrier for developers, solve usage problems quickly, and inspire enthusiastic feedback from developers. Only the combination of soft and hard can make the smart contract programming language ecological prosperity and continue to advance on the road of benign development.

Throughout history, every successful programming language has been accompanied by a strong and diverse ecosystem. For example, Solidity, the most widely used smart contract programming language, has a long way to go compared to universal programming languages, even though Solidity has a well-developed toolkit in the blockchain space.

04 New smart contract language Liquid

security

On the privacy side, Liquid better protects special data and controls access to private data. Liquid first uses cryptography primitives to hide special data and uses non-interactive ZeroKnowledge (NIZK) proof to enforce the correctness of state updates when the user updates the data. Specifically, if the Liquid developer wants to ensure that the value of some variable in the contract is not disclosed on the blockchain, all it needs to do is read and write the account address of the state variable after the relevant state variable using the cryptographic primitive provided by Liquid to clarify the attribution of the data.

performance

In terms of contract execution efficiency, Liquid uses the Wasm engine to take care of contract execution. Wasm is a portable, small, fast loading bytecode format, and Liquid supports the compilation of contract code into compact Wasm bytecode, enabling smart contracts to run more efficiently in blockchain systems. Wasm is currently implemented in a variety of high-performance virtual machine implementations, with virtual machine performance ideally approaching the execution efficiency of native binary code. In addition, Wasm was originally designed for the browser runtime environment and has a natural sandbox property to facilitate isolation from the outside world and meet the technical requirements of blockchain. Furthermore, Wasm’s simple and secure design minimizes possible attack surfaces, which also meets the security requirements of blockchain. The Wasm standard will continue to evolve, with advanced features such as parallelism, multiple return values, and dynamic linking likely to be introduced in the future.

experience

Based on the flourishing development and ecology of the Rust language, Liquid brings more to the development of smart contracts with less effort in terms of experience.

First, Liquid has a well-established development library, thanks to the rapid growth of third-party libraries in the Rust language. With Cargo, third-party packages can be used in Liquid projects as long as they support the “NO_STD” feature. The developer only needs to declare the name, version, and features of the dependent third-party libraries in the project configuration file to be used in the project. In the Rust language ecosystem, more and more third-party libraries support no_STD, including SERDE for JSON codec and Lazy_static for managing static variables of the whole office. Cargo also provides one-click management for project packaging and release, greatly reducing the burden on developers.

Furthermore, Liquid can be integrated with existing development tools. When developing a Liquid project, you can use tools such as GDB and LLDB to quickly debug contracts. You can also use fuzzy testing tools such as cargo Fuzz to test contracts in depth. Tools such as WASM-opt and WASM-strip can further optimize the size and efficiency of bytecode. With the help of multiple tools, developers can develop more efficient and robust Liquid projects with a better experience.

Custom ability

As an implementation mechanism, Liquid makes extensive use of the macro-based metaprogramming techniques of Rust, allowing for the ability to arbitrarily modify the AST generated from source code at compile time, thus giving the existing syntax more semantic meaning. With this feature, Liquid is able to provide a more concise and powerful programming model based on the interface provided by the underlying blockchain platform and the real-world business requirements, in addition to the traditional smart contract programming model. Examples include PDC and cross-chain synergy. PDC allows developers to easily simulate the behavior of multiple parties in a real business collaboration. In such multi-party collaboration scenarios, concepts such as parties, contracts, and grants of rights are involved, and the implementation of these concepts is often trivial and complex, making it difficult for developers to navigate. Moreover, such scenarios are often sensitive to the correctness of the code, because multiple organizations cooperate through the same smart contract, and any errors can be amplified through a chain reaction, resulting in huge business losses. To address this pain point, PDC provides high-level abstractions specifically for business contracts, with specific syntax to help developers write contracts directly in natural language thinking. For example, simple iOU contracts can be implemented in Liquid as follows:

In terms of cross-chain collaboration, with the increasing number of blockchain application scenarios, inter-chain interoperability needs to be solved urgently. Moreover, since the account states of different chains are maintained by different chains and not visible to each other, and their updates are also driven by different chains, achieving atomic interoperation between chains is a huge challenge. To solve this problem, Liquid uses an internal transaction to encapsulate cross-chain operations, similar to intra-transaction cross-contract invocation operations on the same chain, except that the internal transaction carries the signature of the contract to initiate the cross-chain operation, which is then broadcast by the node of the current chain. At the same time, nodes in other chains listen for cross-chain transactions, and if they identify the destination of the transaction as themselves, they package the transaction onto the chain as normal transactions would. After the trade is executed, the returned data is notified to the original contract in the form of a callback to continue the subsequent logic. Instead of dealing with validation and asynchrony during cross-chain contract calls, developers can simply write contract code in the usual async/await asynchronous programming style.

About WeBank blockchain 2021 technical route:

Q1 Base version: Finish the development of Liquid base and programming models, LAM, PDC and cargo Liquid, and finish the adaptation of node. js SDK, and release Liquid community experience version;

Q2 Parallelization and privacy protection solution: Based on Liquid community experience version, complete the language design and development of automatic contract parallelization scheme and data confirmation scheme based on NIZK;

Q3 Cross-chain collaborative solution: Complete the integration with WeCross cross-chain technology at the language level, study the asynchronous scheme of cross-system contract invocation and asset transfer, and realize the lightweight and convenient cross-chain process;

Q4 Formal verification scheme: Based on pre-attribute specification, symbol execution, data flow analysis, code verification intermediate language and other technologies, Liquid provides support for formal verification of contracts to help developers write more secure and robust smart contracts.

Liquid-doc.readthedocs. IO /zh_CN/lates… GitHub codebase: github.com/WeBankBlock… Gitee codebase address: gitee.com/WeBankBlock…

About Patract

Patract provides solutions for parallel chain and DApp development in boca’s Wasm contract ecosystem. We help the community design and develop on-chain contract module and Runtime support, and provide DApp developers with a full stack of tools and services covering the development, testing, debugging, deployment, monitoring, data provisioning, and front-end development phases.

How to join Patract

1. For contract developers, visit the official website (Patract.io) to familiarize yourself with the test chain and tool suite. Element (app.element. IO /#/room/#Pat… Discord (Discord. Gg/wJ8TnTfjcq)

2. For parallel chain projects that will integrate Wasm contract functions, or DApp projects developed using Wasm contract, please contact [email protected] for business cooperation

3. For users, welcome to join: Telegram (t.me/ Patract) Twitter (twitter.com/PatractLabs…

4. For job seekers, we are recruiting blockchain development engineer, front-end/full stack development engineer, developer operation and other positions, you can contact [email protected]