Skip to content

Commit f723bf4

Browse files
committed
Skip bids from builders exited by the parent payload during block production ethereum/consensus-specs#5580
1 parent f1c171a commit f723bf4

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

beacon_node/beacon_chain/src/block_production/gloas.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ use sensitive_url::SensitiveUrl;
4646
use crate::block_production::bid_selection::{self, BidCandidate, BidSource, ExecutionPayloadData};
4747
use crate::payload_bid_verification::PayloadBidError;
4848
use crate::payload_bid_verification::direct_verified_bid::verify_direct_bid;
49-
use crate::payload_bid_verification::gossip_verified_bid::verify_bid_state_conditions;
49+
use crate::payload_bid_verification::gossip_verified_bid::{
50+
builder_exit_requested, verify_bid_state_conditions,
51+
};
5052
use crate::payload_bid_verification::payload_bid_cache::BidParent;
5153
use crate::pending_payload_envelopes::PendingEnvelopeData;
5254
use crate::{
@@ -292,6 +294,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
292294
&builder_config,
293295
proposer_preferences.as_deref(),
294296
&state,
297+
&parent_execution_requests,
295298
);
296299
let local_fut = self.clone().produce_execution_payload_bid(
297300
&state,
@@ -1019,6 +1022,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
10191022
builder_config: &BuilderConfig,
10201023
proposer_preferences: Option<&SignedProposerPreferences>,
10211024
state: &BeaconState<T::EthSpec>,
1025+
parent_execution_requests: &ExecutionRequestsGloas<T::EthSpec>,
10221026
) -> Vec<BidCandidate<T::EthSpec>> {
10231027
let mut externals = Vec::new();
10241028

@@ -1073,6 +1077,22 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
10731077
}
10741078
}
10751079

1080+
// The parent's exit requests apply to the state before this block's bid is processed, so a
1081+
// bid from a builder the parent payload exits fails `process_execution_payload_bid`.
1082+
externals.retain(|candidate| {
1083+
let builder_index = candidate.signed_bid.message.builder_index;
1084+
let exit_requested = state
1085+
.get_builder(builder_index)
1086+
.is_ok_and(|builder| builder_exit_requested(builder, parent_execution_requests));
1087+
if exit_requested {
1088+
warn!(
1089+
builder_index,
1090+
"Skipping bid from a builder the parent payload exits"
1091+
);
1092+
}
1093+
!exit_requested
1094+
});
1095+
10761096
externals
10771097
}
10781098

beacon_node/beacon_chain/src/payload_bid_verification/gossip_verified_bid.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ use state_processing::signature_sets::{
1919
};
2020
use tracing::debug;
2121
use types::{
22-
BeaconState, ChainSpec, EthSpec, ExecutionPayloadBid, SignedExecutionPayloadBid,
23-
SignedProposerPreferences, Slot, consts::gloas::PAYLOAD_BUILDER_VERSION,
22+
BeaconState, Builder, ChainSpec, EthSpec, ExecutionPayloadBid, ExecutionRequestsGloas,
23+
SignedExecutionPayloadBid, SignedProposerPreferences, Slot,
24+
consts::gloas::PAYLOAD_BUILDER_VERSION,
2425
};
2526

2627
pub(crate) fn verify_bid_slot(bid_slot: Slot, current_slot: Slot) -> Result<(), PayloadBidError> {
@@ -156,14 +157,19 @@ pub(crate) fn parent_payload_exits_builder<T: BeaconChainTypes>(
156157
parent_block_hash: bid.parent_block_hash,
157158
})?;
158159

159-
Ok(parent_envelope
160-
.message
161-
.execution_requests
162-
.builder_exits
163-
.iter()
164-
.any(|request| {
165-
request.pubkey == builder.pubkey && request.source_address == builder.execution_address
166-
}))
160+
Ok(builder_exit_requested(
161+
builder,
162+
&parent_envelope.message.execution_requests,
163+
))
164+
}
165+
166+
pub(crate) fn builder_exit_requested<E: EthSpec>(
167+
builder: &Builder,
168+
execution_requests: &ExecutionRequestsGloas<E>,
169+
) -> bool {
170+
execution_requests.builder_exits.iter().any(|request| {
171+
request.pubkey == builder.pubkey && request.source_address == builder.execution_address
172+
})
167173
}
168174

169175
/// Checks if `bid` is compatible with the head branch

0 commit comments

Comments
 (0)