@@ -340,8 +340,7 @@ func getMaxBlobsPerBlock(cfg: RuntimeConfig, slot: Slot): uint64 =
340340 else :
341341 cfg.MAX_BLOBS_PER_BLOCK
342342
343- debugGloasComment " "
344- # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/gloas/p2p-interface.md#beacon_block
343+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/p2p-interface.md#beacon_block
345344template validateBeaconBlockBellatrix (
346345 _: phase0.SignedBeaconBlock | altair.SignedBeaconBlock | gloas.SignedBeaconBlock ,
347346 _: BlockRef ): untyped =
@@ -401,8 +400,7 @@ template validateBeaconBlockBellatrix(
401400 # cannot occur here, because Nimbus's optimistic sync waits for either
402401 # `ACCEPTED` or `SYNCING` from the EL to get this far.
403402
404- debugGloasComment " "
405- # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/gloas/p2p-interface.md#beacon_block
403+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/p2p-interface.md#beacon_block
406404template validateBeaconBlockDeneb (
407405 _: ChainDAGRef ,
408406 _:
@@ -428,6 +426,49 @@ template validateBeaconBlockDeneb(
428426 blob_params.MAX_BLOBS_PER_BLOCK ):
429427 return dag.checkedReject (" validateBeaconBlockDeneb: too many blob commitments" )
430428
429+ template validateBeaconBlockGloas (
430+ _: ChainDAGRef ,
431+ _:
432+ phase0.SignedBeaconBlock | altair.SignedBeaconBlock |
433+ bellatrix.SignedBeaconBlock | capella.SignedBeaconBlock |
434+ deneb.SignedBeaconBlock | electra.SignedBeaconBlock |
435+ fulu.SignedBeaconBlock ): untyped =
436+ discard
437+
438+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/p2p-interface.md#beacon_block
439+ template validateBeaconBlockGloas (
440+ dag: ChainDAGRef ,
441+ signed_beacon_block: gloas.SignedBeaconBlock ): untyped =
442+ template blck : untyped = signed_beacon_block.message
443+ template bid : untyped = blck.body.signed_execution_payload_bid.message
444+
445+ # If execution_payload verification of block's execution payload parent by an
446+ # execution node is complete:
447+ #
448+ # - [REJECT] The block's execution payload parent (defined by
449+ # bid.parent_block_hash) passes all validation.
450+ let
451+ parentRef = dag.getBlockRef (bid.parent_block_root)
452+ parentBlock =
453+ if parentRef.isSome ():
454+ dag.getForkedBlock (parentRef.get ().bid)
455+ else :
456+ Opt .none (ForkedTrustedSignedBeaconBlock )
457+ if parentBlock.isSome ():
458+ withBlck (parentBlock.get ()):
459+ if forkyBlck.message.is_execution_block:
460+ let parentHash = dag.loadExecutionBlockHash (parentRef.get ()).valueOr:
461+ return dag.checkedReject (
462+ " validateBeaconBlockGloas: invalid execution parent" )
463+ if not (bid.parent_block_hash == parentHash):
464+ return dag.checkedReject (
465+ " validateBeaconBlockGloas: invalid execution parent" )
466+
467+ # [REJECT] The bid's parent (defined by `bid.parent_block_root`) equals the
468+ # block's parent (defined by `block.parent_root`).
469+ if not (bid.parent_block_root == blck.parent_root):
470+ return dag.checkedReject (" validateBeaconBlockGloas: parent block mismatch" )
471+
431472# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id
432473proc validateBlobSidecar * (
433474 dag: ChainDAGRef , quarantine: ref Quarantine ,
@@ -806,8 +847,9 @@ proc validateDataColumnSidecar*(
806847
807848 ok ()
808849
809- # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_block
810- # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#beacon_block
850+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/phase0/p2p-interface.md#beacon_block
851+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/bellatrix/p2p-interface.md#beacon_block
852+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/p2p-interface.md#beacon_block
811853proc validateBeaconBlock * (
812854 dag: ChainDAGRef , quarantine: ref Quarantine ,
813855 signed_beacon_block: ForkySignedBeaconBlock ,
@@ -888,9 +930,10 @@ proc validateBeaconBlock*(
888930 quarantine[].addOrphan (dag.finalizedHead.slot, signed_beacon_block).isOkOr:
889931 # Queueing failed because the parent was unviable - this means this block
890932 # is unviable as well, for the same reason
891- return
892- case error
893- of UnviableKind .Invalid :
933+ case error
934+ of UnviableKind .Invalid :
935+ when typeof (signed_beacon_block).kind <= ConsensusFork .Fulu :
936+ # These checks are removed in Gloas.
894937 if signed_beacon_block.message.is_execution_block:
895938 # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#beacon_block
896939 #
@@ -917,11 +960,11 @@ proc validateBeaconBlock*(
917960 # whether it was marked unviable due to consensus (REJECT) or
918961 # execution (IGNORE) verification failure. We err on the IGNORE side.
919962 # TODO track this as a separate UnviableKind
920- errIgnore (" BeaconBlock: parent invalid" )
963+ return errIgnore (" BeaconBlock: parent invalid" )
921964 else :
922- errReject (" BeaconBlock: parent invalid" )
923- of UnviableKind .UnviableFork :
924- errIgnore (" BeaconBlock: parent from unviable fork" )
965+ return errReject (" BeaconBlock: parent invalid" )
966+ of UnviableKind .UnviableFork :
967+ return errIgnore (" BeaconBlock: parent from unviable fork" )
925968
926969 debug " Block quarantined" ,
927970 blockRoot = shortLog (signed_beacon_block.root),
@@ -937,6 +980,8 @@ proc validateBeaconBlock*(
937980
938981 dag.validateBeaconBlockDeneb (signed_beacon_block, wallTime)
939982
983+ dag.validateBeaconBlockGloas (signed_beacon_block)
984+
940985 # [REJECT] The block is from a higher slot than its parent.
941986 if not (signed_beacon_block.message.slot > parent.bid.slot):
942987 return dag.checkedReject (
0 commit comments