Skip to content

Commit

Permalink
feat: reth-scroll crates (#33)
Browse files Browse the repository at this point in the history
* add all the scroll crates

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* Scroll `Account` extension

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* add `Default::default` to make tests compile

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* fix rebasing

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* fix lints + feature check

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* don't compile optimism crates with `scroll` feature

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* fix optimism lints

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* update `poseidon` to `hash_code` and import to workspace

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* gate `WithContext` implementation behind test-utils

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

* pin poseidon-bn254

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>

---------

Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>
  • Loading branch information
greged93 authored Nov 25, 2024
1 parent 7f00db6 commit 5f1c8e3
Show file tree
Hide file tree
Showing 65 changed files with 2,387 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
with:
cache-on-failure: true
- uses: taiki-e/install-action@cargo-udeps
- run: cargo udeps --workspace --lib --examples --tests --benches --all-features --locked
- run: cargo udeps --workspace --lib --examples --tests --benches --all-features --locked --exclude "reth-optimism-*" --exclude op-reth

book:
name: book
Expand Down
91 changes: 89 additions & 2 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ members = [
"crates/rpc/rpc-testing-util/",
"crates/rpc/rpc-types-compat/",
"crates/rpc/rpc/",
"crates/scroll/execution",
"crates/scroll/primitives",
"crates/scroll/revm",
"crates/scroll/storage",
"crates/stages/api/",
"crates/stages/stages/",
"crates/stages/types/",
Expand Down Expand Up @@ -403,6 +407,10 @@ reth-rpc-eth-types = { path = "crates/rpc/rpc-eth-types", default-features = fal
reth-rpc-layer = { path = "crates/rpc/rpc-layer" }
reth-rpc-server-types = { path = "crates/rpc/rpc-server-types" }
reth-rpc-types-compat = { path = "crates/rpc/rpc-types-compat" }
reth-scroll-execution = { path = "crates/scroll/execution" }
reth-scroll-primitives = { path = "crates/scroll/primitives" }
reth-scroll-revm = { path = "crates/scroll/revm" }
reth-scroll-storage = { path = "crates/scroll/storage" }
reth-stages = { path = "crates/stages/stages" }
reth-stages-api = { path = "crates/stages/api" }
reth-stages-types = { path = "crates/stages/types" }
Expand Down Expand Up @@ -470,6 +478,10 @@ alloy-transport-http = { version = "0.6.4", features = [
alloy-transport-ipc = { version = "0.6.4", default-features = false }
alloy-transport-ws = { version = "0.6.4", default-features = false }

# scroll
# TODO (scroll): point to crates.io/tag once the crate is published/a tag is created.
poseidon-bn254 = { git = "https://github.com/scroll-tech/poseidon-bn254", rev = "526a64a", features = ["bn254"] }

# op
op-alloy-rpc-types = "0.6.5"
op-alloy-rpc-types-engine = "0.6.5"
Expand Down
3 changes: 3 additions & 0 deletions crates/ethereum/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ secp256k1.workspace = true
serde_json.workspace = true
alloy-genesis.workspace = true

reth-scroll-primitives.workspace = true

[features]
default = ["std"]
std = [
Expand All @@ -52,3 +54,4 @@ std = [
"revm-primitives/std",
"secp256k1/std"
]
scroll = []
28 changes: 26 additions & 2 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ mod tests {
balance: U256::ZERO,
bytecode_hash: Some(keccak256(BEACON_ROOTS_CODE.clone())),
nonce: 1,
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&BEACON_ROOTS_CODE,
)),
};

db.insert_account(
Expand All @@ -344,6 +348,10 @@ mod tests {
nonce: 1,
balance: U256::ZERO,
bytecode_hash: Some(keccak256(WITHDRAWAL_REQUEST_PREDEPLOY_CODE.clone())),
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&WITHDRAWAL_REQUEST_PREDEPLOY_CODE,
)),
};

db.insert_account(
Expand Down Expand Up @@ -707,6 +715,10 @@ mod tests {
balance: U256::ZERO,
bytecode_hash: Some(keccak256(HISTORY_STORAGE_CODE.clone())),
nonce: 1,
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&HISTORY_STORAGE_CODE,
)),
};

db.insert_account(
Expand Down Expand Up @@ -1059,7 +1071,13 @@ mod tests {

db.insert_account(
sender_address,
Account { nonce: 1, balance: U256::from(ETH_TO_WEI), bytecode_hash: None },
Account {
nonce: 1,
balance: U256::from(ETH_TO_WEI),
bytecode_hash: None,
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::empty()),
},
None,
HashMap::default(),
);
Expand Down Expand Up @@ -1141,7 +1159,13 @@ mod tests {
// Insert the sender account into the state with a nonce of 1 and a balance of 1 ETH in Wei
db.insert_account(
sender_address,
Account { nonce: 1, balance: U256::from(ETH_TO_WEI), bytecode_hash: None },
Account {
nonce: 1,
balance: U256::from(ETH_TO_WEI),
bytecode_hash: None,
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::empty()),
},
None,
HashMap::default(),
);
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ optimism = [
"reth-optimism-rpc/optimism",
"reth-provider/optimism"
]
scroll = []

dev = [
"reth-optimism-cli/dev"
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
// The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

/// Re-exported from `reth_optimism_cli`.
pub mod cli {
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![allow(missing_docs, rustdoc::missing_crate_level_docs)]
// The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

use clap::Parser;
use reth_node_builder::{engine_tree_config::TreeConfig, EngineNodeLauncher};
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ serde = [
"reth-execution-types/serde",
"reth-provider/serde"
]
scroll = []
3 changes: 3 additions & 0 deletions crates/optimism/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
// The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

/// Optimism chain specification parser.
pub mod chainspec;
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ optimism = [
"revm/optimism",
"revm-primitives/optimism"
]
scroll = []
3 changes: 3 additions & 0 deletions crates/optimism/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#![cfg_attr(not(feature = "std"), no_std)]
// The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

extern crate alloc;

Expand Down
1 change: 1 addition & 0 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ test-utils = [
"revm/test-utils",
"reth-optimism-node/test-utils",
]
scroll = []
3 changes: 3 additions & 0 deletions crates/optimism/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
// The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

/// CLI argument parsing for the optimism node.
pub mod args;
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/node/tests/e2e/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![allow(missing_docs)]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

#[cfg(feature = "optimism")]
mod p2p;
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/node/tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![allow(missing_docs)]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

#[cfg(feature = "optimism")]
mod builder;
Expand Down
Loading

0 comments on commit 5f1c8e3

Please sign in to comment.