Skip to content

Commit f13be70

Browse files
authored
[breaking-change] Fix arg for calculating state root (#314)
* Fix arg for calculating state root * fix tests
1 parent b473f4e commit f13be70

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

crates/op-rbuilder/src/args/op.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ pub struct FlashblocksArgs {
149149
)]
150150
pub flashblocks_leeway_time: u64,
151151

152-
/// Should we calculate state root for each flashblock
152+
/// Whether to disable state root calculation for each flashblock
153153
#[arg(
154-
long = "flashblocks.calculate-state-root",
155-
default_value = "true",
156-
env = "FLASHBLOCKS_CALCULATE_STATE_ROOT"
154+
long = "flashblocks.disable-state-root",
155+
default_value = "false",
156+
env = "FLASHBLOCKS_DISABLE_STATE_ROOT"
157157
)]
158-
pub flashblocks_calculate_state_root: bool,
158+
pub flashblocks_disable_state_root: bool,
159159

160160
/// Flashblocks number contract address
161161
///

crates/op-rbuilder/src/builders/flashblocks/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub struct FlashblocksConfig {
3131
/// Disables dynamic flashblocks number adjustment based on FCU arrival time
3232
pub fixed: bool,
3333

34-
/// Should we calculate state root for each flashblock
35-
pub calculate_state_root: bool,
34+
/// Should we disable state root calculation for each flashblock
35+
pub disable_state_root: bool,
3636

3737
/// The address of the flashblocks number contract.
3838
///
@@ -65,7 +65,7 @@ impl Default for FlashblocksConfig {
6565
interval: Duration::from_millis(250),
6666
leeway_time: Duration::from_millis(50),
6767
fixed: false,
68-
calculate_state_root: true,
68+
disable_state_root: false,
6969
flashblocks_number_contract_address: None,
7070
flashblocks_number_contract_use_permit: false,
7171
p2p_enabled: false,
@@ -92,7 +92,7 @@ impl TryFrom<OpRbuilderArgs> for FlashblocksConfig {
9292

9393
let fixed = args.flashblocks.flashblocks_fixed;
9494

95-
let calculate_state_root = args.flashblocks.flashblocks_calculate_state_root;
95+
let disable_state_root = args.flashblocks.flashblocks_disable_state_root;
9696

9797
let flashblocks_number_contract_address =
9898
args.flashblocks.flashblocks_number_contract_address;
@@ -105,7 +105,7 @@ impl TryFrom<OpRbuilderArgs> for FlashblocksConfig {
105105
interval,
106106
leeway_time,
107107
fixed,
108-
calculate_state_root,
108+
disable_state_root,
109109
flashblocks_number_contract_address,
110110
flashblocks_number_contract_use_permit,
111111
p2p_enabled: args.flashblocks.p2p.p2p_enabled,

crates/op-rbuilder/src/builders/flashblocks/payload.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ pub struct FlashblocksExtraCtx {
8787
gas_per_batch: u64,
8888
/// DA bytes limit per flashblock
8989
da_per_batch: Option<u64>,
90-
/// Whether to calculate the state root for each flashblock
91-
calculate_state_root: bool,
90+
/// Whether to disable state root calculation for each flashblock
91+
disable_state_root: bool,
9292
}
9393

9494
impl FlashblocksExtraCtx {
@@ -299,14 +299,14 @@ where
299299
);
300300

301301
let timestamp = config.attributes.timestamp();
302-
let calculate_state_root = self.config.specific.calculate_state_root;
302+
let disable_state_root = self.config.specific.disable_state_root;
303303
let ctx = self
304304
.get_op_payload_builder_ctx(
305305
config.clone(),
306306
block_cancel.clone(),
307307
FlashblocksExtraCtx {
308308
target_flashblock_count: self.config.flashblocks_per_block(),
309-
calculate_state_root,
309+
disable_state_root,
310310
..Default::default()
311311
},
312312
)
@@ -355,7 +355,7 @@ where
355355
&mut state,
356356
&ctx,
357357
&mut info,
358-
calculate_state_root || ctx.attributes().no_tx_pool, // need to calculate state root for CL sync
358+
!disable_state_root || ctx.attributes().no_tx_pool, // need to calculate state root for CL sync
359359
)?;
360360

361361
self.payload_tx
@@ -450,7 +450,7 @@ where
450450
target_da_for_batch,
451451
gas_per_batch,
452452
da_per_batch,
453-
calculate_state_root,
453+
disable_state_root,
454454
};
455455

456456
let mut fb_cancel = block_cancel.child_token();
@@ -699,7 +699,7 @@ where
699699
state,
700700
ctx,
701701
info,
702-
ctx.extra_ctx.calculate_state_root || ctx.attributes().no_tx_pool,
702+
!ctx.extra_ctx.disable_state_root || ctx.attributes().no_tx_pool,
703703
);
704704
let total_block_built_duration = total_block_built_duration.elapsed();
705705
ctx.metrics

crates/op-rbuilder/src/tests/flashblocks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ async fn test_flashblock_min_max_filtering(rbuilder: LocalInstance) -> eyre::Res
419419
flashblocks_block_time: 200,
420420
flashblocks_leeway_time: 100,
421421
flashblocks_fixed: false,
422-
flashblocks_calculate_state_root: false,
422+
flashblocks_disable_state_root: true,
423423
..Default::default()
424424
},
425425
..Default::default()
@@ -436,7 +436,7 @@ async fn test_flashblocks_no_state_root_calculation(rbuilder: LocalInstance) ->
436436
.send()
437437
.await?;
438438

439-
// Build a block with current timestamp (not historical) and calculate_state_root: false
439+
// Build a block with current timestamp (not historical) and disable_state_root: true
440440
let block = driver.build_new_block_with_current_timestamp(None).await?;
441441

442442
// Verify that flashblocks are still produced (block should have transactions)
@@ -449,7 +449,7 @@ async fn test_flashblocks_no_state_root_calculation(rbuilder: LocalInstance) ->
449449
assert_eq!(
450450
block.header.state_root,
451451
B256::ZERO,
452-
"State root should be zero when calculate_state_root is false"
452+
"State root should be zero when disable_state_root is true"
453453
);
454454

455455
Ok(())

0 commit comments

Comments
 (0)