Filecoin oracle on Ethereum

Wed, Feb 17, 2021 3-minute read

A short article on how we implemented a proof of concept for a Filecoin oracle on Ethereum during PL hack week.

Introduction

During Protocol Labs’ hack week held from February 1st, 2020 to February 5th, 2020, a few of us (ZX, Nicola, Raul, Alex C, Dirk and myself) attempted to push forward the vision of Data DAOs (check out this awesome blog post on Data DAOs) and realize a Filecoin oracle on Ethereum.

We rolled our sleeves, and went through a few iterations until we landed on a pragmatic solution that could be put on production today.

What is a blockchain oracle

A blockchain oracle is a system that connects a blockchain with off-chain data. For example, the MakerDAO Price oracles publish prices of various assets, such as ETH, USDT, etc. periodically on Ethereum for other smart contracts to use and benefit from. Oracles are a central and critical part of many DeFi applications today.

Why do we need a Filecoin oracle on Ethereum

We want to motivate the community to think about Data DAOs and Data Supply Chains. We aim to inspire the Web3 community by conceptualizing the future of decentralised datasets, and to inspire developers (on Filecoin and on Ethereum to begin with) by implementing attractive prototypes.

A Filecoin oracle on Ethereum is going to be an important primitive, enabling developers and decentralised organisation to verify that a certain dataset is stored securely and proven continuously on the Filecoin network.

Demo

You can find a short live demo and presentation of the project on YouTube.

Architecture of the oracle

After a few iterations and discussions on how to implement the proof of concept oracle, we set on the following architecture:

  1. smart contracts (github.com/nonsense/filecoin-oracle) - Solidity smart contracts for Ethereum

  2. web oracle (github.com/dirkmc/filecoin-deal-proofs-svc) - A trusted web service which monitors the state of the Filecoin blockchain

  3. sample verify tool (github.com/nonsense/filecoin-deal-verify) - A verify tool which queries the Ethereum blockchain and accepts/rejects a proof

The web oracle continuously monitors the Filecoin blockchain, once an hour processes the state for all deals, and produces a merkle tree root hash of the serialized dataset. This service is backed by the Filecoin Sentinel.

Users are able to query data CIDs of interest on the web oracle and get a merkle inclusion proof with all the relevant data for the data CID at that point in time: dataCid, pieceCid, dealId, provider, startEpoch, endEpoch, signedEpoch.

We considered using directly the Filecoin state via the ParentStateRoot hash, instead of using a custom data structure, but this turned out to be infeasible, due to the number of elements in the data structure that would need to be serialized alongside the deal information in order to produce an inclusion proof.

Trusted element

For the proof of concept we didn’t have capacity to implement a DAO and consensus layer around the Filecoin Sentinel service, which is the ETL pipeline which produces the custom data structure, which we then serialize into a merkle tree. Considering that Sentinel is open-source, it is possible to architect a DAO around it and have consensus around the data it generates.

References

We would like to thank the Sentinel team for all the great work they’ve done in extracting Filecoin insights into easily digestable formats. Without it this project would not have been possible. We would also like to thank the OpenZeppelin team and the Uniswap team - the smart contracts we created for verification of inclusion proofs are based on their work.