From 9d281ea883a8d3c3bf901f1b73c7f1776e9d157f Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 6 May 2024 15:27:32 -0600 Subject: [PATCH] ignore payload attributes we have already created --- mev-build-rs/src/auctioneer/service.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mev-build-rs/src/auctioneer/service.rs b/mev-build-rs/src/auctioneer/service.rs index c28305c5..22eed0da 100644 --- a/mev-build-rs/src/auctioneer/service.rs +++ b/mev-build-rs/src/auctioneer/service.rs @@ -216,7 +216,7 @@ impl< proposer: Proposer, relays: HashSet, mut attributes: BuilderPayloadBuilderAttributes, - ) { + ) -> Option { let (bidder, revenue_updates) = mpsc::channel(DEFAULT_BUILDER_BIDDER_CHANNEL_SIZE); let proposal = ProposalAttributes { proposer_gas_limit: proposer.gas_limit, @@ -235,10 +235,19 @@ impl< if let Err(err) = self.builder.new_payload(auction.attributes.clone()).await { warn!(%err, "could not start build with payload builder"); - return + return None } + let payload_id = auction.attributes.payload_id(); self.bidder.start_bid(auction, revenue_updates); + Some(payload_id) + } + + // Record `payload_id` as processed so that we can identify duplicate notifications. + // Return value indicates if the `payload_id` has been observed before or not. + fn observe_payload_id(&mut self, slot: Slot, payload_id: PayloadId) -> bool { + let processed_set = self.processed_payload_attributes.entry(slot).or_default(); + processed_set.insert(payload_id) } async fn on_payload_attributes(&mut self, attributes: BuilderPayloadBuilderAttributes) { @@ -249,8 +258,7 @@ impl< ) .expect("is past genesis"); - let processed_set = self.processed_payload_attributes.entry(slot).or_default(); - let is_new = processed_set.insert(attributes.payload_id()); + let is_new = self.observe_payload_id(slot, attributes.payload_id()); if !is_new { trace!(payload_id = %attributes.payload_id(), "ignoring duplicate payload attributes"); @@ -259,7 +267,11 @@ impl< if let Some(proposals) = self.get_proposals(slot) { for (proposer, relays) in proposals { - self.open_auction(slot, proposer, relays, attributes.clone()).await; + if let Some(payload_id) = + self.open_auction(slot, proposer, relays, attributes.clone()).await + { + self.observe_payload_id(slot, payload_id); + } } } }