
Blockchains are systems that operate independently of the real world. The data in the encrypted world is generated on the chain and continues to be used on the chain. Data in the off-chain world cannot be directly transferred to the blockchain.
However, in some smart contract application scenarios, it is necessary to use data from the outside world. For example, in some DeFi contracts, it is necessary to obtain the price of external assets as a parameter for the operation of the smart contract. In these scenarios, an oracle (Oracle) is needed. The oracle machine is a tool for transmitting off-chain data to smart contracts on the chain, and can also transmit on-chain data to the off-chain world.
The oracle is a bridge linking smart contracts on the chain with the world outside the chain, and a way for smart contracts to obtain off-chain data. If there is no oracle machine, the smart contract can only use the data generated on the chain, and cannot use external data.
With the increase in the interaction between various protocols, the data dependence between each other is gradually increasing, and the oracle machine is becoming an important infrastructure in the blockchain world.
On the surface, oracles solve the problem of passing off-chain data to on-chain. But in essence, this is not a difficult process. How to make the data transmitted to the chain truly credible and reliable is the real problem to be solved by the oracle machine.
In other words, what the oracle machine solves is actually a problem of trust. The oracle machine needs to design the technology and mechanism so that the data it provides can be accepted and trusted by the data demanders.
Oracle Classification
As mentioned above, how to generate trust in the data it provides is the top priority of the oracle.
According to different trust generation mechanisms, oracles can be divided into several different types:
1. Centralized oracle
2. Decentralized Oracle
3. Alliance oracle
Centralized oracle
Centralized oracles provide data for smart contracts by a single centralized institution. In this case, the data requester needs to trust that the oracle machine will not deceive them, so the centralized oracle machine needs to prove that it is trustworthy.
There are two implementation mechanisms for centralized oracles:
The first is to use an authenticity proof mechanism such as an algorithm to prove that it is running in a trusted execution environment, and the data provided is the real and untampered data of the data source at a certain point in time. Data users do not need to trust the centralized institution itself, but only need to trust the technologies and mechanisms used by the centralized institution.
The second is the official oracle provided by the data source. These data sources are usually reliable and credible institutions in the off-chain world, which have relatively good credit and reputation, and data users only need to trust the institutions themselves. This model is similar to the traditional Internet. Users use the services provided by institutions and fully trust these service providers.
Centralized oracles have their own advantages and disadvantages.
Since the data is provided by a single organization, the user's trust in the organization determines the credit of the oracle machine. A single data source cannot avoid a single point of failure, and it cannot restrain malicious behavior, so it is difficult to guarantee security.
In addition, centralized oracles are usually difficult to connect to other oracles, so the range of data provided is limited.
However, because there is no need for multi-node coordination and gaming, it saves a lot of time and improves efficiency. At the same time, because there is no need for multiple nodes to support services, there is no need to pay for multi-node networks, and the usage cost is low.
Decentralized Oracle
The decentralized oracle machine is in line with the design spirit of blockchain decentralization, and through the design of the mechanism, the credibility of the data is guaranteed. In the decentralized oracle machine, many nodes form a distributed node network, cooperate together to provide data, play and control each other, reduce the possibility of doing evil through economic models, and improve the fault tolerance of the entire system.
Because multiple nodes are required to work together, the scale of the node network of the decentralized oracle machine will affect the reliability of the data it provides. The data provided by a larger network has higher credibility, so the system usually provides some economic Incentives to encourage more nodes to participate.
Nodes participating in the provision of services are usually required to pledge a part of tokens (usually the project tokens themselves) when providing data. Once the system finds out that the nodes are doing evil, the pledged tokens will be confiscated.
The following issues need to be considered when designing a decentralized oracle:
1. The problem of node collusion, if multiple nodes join forces to do evil, how should we deal with it;
2. Data privacy, in the case of open transmission and query of node data, how to ensure the privacy of these data;
3. Timeliness of data acquisition, how to reduce data coordination and confirmation time between multiple nodes;
4. The problem of nodes copying data from other nodes, how to prevent nodes from directly obtaining data from other nodes instead of extracting data from the data source;
Decentralized node network can avoid the single point of failure of centralized oracle machine, but correspondingly, decentralized oracle machine is more expensive to use due to the need to pay service fees to multiple nodes.
Alliance Oracle
A federation oracle is a special form of a decentralized oracle. There are not only ordinary nodes that make up the node network, but also some designated trusted institutions as nodes. For example, MakerDAO's v2 version of the oracle, its nodes include institutions such as dYdX and 0x.
The source of trust for the alliance oracle machine is more complicated than the previous two, including trust in institutions with industry reputation as nodes, trust in the entire network check and balance mechanism, and selection of nodes by the oracle project party. Data users need to trust that all these relevant parties will not choose to do harm to their own reputation because of their interests.
The composition of this node network has a certain degree of centralization, but as a cost-effective trade-off, it is a good choice in the early stages of industry development. It's just that this kind of centralized trust mechanism may not be able to bear the demand of smart contracts with too much value.
From the above description, it is not difficult to see the problems faced by the alliance oracle machine:
1. The identity confidentiality of trusted nodes will affect whether the nodes will be blackmailed or bribed, which will affect the safe operation of the network;
2. Whether the data provided by trusted nodes has a great correlation with their own interests. After all, if it involves their own interests, it is difficult to avoid the possibility of data being maliciously manipulated.
Representative projects of the oracle track
The following will briefly introduce Chainlink, the leading project in the oracle track, and Banksea, the representative project in the NFT oracle.
Chainlink
The working mechanism of the oracle machine can be summarized as follows: the user smart contract (User-SC Contract) that needs to use data requests data from the oracle machine contract. After the oracle machine obtains the data from the external data source API, it returns a weighted result to the user after summary processing smart contract.
There are several main roles in this process: data demanders (user smart contracts), oracles and off-chain data sources.
Chainlink is a decentralized oracle machine. After receiving data requirements, multiple nodes in its distributed node network will request data from multiple external data sources, and then each node will send the collected data to the chain. An oracle contract for data aggregation. This contract will review the collected data, and after removing outliers, take an average value and send it to the data demander.
There are three main smart contracts in Chainlink, namely reputation contract, order matching contract and aggregation contract.
The reputation contract is used to record the historical performance of the service provided by the oracle node; the order matching contract matches the appropriate node network solution for the data demander through the Service level agreement (SLA, Service Level Agreement). The reference factors include node reputation, price, node network The number of nodes, etc.; the summary contract summarizes the data provided by the oracle nodes and gives the final result data.
By selecting parameters such as price level, network scale, node reputation, etc., the user screens and combines oracle node service providers that meet the needs, and determines the SLA proposal. The proposal will be submitted to the order matching contract, and then the selected service provider node chooses whether to When bidding, a deposit (a certain amount of LINK tokens) needs to be attached to the bid. The deposit is used to prevent nodes from engaging in malicious behavior. Once malicious behavior occurs, the deposit will be deducted. When the number of bidding nodes reaches the requirement, no new node bidding will be accepted, and the final service provider will be selected from the previous bidding nodes. Deposits pledged by nodes that are not selected will be refunded.
The selected nodes will go off-chain to collect data, and finally submit the data received from multiple data sources to the summary contract. The summary contract will go through various processes, such as eliminating obviously deviated data and performing weighted calculations. User smart contracts use LINK tokens to pay fees to service provider nodes that provide data.
In the process of nodes providing services, the reputation contract will record the performance of nodes. It mainly includes: the total number of assigned requests (complete responses and unfinished responses); the total number of completed requests, the success rate of completion; the total number of accepted requests, the total number of requests accepted by the contract, the accuracy rate; the average response time; pledge Amounts, fines, etc.
Banksea
As an important infrastructure of the NFTFi industry, the NFT oracle provides a reference for the valuation and pricing of NFT in the market, and supports the development of subsequent financial services.
A typical application scenario is NFT mortgage lending. With the help of data from the NFT oracle machine, the loan service provider can determine the amount that the borrower can lend, and decide whether the mortgaged NFT needs to be liquidated when the market price changes, so as to stop the loss in time.
According to Banksea's official white paper, Banksea is a decentralized NFT oracle machine that integrates functions such as NFT data analysis, NFT valuation, and NFT comprehensive risk assessment.
epilogue
epilogue
When the oracle was first born, due to the lack of application scenarios, it did not receive much attention.
However, as the application scenarios of smart contracts gradually increase, and various DeFi and NFTFi applications emerge, blockchains increasingly need to interact with the outside world, and oracles have gradually become an important infrastructure in the blockchain world.
Although the centralized oracle machine is low in cost and high in efficiency, its design violates the spirit of decentralization, and it will never get rid of doubts about reliability and security. In comparison, although the decentralized oracle machine is slightly less efficient, it can effectively avoid the risk of a single point of failure, and the competition and balance between network nodes can also reduce malicious behavior.
In the final analysis, what the oracle machine needs to solve is the problem of trust and security. Decentralization is a direction to solve problems. Whether there will be other directions and products in the future, we will wait and see.