Skip to content

Commit 5f1c8e3

Browse files
authored
feat: reth-scroll crates (#33)
* add all the scroll crates Signed-off-by: Gregory Edison <[email protected]> * Scroll `Account` extension Signed-off-by: Gregory Edison <[email protected]> * add `Default::default` to make tests compile Signed-off-by: Gregory Edison <[email protected]> * fix rebasing Signed-off-by: Gregory Edison <[email protected]> * fix lints + feature check Signed-off-by: Gregory Edison <[email protected]> * don't compile optimism crates with `scroll` feature Signed-off-by: Gregory Edison <[email protected]> * fix optimism lints Signed-off-by: Gregory Edison <[email protected]> * update `poseidon` to `hash_code` and import to workspace Signed-off-by: Gregory Edison <[email protected]> * gate `WithContext` implementation behind test-utils Signed-off-by: Gregory Edison <[email protected]> * pin poseidon-bn254 Signed-off-by: Gregory Edison <[email protected]> --------- Signed-off-by: Gregory Edison <[email protected]>
1 parent 7f00db6 commit 5f1c8e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2387
-56
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
with:
153153
cache-on-failure: true
154154
- uses: taiki-e/install-action@cargo-udeps
155-
- run: cargo udeps --workspace --lib --examples --tests --benches --all-features --locked
155+
- run: cargo udeps --workspace --lib --examples --tests --benches --all-features --locked --exclude "reth-optimism-*" --exclude op-reth
156156

157157
book:
158158
name: book

Cargo.lock

+89-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ members = [
100100
"crates/rpc/rpc-testing-util/",
101101
"crates/rpc/rpc-types-compat/",
102102
"crates/rpc/rpc/",
103+
"crates/scroll/execution",
104+
"crates/scroll/primitives",
105+
"crates/scroll/revm",
106+
"crates/scroll/storage",
103107
"crates/stages/api/",
104108
"crates/stages/stages/",
105109
"crates/stages/types/",
@@ -403,6 +407,10 @@ reth-rpc-eth-types = { path = "crates/rpc/rpc-eth-types", default-features = fal
403407
reth-rpc-layer = { path = "crates/rpc/rpc-layer" }
404408
reth-rpc-server-types = { path = "crates/rpc/rpc-server-types" }
405409
reth-rpc-types-compat = { path = "crates/rpc/rpc-types-compat" }
410+
reth-scroll-execution = { path = "crates/scroll/execution" }
411+
reth-scroll-primitives = { path = "crates/scroll/primitives" }
412+
reth-scroll-revm = { path = "crates/scroll/revm" }
413+
reth-scroll-storage = { path = "crates/scroll/storage" }
406414
reth-stages = { path = "crates/stages/stages" }
407415
reth-stages-api = { path = "crates/stages/api" }
408416
reth-stages-types = { path = "crates/stages/types" }
@@ -470,6 +478,10 @@ alloy-transport-http = { version = "0.6.4", features = [
470478
alloy-transport-ipc = { version = "0.6.4", default-features = false }
471479
alloy-transport-ws = { version = "0.6.4", default-features = false }
472480

481+
# scroll
482+
# TODO (scroll): point to crates.io/tag once the crate is published/a tag is created.
483+
poseidon-bn254 = { git = "https://github.com/scroll-tech/poseidon-bn254", rev = "526a64a", features = ["bn254"] }
484+
473485
# op
474486
op-alloy-rpc-types = "0.6.5"
475487
op-alloy-rpc-types-engine = "0.6.5"

crates/ethereum/evm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ secp256k1.workspace = true
3939
serde_json.workspace = true
4040
alloy-genesis.workspace = true
4141

42+
reth-scroll-primitives.workspace = true
43+
4244
[features]
4345
default = ["std"]
4446
std = [
@@ -52,3 +54,4 @@ std = [
5254
"revm-primitives/std",
5355
"secp256k1/std"
5456
]
57+
scroll = []

crates/ethereum/evm/src/execute.rs

+26-2
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ mod tests {
325325
balance: U256::ZERO,
326326
bytecode_hash: Some(keccak256(BEACON_ROOTS_CODE.clone())),
327327
nonce: 1,
328+
#[cfg(feature = "scroll")]
329+
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
330+
&BEACON_ROOTS_CODE,
331+
)),
328332
};
329333

330334
db.insert_account(
@@ -344,6 +348,10 @@ mod tests {
344348
nonce: 1,
345349
balance: U256::ZERO,
346350
bytecode_hash: Some(keccak256(WITHDRAWAL_REQUEST_PREDEPLOY_CODE.clone())),
351+
#[cfg(feature = "scroll")]
352+
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
353+
&WITHDRAWAL_REQUEST_PREDEPLOY_CODE,
354+
)),
347355
};
348356

349357
db.insert_account(
@@ -707,6 +715,10 @@ mod tests {
707715
balance: U256::ZERO,
708716
bytecode_hash: Some(keccak256(HISTORY_STORAGE_CODE.clone())),
709717
nonce: 1,
718+
#[cfg(feature = "scroll")]
719+
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
720+
&HISTORY_STORAGE_CODE,
721+
)),
710722
};
711723

712724
db.insert_account(
@@ -1059,7 +1071,13 @@ mod tests {
10591071

10601072
db.insert_account(
10611073
sender_address,
1062-
Account { nonce: 1, balance: U256::from(ETH_TO_WEI), bytecode_hash: None },
1074+
Account {
1075+
nonce: 1,
1076+
balance: U256::from(ETH_TO_WEI),
1077+
bytecode_hash: None,
1078+
#[cfg(feature = "scroll")]
1079+
account_extension: Some(reth_scroll_primitives::AccountExtension::empty()),
1080+
},
10631081
None,
10641082
HashMap::default(),
10651083
);
@@ -1141,7 +1159,13 @@ mod tests {
11411159
// Insert the sender account into the state with a nonce of 1 and a balance of 1 ETH in Wei
11421160
db.insert_account(
11431161
sender_address,
1144-
Account { nonce: 1, balance: U256::from(ETH_TO_WEI), bytecode_hash: None },
1162+
Account {
1163+
nonce: 1,
1164+
balance: U256::from(ETH_TO_WEI),
1165+
bytecode_hash: None,
1166+
#[cfg(feature = "scroll")]
1167+
account_extension: Some(reth_scroll_primitives::AccountExtension::empty()),
1168+
},
11451169
None,
11461170
HashMap::default(),
11471171
);

crates/optimism/bin/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ optimism = [
4646
"reth-optimism-rpc/optimism",
4747
"reth-provider/optimism"
4848
]
49+
scroll = []
4950

5051
dev = [
5152
"reth-optimism-cli/dev"

crates/optimism/bin/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
2727
// The `optimism` feature must be enabled to use this crate.
2828
#![cfg(feature = "optimism")]
29+
// Don't use the crate if `scroll` feature is used.
30+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
31+
#![cfg(not(feature = "scroll"))]
2932

3033
/// Re-exported from `reth_optimism_cli`.
3134
pub mod cli {

crates/optimism/bin/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![allow(missing_docs, rustdoc::missing_crate_level_docs)]
22
// The `optimism` feature must be enabled to use this crate.
33
#![cfg(feature = "optimism")]
4+
// Don't use the crate if `scroll` feature is used.
5+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
6+
#![cfg(not(feature = "scroll"))]
47

58
use clap::Parser;
69
use reth_node_builder::{engine_tree_config::TreeConfig, EngineNodeLauncher};

crates/optimism/cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ serde = [
121121
"reth-execution-types/serde",
122122
"reth-provider/serde"
123123
]
124+
scroll = []

crates/optimism/cli/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
1010
// The `optimism` feature must be enabled to use this crate.
1111
#![cfg(feature = "optimism")]
12+
// Don't use the crate if `scroll` feature is used.
13+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
14+
#![cfg(not(feature = "scroll"))]
1215

1316
/// Optimism chain specification parser.
1417
pub mod chainspec;

crates/optimism/evm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ optimism = [
6969
"revm/optimism",
7070
"revm-primitives/optimism"
7171
]
72+
scroll = []

crates/optimism/evm/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#![cfg_attr(not(feature = "std"), no_std)]
1010
// The `optimism` feature must be enabled to use this crate.
1111
#![cfg(feature = "optimism")]
12+
// Don't use the crate if `scroll` feature is used.
13+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
14+
#![cfg(not(feature = "scroll"))]
1215

1316
extern crate alloc;
1417

crates/optimism/node/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ test-utils = [
117117
"revm/test-utils",
118118
"reth-optimism-node/test-utils",
119119
]
120+
scroll = []

crates/optimism/node/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
99
// The `optimism` feature must be enabled to use this crate.
1010
#![cfg(feature = "optimism")]
11+
// Don't use the crate if `scroll` feature is used.
12+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
13+
#![cfg(not(feature = "scroll"))]
1114

1215
/// CLI argument parsing for the optimism node.
1316
pub mod args;

crates/optimism/node/tests/e2e/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![allow(missing_docs)]
2+
// Don't use the crate if `scroll` feature is used.
3+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
4+
#![cfg(not(feature = "scroll"))]
25

36
#[cfg(feature = "optimism")]
47
mod p2p;

crates/optimism/node/tests/it/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#![allow(missing_docs)]
2+
// Don't use the crate if `scroll` feature is used.
3+
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
4+
#![cfg(not(feature = "scroll"))]
25

36
#[cfg(feature = "optimism")]
47
mod builder;

0 commit comments

Comments
 (0)