Skip to content

Commit 9faafb3

Browse files
frisitanogreged93
andauthored
feat: Sequencer rnm integration (#63)
* test: move calldata to files * feat: batch header decoding * feat: improve codec interface * chore: manifests fixes * feat: revert some codec changes * feat: wip derivation pipeline * feat: batch header v7 * feat: add batch abstraction * feat: basic derivation pipeline * feat: implement batch data hash * feat: move PayloadData * feat: improve batch data hash computation * test: derivation * chore: cleaning * fix: lints * fix: lints * fix: skip wasm for derivation pipeline * fix: data hash computation for batch * fix: lint * fix: lint * fix: lints * fix: answer comments * fix: lints * feat: wip * feat: changes to the data model * fix: codec issue * feat: modify derivation pipeline to fetch blob * test: move test data to file * fix: lints * fix: answer comments * test: fix migration * fix: comments * feat: providers crate * feat: l1 providers crate * feat: l1 provider implementation * feat: l1 message provider * feat: pipeline modifications * fix: avoid iterating the cache * chore: simplify derivation pipeline interface * fix: lints * fix: rebasing * fix: answer comments * feat: add sequencer * sequencer initial implementation * sequencer implementation * sequencer implementation * refactor sequencer provider * sequencer implementation * lint * lint deps * address comments * feat: sequencer integration * remove redundant file * add std feature for scroll-reth-primitives * comments and clean up * address feedback --------- Co-authored-by: Gregory Edison <[email protected]>
1 parent 09f6d73 commit 9faafb3

File tree

26 files changed

+1018
-313
lines changed

26 files changed

+1018
-313
lines changed

Cargo.lock

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

bin/rollup/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exclude.workspace = true
1010
# alloy
1111
alloy-chains.workspace = true
1212
alloy-provider.workspace = true
13+
alloy-primitives.workspace = true
1314
alloy-rpc-types-engine.workspace = true
1415
alloy-rpc-client.workspace = true
1516
alloy-transport.workspace = true
@@ -50,6 +51,7 @@ scroll-wire.workspace = true
5051
# rollup-node
5152
rollup-node-manager.workspace = true
5253
rollup-node-providers.workspace = true
54+
rollup-node-sequencer.workspace = true
5355
rollup-node-watcher.workspace = true
5456

5557
# misc

bin/rollup/src/args.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::constants;
2+
use alloy_primitives::Address;
23
use std::path::PathBuf;
34

45
/// A struct that represents the arguments for the rollup node.
@@ -20,6 +21,9 @@ pub struct ScrollRollupNodeArgs {
2021
/// The provider arguments
2122
#[command(flatten)]
2223
pub l1_provider_args: L1ProviderArgs,
24+
/// The sequencer arguments
25+
#[command(flatten)]
26+
pub sequencer_args: Option<SequencerArgs>,
2327
}
2428

2529
#[derive(Debug, clap::Args)]
@@ -40,3 +44,19 @@ pub struct L1ProviderArgs {
4044
#[arg(long, default_value_t = constants::PROVIDER_INITIAL_BACKOFF)]
4145
pub initial_backoff: u64,
4246
}
47+
48+
#[derive(Debug, clap::Args)]
49+
pub struct SequencerArgs {
50+
/// The block time for the sequencer.
51+
#[arg(long)]
52+
pub block_time: u64,
53+
/// The payload building duration for the sequencer (milliseconds)
54+
#[arg(long)]
55+
pub payload_building_duration: u64,
56+
/// The max L1 messages per block for the sequencer.
57+
#[arg(long)]
58+
pub max_l1_messages_per_block: u64,
59+
/// The fee recipient for the sequencer.
60+
#[arg(long)]
61+
pub fee_recipient: Option<Address>,
62+
}

bin/rollup/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Scroll Network Bridge Components.
22
33
mod args;
4-
pub use args::{L1ProviderArgs, ScrollRollupNodeArgs};
4+
pub use args::{L1ProviderArgs, ScrollRollupNodeArgs, SequencerArgs};
55

66
mod constants;
77
pub use constants::{PROVIDER_INITIAL_BACKOFF, PROVIDER_MAX_RETRIES, WATCHER_START_BLOCK_NUMBER};

bin/rollup/src/network.rs

+32-6
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ use reth_scroll_primitives::ScrollPrimitives;
1212
use reth_transaction_pool::{PoolTransaction, TransactionPool};
1313
use rollup_node_manager::{PoAConsensus, RollupNodeManager};
1414
use rollup_node_providers::{beacon_provider, DatabaseL1MessageProvider, OnlineL1Provider};
15+
use rollup_node_sequencer::Sequencer;
1516
use rollup_node_watcher::L1Watcher;
1617
use scroll_alloy_provider::ScrollAuthEngineApiProvider;
1718
use scroll_db::{Database, DatabaseConnectionProvider};
1819
use scroll_engine::{test_utils::NoopExecutionPayloadProvider, EngineDriver, ForkchoiceState};
1920
use scroll_network::NetworkManager as ScrollNetworkManager;
2021
use scroll_wire::{ProtocolHandler, ScrollWireConfig};
21-
use std::sync::Arc;
22+
use std::{sync::Arc, time::Duration};
2223
use tracing::info;
2324

2425
use crate::{
2526
constants::PROVIDER_BLOB_CACHE_SIZE, L1ProviderArgs, ScrollRollupNodeArgs,
2627
WATCHER_START_BLOCK_NUMBER,
2728
};
2829

29-
/// The network builder for the eth-wire to scroll-wire bridge.
30+
/// The network builder for the scroll rollup.
3031
#[derive(Debug)]
3132
pub struct ScrollRollupNetworkBuilder {
3233
config: ScrollRollupNodeArgs,
@@ -100,7 +101,20 @@ where
100101
auth_secret,
101102
self.config.engine_api_url.unwrap_or(format!("http://localhost:{auth_port}").parse()?),
102103
);
103-
let engine = EngineDriver::new(engine_api, payload_provider);
104+
let fcs =
105+
ForkchoiceState::head_from_genesis(ctx.config().chain.genesis_header().hash_slow());
106+
let engine = EngineDriver::new(
107+
Arc::new(engine_api),
108+
Arc::new(payload_provider),
109+
fcs,
110+
Duration::from_millis(
111+
self.config
112+
.sequencer_args
113+
.as_ref()
114+
.map(|args| args.payload_building_duration)
115+
.unwrap_or(0),
116+
),
117+
);
104118

105119
// Instantiate the database
106120
let database_path = if let Some(db_path) = self.config.database_path {
@@ -144,18 +158,30 @@ where
144158
OnlineL1Provider::new(beacon_provider, PROVIDER_BLOB_CACHE_SIZE, l1_messages_provider)
145159
.await;
146160

161+
// Construct the Sequencer.
162+
let (sequencer, block_time) = if let Some(args) = self.config.sequencer_args {
163+
let message_provider = DatabaseL1MessageProvider::new(db.clone(), 0);
164+
let sequencer = Sequencer::new(
165+
Arc::new(message_provider),
166+
args.fee_recipient.unwrap_or_default(),
167+
args.max_l1_messages_per_block,
168+
);
169+
(Some(sequencer), Some(args.block_time))
170+
} else {
171+
(None, None)
172+
};
173+
147174
// Spawn the rollup node manager
148175
let rollup_node_manager = RollupNodeManager::new(
149176
scroll_network_manager,
150177
engine,
151178
l1_provider,
152179
db,
153180
l1_notification_rx,
154-
// initiating the safe and finalized block info with a null hash triggers a backfill
155-
// using the unsafe head at the EN.
156-
ForkchoiceState::default(),
157181
consensus,
158182
block_rx,
183+
sequencer,
184+
block_time,
159185
);
160186

161187
ctx.task_executor().spawn(rollup_node_manager);

bin/rollup/tests/e2e.rs

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ pub async fn build_bridge_node(
145145
initial_backoff: 100,
146146
},
147147
engine_api_url: None,
148+
sequencer_args: None,
148149
};
149150
let node = ScrollNode;
150151
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone())

crates/engine/Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ scroll-alloy-provider.workspace = true
2222
scroll-alloy-rpc-types-engine.workspace = true
2323

2424
# reth
25+
reth-network-api.workspace = true
2526
reth-payload-primitives = { git = "https://github.com/scroll-tech/reth.git" }
2627
reth-primitives = { workspace = true }
2728

@@ -34,9 +35,13 @@ reth-scroll-engine-primitives = { git = "https://github.com/scroll-tech/reth.git
3435
rollup-node-primitives.workspace = true
3536
rollup-node-providers.workspace = true
3637

38+
# scroll
39+
scroll-network.workspace = true
40+
3741
# misc
3842
async-trait.workspace = true
3943
eyre.workspace = true
44+
futures.workspace = true
4045
thiserror.workspace = true
4146
tokio.workspace = true
4247
tracing.workspace = true
@@ -71,4 +76,6 @@ serde = [
7176
"reth-scroll-primitives/serde",
7277
"scroll-alloy-rpc-types-engine/serde",
7378
"alloy-chains/serde",
79+
"reth-network-api/serde",
80+
"scroll-network/serde",
7481
]

0 commit comments

Comments
 (0)