11//! The [`ScrollRollupNodeAddOns`] implementation for the Scroll rollup node.
22
33use super :: args:: ScrollRollupNodeConfig ;
4+ use crate :: constants;
5+
46use reth_evm:: { ConfigureEvm , EvmFactory , EvmFactoryFor } ;
57use reth_network:: NetworkProtocols ;
68use reth_network_api:: FullNetwork ;
79use reth_node_api:: { AddOnsContext , NodeAddOns } ;
810use reth_node_builder:: {
911 rpc:: {
1012 BasicEngineApiBuilder , EngineValidatorAddOn , EngineValidatorBuilder , EthApiBuilder ,
11- RethRpcAddOns , RpcAddOns , RpcHandle ,
13+ Identity , RethRpcAddOns , RethRpcMiddleware , RpcAddOns ,
1214 } ,
1315 FullNodeComponents ,
1416} ;
@@ -22,7 +24,7 @@ use reth_scroll_node::{
2224 ScrollEngineValidator , ScrollEngineValidatorBuilder , ScrollNetworkPrimitives , ScrollStorage ,
2325} ;
2426use reth_scroll_primitives:: ScrollPrimitives ;
25- use reth_scroll_rpc:: { eth:: ScrollEthApiBuilder , ScrollEthApi , ScrollEthApiError } ;
27+ use reth_scroll_rpc:: { eth:: ScrollEthApiBuilder , ScrollEthApiError } ;
2628use scroll_alloy_evm:: ScrollTransactionIntoTxEnv ;
2729use scroll_wire:: ScrollWireEvent ;
2830
@@ -36,7 +38,7 @@ use tokio::sync::mpsc::UnboundedReceiver;
3638
3739/// Add-ons for the Scroll follower node.
3840#[ derive( Debug ) ]
39- pub struct ScrollRollupNodeAddOns < N >
41+ pub struct ScrollRollupNodeAddOns < N , RpcMiddleware = Identity >
4042where
4143 N : FullNodeComponents ,
4244 ScrollEthApiBuilder : EthApiBuilder < N > ,
4850 ScrollEthApiBuilder ,
4951 ScrollEngineValidatorBuilder ,
5052 BasicEngineApiBuilder < ScrollEngineValidatorBuilder > ,
53+ RpcMiddleware ,
5154 > ,
5255
5356 /// Rollup manager addon responsible for managing the components of the rollup node.
@@ -65,16 +68,33 @@ where
6568 ) -> Self {
6669 let rpc_add_ons = RpcAddOns :: new (
6770 ScrollEthApiBuilder :: default ( )
71+ . with_min_suggested_priority_fee (
72+ config. gas_price_oracle_args . default_suggested_priority_fee ,
73+ )
74+ . with_payload_size_limit ( constants:: DEFAULT_PAYLOAD_SIZE_LIMIT )
6875 . with_sequencer ( config. network_args . sequencer_url . clone ( ) ) ,
6976 Default :: default ( ) ,
7077 Default :: default ( ) ,
71- Default :: default ( ) ,
78+ Identity :: new ( ) ,
7279 ) ;
7380 let rollup_manager_addon = RollupManagerAddOn :: new ( config, scroll_wire_event) ;
7481 Self { rpc_add_ons, rollup_manager_addon }
7582 }
7683}
77- impl < N > NodeAddOns < N > for ScrollRollupNodeAddOns < N >
84+
85+ impl < N , RpcMiddleware > ScrollRollupNodeAddOns < N , RpcMiddleware >
86+ where
87+ N : FullNodeComponents ,
88+ ScrollEthApiBuilder : EthApiBuilder < N > ,
89+ {
90+ /// Sets the provided middleware for the rollup node addons.
91+ pub fn with_middleware < T > ( self , middleware : T ) -> ScrollRollupNodeAddOns < N , T > {
92+ let rpc_add_ons = self . rpc_add_ons . with_rpc_middleware ( middleware) ;
93+ ScrollRollupNodeAddOns { rpc_add_ons, rollup_manager_addon : self . rollup_manager_addon }
94+ }
95+ }
96+
97+ impl < N , RpcMiddleware > NodeAddOns < N > for ScrollRollupNodeAddOns < N , RpcMiddleware >
7898where
7999 N : FullNodeComponents <
80100 Types : NodeTypes <
@@ -88,16 +108,13 @@ where
88108 > ,
89109 ScrollEthApiError : FromEvmError < N :: Evm > ,
90110 EvmFactoryFor < N :: Evm > : EvmFactory < Tx = ScrollTransactionIntoTxEnv < TxEnv > > ,
111+ RpcMiddleware : RethRpcMiddleware ,
91112{
92- type Handle = ScrollAddOnsHandle < N , ScrollEthApi < N > > ;
113+ type Handle = ScrollAddOnsHandle < N , < ScrollEthApiBuilder as EthApiBuilder < N > > :: EthApi > ;
93114
94- async fn launch_add_ons (
95- self ,
96- ctx : reth_node_api:: AddOnsContext < ' _ , N > ,
97- ) -> eyre:: Result < Self :: Handle > {
115+ async fn launch_add_ons ( self , ctx : AddOnsContext < ' _ , N > ) -> eyre:: Result < Self :: Handle > {
98116 let Self { rpc_add_ons, rollup_manager_addon : rollup_node_manager_addon } = self ;
99- let rpc_handle: RpcHandle < N , ScrollEthApi < N > > =
100- rpc_add_ons. launch_add_ons_with ( ctx. clone ( ) , |_| Ok ( ( ) ) ) . await ?;
117+ let rpc_handle = rpc_add_ons. launch_add_ons_with ( ctx. clone ( ) , |_| Ok ( ( ) ) ) . await ?;
101118 let ( rollup_manager_handle, l1_watcher_tx) =
102119 rollup_node_manager_addon. launch ( ctx. clone ( ) , rpc_handle. clone ( ) ) . await ?;
103120 Ok ( ScrollAddOnsHandle {
@@ -109,7 +126,7 @@ where
109126 }
110127}
111128
112- impl < N > RethRpcAddOns < N > for ScrollRollupNodeAddOns < N >
129+ impl < N , RpcMiddleware > RethRpcAddOns < N > for ScrollRollupNodeAddOns < N , RpcMiddleware >
113130where
114131 N : FullNodeComponents <
115132 Types : NodeTypes <
@@ -123,8 +140,9 @@ where
123140 > ,
124141 ScrollEthApiError : FromEvmError < N :: Evm > ,
125142 EvmFactoryFor < N :: Evm > : EvmFactory < Tx = ScrollTransactionIntoTxEnv < TxEnv > > ,
143+ RpcMiddleware : RethRpcMiddleware ,
126144{
127- type EthApi = ScrollEthApi < N > ;
145+ type EthApi = < ScrollEthApiBuilder as EthApiBuilder < N > > :: EthApi ;
128146
129147 fn hooks_mut ( & mut self ) -> & mut reth_node_builder:: rpc:: RpcHooks < N , Self :: EthApi > {
130148 self . rpc_add_ons . hooks_mut ( )
0 commit comments