Lifting the hood on Mainnet: the good bits!
12月 19, 2019
This mainnet release, code-named Auriga, is the culmination of more than two years of hard work by our world-class team. It marks the start of something truly special. In this article, we take a look at the technical components that make up the mainnet release.
Prior to the release of our mainnet, the native FET token was only available as a test token, and real funds were held in ERC20 FET tokens. Now you can start developing real, main network applications using the native FET. Indeed, you will very soon be able to convert existing ERC20 into native tokens using our migration tool.
Our consensus protocol uses a Proof-of-Stake (PoS) mechanism to construct a blockchain. All of the consensus participants contribute a stake to gain entry to the consensus. PoS severely reduces the amount of energy consumed compared to Proof-of-Work (PoW), and allows us to introduce penalties to make 51% attacks more expensive (for example, a loss of stake).
In developing the protocol, we have implemented a Decentralized Random Beacon (DRB). This is a distributed random number generator used to elect a group of nodes that we refer to as a ‘committee’, who collaboratively build and decide upon the next block that will be entered into the ledger. This beacon selects on a block by block basis which miners in the cabinet are eligible to mint a block, which ensures fairness and fault-tolerance. To achieve this, the nodes participate in a protocol using threshold cryptography, creating a group public key that requires the collaboration of 51% of the miners to utilize.
The implementation of our consensus algorithm is still under development. If you would like to understand better what the complete system will look like, and what its advantages are over other systems, please check out this 博客文章.
Etch is a high-level, statically-typed programming language designed for creating smart contracts on the Fetch.ai ledger. The Etch language imposes rigorous compilation restrictions in order to avoid costly runtime errors. Its syntax is inspired by Rust, C++ and Python.
You can check out the technical documentation to start learning how to develop in Etch. And if you are familiar with the Solidity language, you can try our transpiler (under development) to achieve most of the work of converting existing contracts to Etch.
Synergetic smart contracts
A smart contract is a computer program to reach an agreement between two or more parties. Because this agreement is deployed across a decentralized blockchain network, transactions can be executed without involving third parties, and they are trackable and irreversible. Thus far in the evolution of blockchain technology, smart contracts have been used for relatively straightforward functionality.
Synergetic smart contracts are extensions to the original concept of smart contracts, enabling off-chain computation. In the case of the Ethereum VM, its design requires ‘gas’ to execute on-chain computing functions, which is a clever solution to prevent spam but makes solving complex problems too costly.
Agreements specified as synergetic smart contracts can also involve any number of parties. Importantly, they enable those parties to optimize their coordination to provide an economic gain to all participants. For instance, in the shipping industry, delivery trucks could be matched with multiple suppliers; in the tourism industry, visitors could be matched with combinations of flights, car rental services and hotels.
After specifying these problems within a synergetic smart contract, miners on the Fetch.ai network can then compete to provide the best algorithm and solution to the problem by processing the available data. The different stakeholders contribute a small fee, which provides the reward to miners for finding a solution.
You can find an example of a synergetic smart contract implemented in Etch, the Fetch.ai smart contract language, in the technical documentation.
Fixed point arithmetic
The Fetch.ai ledger will be computing and storing the results of complex mathematical operations in smart contracts, and these results will be cryptographically hashed. These hashes will need to be absolutely identical on every hardware and software architecture attempting to verify them.
Floating point numbers can have different binary representation depending on the hardware architecture, due to many CPUs not being fully compatible with the IEEE 754 standard for floating-point arithmetic. This will almost always result in tiny differences at extremely high levels of precision.
In order to overcome this issue, our system implements a fixed point data type which utilizes integer mathematics to guarantee identical results across architectures.
TensorFlow-like Machine Learning library
Machine Learning in the Fetch.ai ecosystem is supported by a library built for training and evaluation of neural networks. Uniquely, due to the underlying fixed point maths library, neural networks can be trained and run on or off-chain to suit the needs of your application.
Given the decentralized and heterogeneous nature of the network, we need to guarantee that given a certain input, the output will be the same across any hardware and software architecture. This is the only way to make every machine learning operation taking place on the ledger verifiable by every other node in the network.
Unfortunately the last requirement ruled out TensorFlow and PyTorch due to their use of floating point arithmetic, so we have developed our own library using fixed point arithmetic. However, in order to make it easy to use it supports:
- Types and interfaces very similar to TensorFlow, with tensors 和 models among others
- Most popular optimizers: Adam, RmsProp, Sgd, Adagrad and Momentum
- Most of the operations available in TensorFlow Lite, like 1D and 2D convolution, MaxPool, and OneHot, as well as many that are not, such as embeddings and self-attention.
You can find more information about our Machine Learning library in the technical documentation.
AI-powered smart contracts
We have achieved a world-first by running neural networks on smart contracts. Other blockchain and AI offerings permit either storing or retrieving data and models. In a minority of cases they allow ‘prediction’ as well, but this actually done off-chain, and the scope of what is possible is severely limited by the lack of an interoperable ML framework.
Performing neural network construction, training, and operation on-chain are all possible and easy in a smart contract on the Fetch.ai distributed ledger. The replication of effort makes on-chain work more expensive, but there might be cases where transparency is so important, that it’s worth paying the cost.
In other cases, where cost is more important, or where data privacy is a concern, it is better to train the model off-chain (with or without a synergetic contract involved). After that the model can be uploaded to the ledger, and invoked by the public to make predictions. We can accommodate this easily in an Etch smart contract too, limiting the model upload stage to a pre-specified address (e.g. such as the smart contract owner) to prevent malicious parties from overwriting the model.
Some of the functionalities of the Fetch.ai ML library can already be used in smart contracts implemented in the Etch language. These include:
- Sequential models to train a neural network to predict either continuous variables or classes
- Adaptive Moment Estimation (Adam) and Stochastic Gradient Descent (SGD) optimizers for neural network training
- Tensor manipulations like dot, argmax, transpose etc.
Autonomous Economic Agents (AEA) are intelligent programs operating on their owners’ (human or non-human) behalf, with little or no interference, and focused on generating economic value for them. AEAs run off-chain but can use the ledger to achieve their goals, such as by interacting with smart contracts or signing transactions. AEAs achieve their goals through specialized modules called ‘skills’ which can vary in complexity, from simple conditional logic to advanced deep and reinforcement learning models. If you want to learn more about AEAs, and see examples of what they can do, please check out this video:
AEAs are a vital part of our vision to enable a decentralized digital world, where decisions are made autonomously to simplify people’s lives. To simplify the development of AEAs, we provide a framework with an intuitive command-line interface to set up the skeleton of an agent, add new skills and communication protocols, and share code with the community via a registry that will be launched soon.
Agents can use a modelling language to describe their characteristics, then advertise them to the rest of the network. Agents interested in solving the same problem can search for other agents described using the same model, independently of their underlying implementations. These implementations can even interact with different blockchains: using our framework, an agent could perform a transaction on the Fetch.ai network, and another could run the equivalent on the Ethereum network. A single agent could even operate against both at the same time.
You can find more information about the AEA framework, including several demos and guides, in the technical documentation. If you want to start developing an agent yourself, you can download the PyPI package or check out the 源代码, then follow our video tutorial.
Developer website and tools
Our developer website is a hub for those interested in developing solutions based on Fetch.ai technologies.
It provides direct access to written resources such as the quickstart guide, technical documentation (including demos and examples), and whitepapers for those who would like to understand the architecture in detail.
The developer website also links to Fetch.ai tools. The Etch playground allows you to easily try the Etch language without any installation. It also supports transpiling Solidity code into Etch (currently under development).
此 区块浏览器 lets you track the state of the blockchain, including blocks, transactions, contracts and accounts.