Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restructure Part2 database crate #1784

Merged
merged 5 commits into from
Sep 18, 2024
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
29 changes: 26 additions & 3 deletions Cargo.lock

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

29 changes: 26 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,55 @@
[workspace]
resolver = "2"
default-members = ["crates/revm"]
members = [
# binary
"bins/revme",

# libraries
"crates/revm",
"crates/primitives",
"crates/interpreter",
"crates/precompile",
"crates/optimism",
"crates/database",
"crates/database/interface",
"crates/bytecode",
"crates/state",
"crates/wiring",
"crates/specification",

# examples
#"examples/block_traces",
#"examples/contract_deployment",
#"examples/custom_opcodes",
#"examples/database_components",
#"examples/database_ref",
#"examples/uniswap_get_reserves",
#"examples/uniswap_v2_usdc_swap",
]
resolver = "2"
default-members = ["crates/revm"]

[workspace.dependencies]
# revm
primitives = { path = "crates/primitives", package = "revm-primitives", version = "9.0.1", default-features = false }
bytecode = { path = "crates/bytecode", package = "revm-bytecode", version = "1.0.0", default-features = false }
database = { path = "crates/database", package = "revm-database", version = "1.0.0", default-features = false }
database-interface = { path = "crates/database/interface", package = "revm-database-interface", version = "1.0.0", default-features = false }
specification = { path = "crates/specification", package = "revm-specification", version = "1.0.0", default-features = false }
state = { path = "crates/state", package = "revm-state", version = "1.0.0", default-features = false }
wiring = { path = "crates/wiring", package = "revm-wiring", version = "1.0.0", default-features = false }
revm = { path = "crates/revm", version = "14.0.1", default-features = false }
interpreter = { path = "crates/interpreter", package = "revm-interpreter", version = "10.0.1", default-features = false }
precompile = { path = "crates/precompile", package = "revm-precompile", version = "11.0.1", default-features = false }
# misc

[workspace.package]
license = "MIT"
authors = ["Dragan Rakita <[email protected]>"]
categories = ["no-std", "compilers", "cryptography::cryptocurrencies"]
keywords = ["revm", "evm", "ethereum", "blockchain", "no_std"]
repository = "https://github.com/bluealloy/revm"
documentation = "https://bluealloy.github.io/revm/"
homepage = ""
edition = "2021"

