@lodestar/beacon-node 1.52.0-dev.93209fd84a → 1.52.0-dev.97ba67c17e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -165,17 +165,23 @@ async function validateExecutionPayloadBid(
165
165
  });
166
166
  }
167
167
 
168
- // [IGNORE] this is the first signed bid seen with a valid signature from the given builder for
169
- // the tuple `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
170
- // Entries are only added after signature verification, so known tuples can be dropped before
171
- // state regeneration and the other expensive validation steps.
172
- if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)) {
168
+ // [IGNORE] The builder has not reached its bid limit, checked against the limit of its last valid bid.
169
+ // Bids for the same slot and parent root are validated against the same state, so bids past the
170
+ // limit can be dropped before state regeneration and the other expensive validation steps.
171
+ const seenBids = chain.seenExecutionPayloadBids.get(
172
+ bid.slot,
173
+ bid.builderIndex,
174
+ bidParentBlockHash,
175
+ bidParentBlockRoot
176
+ );
177
+ if (seenBids !== undefined && seenBids.count >= seenBids.limit) {
173
178
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
174
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN,
179
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
175
180
  builderIndex: bid.builderIndex,
176
181
  slot: bid.slot,
177
182
  parentBlockRoot: bidParentBlockRoot,
178
183
  parentBlockHash: bidParentBlockHash,
184
+ bidLimit: seenBids.limit,
179
185
  });
180
186
  }
181
187
 
@@ -366,6 +372,24 @@ async function validateExecutionPayloadBid(
366
372
  });
367
373
  }
368
374
 
375
+ // [IGNORE] The builder has not reached its bid limit for the tuple
376
+ // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)` -- i.e. one bid per ETH of builder balance
377
+ // not owed in pending withdrawals, `get_builder_bid_limit(state, bid.builder_index)`.
378
+ const bidLimit = state.getBuilderBidLimit(bid.builderIndex);
379
+ if (
380
+ (chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
381
+ 0) >= bidLimit
382
+ ) {
383
+ throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
384
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
385
+ builderIndex: bid.builderIndex,
386
+ slot: bid.slot,
387
+ parentBlockRoot: bidParentBlockRoot,
388
+ parentBlockHash: bidParentBlockHash,
389
+ bidLimit,
390
+ });
391
+ }
392
+
369
393
  // [IGNORE] `bid.value` is less or equal than the builder's excess balance --
370
394
  // i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
371
395
  if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
@@ -426,20 +450,24 @@ async function validateExecutionPayloadBid(
426
450
  });
427
451
  }
428
452
 
429
- // Repeat the seen check after the awaited signature verification to prevent concurrent bids
430
- // for the same builder and tuple from both passing validation.
431
- if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)) {
453
+ // Repeat the bid limit check after the awaited signature verification to prevent concurrent bids
454
+ // for the same builder and tuple from all passing validation.
455
+ if (
456
+ (chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
457
+ 0) >= bidLimit
458
+ ) {
432
459
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
433
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN,
460
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
434
461
  builderIndex: bid.builderIndex,
435
462
  slot: bid.slot,
436
463
  parentBlockRoot: bidParentBlockRoot,
437
464
  parentBlockHash: bidParentBlockHash,
465
+ bidLimit,
438
466
  });
439
467
  }
440
468
 
441
469
  // Valid
442
- chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot);
470
+ chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot, bidLimit);
443
471
 
444
472
  return {proposerIndex: proposerPreferences.message.validatorIndex};
445
473
  }
@@ -376,7 +376,8 @@ export class BlockInputSync {
376
376
  // because the payload at the finalized block is not finalized
377
377
  const finalizedSlot = this.chain.forkChoice.getFinalizedBlock().slot;
378
378
  const nowSec = Date.now() / 1000;
379
- const maxSecInCache = (PRUNE_UNRESOLVED_SLOT_EPOCHS * SLOTS_PER_EPOCH * this.config.SLOT_DURATION_MS) / 1000;
379
+ const slotDurationMs = this.config.getSlotDurationMs(this.config.getForkName(this.chain.clock.currentSlot));
380
+ const maxSecInCache = (PRUNE_UNRESOLVED_SLOT_EPOCHS * SLOTS_PER_EPOCH * slotDurationMs) / 1000;
380
381
 
381
382
  let belowFinalizedPayloads = 0;
382
383
  let agedOutPayloads = 0;