Skip to content

Commit 4926f1f

Browse files
committed
refactor checkPayload and implements checkBlobs availabilty
1 parent 703e698 commit 4926f1f

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

beacon_chain/validators/beacon_validators.nim

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -843,30 +843,44 @@ proc checkPayloadPresent(
843843
## Check if we received the payload envelope for
844844
## this slot and a corresponding block
845845

846-
let blockData = node.dag.getForkedBlock(beacon_block_root).valueOr:
846+
let blokData = node.dag.getForkedBlock(beacon_block_root).valueOr:
847847
return false
848848

849-
withBlck(blockData):
849+
withBlck(blokData):
850+
when consensusFork >= ConsensusFork.Gloas:
851+
var envelope: TrustedSignedExecutionPayloadEnvelope
852+
node.dag.db.getExecutionPayloadEnvelope(beacon_block_root, envelope) and
853+
envelope.message.beacon_block_root == beacon_block_root
854+
else:
855+
return true
856+
857+
proc checkBlobDataAvailable(
858+
node: BeaconNode, beacon_block_root: Eth2Digest
859+
): bool =
860+
## Check if the blob sidecars for this slot and envelope are available
861+
862+
let blckData = node.dag.getForkedBlock(beacon_block_root).valueOr:
863+
return false
864+
865+
withBlck(blckData):
850866
when consensusFork >= ConsensusFork.Gloas:
851867
var envelope: TrustedSignedExecutionPayloadEnvelope
852868
if not node.dag.db.getExecutionPayloadEnvelope(
853869
beacon_block_root, envelope):
854870
return false
855871

856-
# check that the envelope correctly references this block
857-
if envelope.message.beacon_block_root != beacon_block_root:
858-
return false
872+
template commitments: untyped = envelope.message.blob_kzg_commitments
873+
if commitments.len == 0:
874+
return true # No blobs required for this slot
875+
876+
for i in 0..<commitments.len:
877+
var blob: BlobSidecar
878+
if not node.dag.db.getBlobSidecar(beacon_block_root, BlobIndex(i), blob):
879+
return false
859880
return true
860881
else:
861882
return true
862883

863-
proc checkBlobDataAvailable*(
864-
node: BeaconNode, beacon_block_root: Eth2Digest
865-
): bool =
866-
## Check if the blob sidecars for this slot are available
867-
debugGloasComment"TODO - check for blob availability"
868-
return true
869-
870884
proc createAndSendPayloadAttestation(node: BeaconNode,
871885
fork: Fork,
872886
genesis_validators_root: Eth2Digest,

0 commit comments

Comments
 (0)