ELI5: The Runtime Offchain Logic Framework

ROFL makes it possible to create custom offchain logic that can be easily verifiable onchain through trusted execution environments. 

Trustless computation lies at the heart of Web3. This is made possible through cryptographic protocols with built-in consensus mechanisms, which enable decentralized, verifiable record-keeping and reduce the need to rely on third parties. 

Parallel to trust minimization is the issue of privacy. In a post-Ethereum world, privacy has been an issue largely due to the patterns revealed by smart contract usage, but storing data privately on a blockchain is necessary for many use cases. To this end, the Oasis team built Sapphire, a paratime that supports encrypted transactions and confidential smart contracts. 

However, while the blockchain is trustless, it’s constrained in many ways and was never designed for non-deterministic applications. APIs are also great, and developers should be able to use them while leveraging blockchain benefits. Enter ROFL. 

What is ROFL?

Runtime Offchain Logic, or ROFL, is a generalized computing framework that enables arbitrary applications to function in a decentralized, verifiable, and confidentiality-preserving way. ROFL makes it possible to create custom offchain logic that can be easily verifiable onchain through trusted execution environments (TEEs). 

In this case, offchain logic simply means programs that don't run onchain. They don't do consensus. They run asynchronously offchain and then communicate with the onchain logic through transactions, events, etc., and they can generally be trusted because each operates within a TEE. 

Although many onchain privacy tools/methods exist, ROFL uses TEEs for generality and performance. By using TEEs 'outside' the blockchain context, ROFL unlocks flexible, cheap, and verifiable computation without compromising on trust. And in this way, it extends the Sapphire runtime's capabilities, making it so anyone can run complex workloads offchain while enjoying onchain guarantees. 

These guarantees are centered on two key properties. 

  • Verifiability: With the introduction of offchain computation, users will need to know that a node operator properly handled the data and executed the job as expected. For example, if an AI-powered agent is managing a high amount of TVL, it will be important to confirm which model they’re using. 
  • Confidentiality: As more of our lives get entrusted to machine intelligence, protecting personal data will increasingly matter. For example, in the case of LLM-powered applications, confidentiality-preserving frameworks like ROFL safeguard sensitive inputs/outputs and, in some cases, protect the models themselves. 

ROFL, and by extension Sapphire, provides both of these properties. Using ROFL, a developer can open HTTPS/TLS or API connections and do almost whatever computation is desired offchain while maintaining a communication line with the onchain realm.

How Does ROFL Work? 

ROFL relies on trusted execution environments (Intel SGX), remote attestation, and a decentralized validator set as a root of trust. An Oasis node provisions the TEE for each ROFL app. The secure enclave enforces execution integrity, and all the computation happens offchain, with ROFL apps registering to the Oasis Network to authenticate and interact with smart contracts.

Inside the TEE, the ROFL app performs functions that ensure its security and ability to communicate externally. For instance, ROFL must be registered onchain and added to a config file of one or more Oasis nodes to execute alongside Sapphire. It needs a light client to establish a fresh view of the Oasis consensus layer, which verifies all onchain state. The application also generates a set of cryptographic keys used for remote attestation. These processes ensure that the ROFL can authenticate to onchain modules and interact with the outside world. 

For more specifics, refer to the ROFL documentation

What Can You Build With ROFL? 

The use cases for ROFL are limitless. Anything that can be written in software can be put into a ROFL application. However, ROFL is best for use cases that require intensive computation and a high degree of trust. AI pipelines are one clear example. 

Due to cost and storage constraints, the workflow for developing, training, and deploying machine learning models has, so far, not been feasible within blockchain runtimes. ROFL changes this, making it possible to, for instance, conduct AI training and inference offchain and then verify the results onchain.  As an extension, ROFL can enable AI workloads to use Sapphire for verifiability, provenance, usage tracking, value determination, and transfer, thereby reducing the need for trust.

This, of course, is just one example. ROFL opens up new options for not only AI but also decentralized finance, interoperability, gaming, digital identity, and more. Some examples:

Autonomous AI Agents

  • Decentralized agents can run inside ROFL, enhancing their trustworthiness and ability to interact and perform complex tasks.
  • Upcoming support for Intel TDX will facilitate inference while ensuring model privacy and verifiability.

Oracles, Bridges, and Light Clients

  • ROFL can run Bitcoin (or any chain) light clients and interact with remote services over HTTPS to provide oracles directly to onchain smart contracts. 
  • Onchain logic is then able to manage fee payments, proof verification, and data aggregation efficiently.

Intent Solvers and Chain Abstraction

  • ROFL upgrades UX by allowing users to express goals (intents) while the system identifies optimal solutions.
  • ROFL excels in this sense by enabling real-time information retrieval from various sources, managing keys, signing transactions, and submitting them to other chains, allowing for complex multi-chain swaps without bridges.

Defense in Depth for Sequencers and ZK-Provers

  • ROFL improves ZK protocol robustness by performing computations covered by ZK proofs, providing additional RA proofs for stronger security. 
  • It can also support the creation of decentralized sequencers that ensure fairness in block production and can handle encrypted transactions.

Getting Started With ROFL

At its core, ROFL combines the best of both worlds, offchain performance and onchain trust. By encompassing offchain components, ROFL enables greater flexibility and efficiency in processing data.

Foundational ROFL support has been included in Oasis Core v24.2. The more recent release, v24.3, also includes support for Intel TDX hardware, enabling quote verification and the provisioning of TDX virtual machines, making it possible to use TDX in ROFL apps. A new SDK version will make this usable shortly, significantly expanding the range of what’s possible within ROFL. Much more to come!

To get started with ROFL, click here.

How we use cookies?

At Oasis Foundation we believe in your privacy, so you can choose to browse our site without any tracking or by clicking “Accept”, you help us to improve our site and help us grow our ecosystem. View our Privacy Policy for more information.