ChainLink, the oracle connecting the two worlds

After the birth of the Internet, people have a real world and an Internet world. Today, people have a new world: the crypto world. This is a gift that the blockchain brings to people.

Over the past two decades, innovators have continually merged the real world and the Internet world, and the two are integrated into each other and difficult to separate. More than ten years after the birth of Bitcoin, the crypto world has also accelerated its pace of interaction with the real world. From the perspective of Blue Fox Notes, the integration of the encrypted world and the real world will be one of the most important development lines in the next two decades, and can go hand in hand with artificial intelligence and the Internet of Things.

Crypto World vs Real World

The pure crypto world has a different operating logic than the real world.

The crypto world runs on the chain, and through consensus mechanism, cryptography, and distributed nodes to ensure that it cannot be tampered with, and to achieve trust without relying on third parties. Smart contracts run on the chain. Similarly, no one can modify their code or interfere with its operation, including the creator of the smart contract. In smart contracts, the execution logic is that if x occurs, then y will be executed, and the result here is deterministic. Smart contracts can self-verify and self-execute, and it represents the trustworthiness of the crypto world.

In the real world, it is difficult to have a global deterministic consensus, full of uncertain possibilities, such as applications that can be modified and terminated. In this case, the convergence of the crypto world and the real world presents challenges. The Internet world can move parts of the real world to the Internet, such as newspapers and magazines, and become new media; moving offline retail stores to online stores becomes online stores. The integration of the crypto world with the real world is more complicated.

So how do the two worlds communicate? Is it possible to communicate? This is the meaning of the oracle. Blue Fox Notes previously introduced Uniswap and Kyber, the trading protocols in the DeFi space. Today Blue Fox Note introduces the field of oracles in DeFi.

The oracles connect the encrypted world with the real world

Communication between the crypto world and the real world requires oracles. In Blue Fox's notes, oracles are "middleware" that connect two different worlds.

If the crypto world is only satisfied with currency applications, then it can be done only within the crypto world, such as Bitcoin transactions. However, if you want richer services, want to meet more needs, and want to maximize the potential of smart contracts, then it is necessary to introduce data from the real world for smart contracts.

Some people may ask, why doesn't the blockchain get this data directly? Not directly available. As mentioned above, because the operating logic of these two worlds is different. The data on the blockchain is the global consensus reached through the consensus mechanism, and not all data in the real world are the result of consensus. The connection of the two worlds requires a reliable oracle. Provide trustworthy data through the oracle, and transform it into data readable and usable by the blockchain.

What real-world data does the crypto world need? Judging from the current development, so far, the biggest demand is in the field of DeFi. MakerDAO, Compound, Synthetix, dYdX, etc. in DeFi all need the price data stream service provided by the oracle.

With the development of smart contracts, there will be more scenarios that require data off-chain. For example, synthetic asset smart contracts may require price data streams from NASDAQ and NYSE; real estate smart contracts may require data streams from the real estate market; insurance smart contracts, such as flight delay insurance, require data streams for flight activities Smart contracts for trade finance may require GPS-related data. In addition, with the development of artificial intelligence and the Internet of Things, the demand of smart contracts for real-world data will only increase.

In addition to introducing real-world data into the encrypted world, data in the encrypted world can also enter the real world. For example, data is output from on-chain to off-chain, and is routed to the payment network in the form of payment messages.

Centralized oracles do not fit the blockchain

In order to meet the needs of blockchain smart contracts for off-chain data, some smart contracts use or use over-centralized oracles. What's wrong with the centralized oracle? Its centralized control mode is prone to single-point failures, and once it is down, it will bring losses. In addition, whether it is subjective operation or objective hacking, there is a possibility of tampering. Even through notarization, branding, pledged funds, etc., potential security issues cannot be completely resolved.

Such problems have already occurred in reality. Synthetix had a major oracle problem in June 2019. Its Synthetix Oracle is responsible for providing external data to Synthetix smart contracts. It introduced incorrect price data on June 25, which reported KRW (Korean won) prices that were more than 1,000 times the actual price. This erroneous data was exploited by a trading robot whose owner exchanged 37 million sETH worth more than $ 1 billion. In the end, Synthetix negotiated with the owner of the trading robot to resolve the problem and resumed sETH after paying a certain bug bounty. That is, in the process, Synthetix's centralized oracle machine incorrectly provided the KRW price, leading to tragic consequences.

