pyrevm Blazing-fast Python bindings to revm

Related tags

Command-line pyrevm
Overview

pyrevm

Blazing-fast Python bindings to revm

py rust

Quickstart

make install
make test

Example Usage

Here we show how you can fork from Ethereum mainnet and simulate a transaction from vitalik.eth.

from pyrevm import *

address = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" # vitalik.eth
address2 = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"

fork_url = "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27"

# set up an evm
evm = EVM(
    # can fork from a remote node
    fork_url=fork_url, 
    # can set tracing to true/false
    tracing = True, 
    # can configure the environment
    env = Env(
        block = BlockEnv( timestamp = 100
    ))
);

vb_before = evm.basic(address)
assert vb_before != 0

# Execute the tx
evm.call_raw_committing(
    caller = address,
    to = address2,
    value = 10000
    # data
);

assert vb_before != evm.basic(address)
assert evm.basic(address2).balance == 10000

Develop

We use Poetry for virtual environment management and Maturin as our Rust <> Python FFI build system. The Rust bindings are auto-generated from the macros provided by PyO3.

To build the library, run poetry run maturin develop

Note: If building for production, do not forget the --release flag, else performance will be degraded.

Benchmarks

TODO

You might also like...
⚡ Blazing ⚡ fast ⚡ compiler for Cairo, written in 🦀 Rust 🦀

Cairo 1.0 🐺 ⚡ Blazing ⚡ fast ⚡ compiler for Cairo, written in 🦀 Rust 🦀 Report a Bug - Request a Feature - Ask a Question Getting Started Prerequisi

Blazing-fast and yet Sleuth cameraman to www*  😎⚡✨
Blazing-fast and yet Sleuth cameraman to www* 😎⚡✨

Haylxon 🔥 🦀 SHOOT BEFORE THE BLINK || Haylxon, A tool embodying the K1SS philosophy that allows you to take screenshots of webpages/URLs at lightnin

⚡️Blazing Fast⚡️ CLI tool to get Bible verses with Rust 🦀

bible.rs This is a simple command line tool that accesses bible-api.com to print Bible verses in the terminal Installation brew install wzid/tap/bible

Blazing fast tool to benchmark Starknet sequencers 🦀

Gomu Gomu no Gatling Blazing fast tool to benchmark Starknet sequencers 🦀 . Installation From source git clone https://github.com/keep-starknet-stran

⚡️ Blazing fast terminal file manager written in Rust, based on async I/O.

Yazi - ⚡️ Blazing Fast Terminal File Manager Yazi ("duck" in Chinese) is a terminal file manager written in Rust, based on non-blocking async I/O. It

Minimal, blazing fast Node.js script runner

nrr Minimal, blazing fast Node.js script runner. Why? nrr initializes and resolves scripts way faster than package managers. It achieves this by provi

Rust Imaging Library's Python binding: A performant and high-level image processing library for Python written in Rust

ril-py Rust Imaging Library for Python: Python bindings for ril, a performant and high-level image processing library written in Rust. What's this? Th

Songbird bindings for python

Songbird-Py Songbird bindings for python. The goal is to provide an easy to use alternitive to Lavalink. Its written with rust-bindings to Songbird. S

Python bindings for decancer.

decancer_py Python bindings for decancer. Installation You can get started with decancer_py by installing from PyPI: pip install -U decancer-py Usage

