• Stars
    star
    190
  • Rank 203,739 (Top 5 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 2 years ago
  • Updated 12 months ago

Reviews

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

Repository Details

Beerus is a trustless StarkNet Light Client ⚡blazing fast ⚡ and powered by Rust 🦀

GitHub Workflow Status Project license Pull Requests welcome

Table of Contents

Roadmap

We have big plans for Beerus. Check out the Roadmap!

Beerus Roadmap

About

Beerus is a StarkNet Light Client inspired by and using helios. The goal is to provide a simple and easy to use client to query StarkNet state and interact with contracts.

Built With

Architecture

Here is a high level overview of the architecture of Beerus.

Beerus architecture

Simple usage overview

Here is a simple overview of how Beerus work. The example is for querying a storage value of a StarkNet contract.

Beerus Query Contract Storage

Endpoint support

Here are all the endpoints supported by Beerus in tag v0.2.0

Starknet endpoints (20) (in compliance with Starknet specs):

Endpoint Supported
starknet_getBlockWithTxHashes
starknet_getBlockWithTxs
starknet_getStateUpdate
starknet_getStorageAt
starknet_getTransactionByHash
starknet_getTransactionByBlockIdAndIndex
starknet_getTransactionReceipt
starknet_getClass
starknet_getClassHashAt
starknet_getClassAt
starknet_getBlockTransactionCount
starknet_call
starknet_estimateFee
starknet_blockNumber
starknet_blockHashAndNumber
starknet_chainId
starknet_pendingTransactions
starknet_syncing
starknet_getEvents
starknet_getNonce

Ethereum endpoints (21) (in compliance with Helios specs):

Endpoint Supported
eth_getBalance
eth_getTransactionCount
eth_getCode
eth_call
eth_estimateGas
eth_getChainId
eth_gasPrice
eth_maxPriorityFeePerGas
eth_blockNumber
eth_getBlockByNumber
eth_getBlockByHash
eth_sendRawTransaction
eth_getTransactionReceipt
eth_getLogs
eth_getStorageAt
eth_getBlockTransactionCountByHash
eth_getBlockTransactionCountByNumber
eth_coinbase
eth_syncing
eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex

Additional endpoints (8):

Endpoint Supported
starknet_l1_to_l2_messages
starknet_l1_to_l2_message_nonce
starknet_l1_to_l2_message_cancellations
starknet_l2_to_l1_messages
starknet_addDeclareTransaction
starknet_addDeployAccountTransaction
starknet_getContractStorageProof
starknet_addInvokeTransaction

Getting Started

Installation

Beerusup

To install with beerusup:

curl -sL https://raw.githubusercontent.com/keep-starknet-strange/beerus/main/beerusup | sh

Build

cargo build --all --release

Build beerus-core for WASM:

cargo build -p beerus-core --no-default-features --target wasm32-unknown-unknown --release

Test

cargo test --all

Config

The project requires an Ethereum node and a Starknet node. For Ethereum nodes you can use Alchemy (not Infura since it does not support getProof endpoint).

Ethereum execution layer RPC URL (must be an Ethereum provider that supports the eth_getProof endpoint).

Ethereum consensus layer RPC URL (must be a consensus node that supports the light client beacon chain api)

For StarkNet node for the moment you can use Infura but soon verify proof will be implemented in Pathfinder nodes, and so will these nodes be working as well.

Env Var TOML Mainnet Goerli
ETHEREUM_NETWORK ethereum_network mainnet goerli(default)
ETHEREUM_EXECUTION_RPC_URL ethereum_consensus_rpc https://eth-mainnet.g.alchemy.com/v2/XXXXX https://eth-goerli.g.alchemy.com/v2/XXXXX
ETHEREUM_CONSENSUS_RPC_URL ethereum_execution_rpc https://www.lightclientdata.org http://testing.prater.beacon-api.nimbus.team
STARKNET_RPC_URL starknet_rpc https://starknet-mainnet.infura.io/v3/XXXXX https://starknet-goerli.infura.io/v3/XXXXX

To speed up the launch of the Ethereum client, it is recommended to set a more recent checkpoint. You can find one, for example, at this link: https://sync.invis.tools/.

Env Var TOML Mainnet
ETHEREUM_CHECKPOINT ethereum_checkpoint 0x419347336a423e0ad7ef3a1e8c0ca95f8b4f525122eea0178a11f1527ba38c0f
Config File

Beerus is configurable via a config toml. If you have set the env var BEERUS_CONFIG = path/to/config this will override all other environment variables and take configuration from values defined herein. Also the the cli can be directed via beerus --config <path/to/config>

goerli.toml

mainnet.toml

Environment Variables

Beerus is configurable through environment variables.

cp examples/.env.example .env
source .env

Examples

cargo run -p beerus-core --example basic

Using config from .toml file

BEERUS_CONFIG=path/to/config.toml cargo run -p beerus-core --example basic

Using Beerus as a Library

Beerus can be imported into any Rust project.

use env_logger::Env;
use eyre::Result;
use beerus_core::{
  config::Config,
  lightclient::{
    beerus::BeerusLightClient, ethereum::helios_lightclient::HeliosLightClient,
    starknet::StarkNetLightClientImpl,
  },
};

#[tokio::main]
async fn main() -> Result<()> {
  env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
  let config = Config::from_env();

  let ethereum_lightclient = HeliosLightClient::new(config.clone()).await?;
  let starknet_lightclient = StarkNetLightClientImpl::new(&config)?;
  let mut beerus = BeerusLightClient::new(
    config.clone(),
    Box::new(ethereum_lightclient),
    Box::new(starknet_lightclient),
  );
  beerus.start().await?;
  let current_starknet_block = beerus.starknet_lightclient.block_number().await?;
  println!("{:?}", current_starknet_block);

  let current_ethereum_block = beerus
          .ethereum_lightclient
          .lock()
          .await
          .get_block_number()
          .await?;
  println!("{:?}", current_ethereum_block);
  Ok(())
}

Beerus RPC

Beerus RPC
cargo run --bin beerus-rpc
Beerus JS(wasm demo)

Dependencies:

  • npm
  • CORS bypass
  • local pathfinder node at http://localhost:9545
  • execution env var - ETHEREUM_EXECUTION_RPC_URL
cd crates/beerus-js

# install node deps
npm i

# build webpack & wasm modules
npm run build

# run example
./run.sh

# navigate browser to http://localhost:8080
# open developer console

Work in progress

See the open issues for a list of proposed features (and known issues).

Support

Reach out to the maintainer at one of the following places:

Project assistance

If you want to say thank you or/and support active development of Beerus:

  • Add a GitHub Star to the project.
  • Tweet about the Beerus.
  • Write interesting articles about the project on Dev.to, Medium or your personal blog.

Together, we can make Beerus better!

Contributing

First off, thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Security

Beerus follows good practices of security, but 100% security cannot be assured. Beerus is provided "as is" without any warranty. Use at your own risk.

_For more information and to report security issues, please refer to our security documentation.

Acknowledgements

  • Huge props to A16z for their work on helios.

Contributors

The contributors page.

Thanks goes to these wonderful people (emoji key):

Abdel @ StarkWare
Abdel @ StarkWare

⚠️ 💻
Lucas @ StarkWare
Lucas @ StarkWare

💻
danilowhk
danilowhk

💻
Clément Walter
Clément Walter

💻
Elias Tazartes
Elias Tazartes

💻
drspacemn
drspacemn

💻
Mathieu
Mathieu

💻
TurcFort07
TurcFort07

📖
Florian Bellotti
Florian Bellotti

💻
Tom Brand
Tom Brand

💻
ftupas
ftupas

💻
pscott
pscott

💻
Robin Straub
Robin Straub

💻
Francisco Krause Arnim
Francisco Krause Arnim

📖
joshualyguessennd
joshualyguessennd

📖
Santiago Galván (Dub)
Santiago Galván (Dub)

💻
chirag-bgh
chirag-bgh

💻
greged93
greged93

💻
bigherc18
bigherc18

💻
Lakhdar Slaim
Lakhdar Slaim

💻
Lance N. Davis
Lance N. Davis

💻
Tino Huynh
Tino Huynh

💻
Iris
Iris

💻
Alex Ponce
Alex Ponce

💻
glihm
glihm

💻
Paul-Henry Kajfasz
Paul-Henry Kajfasz

💻
Damián Piñones
Damián Piñones

💻
Betacodd
Betacodd

💻
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

awesome-starknet

A curated list of awesome StarkNet resources, libraries, tools and more
1,498
star
2

madara

DEPRECATED in favor of https://github.com/madara-alliance/madara
Rust
533
star
3

garaga

State-of-the-art Elliptic Curve operations and SNARKS verification for Cairo & Starknet 🐺.
Cairo
171
star
4

unruggable.meme

☣️ A framework for building safer memecoins 💸
Cairo
134
star
5

satoru

Synthetics platform for Starknet, inspired by GMX v2 design.
Cairo
110
star
6

quaireaux

A set of opinionated Cairo 1.0 libraries and algorithms.
Cairo
81
star
7

ziggy-starkdust

⚡ Cairo VM in Zig ⚡
Zig
77
star
8

joyboy

Decentralized social built with Nostr and powered by Starknet account abstraction.
TypeScript
67
star
9

shenlong

Shenlong is a blazingly fast ⚡ tool to generate LLVM IR from Cairo, written in Rust 🦀
Rust
64
star
10

abi-wan-kanabi

Abi parser for Cairo smart contracts, based on wagmi abitype
TypeScript
59
star
11

snos

Rust Library for running the Starknet OS via the Cairo VM
Rust
54
star
12

bonsai-trie

A storage system inspired by Besu using Starknet Merkle Trees
Rust
51
star
13

raito

Bitcoin ZK client written in Cairo.
Cairo
39
star
14

piltover

Starknet Core Contract components in Cairo.
Rust
26
star
15

rosettanet

Ethereum <> Starknet RPC middleware.
TypeScript
26
star
16

poseidon-rs

Poseidon Rust library
Rust
25
star
17

gomu-gomu-no-gatling

Blazing fast tool to benchmark Starknet sequencers 🦀
Rust
21
star
18

madara-tsukuyomi

Madara Desktop Application
TypeScript
20
star
19

starknet-phone

Mobile OS built for Starknet
Kotlin
19
star
20

madara-infra

Infrastructure related stuff for Madara.
Shell
16
star
21

bifrost

Example of an ERC20 bridge for tokens minted on StarkNet layer 2
Solidity
13
star
22

madara-docs

MDX
12
star
23

zaun

Solidity contracts for the Starknet Decentralized Protocol proposal
Rust
12
star
24

nori

RPC request router and proxy for Starknet, forked from Optimism proxyd.
Go
10
star
25

agentstark

Giza agents run provable ML models and act autonomously on Starknet using native Account Abstraction
Cairo
6
star
26

madara-app

Madara Kit is a simple app to interact with Starknet Appchains.
TypeScript
6
star
27

awesome-slinks

Unofficial community curated list of Slinks.
5
star
28

gitcoin-allo-starknet

Gitcoin Allo protocol for Starknet 🐺
Cairo
5
star
29

heimdall

Heimdall is the guardian of our best practices
Rust
4
star
30

madara-app-chain-template

Rust
4
star
31

backlog

Keep Starknet Strange projects backlog and ideas
3
star
32

fc-frames-starknet

Starknet x Warpcast
3
star
33

madara-website

Madara website.
JavaScript
2
star
34

edo-tensei

Edo Tensei is an experiment to build a combination of optimization techniques for Starknet storage layout, inspired by Bonsai storage model developed in Besu Ethereum execution client.
Rust
2
star
35

starknet-foundry-compatibility-tests

A standalone github action for testing Starknet RPC compatibility with Starknet Foundry - Cast
Shell
2
star
36

starkton

TON on Starknet
2
star
37

tsubasa-website

Website for Tsubasa Starknet.
JavaScript
1
star
38

madara-swap

Madara Swap
TypeScript
1
star
39

do-it-onchain-with-cairo

Showcase of heavy computation enabled by the Cairo VM on Starknet.
1
star