If the centralized oracle is prone to problems, is it feasible to use manual input to ensure that data such as prices are not wrong? Manually entered oracles can be seen in the prediction market. For manual input parties, assets need to be mortgaged to prevent a certain degree of cheating, and through crowdsourcing, there is a certain degree of decentralization. However, the method of manual input has higher cost, lower efficiency, cannot be feedbacked immediately, and is not scalable.

Safety is the key to the oracle

For oracles, centralization or decentralization is not the purpose. The purpose is to achieve a secure and reliable data delivery service. (From the perspective of Blue Fox Notes, the term "decentralization" is not a good expression. "Decentralized" or "distributed" is a more appropriate description, because from the current practice, there is no real decentralization. , Just more nodes and more scattered)

During the execution of the code logic of the smart contract, once X occurs, Y will be triggered. This method guarantees trustworthiness and transparency; however, if the input data is wrong, it will also bring losses. Just like the Synthetix case mentioned above, the KRW price data entered by it is more than 1,000 times the normal price, leading to serious consequences. Synthetix is ​​a synthetic asset trading platform where users generate synthetic assets by staking SNX tokens. Synthetic assets can be cryptocurrencies such as BTC and ETH, or Tesla stocks, commodities, etc. Regardless of whether it is cryptocurrency, stocks, or gold, Synthetix's synthetic asset trading requires accurate asset price data streams. In the event of price data problems, the consequences are unimaginable.

Similarly, in the MakerDAO protocol, users can use ETH to mortgage, which can generate a stable coin Dai with a mortgage rate of more than 150%. If the input ETH data is malicious, it will cause most user assets to be liquidated and there will be a 14% penalty . If this extreme situation occurs, the MakerDAO system will not work. The same is true for DeFi projects such as Compound and dYdX, which require the oracle to provide the correct price data stream to ensure the security of its system.

It can be said that the oracle is a common problem for most projects in the DeFi field (except for Uniswap, which does not require the oracle to provide price data services). Without a secure oracle, the DeFi building will not have a solid foundation and cannot be expanded. At present, DeFi has locked more than 680 million US dollars in assets and is still in continuous development. If the prediction machine fails, it will be almost unbearable.

Now that centralized oracles have potential security issues, how do you get more secure oracle services? Regarding this, ChainLink was proposed as early as 2017. I have to say that this was far-sighted at the time. After all, DeFi had not yet developed in 2017, and the demand for predictors was not obvious.

How ChainLink oracles connect two worlds

The above can be drawn from two points. First, the oracle is an indispensable "middleware" for the communication between the encrypted world and the real world. This determines its important position, and there will be an increasing market size. The second is that oracle security is very important. It is a smart building, especially the basic building blocks of the DeFi building. Security is the foundation of its life.

So, how does ChainLink connect the crypto world and the real world?

