Skip to content

Commit

Permalink
wip examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Sep 18, 2024
1 parent 67b374b commit 0a9f0dc
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 8 deletions.
24 changes: 23 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[workspace]
members = [
# binary
"bins/revme",

# libraries
"crates/revm",
"crates/primitives",
"crates/interpreter",
Expand All @@ -12,6 +15,15 @@ members = [
"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"]
Expand All @@ -28,7 +40,17 @@ 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-file = "LICENSE"
authors = ["Dragan Rakita <dragan0rakita@gmail.com>"]
categories = ["no-std",]
keywords = ["revm", "evm", "ethereum", "blockchain", "no_std"]
repository = "https://github.com/bluealloy/revm"
documentation = "https://bluealloy.github.io/revm/"
homepage = ""
licence = "MIT"
edition = "2021"

[workspace.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion crates/database/src/alloydb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_eips::BlockId;
pub use alloy_eips::BlockId;
use alloy_provider::{
network::{BlockResponse, HeaderResponse},
Network, Provider,
Expand Down
8 changes: 2 additions & 6 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -76,7 +77,7 @@ arbitrary = ["primitives/arbitrary"]
asm-keccak = ["primitives/asm-keccak"]
portable = ["wiring/portable"]

test-utils = []
test-utils = ["database"]

dev = [
"memory_limit",
Expand Down Expand Up @@ -120,11 +121,6 @@ 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"
Expand Down
22 changes: 22 additions & 0 deletions examples/block_traces/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "example-block-traces"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
22 changes: 22 additions & 0 deletions examples/contract_deployment/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "example-contract-deployment"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Optimism-specific constants, types, and helpers.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use anyhow::{anyhow, bail};
use database::InMemoryDB;
use revm::{
Expand Down
22 changes: 22 additions & 0 deletions examples/custom_opcodes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "example-custom-opcodes"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Optimism-specific constants, types, and helpers.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use revm::{
interpreter::{
gas,
Expand Down
22 changes: 22 additions & 0 deletions examples/database_components/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "example-database-components"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
21 changes: 21 additions & 0 deletions examples/database_ref/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "example-db-by-ref"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
3 changes: 3 additions & 0 deletions examples/db_by_ref.rs → examples/database_ref/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! 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;
Expand Down
22 changes: 22 additions & 0 deletions examples/uniswap_get_reserves/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "example-uniswap-get-reserves"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
22 changes: 22 additions & 0 deletions examples/uniswap_v2_usdc_swap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "example-uniswap-v2-usdc-swap"
version = "0.0.0"
publish = false
license.workspace = true
edition.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
Original file line number Diff line number Diff line change
@@ -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};
Expand Down

0 comments on commit 0a9f0dc

Please sign in to comment.