An overview of Chainlink's Off-Chain Reporting (OCR) - 2021-01-27
On May 29, 2019 the first Chainlink aggregator contract (ETH-USD) was created and deployed on the Ethereum mainnet.
The very first Chainlink price feed update on Etherscan
Once the ETH-USD aggregator had seen real world usage, the onboarding of additional node operators progressed rapidly. The number of node operators contributing data to the ETH–USD price feed rose from three to seven, then to nine and ultimately to 21. Decentralised oracle networks were here to stay.
The next component of the network to scale was the number of aggregator contracts, and the pricing data they supplied. We saw XAG-USD, USDC-ETH, GBP– USD join the network, to name a few.
Users, use cases and upgrades
Next came the end-users. Projects like Aave, Synthetix and Loopring quickly embraced the Chainlink network and introduced an array of exciting use cases that are expanding to this very day. The rate of development did not lessen; proxy and façade contracts appeared on the network and helped to increase levels of functionality. Then, in June of 2020 the first version of the AccessControlledAggregator contracts—also known as Flux Aggregators—was deployed.
The appearance of Flux Aggregator contracts marked a significant upgrade on the performance of the original aggregator contracts. In the current Flux Aggregator model, every node must submit a price (data value) individually. Once a minimum number of responses are received on-chain, the consuming smart contract aggregates the data and confirms the latest price.
Fast forward to January 2021 and we now have the latest iteration of the Chainlink aggregator contract, namely Off-Chain Reporting or OCR.
Off-Chain Reporting (OCR)
Like the aggregators that came before it, the goal of OCR is to repeatedly produce reports, which are recorded by a smart contract on a blockchain. However, OCR boasts significant differences and improvements from the previous versions of the aggregator contracts. Most notably, OCR enables nodes to aggregate data off-chain and then transmit this information on-chain in a single transaction.
Also, as with previous versions of Chainlink aggregator contracts, OCR data feeds have a controlling on-chain smart contract that interacts with a group of nodes, or “oracle group”.
NOTE: On-Chain vs Off-Chain. On-chain refers to transactions that occur on or within any given blockchain. Conversely, off-chain refers to transactions that happen outside of a blockchain. Off-chain transactions are characterized by zero to low costs and are gaining significant popularity among blockchain developers.
To fully understand how OCR works, it helps to divide the protocol into three main components.
Off-chain report aggregation; and
On-chain report transmission
For the off-chain reporting protocol to function, a secure peer to peer networking layer is required. This networking layer maintains communication channels between each member of the oracle group. It is also what enables individual oracles to identify peers, connect to them and then to facilitate the transfer of data.
Off-chain report aggregation
The off-chain report aggregation component can be thought of as the engine of the network upgrade, in that it essentially drives the aggregation process. One of the major differences between OCR and previous versions of aggregator contracts is the adoption of leader nodes. A leader node is an elected member of an oracle group that is tasked with carrying out specific functions critical for the: collection, report generation and transmission of data to the on-chain smart contract. The position of a leader node is not fixed. All contributing nodes in an oracle group assume leadership responsibilities periodically.
The process of OCR data aggregation sees individual nodes reporting signed price - data observations to the leader node, at which point a consensus algorithm is run and the values are aggregated into a report.
This report is then returned to the contributing nodes in order to verify its validity. If a minimum number of nodes (quorum) approves the reports authenticity the leader node assembles one final signed report. This report is again returned to all members of the oracle group, who then attempt to transmit it on-chain according to a randomised schedule. The node that eventually transmits the final report to the on-chain smart contract is called the transmitter node.
During transmission, all members of the oracle group monitor the blockchain in question. If the transmission of the report is not confirmed within a predetermined time, an additional protocol initiates, whereby the remaining members of the oracle group once again attempt to transmit the final report. This continues until the oracle group finally receives confirmation of a successful on-chain report transmission.
OCR price feed, the blue circle denotes the transmitter node
On-chain report transmission
Once the transmitter node has successfully submitted a report to the on-chain smart contract, the smart contract in question performs a number of predetermined tasks. The contract verifies the signatures of the contributing oracles, checks that the list of observations is sorted, records which oracles contributed data, and then exposes the reported values to consuming smart contracts on-chain. The contract then pays the oracles that submitted observations to the report. It also compensates the transmitting node with an additional payment, which reimburses it for the Ethereum gas costs incurred whilst transmitting the final report on-chain.
Why is OCR so important?
The significance of OCR should not be underestimated. The benefits that OCR will bring to the Chainlink network, Decentalised finance (DeFi) and the whole of the smart contract ecosystem are considerable.
At a basic level, Ethereum gas costs incurred by node operators running Chainlink jobs will be reduced dramatically. This will in turn allow oracle networks to scale, ultimately increasing the level of decentralisation across the whole of the Chainlink network.
In addition, requiring only a single transaction to transmit reports on-chain will drastically reduce network congestion, bringing much needed relief to all blockchain users.
Make no mistake, OCR is one of the most significant advances in the history of Chainlink. OCR will be a true game-changer and will further revolutionise an already revolutionary space.