Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ repository = "https://github.com/bluealloy/revm"
version = "2.0.3"

[dependencies]
revm-primitives = { path = "../primitives", version="1.1.2", default-features = false }
revm-primitives = { path = "../primitives", version = "1.1.2", default-features = false }
bn = { package = "substrate-bn", version = "0.6", default-features = false }
k256 = { version = "0.13", default-features = false, features = ["ecdsa"] }
num = { version = "0.4.0", default-features = false, features = ["alloc"] }
once_cell = "1.17"
once_cell = { version = "1.17", default-features = false, features = ["alloc"] }
ripemd = { version = "0.1", default-features = false }
secp256k1 = { version = "0.27.0", default-features = false, features = ["alloc", "recovery"], optional = true }
secp256k1 = { version = "0.27.0", default-features = false, features = [
"alloc",
"recovery",
], optional = true }
sha2 = { version = "0.10.5", default-features = false }
sha3 = { version = "0.10.7", default-features = false }

Expand All @@ -28,4 +31,3 @@ default = ["secp256k1"]
# Only problem that it has, it fails to build for wasm target on windows and mac as it is c lib.
# If you dont require wasm on win/mac, i would recommend its usage.
secp256k1 = ["dep:secp256k1"]

20 changes: 10 additions & 10 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod identity;
mod modexp;
mod secp256k1;

use once_cell::sync::OnceCell;
use once_cell::race::OnceBox;
pub use primitives::{
precompile::{PrecompileError as Error, *},
Bytes, HashMap,
Expand All @@ -21,7 +21,7 @@ pub use revm_primitives as primitives;
pub type B160 = [u8; 20];
pub type B256 = [u8; 32];

use alloc::vec::Vec;
use alloc::{boxed::Box, vec::Vec};
use core::fmt;

pub fn calc_linear_cost_u32(len: usize, base: u64, word: u64) -> u64 {
Expand Down Expand Up @@ -119,7 +119,7 @@ impl SpecId {

impl Precompiles {
pub fn homestead() -> &'static Self {
static INSTANCE: OnceCell<Precompiles> = OnceCell::new();
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let fun = [
secp256k1::ECRECOVER,
Expand All @@ -130,14 +130,14 @@ impl Precompiles {
.into_iter()
.map(From::from)
.collect();
Self { fun }
Box::new(Self { fun })
})
}

pub fn byzantium() -> &'static Self {
static INSTANCE: OnceCell<Precompiles> = OnceCell::new();
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let mut precompiles = Self::homestead().clone();
let mut precompiles = Box::new(Self::homestead().clone());
precompiles.fun.extend(
[
// EIP-196: Precompiled contracts for addition and scalar multiplication on the elliptic curve alt_bn128.
Expand All @@ -156,9 +156,9 @@ impl Precompiles {
}

pub fn istanbul() -> &'static Self {
static INSTANCE: OnceCell<Precompiles> = OnceCell::new();
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let mut precompiles = Self::byzantium().clone();
let mut precompiles = Box::new(Self::byzantium().clone());
precompiles.fun.extend(
[
// EIP-152: Add BLAKE2 compression function `F` precompile.
Expand All @@ -176,9 +176,9 @@ impl Precompiles {
}

pub fn berlin() -> &'static Self {
static INSTANCE: OnceCell<Precompiles> = OnceCell::new();
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let mut precompiles = Self::istanbul().clone();
let mut precompiles = Box::new(Self::istanbul().clone());
precompiles.fun.extend(
[
// EIP-2565: ModExp Gas Cost.
Expand Down
17 changes: 13 additions & 4 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ bytes = { version = "1.4", default-features = false }
hashbrown = "0.14"
primitive-types = { version = "0.12", default-features = false }
rlp = { version = "0.5", default-features = false } # used for create2 address calculation
ruint = { version = "1.8.0", features = ["primitive-types", "rlp"] }
ruint = { version = "1.8.0", default-features = false, features = [
"primitive-types",
"rlp",
] }
auto_impl = "1.1"
bitvec = { version = "1", default-features = false, features = ["alloc"] }
bitflags = { version = "2.4.0", default-features = false }

# bits B256 B160 crate
fixed-hash = { version = "0.8", default-features = false, features = ["rustc-hex"] }
fixed-hash = { version = "0.8", default-features = false, features = [
"rustc-hex",
] }

#utility
hex-literal = "0.4"
hex = { version = "0.4", default-features = false, features = ["alloc"] }
to-binary = "0.4"
derive_more = "0.99"
enumn = "0.1"

Expand All @@ -42,7 +46,12 @@ proptest-derive = { version = "0.4", optional = true }
arbitrary = { version = "1.3", features = ["derive"] }
proptest = "1.1"
proptest-derive = "0.4"
ruint = { version = "1.10.1", features = ["primitive-types", "rlp", "proptest", "arbitrary"] }
ruint = { version = "1.10.1", features = [
"primitive-types",
"rlp",
"proptest",
"arbitrary",
] }

[features]
default = ["std"]
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use bitvec::prelude::{bitvec, Lsb0};
use bitvec::vec::BitVec;
use bytes::Bytes;
use core::fmt::Debug;
use to_binary::BinaryString;

/// A map of valid `jump` destinations.
#[derive(Clone, Eq, PartialEq, Default)]
Expand All @@ -14,7 +13,7 @@ pub struct JumpMap(pub Arc<BitVec<u8>>);
impl Debug for JumpMap {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("JumpMap")
.field("map", &BinaryString::from(self.0.as_raw_slice()))
.field("map", &hex::encode(self.0.as_raw_slice()))
.finish()
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub use bytes;
pub use bytes::Bytes;
pub use hex;
pub use hex_literal;
pub use to_binary;
/// Address type is last 20 bytes of hash of ethereum account
pub type Address = B160;
/// Hash, in Ethereum usually keccak256.
Expand Down
8 changes: 5 additions & 3 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ revm-interpreter = { path = "../interpreter", version = "1.1.2", default-feature

#misc
auto_impl = { version = "1.1", default-features = false }
once_cell = { version = "1.17", default-features = false }

# Optional
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
serde_json = { version = "1.0", features = ["preserve_order"], optional = true }

# ethersdb
tokio = { version = "1.32", features = ["rt-multi-thread", "macros"], optional = true }
tokio = { version = "1.32", features = [
"rt-multi-thread",
"macros",
], optional = true }
ethers-providers = { version = "2.0", optional = true }
ethers-core = { version = "2.0", optional = true }
futures = { version = "0.3.27", optional = true }
Expand Down Expand Up @@ -56,7 +58,7 @@ optional_block_gas_limit = ["revm-interpreter/optional_block_gas_limit"]
optional_eip3607 = ["revm-interpreter/optional_eip3607"]
optional_gas_refund = ["revm-interpreter/optional_gas_refund"]
optional_no_base_fee = ["revm-interpreter/optional_no_base_fee"]
std = ["revm-interpreter/std", "once_cell/std", "rayon"]
std = ["revm-interpreter/std", "rayon"]
ethersdb = ["std", "tokio", "futures", "ethers-providers", "ethers-core"]
serde = ["dep:serde", "dep:serde_json", "revm-interpreter/serde"]
arbitrary = ["revm-interpreter/arbitrary"]
Expand Down