Skip to content

Commit 8a574cc

Browse files
committed
Add config for block selection
1 parent 1b73e61 commit 8a574cc

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ To run rollup-boost in debug mode with a specific execution mode, you can use th
193193
rollup-boost debug set-execution-mode [enabled|dry-run|disabled]
194194
```
195195

196+
### Block Selection
197+
198+
The L2 Boost Factor is a percentage multipler to the local payload gas used to choose between local and builder payloads. This is useful for operators that want to prioritize local payloads over builder payloads under certain conditions.
199+
200+
e.g. to configure the payload selection rule such that the local payload is chosen if it has at least 30% more gas used than the builder payload, you can add the following command:
201+
202+
```
203+
rollup-boost --l2-boost-factor 130
204+
```
205+
206+
By default, the L2 Boost Factor is 0, meaning that the builder payload will always be chosen over the local payload.
207+
196208
## License
197209

198210
The code in this project is free software under the [MIT License](/LICENSE).

src/main.rs

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ struct Args {
100100
/// Execution mode to start rollup boost with
101101
#[arg(long, env, default_value = "enabled")]
102102
execution_mode: ExecutionMode,
103+
104+
/// percentage multipler to the local payload gas used for choosing payloads
105+
#[arg(long, env, default_value = "0")]
106+
l2_boost_factor: u64,
103107
}
104108

105109
#[derive(Subcommand, Debug)]
@@ -252,6 +256,7 @@ async fn main() -> eyre::Result<()> {
252256
boost_sync_enabled,
253257
metrics.clone(),
254258
args.execution_mode,
259+
args.l2_boost_factor,
255260
);
256261

257262
// Spawn the debug server

src/server.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub struct RollupBoostServer {
124124
pub metrics: Option<Arc<ServerMetrics>>,
125125
pub payload_trace_context: Arc<PayloadTraceContext>,
126126
execution_mode: Arc<Mutex<ExecutionMode>>,
127+
l2_boost_factor: u64,
127128
}
128129

129130
impl RollupBoostServer {
@@ -133,6 +134,7 @@ impl RollupBoostServer {
133134
boost_sync: bool,
134135
metrics: Option<Arc<ServerMetrics>>,
135136
initial_execution_mode: ExecutionMode,
137+
l2_boost_factor: u64,
136138
) -> Self {
137139
Self {
138140
l2_client,
@@ -141,6 +143,7 @@ impl RollupBoostServer {
141143
metrics,
142144
payload_trace_context: Arc::new(PayloadTraceContext::new()),
143145
execution_mode: Arc::new(Mutex::new(initial_execution_mode)),
146+
l2_boost_factor,
144147
}
145148
}
146149

@@ -509,7 +512,21 @@ impl RollupBoostServer {
509512

510513
let (l2_payload, builder_payload) = tokio::join!(l2_client_future, builder_client_future);
511514
let payload = match (builder_payload, l2_payload) {
512-
(Ok(builder), _) => Ok(builder),
515+
(Ok(builder), Ok(l2)) => {
516+
let builder_gas_used = builder
517+
.0
518+
.execution_payload
519+
.payload_inner
520+
.payload_inner
521+
.gas_used;
522+
let l2_gas_used = l2.0.execution_payload.payload_inner.payload_inner.gas_used;
523+
if builder_gas_used > l2_gas_used * self.l2_boost_factor {
524+
Ok(builder)
525+
} else {
526+
Ok(l2)
527+
}
528+
}
529+
(Ok(builder), Err(_)) => Ok(builder),
513530
(Err(_), Ok(l2)) => Ok(l2),
514531
(Err(_), Err(e)) => Err(e),
515532
};
@@ -719,6 +736,7 @@ mod tests {
719736
boost_sync,
720737
None,
721738
ExecutionMode::Enabled,
739+
0,
722740
);
723741

724742
let module: RpcModule<()> = rollup_boost_client.try_into().unwrap();

0 commit comments

Comments
 (0)