[workspace.metadata.docs.rs]
all-features = true
Expand Down
11 changes: 6 additions & 5 deletions bins/revme/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
authors = ["Dragan Rakita <[email protected]>"]
edition = "2021"
name = "revme"
keywords = ["ethereum", "evm"]
license = "MIT"
repository = "https://github.com/bluealloy/revm"
description = "Rust Ethereum Virtual Machine Executable"
version = "0.10.1"
authors.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
database.workspace = true
# revm
revm = { workspace = true, features = [
"std",
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/analysis.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use database::{BenchmarkDB, EthereumBenchmarkWiring};
use revm::{
bytecode::Bytecode,
db::{BenchmarkDB, EthereumBenchmarkWiring},
interpreter::analysis::to_analysed,
primitives::{address, bytes, Bytes, TxKind},
Evm,
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/burntpix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use static_data::{

use alloy_sol_macro::sol;
use alloy_sol_types::SolCall;
use database::CacheDB;
use revm::{
database_interface::EmptyDB,
db::CacheDB,
primitives::{address, hex, keccak256, Address, Bytes, TxKind, B256, U256},
state::{AccountInfo, Bytecode},
wiring::{
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/snailtracer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use database::{BenchmarkDB, EthereumBenchmarkWiring};
use revm::{
bytecode::Bytecode,
db::{BenchmarkDB, EthereumBenchmarkWiring},
interpreter::analysis::to_analysed,
primitives::{address, bytes, Bytes, TxKind},
Evm,
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use database::{BenchmarkDB, EthereumBenchmarkWiring};
use revm::{
bytecode::Bytecode,
db::{BenchmarkDB, EthereumBenchmarkWiring},
primitives::{TxKind, U256},
Evm,
};
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/evmrunner.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::Parser;
use database::BenchmarkDB;
use revm::{
bytecode::{Bytecode, BytecodeDecodeError},
db::BenchmarkDB,
inspector_handle_register,
inspectors::TracerEip3155,
primitives::{address, Address, TxKind},
Expand Down
6 changes: 2 additions & 4 deletions bins/revme/src/cmd/statetest/merkle_trie.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use alloy_rlp::{RlpEncodable, RlpMaxEncodedLen};
use database::PlainAccount;
use hash_db::Hasher;
use plain_hasher::PlainHasher;
use revm::{
db::PlainAccount,
primitives::{keccak256, Address, Log, B256, U256},
};
use revm::primitives::{keccak256, Address, Log, B256, U256};
use triehash::sec_trie_root;

pub fn log_rlp_hash(logs: &[Log]) -> B256 {
Expand Down
8 changes: 4 additions & 4 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use super::{
models::{SpecName, Test, TestSuite},
utils::recover_address,
};
use database::State;
use indicatif::{ProgressBar, ProgressDrawTarget};
use revm::{
bytecode::Bytecode,
database_interface::EmptyDB,
db::State,
inspector_handle_register,
inspectors::TracerEip3155,
interpreter::analysis::to_analysed,
Expand Down Expand Up @@ -276,7 +276,7 @@ pub fn execute_test_suite(

for (name, unit) in suite.0 {
// Create database and insert cache
let mut cache_state = revm::CacheState::new(false);
let mut cache_state = database::CacheState::new(false);
for (address, info) in unit.pre {
let code_hash = keccak256(&info.code);
let bytecode = to_analysed(Bytecode::new_raw(info.code));
Expand Down Expand Up @@ -391,7 +391,7 @@ pub fn execute_test_suite(

let mut cache = cache_state.clone();
cache.set_state_clear_flag(SpecId::enabled(spec_id, SpecId::SPURIOUS_DRAGON));
let mut state = revm::db::State::builder()
let mut state = database::State::builder()
.with_cached_prestate(cache)
.with_bundle_update()
.build();
Expand Down Expand Up @@ -460,7 +460,7 @@ pub fn execute_test_suite(
// re build to run with tracing
let mut cache = cache_state.clone();
cache.set_state_clear_flag(SpecId::enabled(spec_id, SpecId::SPURIOUS_DRAGON));
let mut state = revm::db::State::builder()
let mut state = database::State::builder()
.with_cached_prestate(cache)
.with_bundle_update()
.build();
Expand Down
14 changes: 7 additions & 7 deletions crates/bytecode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
authors = ["Dragan Rakita <[email protected]>"]
description = "Revm Database interface"
edition = "2021"
keywords = ["ethereum", "evm", "revm", "no_std"]
license = "MIT"
name = "revm-bytecode"
repository = "https://github.com/bluealloy/revm"
description = "Revm Database interface"
version = "1.0.0"
readme = "../../README.md"
authors.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true

[package.metadata.docs.rs]
all-features = true
Expand Down
Empty file added crates/database/CHANGELOG.md
Empty file.
67 changes: 67 additions & 0 deletions crates/database/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[package]
name = "revm-database"
description = "Revm Database implementations"
version = "1.0.0"
authors.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unreachable_pub = "warn"
unused_must_use = "deny"
rust_2018_idioms = "deny"

[lints.rustdoc]
all = "warn"

[dependencies]
state.workspace = true
primitives.workspace = true
database-interface.workspace = true
wiring.workspace = true
bytecode.workspace = true

auto_impl = "1.2"

# Optional
serde = { version = "1.0", default-features = false, features = [
"derive",
"rc",
], optional = true }

# alloydb
tokio = { version = "1.40", features = [
"rt-multi-thread",
"macros",
], optional = true }
alloy-provider = { version = "0.3", optional = true, default-features = false }
alloy-eips = { version = "0.3", optional = true, default-features = false }
alloy-transport = { version = "0.3", optional = true, default-features = false }


[dev-dependencies]
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
anyhow = "1.0.83"
criterion = "0.5"
indicatif = "0.17"
rstest = "0.22.0"
alloy-sol-types = "0.8"

[features]
default = ["std"]
std = ["serde?/std"]
serde = ["dep:serde"]
alloydb = [
"std",
"dep:tokio",
"dep:alloy-provider",
"dep:alloy-eips",
"dep:alloy-transport",
]
21 changes: 21 additions & 0 deletions crates/database/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-2024 draganrakita

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 7 additions & 7 deletions crates/database/interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
authors = ["Dragan Rakita <[email protected]>"]
description = "Revm Database interface"
edition = "2021"
keywords = ["ethereum", "evm", "revm", "no_std"]
license = "MIT"
name = "revm-database-interface"
repository = "https://github.com/bluealloy/revm"
description = "Revm Database interface"
version = "1.0.0"
readme = "../../README.md"
authors.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true

[package.metadata.docs.rs]
all-features = true
Expand Down
Loading
Loading