Coder Social home page Coder Social logo

validator-circuits's Introduction

Validator Circuits

Circuits for validators and validation including...

  • A commitment reveal circuit (up to some amount) plus a proof aggregator to increase throughput
  • An update circuit to prove how an staker update changes the state root

These circuits and proofs are intended to maintain a small rollup that can be updated efficiently and easily prove validator commitment reveals for block slots (also referred to as "signature"). They are optimized by using the Poseidon hash which is easy to verify in zk arithmetization.

TODOs

  • memory efficient data trees (particularly participation.rs and epochs.rs)
  • use custom gates for sha256 hash
  • include already compiled circuits in repo
  • review security

Building

The circuits should be built/compiled ahead of time in order to speed up the benchmarking. This is especially relevant when benchmarking with full wrapping to groth16. Please make sure you have both Rust Cargo and Go (1.19+) installed. It can take around 30 minutes to finish building since the groth16 circuits need to go through the full generation routine with mock trusted setup ceremony and everything.

RUSTFLAGS="-Ctarget-cpu=native" cargo run --release --bin cbuild -- --full

Exclude the --full flag if you want to skip the groth16 stuff.

Benchmarks

Prove Attestations

Proves a minimal amount of "signatures" through the 3 stage attestation aggregation proofs

RUSTFLAGS="-Ctarget-cpu=native" cargo run --release --bin benchmark -- attestations

add a --full flag at the end to include wrapping to groth16

Generate Commitment

Generates a validator commitment merkle tree root. Because Poseidon hash is being used, this can take quite a bit of time compared to typical CPU friendly hash functions. Keep in mind that this only has to be computed once per validator.

RUSTFLAGS="-Ctarget-cpu=native" cargo run --release --bin benchmark -- commitment

add a --full flag at the end to include wrapping to groth16

Benchmark Results

CPU:          Intel Core i7-8700 3.2GHz

results
Generate Commitment:           144.7s
Update Validators State:       3.26
Update Participation State:    3.1s
Prove Validator Participation: 26.89s 
Prove Block Attestations:      66.13s 

Theoretical 1Year Participation Prove Time:  2260s (37.67m)
[19s + 7s*(num_epochs - 1) + 1s]

Theoretical 100K Attestation Prove Time:  550s (9.17m)
Theoretical 1M Attestation Prove Time:    5150s (85.83m)
[4s*ceil(num_att/1024) + 32s*ceil(num_att/(1024*32)) + 32s*ceil(num_att/(1024*32*32)) + 30s]

validator-circuits's People

Contributors

pixelcircuits avatar

Stargazers

Shun Kakinoki avatar

Watchers

 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.