diff --git a/Cargo.lock b/Cargo.lock index 8ac74f9d91..294f541e6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2812,10 +2812,8 @@ dependencies = [ name = "revm" version = "14.0.1" dependencies = [ - "alloy-eips", "alloy-provider", "alloy-sol-types", - "alloy-transport", "anyhow", "auto_impl", "criterion", @@ -2825,6 +2823,7 @@ dependencies = [ "indicatif", "reqwest", "revm-bytecode", + "revm-database", "revm-database-interface", "revm-interpreter", "revm-precompile", @@ -2835,7 +2834,6 @@ dependencies = [ "rstest", "serde", "serde_json", - "tokio", ] [[package]] @@ -2847,6 +2845,29 @@ dependencies = [ "serde", ] +[[package]] +name = "revm-database" +version = "1.0.0" +dependencies = [ + "alloy-eips", + "alloy-provider", + "alloy-sol-types", + "alloy-transport", + "anyhow", + "auto_impl", + "criterion", + "indicatif", + "revm-bytecode", + "revm-database-interface", + "revm-primitives", + "revm-state", + "revm-wiring", + "rstest", + "serde", + "serde_json", + "tokio", +] + [[package]] name = "revm-database-interface" version = "1.0.0" @@ -2890,6 +2911,7 @@ dependencies = [ "enumn", "indicatif", "revm", + "revm-database", "revm-precompile", "rstest", "serde", @@ -2988,6 +3010,7 @@ dependencies = [ "microbench", "plain_hasher", "revm", + "revm-database", "serde", "serde_json", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 2d48060191..1bb9b0b2c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,38 @@ [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 } @@ -26,7 +40,16 @@ wiring = { path = "crates/wiring", package = "revm-wiring", version = "1.0.0", d 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 "] +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 diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 14e510bbbc..12ec072bef 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -1,14 +1,15 @@ [package] -authors = ["Dragan Rakita "] -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", diff --git a/bins/revme/src/cmd/bench/analysis.rs b/bins/revme/src/cmd/bench/analysis.rs index 472fabd1b5..359738567e 100644 --- a/bins/revme/src/cmd/bench/analysis.rs +++ b/bins/revme/src/cmd/bench/analysis.rs @@ -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, diff --git a/bins/revme/src/cmd/bench/burntpix.rs b/bins/revme/src/cmd/bench/burntpix.rs index 663987f700..c7f0755bf8 100644 --- a/bins/revme/src/cmd/bench/burntpix.rs +++ b/bins/revme/src/cmd/bench/burntpix.rs @@ -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::{ diff --git a/bins/revme/src/cmd/bench/snailtracer.rs b/bins/revme/src/cmd/bench/snailtracer.rs index 989bdc15d2..fe729f12b5 100644 --- a/bins/revme/src/cmd/bench/snailtracer.rs +++ b/bins/revme/src/cmd/bench/snailtracer.rs @@ -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, diff --git a/bins/revme/src/cmd/bench/transfer.rs b/bins/revme/src/cmd/bench/transfer.rs index 03ac702f8a..027f1775e8 100644 --- a/bins/revme/src/cmd/bench/transfer.rs +++ b/bins/revme/src/cmd/bench/transfer.rs @@ -1,6 +1,6 @@ +use database::{BenchmarkDB, EthereumBenchmarkWiring}; use revm::{ bytecode::Bytecode, - db::{BenchmarkDB, EthereumBenchmarkWiring}, primitives::{TxKind, U256}, Evm, }; diff --git a/bins/revme/src/cmd/evmrunner.rs b/bins/revme/src/cmd/evmrunner.rs index 4d378000d0..f33a962007 100644 --- a/bins/revme/src/cmd/evmrunner.rs +++ b/bins/revme/src/cmd/evmrunner.rs @@ -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}, diff --git a/bins/revme/src/cmd/statetest/merkle_trie.rs b/bins/revme/src/cmd/statetest/merkle_trie.rs index b7a97cd7c7..e294c4e4be 100644 --- a/bins/revme/src/cmd/statetest/merkle_trie.rs +++ b/bins/revme/src/cmd/statetest/merkle_trie.rs @@ -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 { diff --git a/bins/revme/src/cmd/statetest/runner.rs b/bins/revme/src/cmd/statetest/runner.rs index c6adcd186a..8eeb6c5e59 100644 --- a/bins/revme/src/cmd/statetest/runner.rs +++ b/bins/revme/src/cmd/statetest/runner.rs @@ -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, @@ -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)); @@ -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(); @@ -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(); diff --git a/crates/bytecode/Cargo.toml b/crates/bytecode/Cargo.toml index 6b9f24dacc..f1418d4e5b 100644 --- a/crates/bytecode/Cargo.toml +++ b/crates/bytecode/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -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 diff --git a/crates/database/CHANGELOG.md b/crates/database/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/database/Cargo.toml b/crates/database/Cargo.toml new file mode 100644 index 0000000000..5e49f01f88 --- /dev/null +++ b/crates/database/Cargo.toml @@ -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", +] diff --git a/crates/database/LICENSE b/crates/database/LICENSE new file mode 100644 index 0000000000..ad98ff22cc --- /dev/null +++ b/crates/database/LICENSE @@ -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. diff --git a/crates/database/interface/Cargo.toml b/crates/database/interface/Cargo.toml index bc67977713..6406283099 100644 --- a/crates/database/interface/Cargo.toml +++ b/crates/database/interface/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -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 diff --git a/crates/revm/src/db/alloydb.rs b/crates/database/src/alloydb.rs similarity index 91% rename from crates/revm/src/db/alloydb.rs rename to crates/database/src/alloydb.rs index f0196ac6bc..cfa7d237ab 100644 --- a/crates/revm/src/db/alloydb.rs +++ b/crates/database/src/alloydb.rs @@ -1,20 +1,15 @@ -use crate::{ - bytecode::Bytecode, - database_interface::{Database, DatabaseRef}, - primitives::{Address, B256, U256}, - state::AccountInfo, -}; -use alloy_eips::BlockId; +pub use alloy_eips::BlockId; use alloy_provider::{ network::{BlockResponse, HeaderResponse}, Network, Provider, }; use alloy_transport::{Transport, TransportError}; +use database_interface::{Database, DatabaseRef}; +use primitives::{Address, B256, U256}; +use state::{AccountInfo, Bytecode}; use std::future::IntoFuture; use tokio::runtime::{Handle, Runtime}; -use super::utils::HandleOrRuntime; - /// An alloy-powered REVM [Database]. /// /// When accessing the database, it'll use the given provider to fetch the corresponding account's data. @@ -176,6 +171,27 @@ impl> Database for AlloyDB(&self, f: F) -> F::Output + where + F: std::future::Future + Send, + F::Output: Send, + { + match self { + Self::Handle(handle) => tokio::task::block_in_place(move || handle.block_on(f)), + Self::Runtime(rt) => rt.block_on(f), + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/revm/src/db/ethersdb.rs b/crates/database/src/ethersdb.rs similarity index 100% rename from crates/revm/src/db/ethersdb.rs rename to crates/database/src/ethersdb.rs diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/database/src/in_memory_db.rs similarity index 99% rename from crates/revm/src/db/in_memory_db.rs rename to crates/database/src/in_memory_db.rs index 29cae75811..feca6d2220 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/database/src/in_memory_db.rs @@ -1,8 +1,7 @@ -use bytecode::Bytecode; use core::convert::Infallible; use database_interface::{Database, DatabaseCommit, DatabaseRef, EmptyDB}; use primitives::{hash_map::Entry, Address, HashMap, Log, B256, KECCAK_EMPTY, U256}; -use state::{Account, AccountInfo}; +use state::{Account, AccountInfo, Bytecode}; use std::vec::Vec; use wiring::EthereumWiring; @@ -469,7 +468,7 @@ mod tests { assert_eq!(new_state.storage(account, key1), Ok(value1)); } - #[cfg(feature = "serde-json")] + #[cfg(feature = "serde")] #[test] fn test_serialize_deserialize_cachedb() { let account = Address::with_last_byte(69); diff --git a/crates/revm/src/db.rs b/crates/database/src/lib.rs similarity index 86% rename from crates/revm/src/db.rs rename to crates/database/src/lib.rs index 6e0566aec9..e5d1e4a65a 100644 --- a/crates/revm/src/db.rs +++ b/crates/database/src/lib.rs @@ -1,8 +1,5 @@ //! Database implementations. -#[cfg(feature = "alloydb")] -mod utils; - #[cfg(feature = "alloydb")] mod alloydb; @@ -10,7 +7,7 @@ pub mod in_memory_db; pub mod states; #[cfg(feature = "alloydb")] -pub use alloydb::AlloyDB; +pub use alloydb::{AlloyDB, BlockId}; pub use in_memory_db::*; pub use states::{ diff --git a/crates/revm/src/db/states.rs b/crates/database/src/states.rs similarity index 100% rename from crates/revm/src/db/states.rs rename to crates/database/src/states.rs diff --git a/crates/revm/src/db/states/account_status.rs b/crates/database/src/states/account_status.rs similarity index 100% rename from crates/revm/src/db/states/account_status.rs rename to crates/database/src/states/account_status.rs diff --git a/crates/revm/src/db/states/bundle_account.rs b/crates/database/src/states/bundle_account.rs similarity index 100% rename from crates/revm/src/db/states/bundle_account.rs rename to crates/database/src/states/bundle_account.rs diff --git a/crates/revm/src/db/states/bundle_state.rs b/crates/database/src/states/bundle_state.rs similarity index 99% rename from crates/revm/src/db/states/bundle_state.rs rename to crates/database/src/states/bundle_state.rs index 6b57bf8641..791a304e46 100644 --- a/crates/revm/src/db/states/bundle_state.rs +++ b/crates/database/src/states/bundle_state.rs @@ -857,7 +857,7 @@ impl BundleState { #[cfg(test)] mod tests { use super::*; - use crate::{db::StorageWithOriginalValues, TransitionAccount}; + use crate::{StorageWithOriginalValues, TransitionAccount}; #[test] fn transition_states() { diff --git a/crates/revm/src/db/states/cache.rs b/crates/database/src/states/cache.rs similarity index 100% rename from crates/revm/src/db/states/cache.rs rename to crates/database/src/states/cache.rs diff --git a/crates/revm/src/db/states/cache_account.rs b/crates/database/src/states/cache_account.rs similarity index 100% rename from crates/revm/src/db/states/cache_account.rs rename to crates/database/src/states/cache_account.rs diff --git a/crates/revm/src/db/states/changes.rs b/crates/database/src/states/changes.rs similarity index 100% rename from crates/revm/src/db/states/changes.rs rename to crates/database/src/states/changes.rs diff --git a/crates/revm/src/db/states/plain_account.rs b/crates/database/src/states/plain_account.rs similarity index 100% rename from crates/revm/src/db/states/plain_account.rs rename to crates/database/src/states/plain_account.rs diff --git a/crates/revm/src/db/states/reverts.rs b/crates/database/src/states/reverts.rs similarity index 100% rename from crates/revm/src/db/states/reverts.rs rename to crates/database/src/states/reverts.rs diff --git a/crates/revm/src/db/states/state.rs b/crates/database/src/states/state.rs similarity index 99% rename from crates/revm/src/db/states/state.rs rename to crates/database/src/states/state.rs index c0bb51c340..cf46dc975d 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/database/src/states/state.rs @@ -302,7 +302,7 @@ impl DatabaseCommit for State { #[cfg(test)] mod tests { use super::*; - use crate::db::{ + use crate::{ states::{reverts::AccountInfoRevert, StorageSlot}, AccountRevert, AccountStatus, BundleAccount, RevertToSlot, }; diff --git a/crates/revm/src/db/states/state_builder.rs b/crates/database/src/states/state_builder.rs similarity index 100% rename from crates/revm/src/db/states/state_builder.rs rename to crates/database/src/states/state_builder.rs diff --git a/crates/revm/src/db/states/transition_account.rs b/crates/database/src/states/transition_account.rs similarity index 100% rename from crates/revm/src/db/states/transition_account.rs rename to crates/database/src/states/transition_account.rs diff --git a/crates/revm/src/db/states/transition_state.rs b/crates/database/src/states/transition_state.rs similarity index 100% rename from crates/revm/src/db/states/transition_state.rs rename to crates/database/src/states/transition_state.rs diff --git a/crates/gas/Cargo.toml b/crates/gas/Cargo.toml index 435e80f935..e554cfba45 100644 --- a/crates/gas/Cargo.toml +++ b/crates/gas/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm Database interface" -edition = "2021" -keywords = ["ethereum", "evm", "revm", "no_std"] -license = "MIT" name = "revm-gas" -repository = "https://github.com/bluealloy/revm" +description = "Revm gas constants and calculations" 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 diff --git a/crates/inspector/Cargo.toml b/crates/inspector/Cargo.toml index 053b6ae583..b03c3cacb1 100644 --- a/crates/inspector/Cargo.toml +++ b/crates/inspector/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm Database interface" -edition = "2021" -keywords = ["ethereum", "evm", "revm", "no_std"] -license = "MIT" name = "revm-inspector" -repository = "https://github.com/bluealloy/revm" +description = "Revm inspector 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 @@ -30,9 +30,7 @@ serde = { version = "1.0", default-features = false, features = [ [features] -default = ["std",] -std = [ - "serde?/std", -] +default = ["std"] +std = ["serde?/std"] serde = ["dep:serde"] -serde-json = ["serde"] \ No newline at end of file +serde-json = ["serde"] diff --git a/crates/interface/Cargo.toml b/crates/interface/Cargo.toml index 25793f6d78..2867aba626 100644 --- a/crates/interface/Cargo.toml +++ b/crates/interface/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm Database interface" -edition = "2021" -keywords = ["ethereum", "evm", "revm", "no_std"] -license = "MIT" name = "revm-interface" -repository = "https://github.com/bluealloy/revm" +description = "Revm crate" 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 diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index baf356978c..313e210833 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "revm Interpreter" -edition = "2021" -keywords = ["no_std", "ethereum", "evm", "revm", "interpreter"] -license = "MIT" name = "revm-interpreter" -repository = "https://github.com/bluealloy/revm" +description = "Revm Interpreter that executes bytecode." version = "10.0.1" -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 diff --git a/crates/optimism/Cargo.toml b/crates/optimism/Cargo.toml index fbf7b0138f..46ce6feda2 100644 --- a/crates/optimism/Cargo.toml +++ b/crates/optimism/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm Optimism" -edition = "2021" -keywords = ["ethereum", "optimism", "evm", "revm", "no_std"] -license = "MIT" name = "revm-optimism" -repository = "https://github.com/bluealloy/revm" +description = "Optimism extension of Revm" 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 @@ -37,6 +37,7 @@ serde = { version = "1.0", default-features = false, features = [ [dev-dependencies] +database.workspace = true anyhow = "1.0.89" criterion = "0.5" indicatif = "0.17" diff --git a/crates/optimism/src/fast_lz.rs b/crates/optimism/src/fast_lz.rs index b0cef1fe43..5c75a8820e 100644 --- a/crates/optimism/src/fast_lz.rs +++ b/crates/optimism/src/fast_lz.rs @@ -108,9 +108,9 @@ mod tests { use super::*; use alloy_sol_types::sol; use alloy_sol_types::SolCall; + use database::BenchmarkDB; use revm::{ bytecode::Bytecode, - db::BenchmarkDB, primitives::{address, bytes, Bytes, TxKind, U256}, wiring::EthereumWiring, Evm, diff --git a/crates/optimism/src/handler_register.rs b/crates/optimism/src/handler_register.rs index 495d81b638..89e81b12f0 100644 --- a/crates/optimism/src/handler_register.rs +++ b/crates/optimism/src/handler_register.rs @@ -429,9 +429,9 @@ pub fn end( mod tests { use super::*; use crate::{BedrockSpec, L1BlockInfo, LatestSpec, OptimismEvmWiring, RegolithSpec}; + use database::InMemoryDB; use revm::{ database_interface::EmptyDB, - db::InMemoryDB, interpreter::{CallOutcome, InterpreterResult}, primitives::{bytes, Address, Bytes, B256}, state::AccountInfo, diff --git a/crates/precompile/Cargo.toml b/crates/precompile/Cargo.toml index a7d1baae69..fa4691dffd 100644 --- a/crates/precompile/Cargo.toml +++ b/crates/precompile/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "revm Precompiles - Ethereum compatible precompiled contracts" -edition = "2021" -keywords = ["no_std", "ethereum", "evm", "revm", "precompiles"] -license = "MIT" name = "revm-precompile" -repository = "https://github.com/bluealloy/revm" +description = "Revm Precompiles - Ethereum compatible precompiled contracts" version = "11.0.1" -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 diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 72adf8d5ef..7ba394f7dd 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "revm primitives" -edition = "2021" -keywords = ["no_std", "ethereum", "evm", "revm", "types"] -license = "MIT" name = "revm-primitives" -repository = "https://github.com/bluealloy/revm" +description = "Revm primitives structure" version = "9.0.1" -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 diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 87e6be0544..81e0e7a1b9 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "revm - Rust Ethereum Virtual Machine" -edition = "2021" -keywords = ["no_std", "ethereum", "evm", "revm"] -license = "MIT" name = "revm" -repository = "https://github.com/bluealloy/revm" +description = "Revm - Rust Ethereum Virtual Machine" version = "14.0.1" -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 @@ -31,6 +31,7 @@ database-interface.workspace = true state.workspace = true specification.workspace = true bytecode.workspace = true +database = { workspace = true, optional = true } # misc auto_impl = { version = "1.2", default-features = false } @@ -46,16 +47,8 @@ serde_json = { version = "1.0", default-features = false, features = [ "alloc", ], 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] +database.workspace = true alloy-sol-types = { version = "0.8.2", default-features = false, features = [ "std", ] } @@ -84,15 +77,7 @@ arbitrary = ["primitives/arbitrary"] asm-keccak = ["primitives/asm-keccak"] portable = ["wiring/portable"] -test-utils = [] - -alloydb = [ - "std", - "dep:tokio", - "dep:alloy-provider", - "dep:alloy-eips", - "dep:alloy-transport", -] +test-utils = ["database"] dev = [ "memory_limit", @@ -116,32 +101,27 @@ c-kzg = ["precompile/c-kzg"] kzg-rs = ["precompile/kzg-rs"] blst = ["precompile/blst"] -[[example]] -name = "fork_ref_transact" -path = "../../examples/fork_ref_transact.rs" -required-features = ["alloydb"] - -[[example]] -name = "generate_block_traces" -path = "../../examples/generate_block_traces.rs" -required-features = ["std", "serde-json", "alloydb"] - -[[example]] -name = "db_by_ref" -path = "../../examples/db_by_ref.rs" -required-features = ["std", "serde-json"] - -[[example]] -name = "deploy" -path = "../../examples/deploy.rs" -required-features = [] - -#[[example]] -#name = "uniswap_v2_usdc_swap" -#path = "../../examples/uniswap_v2_usdc_swap.rs" -#required-features = ["alloydb"] - -[[bench]] -name = "bench" -path = "benches/bench.rs" -harness = false +# [[example]] +# name = "fork_ref_transact" +# path = "../../examples/fork_ref_transact.rs" +# required-features = ["alloydb"] + +# [[example]] +# name = "generate_block_traces" +# path = "../../examples/generate_block_traces.rs" +# required-features = ["std", "serde-json", "alloydb"] + +# [[example]] +# name = "db_by_ref" +# path = "../../examples/db_by_ref.rs" +# required-features = ["std", "serde-json"] + +# [[example]] +# name = "deploy" +# path = "../../examples/deploy.rs" +# required-features = [] + +# [[bench]] +# name = "bench" +# path = "benches/bench.rs" +# harness = false diff --git a/crates/revm/benches/bench.rs b/crates/revm/benches/bench.rs index f4f22544d5..89f98c05b7 100644 --- a/crates/revm/benches/bench.rs +++ b/crates/revm/benches/bench.rs @@ -1,10 +1,10 @@ use criterion::{ criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion, }; +use database::BenchmarkDB; use interpreter::{opcode::make_instruction_table, SharedMemory, EMPTY_SHARED_MEMORY}; use revm::{ bytecode::Bytecode, - db::BenchmarkDB, interpreter::{analysis::to_analysed, Contract, DummyHost, Interpreter}, primitives::{address, bytes, hex, Bytes, TxKind, U256}, specification::hardfork::BerlinSpec, diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index 1380c0ebb4..9630ae345e 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -465,8 +465,9 @@ where #[cfg(test)] mod test { - use crate::{Context, Evm, InMemoryDB}; + use crate::{Context, Evm}; use bytecode::Bytecode; + use database::InMemoryDB; use interpreter::Interpreter; use primitives::{address, TxKind, U256}; use state::AccountInfo; diff --git a/crates/revm/src/context/evm_context.rs b/crates/revm/src/context/evm_context.rs index ea1978346b..22279a7dd8 100644 --- a/crates/revm/src/context/evm_context.rs +++ b/crates/revm/src/context/evm_context.rs @@ -463,7 +463,8 @@ where #[cfg(any(test, feature = "test-utils"))] pub(crate) mod test_utils { use super::*; - use crate::{db::CacheDB, journaled_state::JournaledState}; + use crate::journaled_state::JournaledState; + use database::CacheDB; use database_interface::EmptyDB; use interpreter::CallScheme; use primitives::{address, HashSet, B256, U256}; @@ -549,8 +550,9 @@ pub(crate) mod test_utils { #[cfg(test)] mod tests { use super::*; - use crate::{db::CacheDB, Frame, JournalEntry}; + use crate::{Frame, JournalEntry}; use bytecode::Bytecode; + use database::CacheDB; use database_interface::EmptyDB; use primitives::{address, U256}; use state::AccountInfo; diff --git a/crates/revm/src/db/utils.rs b/crates/revm/src/db/utils.rs deleted file mode 100644 index bf06940612..0000000000 --- a/crates/revm/src/db/utils.rs +++ /dev/null @@ -1,22 +0,0 @@ -use tokio::runtime::{Handle, Runtime}; - -// Hold a tokio runtime handle or full runtime -#[derive(Debug)] -pub(crate) enum HandleOrRuntime { - Handle(Handle), - Runtime(Runtime), -} - -impl HandleOrRuntime { - #[inline] - pub(crate) fn block_on(&self, f: F) -> F::Output - where - F: std::future::Future + Send, - F::Output: Send, - { - match self { - Self::Handle(handle) => tokio::task::block_in_place(move || handle.block_on(f)), - Self::Runtime(rt) => rt.block_on(f), - } - } -} diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index f20372dfed..6922d08cf8 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -427,8 +427,8 @@ impl Evm<'_, EvmWiringT> { mod tests { use super::*; - use crate::db::BenchmarkDB; use bytecode::Bytecode; + use database::BenchmarkDB; use interpreter::opcode::{PUSH1, SSTORE}; use primitives::{address, U256}; use specification::eip7702::{Authorization, RecoveredAuthorization, Signature}; diff --git a/crates/revm/src/inspector/customprinter.rs b/crates/revm/src/inspector/customprinter.rs index d5259a0a68..1ba61e7cd0 100644 --- a/crates/revm/src/inspector/customprinter.rs +++ b/crates/revm/src/inspector/customprinter.rs @@ -111,8 +111,9 @@ impl Inspector for CustomPrintTracer { #[cfg(test)] mod test { use super::*; - use crate::{inspector_handle_register, Evm, InMemoryDB}; + use crate::{inspector_handle_register, Evm}; use bytecode::Bytecode; + use database::InMemoryDB; use primitives::{address, bytes, keccak256, Bytes, TxKind, U256}; use specification::hardfork::SpecId; use state::AccountInfo; diff --git a/crates/revm/src/inspector/gas.rs b/crates/revm/src/inspector/gas.rs index 94eb607dbc..b0be32ce54 100644 --- a/crates/revm/src/inspector/gas.rs +++ b/crates/revm/src/inspector/gas.rs @@ -70,8 +70,9 @@ impl Inspector for GasInspector { #[cfg(test)] mod tests { use super::*; - use crate::{db::BenchmarkDB, inspector::inspector_handle_register, Evm, EvmWiring}; + use crate::{inspector::inspector_handle_register, Evm, EvmWiring}; use bytecode::Bytecode; + use database::BenchmarkDB; use interpreter::{opcode, Interpreter}; use primitives::{address, Bytes, Log, TxKind}; use wiring::{DefaultEthereumWiring, EthereumWiring, EvmWiring as PrimitiveEvmWiring}; diff --git a/crates/revm/src/inspector/handler_register.rs b/crates/revm/src/inspector/handler_register.rs index 35bf2e60fc..f7b81225de 100644 --- a/crates/revm/src/inspector/handler_register.rs +++ b/crates/revm/src/inspector/handler_register.rs @@ -262,10 +262,10 @@ fn inspector_instruction( mod tests { use super::*; use crate::{ - db::BenchmarkDB, inspector::inspector_handle_register, inspectors::NoOpInspector, Evm, - EvmContext, EvmWiring, + inspector::inspector_handle_register, inspectors::NoOpInspector, Evm, EvmContext, EvmWiring, }; use bytecode::Bytecode; + use database::BenchmarkDB; use database_interface::EmptyDB; use interpreter::{opcode, CallInputs, CallOutcome, CreateInputs, CreateOutcome}; use primitives::{address, Bytes, TxKind}; diff --git a/crates/revm/src/lib.rs b/crates/revm/src/lib.rs index 8711786400..3e3f0c64a7 100644 --- a/crates/revm/src/lib.rs +++ b/crates/revm/src/lib.rs @@ -22,7 +22,6 @@ mod context; #[cfg(any(test, feature = "test-utils"))] pub mod test_utils; -pub mod db; mod evm; mod evm_wiring; mod frame; @@ -39,10 +38,6 @@ pub use context::{ ContextWithEvmWiring, EvmContext, InnerEvmContext, }; pub use database_interface::{Database, DatabaseCommit, DatabaseRef}; -pub use db::InMemoryDB; -pub use db::{ - CacheState, DBBox, State, StateBuilder, StateDBBox, TransitionAccount, TransitionState, -}; pub use evm::{Evm, CALL_STACK_LIMIT}; pub use evm_wiring::EvmWiring; pub use frame::{CallFrame, CreateFrame, Frame, FrameData, FrameOrResult, FrameResult}; diff --git a/crates/specification/Cargo.toml b/crates/specification/Cargo.toml index 02ea8850f3..a4b28dc4f9 100644 --- a/crates/specification/Cargo.toml +++ b/crates/specification/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm Database interface" -edition = "2021" -keywords = ["ethereum", "evm", "revm", "no_std"] -license = "MIT" name = "revm-specification" -repository = "https://github.com/bluealloy/revm" +description = "Ethereum hardforks and EIP specification structs and constants" 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 diff --git a/crates/state/Cargo.toml b/crates/state/Cargo.toml index 79d747eb1a..e7d62ad841 100644 --- a/crates/state/Cargo.toml +++ b/crates/state/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm state types" -edition = "2021" -keywords = ["ethereum", "evm", "revm", "no_std"] -license = "MIT" name = "revm-state" -repository = "https://github.com/bluealloy/revm" +description = "Revm state types" 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 diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 06c730ab7c..f467907694 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -4,6 +4,7 @@ mod account_info; mod types; +pub use bytecode; pub use account_info::AccountInfo; pub use bytecode::Bytecode; diff --git a/crates/wiring/Cargo.toml b/crates/wiring/Cargo.toml index 242141280a..668bc10bc6 100644 --- a/crates/wiring/Cargo.toml +++ b/crates/wiring/Cargo.toml @@ -1,13 +1,13 @@ [package] -authors = ["Dragan Rakita "] -description = "Revm generic types wiring" -edition = "2021" -keywords = ["ethereum", "evm", "revm", "no_std"] -license = "MIT" name = "revm-wiring" -repository = "https://github.com/bluealloy/revm" +description = "Revm generic types wiring" 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 diff --git a/examples/block_traces/Cargo.toml b/examples/block_traces/Cargo.toml new file mode 100644 index 0000000000..466edfbf77 --- /dev/null +++ b/examples/block_traces/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "example-block-traces" +version = "0.0.0" +publish = false +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] +revm.workspace = true +database.workspace = true diff --git a/examples/generate_block_traces.rs b/examples/block_traces/src/main.rs similarity index 98% rename from examples/generate_block_traces.rs rename to examples/block_traces/src/main.rs index 371c4bdd34..88baf830e7 100644 --- a/examples/generate_block_traces.rs +++ b/examples/block_traces/src/main.rs @@ -1,3 +1,6 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use alloy_eips::{BlockId, BlockNumberOrTag}; use alloy_provider::{network::primitives::BlockTransactions, Provider, ProviderBuilder}; use indicatif::ProgressBar; diff --git a/examples/contract_deployment/Cargo.toml b/examples/contract_deployment/Cargo.toml new file mode 100644 index 0000000000..0d482a26dc --- /dev/null +++ b/examples/contract_deployment/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "example-contract-deployment" +version = "0.0.0" +publish = false +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] +revm.workspace = true +database.workspace = true diff --git a/examples/deploy.rs b/examples/contract_deployment/src/main.rs similarity index 94% rename from examples/deploy.rs rename to examples/contract_deployment/src/main.rs index 9431f32cf2..d025ecb62b 100644 --- a/examples/deploy.rs +++ b/examples/contract_deployment/src/main.rs @@ -1,4 +1,8 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use anyhow::{anyhow, bail}; +use database::InMemoryDB; use revm::{ interpreter::opcode, primitives::{hex, Bytes, TxKind, U256}, @@ -6,7 +10,7 @@ use revm::{ result::{ExecutionResult, Output}, EthereumWiring, }, - Evm, InMemoryDB, + Evm, }; /// Load number parameter and set to storage with slot 0 diff --git a/examples/custom_opcodes/Cargo.toml b/examples/custom_opcodes/Cargo.toml new file mode 100644 index 0000000000..fae13e5da1 --- /dev/null +++ b/examples/custom_opcodes/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "example-custom-opcodes" +version = "0.0.0" +publish = false +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] +revm.workspace = true +database.workspace = true diff --git a/examples/custom_opcodes.rs b/examples/custom_opcodes/src/lib.rs similarity index 98% rename from examples/custom_opcodes.rs rename to examples/custom_opcodes/src/lib.rs index 62b3abe4ac..f514d38c7c 100644 --- a/examples/custom_opcodes.rs +++ b/examples/custom_opcodes/src/lib.rs @@ -1,3 +1,6 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use revm::{ interpreter::{ gas, diff --git a/examples/database_components/Cargo.toml b/examples/database_components/Cargo.toml new file mode 100644 index 0000000000..666c1633a0 --- /dev/null +++ b/examples/database_components/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "example-database-components" +version = "0.0.0" +publish = false +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] +revm.workspace = true +database.workspace = true diff --git a/examples/split_db_trait.rs b/examples/database_components/src/lib.rs similarity index 96% rename from examples/split_db_trait.rs rename to examples/database_components/src/lib.rs index 1382982ce6..095a737956 100644 --- a/examples/split_db_trait.rs +++ b/examples/database_components/src/lib.rs @@ -1,3 +1,6 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + //! Database that is split on State and BlockHash traits. @@ -85,8 +88,8 @@ impl DatabaseCommit for DatabaseComponents< } -//! BlockHash database component from [`crate::db::Database`] -//! it is used inside [`crate::db::DatabaseComponents`] +//! BlockHash database component from [`database::Database`] +//! it is used inside [`database::DatabaseComponents`] use crate::B256; use auto_impl::auto_impl; diff --git a/examples/database_ref/Cargo.toml b/examples/database_ref/Cargo.toml new file mode 100644 index 0000000000..10250d758d --- /dev/null +++ b/examples/database_ref/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "example-db-by-ref" +version = "0.0.0" +publish = false +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] +revm.workspace = true diff --git a/examples/db_by_ref.rs b/examples/database_ref/src/main.rs similarity index 95% rename from examples/db_by_ref.rs rename to examples/database_ref/src/main.rs index 8be90b8dfe..36f335639a 100644 --- a/examples/db_by_ref.rs +++ b/examples/database_ref/src/main.rs @@ -1,8 +1,11 @@ +//! Optimism-specific constants, types, and helpers. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use core::error::Error; use core::fmt::Debug; +use database::CacheDB; use revm::{ database_interface::{EmptyDB, WrapDatabaseRef}, - db::CacheDB, handler::register::HandleRegister, inspector_handle_register, inspectors::{NoOpInspector, TracerEip3155}, diff --git a/examples/uniswap_get_reserves/Cargo.toml b/examples/uniswap_get_reserves/Cargo.toml new file mode 100644 index 0000000000..e275f58bcc --- /dev/null +++ b/examples/uniswap_get_reserves/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "example-uniswap-get-reserves" +version = "0.0.0" +publish = false +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] +revm.workspace = true +database.workspace = true diff --git a/examples/fork_ref_transact.rs b/examples/uniswap_get_reserves/src/main.rs similarity index 97% rename from examples/fork_ref_transact.rs rename to examples/uniswap_get_reserves/src/main.rs index a1467f29b1..8004bf8b07 100644 --- a/examples/fork_ref_transact.rs +++ b/examples/uniswap_get_reserves/src/main.rs @@ -1,3 +1,6 @@ +//! Example of uniswap getReserves() call emulation. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use alloy_eips::BlockId; use alloy_provider::ProviderBuilder; use alloy_sol_types::sol; diff --git a/examples/uniswap_v2_usdc_swap/Cargo.toml b/examples/uniswap_v2_usdc_swap/Cargo.toml new file mode 100644 index 0000000000..6275283a17 --- /dev/null +++ b/examples/uniswap_v2_usdc_swap/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "example-uniswap-v2-usdc-swap" +version = "0.0.0" +publish = false +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] +revm.workspace = true +database.workspace = true diff --git a/examples/uniswap_v2_usdc_swap.rs b/examples/uniswap_v2_usdc_swap/src/main.rs similarity index 98% rename from examples/uniswap_v2_usdc_swap.rs rename to examples/uniswap_v2_usdc_swap/src/main.rs index 3f9905bf42..c6922d98dc 100644 --- a/examples/uniswap_v2_usdc_swap.rs +++ b/examples/uniswap_v2_usdc_swap/src/main.rs @@ -1,3 +1,6 @@ +//! Example of uniswap getReserves() call emulation. +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use alloy_provider::{network::Ethereum, ProviderBuilder, RootProvider}; use alloy_rpc_types::BlockId; use alloy_sol_types::{sol, SolCall, SolValue}; diff --git a/graph.png b/graph.png new file mode 100644 index 0000000000..e69de29bb2