Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions crates/builder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ pub struct FlashblocksArgs {
)]
pub flashblocks_disable_async_calculate_state_root: bool,

/// Enable async trie precalculation during flashblock building.
/// When enabled and disable_state_root is true, background trie calculations
/// are spawned after each flashblock to speed up final state root resolution.
#[arg(
long = "flashblocks.enable-async-trie-precalc",
default_value = "false",
env = "FLASHBLOCKS_ENABLE_ASYNC_TRIE_PRECALC"
)]
pub flashblocks_enable_async_trie_precalc: bool,

/// Which flashblock index to start async trie precalculation from (0-indexed).
/// For example, with 5 flashblocks and start=2, precalculation begins after
/// flashblock 2 (skipping 0 and 1).
#[arg(
long = "flashblocks.async-trie-precalc-start-flashblock",
default_value = "1",
env = "FLASHBLOCKS_ASYNC_TRIE_PRECALC_START_FLASHBLOCK"
)]
pub flashblocks_async_trie_precalc_start_flashblock: u64,

/// Flashblocks number contract address
///
/// This is the address of the contract that will be used to increment the flashblock number.
Expand Down
2 changes: 2 additions & 0 deletions crates/builder/src/metrics/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub struct BuilderMetrics {
pub state_root_calculation_duration: Histogram,
/// Latest state root calculation duration
pub state_root_calculation_gauge: Gauge,
/// Histogram of async trie precalculation duration (background worker)
pub trie_precalc_duration: Histogram,
/// Histogram of sequencer transaction execution duration
pub sequencer_tx_duration: Histogram,
/// Latest sequencer transaction execution duration
Expand Down
14 changes: 14 additions & 0 deletions crates/builder/src/payload/flashblocks/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ pub struct FlashblocksConfig {

/// Maximum number of concurrent WebSocket subscribers
pub ws_subscriber_limit: Option<u16>,

/// Enable async trie precalculation during flashblock building.
/// When enabled and disable_state_root is true, background trie calculations
/// are spawned after each flashblock to speed up final state root resolution.
pub enable_async_trie_precalc: bool,

/// Which flashblock index to start async trie precalculation from (0-indexed).
pub async_trie_precalc_start_flashblock: u64,
}

impl Default for FlashblocksConfig {
Expand All @@ -80,6 +88,8 @@ impl Default for FlashblocksConfig {
p2p_send_full_payload: false,
p2p_process_full_payload: false,
ws_subscriber_limit: None,
enable_async_trie_precalc: false,
async_trie_precalc_start_flashblock: 1,
}
}
}
Expand Down Expand Up @@ -118,6 +128,10 @@ impl TryFrom<BuilderArgs> for FlashblocksConfig {
p2p_send_full_payload: args.flashblocks.p2p.p2p_send_full_payload,
p2p_process_full_payload: args.flashblocks.p2p.p2p_process_full_payload,
ws_subscriber_limit: args.flashblocks.ws_subscriber_limit,
enable_async_trie_precalc: args.flashblocks.flashblocks_enable_async_trie_precalc,
async_trie_precalc_start_flashblock: args
.flashblocks
.flashblocks_async_trie_precalc_start_flashblock,
})
}
}
Expand Down
Loading