Skip to content

Commit 2beb7e0

Browse files
committed
Merge branch 'main' into feat/chain-orchestrator
2 parents 00d18f2 + b06b649 commit 2beb7e0

File tree

16 files changed

+423
-72
lines changed

16 files changed

+423
-72
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- name: Extract docker metadata
3131
id: meta
32-
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
32+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
3333
with:
3434
images: scrolltech/rollup-node
3535
tags: |

crates/node/src/add_ons/rollup.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use reth_network_api::FullNetwork;
66
use reth_node_api::{FullNodeTypes, NodeTypes};
77
use reth_node_builder::{rpc::RpcHandle, AddOnsContext, FullNodeComponents};
88
use reth_rpc_eth_api::EthApiTypes;
9-
use reth_scroll_chainspec::ScrollChainSpec;
9+
use reth_scroll_chainspec::{ChainConfig, ScrollChainConfig, ScrollChainSpec};
1010
use reth_scroll_node::ScrollNetworkPrimitives;
1111
use rollup_node_manager::RollupManagerHandle;
1212
use rollup_node_watcher::L1Notification;
@@ -52,18 +52,13 @@ impl RollupManagerAddOn {
5252
rpc: RpcHandle<N, EthApi>,
5353
) -> eyre::Result<(RollupManagerHandle, Option<Sender<Arc<L1Notification>>>)>
5454
where
55-
<<N as FullNodeTypes>::Types as NodeTypes>::ChainSpec: ScrollHardforks + IsDevChain,
55+
<<N as FullNodeTypes>::Types as NodeTypes>::ChainSpec:
56+
ChainConfig<Config = ScrollChainConfig> + ScrollHardforks + IsDevChain,
5657
N::Network: NetworkProtocols + FullNetwork<Primitives = ScrollNetworkPrimitives>,
5758
{
5859
let (rnm, handle, l1_notification_tx) = self
5960
.config
60-
.build(
61-
ctx.node.network().clone(),
62-
self.scroll_wire_event,
63-
rpc.rpc_server_handles,
64-
ctx.config.chain.clone(),
65-
ctx.config.datadir().db(),
66-
)
61+
.build((&ctx).into(), self.scroll_wire_event, rpc.rpc_server_handles)
6762
.await?;
6863
ctx.node
6964
.task_executor()

crates/node/src/args.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::{
22
add_ons::IsDevChain,
33
constants::{self},
4+
context::RollupNodeContext,
45
};
56
use std::{fs, path::PathBuf, sync::Arc, time::Duration};
67

@@ -17,7 +18,7 @@ use reth_network::NetworkProtocols;
1718
use reth_network_api::FullNetwork;
1819
use reth_node_builder::rpc::RethRpcServerHandles;
1920
use reth_node_core::primitives::BlockHeader;
20-
use reth_scroll_chainspec::SCROLL_FEE_VAULT_ADDRESS;
21+
use reth_scroll_chainspec::{ChainConfig, ScrollChainConfig, SCROLL_FEE_VAULT_ADDRESS};
2122
use reth_scroll_node::ScrollNetworkPrimitives;
2223
use rollup_node_chain_orchestrator::ChainOrchestrator;
2324
use rollup_node_manager::{
@@ -113,22 +114,11 @@ impl ScrollRollupNodeConfig {
113114

114115
impl ScrollRollupNodeConfig {
115116
/// Consumes the [`ScrollRollupNodeConfig`] and builds a [`RollupNodeManager`].
116-
pub async fn build<
117-
N: FullNetwork<Primitives = ScrollNetworkPrimitives> + NetworkProtocols,
118-
CS: ScrollHardforks
119-
+ EthChainSpec<Header: BlockHeader>
120-
+ IsDevChain
121-
+ Clone
122-
+ Send
123-
+ Sync
124-
+ 'static,
125-
>(
117+
pub async fn build<N, CS>(
126118
self,
127-
network: N,
119+
ctx: RollupNodeContext<N, CS>,
128120
events: UnboundedReceiver<ScrollWireEvent>,
129121
rpc_server_handles: RethRpcServerHandles,
130-
chain_spec: CS,
131-
db_path: PathBuf,
132122
) -> eyre::Result<(
133123
RollupNodeManager<
134124
N,
@@ -140,11 +130,21 @@ impl ScrollRollupNodeConfig {
140130
>,
141131
RollupManagerHandle,
142132
Option<Sender<Arc<L1Notification>>>,
143-
)> {
133+
)>
134+
where
135+
N: FullNetwork<Primitives = ScrollNetworkPrimitives> + NetworkProtocols,
136+
CS: EthChainSpec<Header: BlockHeader>
137+
+ ChainConfig<Config = ScrollChainConfig>
138+
+ ScrollHardforks
139+
+ IsDevChain
140+
+ 'static,
141+
{
144142
tracing::info!(target: "rollup_node::args",
145143
"Building rollup node with config:\n{:#?}",
146144
self
147145
);
146+
// Get the chain spec.
147+
let chain_spec = ctx.chain_spec;
148148

149149
// Get the rollup node config.
150150
let named_chain = chain_spec.chain().named().expect("expected named chain");
@@ -175,6 +175,7 @@ impl ScrollRollupNodeConfig {
175175
let l2_provider = Arc::new(l2_provider);
176176

177177
// Instantiate the database
178+
let db_path = ctx.datadir;
178179
let database_path = if let Some(database_path) = self.database_args.path {
179180
database_path.to_string_lossy().to_string()
180181
} else {
@@ -208,10 +209,10 @@ impl ScrollRollupNodeConfig {
208209
let eth_wire_listener = self
209210
.network_args
210211
.enable_eth_scroll_wire_bridge
211-
.then_some(network.eth_wire_block_listener().await?);
212+
.then_some(ctx.network.eth_wire_block_listener().await?);
212213
let scroll_network_manager = ScrollNetworkManager::from_parts(
213214
chain_spec.clone(),
214-
network.clone(),
215+
ctx.network.clone(),
215216
events,
216217
eth_wire_listener,
217218
self.network_args.eth_wire_gossip,
@@ -282,12 +283,14 @@ impl ScrollRollupNodeConfig {
282283
let l1_provider = FullL1Provider::new(blob_provider, l1_messages_provider.clone()).await;
283284

284285
// Construct the Sequencer.
286+
let chain_config = chain_spec.chain_config();
285287
let (sequencer, block_time) = if self.sequencer_args.sequencer_enabled {
286288
let args = &self.sequencer_args;
287289
let sequencer = Sequencer::new(
288290
Arc::new(l1_messages_provider),
289291
args.fee_recipient,
290-
args.max_l1_messages_per_block,
292+
ctx.block_gas_limit,
293+
chain_config.l1_config.num_l1_messages_per_block,
291294
0,
292295
self.sequencer_args.l1_message_inclusion_mode,
293296
);
@@ -536,9 +539,6 @@ pub struct SequencerArgs {
536539
/// The payload building duration for the sequencer (milliseconds)
537540
#[arg(long = "sequencer.payload-building-duration", id = "sequencer_payload_building_duration", value_name = "SEQUENCER_PAYLOAD_BUILDING_DURATION", default_value_t = constants::DEFAULT_PAYLOAD_BUILDING_DURATION)]
538541
pub payload_building_duration: u64,
539-
/// The max L1 messages per block for the sequencer.
540-
#[arg(long = "sequencer.max-l1-messages-per-block", id = "sequencer_max_l1_messages_per_block", value_name = "SEQUENCER_MAX_L1_MESSAGES_PER_BLOCK", default_value_t = constants::DEFAULT_MAX_L1_MESSAGES_PER_BLOCK)]
541-
pub max_l1_messages_per_block: u64,
542542
/// The fee recipient for the sequencer.
543543
#[arg(long = "sequencer.fee-recipient", id = "sequencer_fee_recipient", value_name = "SEQUENCER_FEE_RECIPIENT", default_value_t = SCROLL_FEE_VAULT_ADDRESS)]
544544
pub fee_recipient: Address,

crates/node/src/constants.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Constants related to the [`crate::ScrollRollupNode`]
2+
13
/// The max retries for the L1 provider.
24
pub(crate) const PROVIDER_MAX_RETRIES: u32 = 10;
35

@@ -16,9 +18,6 @@ pub(crate) const DEFAULT_PAYLOAD_BUILDING_DURATION: u64 = 800;
1618
/// The default payload size limit in bytes for the sequencer.
1719
pub(crate) const DEFAULT_PAYLOAD_SIZE_LIMIT: u64 = 122_880;
1820

19-
/// The default max L1 messages per block for the sequencer.
20-
pub(crate) const DEFAULT_MAX_L1_MESSAGES_PER_BLOCK: u64 = 4;
21-
2221
/// The gap in blocks between the P2P and EN which triggers sync.
2322
pub(crate) const BLOCK_GAP_TRIGGER: u64 = 100_000;
2423

@@ -27,3 +26,7 @@ pub(crate) const CHAIN_BUFFER_SIZE: usize = 2000;
2726

2827
/// The default suggested priority fee for the gas price oracle.
2928
pub(crate) const DEFAULT_SUGGEST_PRIORITY_FEE: u64 = 100;
29+
30+
/// Scroll default gas limit.
31+
/// Should match <https://github.com/scroll-tech/reth/blob/scroll/crates/scroll/node/src/builder/payload.rs#L36>.
32+
pub const SCROLL_GAS_LIMIT: u64 = 20_000_000;

crates/node/src/context.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use crate::constants::SCROLL_GAS_LIMIT;
2+
use reth_node_api::{AddOnsContext, FullNodeComponents, FullNodeTypes};
3+
use reth_node_core::cli::config::PayloadBuilderConfig;
4+
use reth_node_types::NodeTypes;
5+
use std::{path::PathBuf, sync::Arc};
6+
7+
/// The context passed to `ScrollRollupNodeConfig::build` method.
8+
#[derive(Debug)]
9+
pub struct RollupNodeContext<N, CS> {
10+
/// The network component of the rollup node.
11+
pub network: N,
12+
/// The chain specification of the rollup node.
13+
pub chain_spec: Arc<CS>,
14+
/// The datadir of the rollup node.
15+
pub datadir: PathBuf,
16+
/// The block gas limit of the rollup node.
17+
pub block_gas_limit: u64,
18+
}
19+
20+
impl<N, CS> RollupNodeContext<N, CS> {
21+
/// Returns a new instance of the [`RollupNodeContext`].
22+
pub const fn new(
23+
network: N,
24+
chain_spec: Arc<CS>,
25+
datadir: PathBuf,
26+
block_gas_limit: u64,
27+
) -> Self {
28+
Self { network, chain_spec, datadir, block_gas_limit }
29+
}
30+
}
31+
32+
impl<N> From<&AddOnsContext<'_, N>>
33+
for RollupNodeContext<N::Network, <<N as FullNodeTypes>::Types as NodeTypes>::ChainSpec>
34+
where
35+
N: FullNodeComponents,
36+
{
37+
fn from(value: &AddOnsContext<'_, N>) -> Self {
38+
Self {
39+
network: value.node.network().clone(),
40+
chain_spec: value.config.chain.clone(),
41+
datadir: value.config.datadir().db(),
42+
block_gas_limit: value.config.builder.gas_limit().unwrap_or(SCROLL_GAS_LIMIT),
43+
}
44+
}
45+
}

crates/node/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
33
pub mod add_ons;
44
mod args;
5-
mod constants;
5+
pub mod constants;
6+
mod context;
67
mod node;
78
#[cfg(feature = "test-utils")]
89
pub mod test_utils;
910

1011
pub use args::*;
12+
pub use context::RollupNodeContext;
1113
pub use node::ScrollRollupNode;

crates/node/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ fn main() {
2323
let handle = builder
2424
.node(ScrollRollupNode::new(args))
2525
.launch_with_fn(|builder| {
26+
info!(target: "reth::cli", config = ?builder.config().chain.config, "Running with config");
27+
2628
// We must use `always_process_payload_attributes_on_canonical_head` in order to
2729
// be able to build payloads with the forkchoice state API
2830
// on top of heads part of the canonical state. Not

crates/node/src/test_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeCon
176176
sequencer_enabled: true,
177177
block_time: 50,
178178
payload_building_duration: 40,
179-
max_l1_messages_per_block: 0,
180179
fee_recipient: Default::default(),
181180
l1_message_inclusion_mode: L1MessageInclusionMode::BlockDepth(0),
182181
},

crates/node/tests/e2e.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ use reth_scroll_chainspec::SCROLL_DEV;
1313
use reth_scroll_node::ScrollNetworkPrimitives;
1414
use reth_tokio_util::EventStream;
1515
use rollup_node::{
16+
constants::SCROLL_GAS_LIMIT,
1617
test_utils::{
1718
default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
1819
generate_tx, setup_engine,
1920
},
2021
BeaconProviderArgs, ChainOrchestratorArgs, ConsensusAlgorithm, ConsensusArgs, DatabaseArgs,
2122
EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs, NetworkArgs as ScrollNetworkArgs,
22-
ScrollRollupNodeConfig, SequencerArgs,
23+
RollupNodeContext, ScrollRollupNodeConfig, SequencerArgs,
2324
};
2425
use rollup_node_chain_orchestrator::ChainOrchestratorEvent;
2526
use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent, RollupManagerHandle};
@@ -50,7 +51,6 @@ async fn can_bridge_l1_messages() -> eyre::Result<()> {
5051
sequencer_args: SequencerArgs {
5152
sequencer_enabled: true,
5253
block_time: 0,
53-
max_l1_messages_per_block: 4,
5454
l1_message_inclusion_mode: L1MessageInclusionMode::BlockDepth(0),
5555
..SequencerArgs::default()
5656
},
@@ -146,7 +146,6 @@ async fn can_sequence_and_gossip_blocks() {
146146
sequencer_args: SequencerArgs {
147147
sequencer_enabled: true,
148148
block_time: 0,
149-
max_l1_messages_per_block: 4,
150149
l1_message_inclusion_mode: L1MessageInclusionMode::BlockDepth(0),
151150
payload_building_duration: 1000,
152151
..SequencerArgs::default()
@@ -587,11 +586,14 @@ async fn graceful_shutdown_consolidates_most_recent_batch_on_startup() -> eyre::
587586
let (rnm, handle, l1_notification_tx) = config
588587
.clone()
589588
.build(
590-
node.inner.network.clone(),
589+
RollupNodeContext::new(
590+
node.inner.network.clone(),
591+
chain_spec.clone(),
592+
path.clone(),
593+
SCROLL_GAS_LIMIT,
594+
),
591595
events,
592596
node.inner.add_ons_handle.rpc_handle.rpc_server_handles.clone(),
593-
chain_spec.clone(),
594-
path.clone(),
595597
)
596598
.await?;
597599

@@ -694,11 +696,14 @@ async fn graceful_shutdown_consolidates_most_recent_batch_on_startup() -> eyre::
694696
let (rnm, handle, l1_notification_tx) = config
695697
.clone()
696698
.build(
697-
node.inner.network.clone(),
699+
RollupNodeContext::new(
700+
node.inner.network.clone(),
701+
chain_spec,
702+
path.clone(),
703+
SCROLL_GAS_LIMIT,
704+
),
698705
events,
699706
node.inner.add_ons_handle.rpc_handle.rpc_server_handles.clone(),
700-
chain_spec,
701-
path.clone(),
702707
)
703708
.await?;
704709
let l1_notification_tx = l1_notification_tx.unwrap();
@@ -876,7 +881,6 @@ async fn can_handle_reorgs_while_sequencing() -> eyre::Result<()> {
876881
.expect("valid url that will not be used as test batches use calldata"),
877882
);
878883
config.engine_driver_args.sync_at_startup = false;
879-
config.sequencer_args.max_l1_messages_per_block = 1;
880884
let (mut nodes, _tasks, _) = setup_engine(config, 1, chain_spec.clone(), false, false).await?;
881885
let node = nodes.pop().unwrap();
882886

crates/node/tests/sync.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ async fn test_should_consolidate_after_optimistic_sync() -> eyre::Result<()> {
195195
sequencer_args: SequencerArgs {
196196
sequencer_enabled: true,
197197
block_time: 0,
198-
max_l1_messages_per_block: 4,
199198
l1_message_inclusion_mode: L1MessageInclusionMode::BlockDepth(0),
200199
..SequencerArgs::default()
201200
},
@@ -444,7 +443,6 @@ async fn test_consolidation() -> eyre::Result<()> {
444443
sequencer_args: SequencerArgs {
445444
sequencer_enabled: true,
446445
block_time: 0,
447-
max_l1_messages_per_block: 4,
448446
l1_message_inclusion_mode: L1MessageInclusionMode::BlockDepth(0),
449447
..SequencerArgs::default()
450448
},
@@ -617,7 +615,6 @@ async fn test_chain_orchestrator_shallow_reorg_with_gap() -> eyre::Result<()> {
617615
sequencer_args: SequencerArgs {
618616
sequencer_enabled: true,
619617
block_time: 0,
620-
max_l1_messages_per_block: 4,
621618
l1_message_inclusion_mode: L1MessageInclusionMode::BlockDepth(0),
622619
..SequencerArgs::default()
623620
},

0 commit comments

Comments
 (0)