PDX Utopia block chain stack calls Ewasm smart contract
PDX Utopia block chain stack supports Ewasm smart contracts. This document explains how to invoke Ewasm.
Ewasm is the future of ethereum’s smart contracts
The common multi-intelligent contract development language is a smart contract that can run on EVM, the ethereum virtual machine, but it has some serious problems, including arithmetic overruns and typos, all of which are problems at the development language level.Ewasm is an innovative technology that provides a decentralized computing solution that can resist attacks and create more secure smart contracts.
PDX Utopia block chain stack supports Ewasm smart contracts.The etheric fang Ewasm can solve existing intelligent virtual machine too complicated contract, performance is low, and only limited support for programming languages and development tools, it can provide an executable binary format, very similar to traditional computer architecture, efficiently and support a variety of programming languages and developer tools, can also be backwards compatible EVM entry, therefore Ewasm is etheric fang intelligent contracts in the future.
In Ewasm, you can skip the hard fork scenario when simply writing and deploying for smart contracts.And it’s computationally efficient enough to open up new levels of interoperability, so much so that most of the precompiled stuff can be cancelled.
Ewasm is powerful and important to avoid clutter, and it’s built into an already standardized language on the world wide web that makes adding ethereum support to the browser a breeze.
Features of Ewasm:
1.Ewasm is a subset of wasm;
2. Because there can be no error, floating point arithmetic is not supported;
3. Can only import the etheric fang library, to avoid the import library ㄒ system;
4. Insert useGAS before each instruction to calculate the cost of GAS.
Ethereum environmental interface (EEI)
EVM has a lot of high-level instructions like SSLOAD and SHA3, which are in Ewasm 1.0, because WASM can dynamically read the function library (module). Ethereum defines the ethereum environment interface (EEI), which allows the client to implement the corresponding function library in different languages, and it is easier to complete prototype and upgrade.
The heart of ethereum is essentially a virtual computer, and the ethereum virtual machine (EVM) is stored on thousands of nodes that make up the ethereum platform.
The following is a list of functions defined by the Ethereum Environment Interface.
How to remove illegal instruction?
Ewasm USES system contracts to remove illegal instructions and to add useGas bytecode, such as floating-point Numbers or illegal imports, in two ways:
1. Use the system contract to check the bytecode of the contract;
2. Current precompiles run on the client, checking the contract before deployment.
The following figure is the stack of Ewasm 1.0. Before deploying the contract, Ewasm bytecode will first be checked by Sentinal. After successful deployment, if the client wants to execute the contract, it will communicate with Heru (Wasm Engine) through evm-c.
Contract development specification
The Ewasm contract interface specification is customized by ethereum to specify the module structure and other information. PDX Utopia strictly follows this specification as follows
The data type
Floating point Numbers are prohibited, compatible with the data types specified in evm, such as:
* bytes: array of indefinite bytes;
* address: 160 bit digits, represented in memory as 20-byte small byte unsigned integer;
* u128:128 bit digits, represented in memory as 16-byte small byte unsigned integer;
- u256:256 bit Numbers, represented in memory as 32-byte small byte unsigned integers.
format
Each contract must be stored as wasm bytecode.
The import module
Provisions of contract ` import ` scope is limited to (EEI) (https://github.com/ewasm/design/blob/master/eth_interface.md) modules, ` ethereum ` namespace outside of the package allows you to use only ` debug `, in a production environment ` debug ` should be banned.
The export function
Each contract must export two functions (only two functions);
* the memory: (EEI) available (https://github.com/ewasm/design/blob/master/eth_interface.md) in the Shared memory;
* main: an entry function, with no parameters and no return value, will be executed by the VM;
To turn off the ‘start function’ function of ‘wasm’, it affects the ability of ‘ewasm’ to get a pointer to the contract memory address before starting.
About the ABI
> we see that the rules for exporting functions are somewhat different from the ‘ABI’ defined in the ‘solfat’ contract;
The > ‘solfund’ contract generates the corresponding ‘ABI’ based on the method signature to schedule the functions in the contract.
> this doesn’t seem to work with ‘ewasm’ because only one ‘main’ function is exported;
How does > use functions other than the ‘main’ function?We naturally thought of using the ‘input’ of the contract;
> defines the target method and the input parameters, in fact ‘solfat’ does the same, but we use this flexibility;
> is returned to the developer for implementation, with the unified ‘main’ function as the entry, and then the ‘input’ serialization scheme is encapsulated by itself.
> we can see a more flexible approach in the following example.
Development environment installation
PDX Utopia USES rust as the ewasm contract development language and compiles the contract through the rust toolchain. The installation and use process is as follows
- Install rustup
> note that the ‘nightly’ channel should be selected when the installation script executes, otherwise the subsequent tool installation cannot be completed;
If path processing fails during > installation, you need to manually load the environment variable: ‘source $HOME/.cargo/env’.
2. Install the rust standard library
3. Install the wasm-pack compilation tool
4. Install wasm post-processing tools
Once compiled, the ‘chisel’ program is found in the ‘target/release’ directory, ensuring that it is copied to the ‘$PATH’ directory.
– the public chain of PDX –
PDX public chain aims to build a public block chain ecosystem. As a public block chain IaaS, it helps enterprise customers, developer groups and ordinary users to enjoy the convenience and fun brought by block chain with powerful underlying patented technology.
The PDX public chain asserts that data sovereignty belongs to the user.
– join the community
The official Telegram
https://t.me/PDXann
https://t.me/PDXbaap
https://t.me/PDX_EngVIP
The official medium
https://medium.com/@pdxbaap
Official English twitter
https://twitter.com/PDXbaap
The official Facebook
https://www.facebook.com/PDXbaap
Official microblog PDXchain
https://weibo.com/PDXbaap/home
Published at Sat, 04 Jan 2020 08:51:41 +0000
{flickr|100|campaign}
