Skip to content

Commit

Permalink
wip wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Oct 30, 2021
1 parent 20ac70b commit 4a1e00b
Show file tree
Hide file tree
Showing 29 changed files with 322 additions and 103 deletions.
120 changes: 116 additions & 4 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@


[workspace]
resolver = "2"
members = [
"crates/*",
"bins/*",
]
default-members = ["crates/revm"]
default-members = ["crates/revm"]
1 change: 1 addition & 0 deletions bins/revm-ethereum-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ sha3 = {version = "0.9", default-features = false}
thiserror = "1.0"
triehash = "0.8"
walkdir = "2.3"
hashbrown = "0.11"
2 changes: 1 addition & 1 deletion bins/revm-ethereum-tests/src/merkle_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rlp::RlpStream;
use sha3::{Digest, Keccak256};

use revm::AccountInfo;
use std::collections::HashMap as Map;
use hashbrown::HashMap as Map;

pub fn merkle_trie_root(
accounts: &Map<H160, AccountInfo>,
Expand Down
5 changes: 3 additions & 2 deletions bins/revm-ethereum-tests/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ pub fn execute_test_suit(
if path.file_name() == Some(OsStr::new("CALLBlake2f_MaxRounds.json")) {
return Ok(());
}
//*/
// */

let json_reader = std::fs::read(&path).unwrap();
let suit: TestSuit = serde_json::from_reader(&*json_reader)?;
let skip_test_unit: HashSet<_> = vec![
Expand Down Expand Up @@ -251,7 +252,7 @@ pub fn run<INSP: 'static + Inspector + Clone + Send>(test_files: Vec<PathBuf>, i
let mut joins = Vec::new();
let queue = Arc::new(Mutex::new((0, test_files)));
let elapsed = Arc::new(Mutex::new(std::time::Duration::ZERO));
for _ in 0..10 {
for _ in 0..1 {
let queue = queue.clone();
let endjob = endjob.clone();
let console_bar = console_bar.clone();
Expand Down
8 changes: 7 additions & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ primitive-types = {version = "0.10", features = ["rlp"]}
revm_precompiles = {path = "../revm_precompiles", version="0.1"}
rlp = {version = "0.5", default-features = false}#used for create2 address calculation
sha3 = {version = "0.9", default-features = false}
auto_impl = "0.4"
auto_impl = {version="0.4", git="https://github.com/dimpolo/auto_impl.git", rev="61874ef"}
hashbrown = "0.11"

[dev-dependencies]
hex = "0.4"


[features]
default = ["std"]
std = ["bytes/std","num_enum/std","primitive-types/std", "sha3/std","rlp/std"]
7 changes: 3 additions & 4 deletions crates/revm/src/db/db.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{collection::Map, Account};
use crate::Account;
use hashbrown::HashMap as Map;

use primitive_types::{H160, H256, U256};

Expand Down Expand Up @@ -47,9 +48,7 @@ pub struct RefDBWrapper<'a> {

impl<'a> RefDBWrapper<'a> {
pub fn new(db: &'a dyn DatabaseRef) -> Self {
Self {
db
}
Self { db }
}
}

Expand Down
4 changes: 3 additions & 1 deletion crates/revm/src/db/dummy_db_impl.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::{
collection::{vec::Vec, Entry, Map},
subroutine::Filth,
Database, KECCAK_EMPTY,
};

use alloc::vec::Vec;
use hashbrown::{HashMap as Map, hash_map::Entry};

use primitive_types::{H160, H256, U256};

use crate::{Account, AccountInfo, Log};
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::collection::Cow;
use alloc::borrow::Cow;
use revm_precompiles::ExitError as PrecompileError;

/// Exit reason.
Expand Down
1 change: 1 addition & 0 deletions crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
BerlinSpec, ByzantineSpec, Env, Inspector, IstanbulSpec, LatestSpec, LondonSpec, NoOpInspector,
Spec, SpecId, TransactOut,
};
use alloc::boxed::Box;
use revm_precompiles::Precompiles;
/// Struct that takes Database and enabled transact to update state dirrectly to database.
/// additionaly it allows user to set all environment parameters.
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use core::{cmp::min, marker::PhantomData};
use primitive_types::{H160, H256, U256};
use sha3::{Digest, Keccak256};

use alloc::vec::Vec;
use hashbrown::HashMap as Map;
use crate::{
collection::{vec::Vec, Map},
db::Database,
error::{ExitError, ExitReason, ExitSucceed},
machine,
Expand Down
32 changes: 10 additions & 22 deletions crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(dead_code)]
//#![forbid(unsafe_code, unused_variables, unused_imports)]
//#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]

mod db;
mod error;
Expand All @@ -16,7 +16,7 @@ mod util;

use evm_impl::Handler;

pub use db::{DatabaseCommit, Database, DummyStateDB};
pub use db::{Database, DatabaseCommit, DummyStateDB};
pub use error::*;
pub use evm::{new, EVM};
pub use inspector::{Inspector, NoOpInspector};
Expand All @@ -27,23 +27,11 @@ pub use spec::*;
pub use subroutine::Account;

/// libraries for no_std flag
#[cfg(no_std)]
pub mod collection {
extern crate alloc;
pub use alloc::{
borrow::{Borrow, Cow},
collections::{btree_map::Entry, BTreeMap as Map},
vec,
vec::Vec,
};
}

#[cfg(not(no_std))]
pub mod collection {
pub use std::{
borrow::{Cow, Cow::Borrowed},
collections::{hash_map::Entry, HashMap as Map},
vec,
vec::Vec,
};
}
//#[cfg(no_std)]
extern crate alloc;
pub use alloc::{
borrow::{Borrow, Cow},
collections::{btree_map::Entry, BTreeMap as Map},
vec,
vec::Vec,
};
2 changes: 1 addition & 1 deletion crates/revm/src/machine/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{collection::vec::Vec, CallContext, ExitError, ExitReason, ExitSucceed};
use crate::{alloc::vec::Vec, CallContext, ExitError, ExitReason, ExitSucceed};
use bytes::Bytes;
use primitive_types::{H160, U256};

Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/machine/machine.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{collection::vec::Vec, opcode::eval, ExitError};
use crate::{alloc::vec::Vec, opcode::eval, ExitError};
use bytes::Bytes;
use core::{cmp::max, ops::Range};
use primitive_types::U256;
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/machine/memory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
collection::vec::Vec,
alloc::vec::Vec,
error::{ExitError, ExitFatal},
};
use bytes::Bytes;
Expand Down
Loading

0 comments on commit 4a1e00b

Please sign in to comment.