Skip to content

Commit b0cf339

Browse files
committed
Fallback to self build if no active builders
1 parent 4a55399 commit b0cf339

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

block_producer/src/block_producer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,12 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
11661166
local_execution_payload_handle: Option<LocalExecutionPayloadJoinHandle<P>>,
11671167
) -> Result<Option<(WithBlobsAndMev<BeaconBlock<P>, P>, Option<BlockRewards>)>> {
11681168
// Start from Gloas, proposer no longer required to build execution payload data
1169-
// unless they choose to self-build
1169+
// unless they choose to self-build, as favor or no active builders
11701170
let mut payload_with_data = None;
1171-
if (!self.beacon_state.is_post_gloas() || self.options.enable_payload_build)
1172-
&& let Some(handle) = local_execution_payload_handle
1171+
if self.beacon_state.post_gloas().is_none_or(|state| {
1172+
self.options.enable_payload_build
1173+
|| accessors::get_active_builder_indices(state).count() == 0
1174+
}) && let Some(handle) = local_execution_payload_handle
11731175
{
11741176
payload_with_data = handle
11751177
.await?

helper_functions/src/accessors.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,17 @@ pub fn get_builder_payment_quorum_threshold<P: Preset>(state: &impl BeaconState<
11681168
quorum.saturating_div(BUILDER_PAYMENT_THRESHOLD_DENOMINATOR)
11691169
}
11701170

1171+
pub fn get_active_builder_indices<P: Preset>(
1172+
state: &(impl PostGloasBeaconState<P> + ?Sized),
1173+
) -> impl Iterator<Item = ValidatorIndex> + '_ {
1174+
(0..)
1175+
.zip(state.builders())
1176+
.filter(move |(_, builder)| {
1177+
predicates::is_active_builder(builder, state.finalized_checkpoint().epoch)
1178+
})
1179+
.map(|(index, _)| index)
1180+
}
1181+
11711182
#[cfg(test)]
11721183
mod tests {
11731184
use types::{

0 commit comments

Comments
 (0)