Skip to content
Closed
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
88 changes: 88 additions & 0 deletions Cargo.lock

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

16 changes: 14 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ members = [
"crates/engine",
"crates/node",
"crates/network",
"crates/scroll-wire"
]
"crates/scroll-wire",
"crates/primitives",
"crates/l1",
"crates/database",
"crates/indexer",
"crates/sequencer",
"crates/pipeline",
"crates/provider",
"crates/codec"]

resolver = "2"

Expand Down Expand Up @@ -111,6 +118,7 @@ alloy-primitives = { version = "0.8.15", default-features = false }
alloy-rpc-types-engine = { version = "0.11.0", default-features = false }

# scroll-alloy
scroll-alloy-rpc-types-engine = { git = "https://github.com/scroll-tech/reth.git", branch = "feat/add-deref-blanket-engine-api" }
scroll-alloy-provider = { git = "https://github.com/scroll-tech/reth.git", branch = "feat/add-deref-blanket-engine-api" }
scroll-alloy-network = { git = "https://github.com/scroll-tech/reth.git", branch = "feat/add-deref-blanket-engine-api" }

Expand All @@ -132,7 +140,11 @@ reth-scroll-primitives = { git = "https://github.com/scroll-tech/reth.git", bran

# rollup node
scroll-engine = { path = "crates/engine" }
scroll-indexer = { path = "crates/indexer" }
scroll-l1 = { path = "crates/l1" }
scroll-network = { path = "crates/network" }
scroll-pipeline = { path = "crates/pipeline"}
scroll-primitives = { path = "crates/primitives" }
scroll-wire = { path = "crates/scroll-wire" }
rollup-node-manager = { path = "crates/node" }

Expand Down
12 changes: 12 additions & 0 deletions crates/codec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "codec"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
exclude.workspace = true

[dependencies]

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/codec/src/batch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub struct BatchCodec;
1 change: 1 addition & 0 deletions crates/codec/src/chunk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub struct ChunkCodec;
3 changes: 3 additions & 0 deletions crates/codec/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub enum CodecError {
Error,
}
3 changes: 3 additions & 0 deletions crates/codec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod batch;
mod chunk;
mod error;
12 changes: 12 additions & 0 deletions crates/database/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "database"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
exclude.workspace = true

[dependencies]

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/database/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub struct Database;
2 changes: 1 addition & 1 deletion crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ alloy-rpc-types-engine.workspace = true
# scroll-alloy
scroll-alloy-network.workspace = true
scroll-alloy-provider.workspace = true
scroll-alloy-rpc-types-engine = { git = "https://github.com/scroll-tech/reth.git", branch = "feat/add-deref-blanket-engine-api" }
scroll-alloy-rpc-types-engine.workspace = true

# reth
reth-engine-primitives = { git = "https://github.com/scroll-tech/reth.git", branch = "feat/add-deref-blanket-engine-api", default-features = false, features = ["scroll"] }
Expand Down
15 changes: 15 additions & 0 deletions crates/indexer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "scroll-indexer"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
exclude.workspace = true

[dependencies]
# rollup-node
scroll-l1.workspace = true
scroll-primitives.workspace = true

[lints]
workspace = true
38 changes: 38 additions & 0 deletions crates/indexer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! A library responsible for indexing data relevant to the L1.

use scroll_l1::L1Event;
use scroll_primitives::{BatchInput, L1Message};
use std::sync::Arc;

/// The indexer is responsible for indexing data relevant to the L1.
#[derive(Debug)]
pub struct Indexer;

impl Indexer {
/// Handles an event from the L1.
pub async fn handle_l1_event(&mut self, event: L1Event) {
match event {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CommitBatch and L1Message are specific events to Scroll and the others are general L1 "events". Is this correct?

What about Revert and Finalize events for batches?

Copy link
Collaborator Author

@frisitano frisitano Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we will need to index Finalize to determine the rollup finality status.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is such a good idea to add the rollup events here.
When having a new version: If we add or change the events intrinsic meaning, even if we remove an event we will always need to support all of this here to be able to sync from genesis.

I still think we should try to encapsulate all the derivation specifics as much as possible and push them into a specific derivation pipeline implementation. We could have derivation pipeline implementations for different versions of the protocol/codec.

This way the general node framework stays the same:

  • notify of L1 updates (and maybe supply data in a very general way. but this a bit tricky as we don't know what exact data is required, so we need to enable the derivation pipeline to specify what events and data it is interested in without decoding the data)
  • derivation pipeline does all the specifics

L1Event::Reorg(block_number) => self.handle_reorg(block_number).await,
L1Event::NewBlock(block_number) => todo!(),
L1Event::Finalized(block_number) => self.handle_finalized(block_number).await,
L1Event::L1Message(l1_message) => self.handle_l1_message(l1_message).await,
L1Event::PipelineEvent(block_number) => (),
}
}

async fn handle_reorg(&mut self, _block_number: u64) {
todo!()
}

async fn handle_finalized(&mut self, _block_number: u64) {
todo!()
}

async fn handle_l1_message(&mut self, _l1_message: Arc<L1Message>) {
todo!()
}

async fn handle_batch_input(&mut self, _batch_input: Arc<BatchInput>) {
todo!()
}
}
22 changes: 22 additions & 0 deletions crates/l1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "scroll-l1"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
exclude.workspace = true

[dependencies]
# alloy
alloy-sol-types = { version = "0.8.20", features = ["json"] }
alloy-contract = { version = "0.11.1", default-features = false }
alloy-primitives.workspace = true

# rollup-node
scroll-primitives.workspace = true

# misc
futures.workspace = true

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/l1/abi/L1MessageQueue.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/l1/abi/ScrollChain.json

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions crates/l1/src/abi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use alloy_sol_types::sol;

// L1 Message Queue Contract
sol!(
#[allow(missing_docs)]
#[sol(rpc)]
L1MessageQueue,
"abi/L1MessageQueue.json",
);

// Scroll Chain Contract
sol!(
#[allow(missing_docs)]
#[sol(rpc)]
ScrollChain,
"abi/ScrollChain.json",
);
11 changes: 11 additions & 0 deletions crates/l1/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use alloy_primitives::{address, Address};

// TODO: Update the addresses.

/// The address of the L1 Message Queue contract on mainnet.
pub const MAINNET_L1_MESSAGE_QUEUE_ADDRESS: Address =
address!("0000000000000000000000000000000000000000");

/// The address of the Scroll Chain contract on mainnet.
pub const MAINNET_L1_SCROLL_CHAIN_ADDRESS: Address =
address!("0000000000000000000000000000000000000000");
17 changes: 17 additions & 0 deletions crates/l1/src/event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use scroll_primitives::L1Message;
use std::sync::Arc;

/// An observation from the L1.
#[derive(Debug)]
pub enum L1Event {
/// A block containing a pipeline event has been added to the L1.
PipelineEvent(u64),
/// A new L1 message has been added to the L1.
L1Message(Arc<L1Message>),
/// A new block has been added to the L1.
NewBlock(u64),
/// A reorg has occurred at the given block number.
Reorg(u64),
/// The L1 has been finalized at the given block number.
Finalized(u64),
}
10 changes: 10 additions & 0 deletions crates/l1/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! A library containing the logic required to interact with L1.

mod abi;
mod constants;
mod event;
mod watcher;

pub use constants::*;
pub use event::L1Event;
pub use watcher::L1Watcher;
Loading
Loading