• Stars
    star
    172
  • Rank 221,201 (Top 5 %)
  • Language
    Solidity
  • License
    GNU General Publi...
  • Created almost 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Secure randomness for Ethereum's execution layer via SNARKs and RANDAO.

zk-eth-rng: Utilities for Randomness On Ethereum

Github Actions

This repository contains contracts, circuits, and scripts related to generating and providing randomness for Ethereum's execution layer.

Meant to accompany the eth-rng blog post.

Getting Started

To get started with this repo, you will need to have the following set up on your machine:

  • Foundry to compile contracts and run Solidity tests
  • Yarn and Node.js for running Typescript util scripts
  • Circom to interact with our circuits

Setup

Circuit setup

cd circuits && yarn install

This automatically downloads a powers of tau file required for generating ZKPs. This download might take a while.

Script setup

cd scripts && yarn install

Directory Structure

The project is structured as a mixed Solidity, Circom, and Typescript workspace.

├── circuits  // <-- Circom source code
├── contracts // <-- Solidity source code
├── scripts   // <-- Block header & proof generation utils

Block Hash Oracle

To run Solidity tests:

cd contracts
forge test --match-contract "BlockhashOpcodeOracleTest|ZKBlockhashOracleTest"

To generate proof calldata for the ZK blockhash oracle contract:

# The circuit proves the parent hash of the specified BLOCK_NUM.
cd scripts
BLOCK_NUM=8150150 RPC_URL=https://ethereum-goerli-rpc.allthatnode.com ./run_single_block_zkp.sh

Randomness Interface and Provider

To run Solidity tests:

cd contracts
forge test --match-contract "RANDAOOracleTest"

Optional: To generate new test data for the RANDAO-based randomness provider use the Typescript helper script:

cd scripts
yarn install
yarn ts-node generateBlockInfo.ts --blockNum 15539395 --rpc https://ethereum-mainnet-rpc.allthatnode.com

This will write a new JSON testdata file to contracts/testdata/blockheaderinfo. To include this block in the test, add the block number to the array similar to this example.

License

ZK related circuits & contracts and their tests are licensed under GPL 3.0 due to circom's license:

These contracts and their tests are licensed under MIT:

All code under scripts is licensed under MIT.

Disclaimer

Contracts and circuits are unoptimized, unaudited, and experimental — use at your own risk! Issues and pull requests are welcome.

More Repositories

1

reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
Rust
3,910
star
2

artemis

A simple, modular, and fast framework for writing MEV bots in Rust.
Rust
2,292
star
3

cryo

cryo is the easiest way to extract blockchain data to parquet, csv, json, or python dataframes
Rust
1,137
star
4

rivet

Developer Wallet & DevTools for Anvil
TypeScript
833
star
5

flux

Graph-based LLM power tool for exploring many completions in parallel.
TypeScript
773
star
6

paradigm-ctf-2021

Official repository for Paradigm CTF 2021
Solidity
488
star
7

flood

flood is a load testing tool for benchmarking EVM nodes over RPC
Python
316
star
8

paradigm-ctf-2022

Rust
296
star
9

paradigm-data-portal

a collection of open source crypto datasets for researchers and tool builders
Python
288
star
10

revmc

JIT and AOT compiler for the Ethereum Virtual Machine, built on Revm.
Rust
202
star
11

mev-share-rs

Rust client library for Flashbots MEV-share
Rust
177
star
12

pyrevm

Python wrapper around https://github.com/bluealloy/revm/ using PyO3
Rust
167
star
13

mesc

MESC is a specification for how crypto tools configure their RPC endpoints
Rust
167
star
14

ultimate_evm_tracing_reference

a collection of EVM tracing information for easy reference
156
star
15

etop

like htop for Ethereum and other EVM chains
Rust
143
star
16

jitevm

convert evm bytecode to native machine code and go vroom - just an experiment, probably broken, reach out to [email protected] to contribute / productionize.
Rust
141
star
17

spice

Simple client for extracting data from the Dune Analytics API
Python
131
star
18

tbl

tbl is a swiss army knife for parquet read and write operations
Rust
112
star
19

reth-exex-examples

Collection of ExEx examples built on Reth
Rust
100
star
20

paradigm-ctf-infrastructure

Public infra related to hosting Paradigm CTF
Solidity
98
star
21

sinker

Synchronize Postgres to Elasticsearch
Python
63
star
22

local_reth

Run Reth+Prometheus+Grafana locally via docker-compose
Dockerfile
60
star
23

paradigm-ctf-2023

Solidity
59
star
24

stress4844

Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844blobs.
Rust
55
star
25

fig

Guidelines & best practices for developing Frames: https://www.figma.com/community/file/1367670879509913267/frame-interface-guidelines
52
star
26

paradigm-ctf-2022-teaser

https://rinkeby.etherscan.io/address/0xffb9205c84d0b209c215212a3cdfc50bf1cfb0e0#code
Solidity
40
star
27

op-rs

Rust
37
star
28

how-to-raise-the-gas-limit

Data & code accompanying Paradigm's How to Raise the Gas Limit post.
Jupyter Notebook
33
star
29

foundry-alphanet

Foundry tools for interfacing with Reth Alphanet's bleeding-edge EVM extensions.
Shell
29
star
30

humanizooor

16
star
31

phishing-list

A rapidly-updated list of live phishing domains for consumption by the eth-phishing-detect module
16
star
32

state_growth

Python
15
star
33

homebrew-brew

A homebrew tap
Ruby
12
star
34

.github

7
star
35

evm-inspectors

EVM Execution Hooks.
2
star
36

crypto_colors

Python
1
star