|
8 | 8 | {.push raises: [].}
|
9 | 9 |
|
10 | 10 | import
|
11 |
| - std/[os, random, terminal, times, exitprocs], |
| 11 | + std/[os, random, terminal, times, exitprocs, sequtils], |
12 | 12 | chronos, chronicles,
|
13 | 13 | metrics, metrics/chronos_httpserver,
|
| 14 | + ssz_serialization/types, |
14 | 15 | stew/[byteutils, io2],
|
15 | 16 | eth/p2p/discoveryv5/[enr, random2],
|
16 | 17 | ./consensus_object_pools/[
|
@@ -459,21 +460,67 @@ proc initFullNode(
|
459 | 460 | maybeFinalized: bool):
|
460 | 461 | Future[Result[void, VerifierError]] {.async: (raises: [CancelledError]).} =
|
461 | 462 | withBlck(signedBlock):
|
462 |
| - when consensusFork >= ConsensusFork.Deneb: |
| 463 | + when consensusFork >= ConsensusFork.Electra: |
| 464 | + # Pull blobs and proofs from the EL blob pool |
| 465 | + let blobsFromElOpt = await node.elManager.sendGetBlobs(forkyBlck) |
| 466 | + if blobsFromElOpt.isSome(): |
| 467 | + let blobsEl = blobsFromElOpt.get() |
| 468 | + # check lengths of array[BlobAndProofV1] with blob |
| 469 | + # kzg commitments of the signed block |
| 470 | + if blobsEl.len == forkyBlck.message.body.blob_kzg_commitments.len: |
| 471 | + # create blob sidecars from EL instead |
| 472 | + var |
| 473 | + kzgBlbs: deneb.Blobs |
| 474 | + kzgPrfs: deneb.KzgProofs |
| 475 | + |
| 476 | + for idx in 0..<blobsEl.len: |
| 477 | + kzgBlbs[idx] = blobsEl[idx].blob.data |
| 478 | + kzgPrfs[idx].bytes = blobsEl[idx].proof.data |
| 479 | + let blob_sidecars_el = |
| 480 | + create_blob_sidecars(forkyBlck, kzgPrfs, kzgBlbs) |
| 481 | + |
| 482 | + # populate blob quarantine to tackle blob loop |
| 483 | + for blb_el in blob_sidecars_el: |
| 484 | + blobQuarantine[].put(newClone blb_el) |
| 485 | + |
| 486 | + # now pop blobQuarantine and make block available for attestation |
| 487 | + let blobs = blobQuarantine[].popBlobs(forkyBlck.root, forkyBlck) |
| 488 | + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, |
| 489 | + Opt.some(blobs), |
| 490 | + maybeFinalized = maybeFinalized) |
| 491 | + |
| 492 | + # in case EL does not support `engine_getBlobsV1` |
| 493 | + else: |
| 494 | + if not blobQuarantine[].hasBlobs(forkyBlck): |
| 495 | + # We don't have all the blobs for this block, so we have |
| 496 | + # to put it in blobless quarantine. |
| 497 | + if not quarantine[].addBlobless(dag.finalizedHead.slot, forkyBlck): |
| 498 | + return err(VerifierError.UnviableFork) |
| 499 | + else: |
| 500 | + return err(VerifierError.MissingParent) |
| 501 | + else: |
| 502 | + let blobs = blobQuarantine[].popBlobs(forkyBlck.root, forkyBlck) |
| 503 | + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, |
| 504 | + Opt.some(blobs), |
| 505 | + maybeFinalized = maybeFinalized) |
| 506 | + |
| 507 | + elif consensusFork >= ConsensusFork.Deneb and |
| 508 | + consensusFork < ConsensusFork.Electra: |
463 | 509 | if not blobQuarantine[].hasBlobs(forkyBlck):
|
464 | 510 | # We don't have all the blobs for this block, so we have
|
465 | 511 | # to put it in blobless quarantine.
|
466 | 512 | if not quarantine[].addBlobless(dag.finalizedHead.slot, forkyBlck):
|
467 |
| - err(VerifierError.UnviableFork) |
| 513 | + return err(VerifierError.UnviableFork) |
468 | 514 | else:
|
469 |
| - err(VerifierError.MissingParent) |
| 515 | + return err(VerifierError.MissingParent) |
470 | 516 | else:
|
471 | 517 | let blobs = blobQuarantine[].popBlobs(forkyBlck.root, forkyBlck)
|
472 |
| - await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, |
473 |
| - Opt.some(blobs), |
474 |
| - maybeFinalized = maybeFinalized) |
| 518 | + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, |
| 519 | + Opt.some(blobs), |
| 520 | + maybeFinalized = maybeFinalized) |
| 521 | + |
475 | 522 | else:
|
476 |
| - await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, |
| 523 | + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, |
477 | 524 | Opt.none(BlobSidecars),
|
478 | 525 | maybeFinalized = maybeFinalized)
|
479 | 526 | rmanBlockLoader = proc(
|
|
0 commit comments