(ChainLink's ETH / USD price data stream, 21 nodes provide services)

1.ChainLink oracle workflow

The workflow of the ChainLink oracle is roughly as follows:

  • User smart contract (USER-SC) sends a request from the chain
  • ChainLink smart contract (CHAINLINK-SC) records an event for the oracle
  • ChainLink Core receives events and routes tasks to adapters
  • ChainLink adapter makes a request to an external API
  • The ChainLink adapter processes the response and returns it to the Core
  • ChainLink Core reports data to ChainLink smart contract (CHAINLINK-SC)
  • The ChainLink smart contract aggregates the responses, weights it to get a final feedback, and sends it to the user smart contract
(From the ChainLink white paper)

ChainLink is currently built mainly on Ethereum, and will also support other smart contract platforms in the future, such as cooperation with IoT public chain IoTeX and fragmented public chain Harmony.

In order to achieve the above workflow, ChainLink can be divided into two parts from the architecture: the on-chain part and the off-chain part.

* ChainLink's crypto world part

ChainLink smart contracts respond to data requests or inquiries from users of smart contracts. It includes three constituent contracts: a reputation contract, an order matching contract, and a roll-up contract. The reputation contract records the historical performance of the oracle service provider; the order matching contract provides choices for the oracle machine demander through the SLA (Service Level Agreement), such as price level, number of oracle machines, reputation, etc., and is based on The demand determines the oracle service provider; the summary contract summarizes the responses of different oracles and calculates the final result by weighting.

In general, the workflow on the ChainLink chain has three steps: one is to choose the oracle; the other is to report the data; the third is to summarize the results.

Users choose oracles mainly by specifying SLA proposals. They can choose query parameters, number of oracles, reputation, price levels, and so on. Based on these, you can sort, filter, and finally make a choice. After the SLA proposal is determined, it will be submitted to the order matching smart contract, and the ChainLink node that meets the SLA requirements will choose whether to bid on the proposal. If the oracle service provider bids, it will be submitted to the contract with a pledge deposit, and if it is mishandled, it will be confiscated. Once the SLA has received enough eligible bids, the bid window closes and the final oracle server is selected from this bid pool. If it is not selected, the deposit will be refunded.

Once the oracle that executes the SLA task is selected, the next is the oracle to execute the agreement and report the data to the on-chain. When the oracle machine contract receives the results submitted by the oracle machine, these results will be fed back to the summary contract. Summarize the contract to calculate the weighted result and get the final feedback answer. The weighted answer is returned to the user's smart contract, which triggers a specific function. At the same time, the validity of each oracle's response is fed back to the reputation contract.

Of course, there are many ways to handle this aggregate weighting. Some need to remove outliers before summarizing. For example, you can discard discrete values, such as removing the maximum and minimum values ​​during calculation, and outputting the median value of the remaining values.

* ChainLink Real-World Part

The real-world part of ChainLink, that is, its off-chain part, is mainly composed of a network of oracle nodes, which are connected to the public chain (such as the Ethereum network). These nodes independently collect data from real-world data sources in response to requests on the chain.

The ChainLink Core node software is responsible for interacting with the blockchain. The work of the CHainLink node is to complete various tasks. Each task has a set of small subtasks. Each sub-task executes a specific task and then passes its results to the next sub-task to get the final result. ChainLink node software has built-in sub-tasks, including HTTP requests, JSON parsing, and conversion to various blockchain formats.

In addition to the built-in subtask types, subtasks can also be customized by creating adapters. Adapters are external services with minimal REST API. By modeling the adapter in a service-oriented manner, you can implement programs in any programming language by adding a small intermediate API before the program. Many adapters are open source, services can be audited, and are run by different community members. Various adapters are developed by different developers, and ensuring compatibility between adapters is also critical. ChainLink works with a JSON-based schema system to specify what input each adapter requires and how to format them.

2. Decentralization is the foundation of ChainLink's secure connection

It is not difficult to realize the oracle itself. The difficulty is to provide continuous and secure oracle services. As mentioned in the Blue Fox note above, the difficulties faced by centralized oracles include single points of failure, data confidentiality, and data tampering. In order to achieve a secure oracle, a decentralized approach, that is, a decentralized approach, is the basic exploration of achieving security.

Aiming at the possible security loopholes of oracles, ChainLink proposed a decentralized security method, which is essentially decentralized, including decentralization of data sources and decentralization of oracle nodes. Of course, decentralization is not enough. ChainLink also considers using trusted hardware and signing data source data to ensure security.

The first is the decentralization of data sources. If there is only one data source, once the data source is tampered with, or shut down, etc., then the oracle is not safe. Decentralization is a solution. Data can be obtained from multiple sources to obtain multiple feedback to spread risk.

The second is the decentralization of oracle nodes. Different oracle nodes can obtain data from one or more data sources, and can also prevent some malicious nodes from entering wrong data. Even if some of the oracles are wrong, as long as the weighted calculation of the contract is summarized by ChainLink, there is still a chance to get a more reliable response.

However, there is a hitchhiking problem here. Some nodes may copy the response data of other nodes in order to save the cost of collecting data, which is not only unfair to other nodes, but also substantially reduces the decentralization of the data source of the oracle machine, which is not conducive to security. ChainLink will use an encrypted submission method. The oracle node sends an encrypted response to the CHAINLINK-SC smart contract. The feedback value will only be revealed when a certain number is reached and the second round is initiated.

At the beginning of ChainLink, the method of in-contract aggregation is adopted. In the long term, the method of out-chain aggregation will be adopted. The problem summarized in the contract is the cost problem, which will involve the cost of on-chain oracle message transmission and processing. If there are many nodes, there may be a high cost here. A more economical way is to perform a summary of the feedback off-chain and then send a message to CHAINLINK-SC. ChainLink also proposes the use of threshold signatures (blue fox note: threshold signature), such as Schnorr signatures. The off-chain aggregation system uses a distributed protocol based on threshold signatures, which can prevent free-riding plagiarism of f <n / 3 oracles.

3.ChainLink other measures to achieve oracle security

Decentralization (decentralization) alone cannot achieve comprehensive security. ChainLink also considers other measures, including, for example, trusted hardware, digital signatures of source data, and its security services.

Trusted hardware and digital signatures are things that ChainLink has to do to achieve oracle security in the long run. The following mainly introduces ChainLink's measures to improve security in early oracle services, that is, its main security services, which include: authentication systems, reputation systems, authentication services, and contract upgrade services.

First look at the verification system. The ChainLink verification system monitors the behavior of the oracles on the chain and provides indicators to help users make choices. Metrics include availability and correctness. Availability mainly records the number of times the oracle fails to respond to the query immediately. Correctness means correct response. If the deviation is large, it can be compared with the response of other nodes. When processing aggregate data on-chain, the activity of the oracle is visible, but when performing aggregation on off-chain, it is not possible to directly observe its availability and correctness. For the correctness of the off-chain feedback, ChainLink requires the oracle to digitally sign its response, while other nodes can report behavior that is obviously wrong (reporting nodes with excessive deviation values), and the reporting node will be rewarded. Availability is difficult to monitor. ChainLink requires the oracle to digitally sign the feedback results received from other oracles, which means that others can prove their success rate. The verification contract will accept these proofs.

Second is the reputation system. The reputation system primarily records historical performance. It mainly includes: the total number of requests allocated (completed response and uncompleted response); the total number of completed requests, which can calculate the success rate of completion; the total number of accepted requests, by calculating the total number of requests accepted by the contract, and then with other nodes Compare and compare with the total number of completed requests to get the accuracy rate. Average response time: it is calculated based on the completed requests. Pledge amount: the amount of the locked penalties, which can calculate the node's error cost. In order to gain a good reputation, nodes will act correctly.

Finally, authentication services. Authentication services are mainly credit endorsements for high-quality oracle providers. However, this may be mistaken for the meaning of allowing nodes to participate. There was a certain need for such services in the early days to obtain security. Of course, in the long run, whether we can find a more suitable method is also worth considering. The authentication service monitors the data statistics of the verification system, especially auditing the response of high-value transactions, as well as off-chain audits, including post-event audits. At the same time, it also considered the possibility of witch and mirror attacks. The witch attack will control the pool of oracles, provide incorrect data, and affect the final answer. To reduce operating costs, witch attackers also use mirroring. These malicious oracles share data off-chain and pretend to be independent data sources. This results in less fragmentation of the data source and lower security. In the long run, this can be solved by using trusted hardware. In the short term, some certification measures are needed.

Where does the value of ChainLink come from

LINK token is a payment medium for its oracle data transaction market, and it is also a working right token. The ChainLink network uses LINK tokens to pay node operators for services to retrieve data from the off-chain data stream provided by the node, format the data into a blockchain-readable format, off-chain calculations, and ensure normal operation. In order for user smart contracts to use ChainLink oracle nodes, they also need to pay operating costs to their chosen ChainLink nodes.

It can be seen that the value of LINK comes from the scale of the ChainLink oracle service market.

Decentralized oracle market potential

How big is the field of decentralized oracles? The larger the scale of smart contract carrying value, the greater the demand for decentralized oracles. If the scale of DeFi projects such as Maker, Compound, and dydx reaches billions to tens of billions of dollars, the importance of oracle machine security can be imagined. It requires more nodes to participate, more data sources to participate, and more secure. Technology foundation (such as data encryption and trusted hardware) and other facilities participate in the exploration of more oracle security solutions.

For billions and tens of billions of values, tens of millions or even hundreds of millions of dollars are worthwhile to ensure their security. The cost of the service paid to the oracle is essentially the cost of security. With the development of derivatives markets such as synthetic assets, this market may be larger than the spot market, so the demand for secure oracle services will also increase.

Conclusion

The oracle is the "middleware" that connects the encrypted world with the real world. It is related to the sustainable development of the encryption field, especially for the DeFi field, its importance is obvious.

For oracles, the core issue is security. Only by solving the security problem can it have a foundation. In solving the security problem, decentralization is an important way to achieve security. ChainLink has proposed a series of solutions, including decentralization of data sources, decentralization of oracles, trusted hardware, signature of data, and security service measures (verification, reputation, certification, contract upgrade), etc. It opened the way for people to explore the field of decentralized oracles.

At the same time, some people think that ChainLink's decentralization is not enough, and there is still room for improvement in security. Then, may wish to explore more oracle network to provide more options. Next, Blue Fox Note will pay attention to other players in the oracle machine field if there is an opportunity. Maybe not only ChainLink in the future, but also other oracle networks will also grow and develop with the rise of smart contract applications. There will not be only one player in this field. As the market grows, as long as more secure oracles can be realized, there are still opportunities and the pattern is uncertain.

——

Risk warning: All articles of Blue Fox Note can not be used as investment advice or recommendations. Investment is risky. Investment should consider personal risk tolerance. It is recommended to conduct in-depth inspection of the project and make good investment decisions.