Giter VIP home page Giter VIP logo

demo's Introduction

Succinct Alpha Demo: Consensus Oracle

Go to the Succinct platform and login to create a project and try out deploying this demo application.

Welcome! You've succesfully created the demo project. This project will demonstrate end-to-end usage of the platform, including:

  1. Creating a release of your project or a versioned build of your circuit artifacts.
  2. Deploying your verifier onchain so that your application can verify proofs.
  3. Requesting a proof onchain and having the result delivered to your smart contract.

This demo will deploy an oracle that returns the sum of the balances of the first four Ethereum validators. The entire result will be computed using zero-knowledge proofs, meaning that there are absolutely no trust assumptions (beyond implementation bugs).

The important parts of the core logic are described below using our proving framework plonky2x. The platform can support any proving system, ranging from zkVMs to circuit libraries like Halo2, Gnark, and more. The source code attached with this project is available on GitHub.

Motivation

Once EIP-4788 is implemented, all smart contracts on the Ethereum Mainnet will gain access to the beacon block root. This means that smart contracts will now be able to access all the information stored in the consensus layer, including validator balances and participation rates. Presently, numerous liquid staking protocols, such as Lido, rely on centralized oracles to transmit this information to the Ethereum Mainnet.

With access to the block root, protocols can trustlessly retrieve this data using Merkle Proofs. However, calculating many of the statistics that protocols require would still be prohibitively costly to verify on the Ethereum Virtual Machine (EVM). For instance, Lido employs us to compute the sum of up to 1 million validator balances, a task that would necessitate over 4 million calls to SHA-256 for verification on the EVM.

Rather than executing all computations in the EVM, we can leverage zero-knowledge proofs to condense the computation into a proof verification, which only consumes approximately 250,000 gas. Although this approach has been theoretically viable for some time, several steps are necessary to transition such an application to production. These steps include running the prover, transmitting the proof, and monitoring the system. Succinct's platform aims to simplify this process for developers, allowing them to deploy applications without the burden of managing their own infrastructure.

Source Code

This circuit was built using plonky2x which comes built-in with support for all Ethereum types (i.e., bytes32, uint256) and helper methods for accessing Ethereum data.

impl Circuit for ValidatorBalanceOracle {
    fn define<L: PlonkParameters<D>, const D: usize>(builder: &mut CircuitBuilder<L, D>)
    where
        <<L as PlonkParameters<D>>::Config as GenericConfig<D>>::Hasher:
            AlgebraicHasher<<L as PlonkParameters<D>>::Field>,
    {
        let block_root = builder.evm_read::<Bytes32Variable>();
        let balances = builder.beacon_get_balances(block_root);

        let mut sum = builder.zero::<U64Variable>();
        for i in 0..4 {
            let idx = builder.constant::<U64Variable>(i);
            let balance = builder.beacon_get_balance(balances, idx);
            sum = builder.add(sum, balance);
        }

        builder.evm_write::<U64Variable>(sum);
    }
}

demo's People

Contributors

jtguibas avatar puma314 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.