Comments
  • Add `snailtracer` benchmark

    Add `snailtracer` benchmark

    Note: this PR includes #1 cuz it made it easier

    Did some benchmarking using snailtracer -- results are pretty good IMO:

    ~50ms using revm, ~113ms using pyrevm, eh not bad. I expected it to be a bit closer, but I imagine a good portion of this is Python FFI overhead. Haven't dug into it too much.

    This isn't a perfect apples-to-apples comparison, the revm benchmark modifies the transaction context before starting the benchmark, this benchmark constructions the environment during the benchmark. With a little more effort we could probably remove any additional overhead due to that, but I don't think it's that big of a deal.


    Baseline results using the snailtracer benchmark from revm:

    Hello, world!
    elapsed: 49.963531ms
    0: 63.562866ms
    1: 61.138572ms
    2: 55.771676ms
    3: 49.228193ms
    4: 49.100465ms
    5: 48.995046ms
    6: 48.847959ms
    7: 48.743462ms
    8: 48.731132ms
    9: 48.718941ms
    10: 48.71229ms
    11: 48.696701ms
    12: 48.694723ms
    13: 48.671922ms
    14: 48.65721ms
    15: 48.611618ms
    16: 48.610157ms
    17: 48.547279ms
    18: 48.50588ms
    19: 48.456446ms
    20: 48.451354ms
    21: 48.449931ms
    22: 48.373144ms
    23: 48.316536ms
    24: 48.315507ms
    end!
    

    Results from this benchmark:

             21 function calls in 1.135 seconds
    
       Ordered by: cumulative time
    
       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
           10    0.000    0.000    1.135    0.113 /home/ziyadedher/code/eth/pyrevm/bench/snailtracer/snailtracer.py:39(bench)
           10    1.135    0.113    1.135    0.113 {method 'call_raw' of 'builtins.EVM' objects}
            1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
    
    opened by ziyadedher 9
  • Introduce Python type stubs for the bindings

    Introduce Python type stubs for the bindings

    I wish PyO3 had automatic type stub generation but alas, not quite yet: https://github.com/PyO3/pyo3/issues/2454

    This PR introduces some manually-written types. Gonna need to keep types manually up to date if the underlying Rust changes, though, which might be annoying.

    Maturin should automatically pick up the type bindings at build time: https://maturin.rs/project_layout.html#adding-python-type-information

    opened by ziyadedher 0
Owner
Georgios Konstantopoulos
cto & research partner at paradigm.xyz. mev, layer 2, proof of stake, zkps. we're hiring engineers internally & for the portfolio: georgios at paradigm dot xyz
Georgios Konstantopoulos
🚀 Blazing fast and Powerful Discord Token Grabber, no popo made with python

Rusty-Grabber ?? a blazing fast Discord Token Grabber, no popo made with python Fastest Token Grabber ever : Rusty-Grabber> time ./target/release/grab

bishop 5 Sep 1, 2023
PyO3 bindings and Python interface to skani, a method for fast fast genomic identity calculation using sparse chaining.

?? ⛓️ ?? Pyskani PyO3 bindings and Python interface to skani, a method for fast fast genomic identity calculation using sparse chaining. ??️ Overview

Martin Larralde 13 Mar 21, 2023
zoxide is a blazing fast replacement for your cd command

zoxide A smarter cd command for your terminal zoxide is a blazing fast replacement for your cd command, inspired by z and z.lua. It keeps track of the

Ajeet D'Souza 8.7k Dec 31, 2022
⚡️ A blazing fast way of maintaining powerful notes with connections between them.

Zettl ⚡️ A blazing fast way of maintaining powerful notes with connections between them. Installing Zettl To install Zettl, you will need the Rust too

Tirth Jain 26 Dec 2, 2022
☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell

☄??️ The minimal, blazing-fast, and infinitely customizable prompt for any shell

Starship Command 31.6k Dec 30, 2022
A blazing fast command line license generator for your open source projects written in Rust🚀

Overview This is a blazing fast ⚡ , command line license generator for your open source projects written in Rust. I know that GitHub

Shoubhit Dash 43 Dec 30, 2022
⚡ A Blazing fast alternative to the stock windows folder delete function!

Turbo Delete A blazing fast alternative to the default Windows delete. Turbodelete is a blazing fast alternative to the default Windows delete functio

Tejas Ravishankar 165 Dec 4, 2022
A blazing fast and easy to use TRPC-like server for Rust.

rspc ?? Work in progress ?? A blazing fast and easy to use TRPC-like server for Rust. Website Example You define a trpc router and attach resolvers to

Oscar Beaumont 344 Dec 31, 2022
Minimal and blazing-fast file server. For real, this time.

Zy Minimal and blazing-fast file server. For real, this time. Features Single Page Application support Partial responses (Range support) Cross-Origin

Miraculous Owonubi 17 Dec 18, 2022
Starkli (/ˈstɑːrklaɪ/), a ⚡ blazing ⚡ fast ⚡ CLI tool for StarkNet powered by 🦀 starknet-rs 🦀

starkli Starkli (/ˈstɑːrklaɪ/), a ⚡ blazing ⚡ fast ⚡ CLI tool for StarkNet powered by ?? starknet-rs ?? Installation The package will be published to

Jonathan LEI 26 Dec 5, 2022