Skip to content

Commit

Permalink
feat: Introduce ByteCode format, Update Readme (#156)
Browse files Browse the repository at this point in the history
* Bytecode wip

* bytecode wip2

* Bytecode analysis cleanup

* Optimizations

* cleanup

* fmt, clippy

* comments

* serde

* tests

* Added MergeSpec and merge eth/tests

* fmt

* README updated. bytecode review requests
  • Loading branch information
rakita authored Aug 1, 2022
1 parent 54460fa commit 186b20d
Show file tree
Hide file tree
Showing 28 changed files with 660 additions and 423 deletions.
90 changes: 45 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
# revm - Revolutionary Machine
# revm - Rust Ethereum Virtual Machine

Is **Rust Ethereum Virtual Machine** with great name that is focused on **speed** and **simplicity**. It gets ispiration from `SputnikVM` (got opcodes/interp from here), `OpenEthereum` and `Geth` with a help from [wolflo/evm-opcodes](https://github.com/wolflo/evm-opcodes).

It is fast and flexible implementation of EVM with simple interface and embedded Host, there are multiple things done on Host part from const EVM Spec to optimistic changelogs for subroutines to merging `eip2929` in EVM state so that it can be accesses only once that are improving the speed of execution. There are still some improvements on Interpreter part that needs to be done so that we can be comparable with evmone, for more info track [this issue](https://github.com/bluealloy/revm/issues/7).
Is EVM written in rust that is focused on **speed** and **simplicity**. It has fast and flexible implementation with simple interface and embedded Host. It is passing all `ethereum/tests` test suits

Here is list of things that i would like to use as guide in this project:
- **EVM compatibility and stability** - this goes without saying but it is nice to put it here. In blockchain industry, stability is most desired attribute of any system.
- **Speed** - is one of the most important things and most decision are made to complement this.
- **Simplicity** - simplification of internals so that it can be easily understood and extended, and interface that can be easily used or integrated into other project.
- **interfacing** - `[no_std]` so that it can be used as wasm lib and integrate with JavaScript and cpp binding if needed.

Read more on REVM here [crates/revm/README.md](crates/revm/README.md)
# Project structure

* crates
* revm -> main EVM library
* revm_precompiles -> EVM precompiles are standalone
* revmjs -> Binding for js. (in not finished state)
* bins:
* revme: cli binary, used for running state test json
* revm-test: test binaries with contracts, used mostly to checke performance (will proably merge it inside revme).
# Running eth tests

go to `cd bins/revme/`

Download eth tests from (this will take some time): `git clone https://github.com/ethereum/tests`

run tests with command: `cargo run --release -- statetest tests/GeneralStateTests/`

`GeneralStateTests` contains all tests related to EVM.

# Used by

* Foundry: https://github.com/foundry-rs/foundry

(If you want to add your project to the list, ping me or open the PR)


# Contact

There is public telegram group: https://t.me/+Ig4WDWOzikA3MzA0

Or you can contact me directly on email: dragan0rakita@gmail.com


For executable binary that contains `debuger`, `statetest` for running eth/tests, and `runner` check REVME at [bin/revme/README.md](bins/revme/README.md)
4 changes: 4 additions & 0 deletions bins/revm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ bytes = "1.1"
hex = "0.4"
primitive-types = { version = "0.11", features = ["rlp"] }
revm = { path = "../../crates/revm", version="1.3" }


[[bin]]
name = "analysis"
59 changes: 59 additions & 0 deletions bins/revm-test/src/bin/analysis.rs

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions bins/revm-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{str::FromStr, time::Instant};

use bytes::Bytes;
use primitive_types::H160;
use revm::{db::BenchmarkDB, TransactTo};
use revm::{db::BenchmarkDB, Bytecode, TransactTo};

extern crate alloc;

Expand All @@ -11,7 +11,7 @@ pub fn simple_example() {

// BenchmarkDB is dummy state that implements Database trait.
let mut evm = revm::new();
evm.database(BenchmarkDB(contract_data));
evm.database(BenchmarkDB::new_bytecode(Bytecode::new_raw(contract_data)));

// execution globals block hash/gas_limit/coinbase/timestamp..
evm.env.tx.caller = H160::from_str("0x1000000000000000000000000000000000000000").unwrap();
Expand All @@ -29,7 +29,9 @@ pub fn simple_example() {
elapsed += i;
}
println!("elapsed: {:?}", elapsed / 30);
for (i, time) in times.iter().enumerate() {
let mut times = times[5..].to_vec();
times.sort();
for (i, time) in times.iter().rev().enumerate() {
println!("{}: {:?}", i, time);
}
}
Expand Down
Loading

0 comments on commit 186b20d

Please sign in to comment.