@@ -400,7 +400,7 @@ template validateBeaconBlockBellatrix(
400400 # cannot occur here, because Nimbus's optimistic sync waits for either
401401 # `ACCEPTED` or `SYNCING` from the EL to get this far.
402402
403- # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta. 1/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
404404template validateBeaconBlockDeneb (
405405 _: ChainDAGRef ,
406406 _:
@@ -432,44 +432,43 @@ template validateBeaconBlockGloas(
432432 phase0.SignedBeaconBlock | altair.SignedBeaconBlock |
433433 bellatrix.SignedBeaconBlock | capella.SignedBeaconBlock |
434434 deneb.SignedBeaconBlock | electra.SignedBeaconBlock |
435- fulu.SignedBeaconBlock ,
436- _: BlockRef ): untyped =
435+ fulu.SignedBeaconBlock ): untyped =
437436 discard
438437
439- # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta. 1/specs/gloas/p2p-interface.md#beacon_block
438+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/p2p-interface.md#beacon_block
440439template validateBeaconBlockGloas (
441440 dag: ChainDAGRef ,
442- signed_beacon_block: gloas.SignedBeaconBlock ,
443- parent: BlockRef ): untyped =
441+ signed_beacon_block: gloas.SignedBeaconBlock ): untyped =
444442 template blck : untyped = signed_beacon_block.message
445443 template bid : untyped = blck.body.signed_execution_payload_bid.message
446444
447- # If `execution_payload` verification of block's execution payload parent by
448- # an execution node **is complete**
449- debugGloasComment (" " )
450- let isExecutionEnabled =
451- if signed_beacon_block.message.is_execution_block:
452- true
453- else :
454- # If we don't know whether the parent block had execution enabled,
455- # assume it didn't. This way, we don't reject here if the timestamp
456- # is invalid, and let state transition check the timestamp.
457- # This is an edge case, and may be hit in a pathological scenario with
458- # checkpoint sync, because the checkpoint block may be unavailable
459- # and it could already be the parent of the new block before backfill.
460- not dag.loadExecutionBlockHash (parent).get (ZERO_HASH ).isZero
461- if isExecutionEnabled:
462- # [REJECT] The block's execution payload parent (defined by
463- # `bid.parent_block_hash`) passes all validation.
464- withState (dag.headState):
465- when consensusFork >= ConsensusFork .Gloas :
466- if bid.parent_block_hash != forkyState.data.latest_block_hash:
467- return dag.checkedReject (" validateBeaconBlockGloas: invalid execution payload parent" )
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+ block :
454+ if parentRef.isSome ():
455+ dag.getForkedBlock (parentRef.get ().bid)
456+ else :
457+ Opt .none (ForkedTrustedSignedBeaconBlock )
458+ if parentBlock.isSome ():
459+ withBlck (parentBlock.get ()):
460+ if forkyBlck.message.is_execution_block:
461+ let parentHash = dag.loadExecutionBlockHash (parentRef.get ()).valueOr:
462+ return dag.checkedReject (
463+ " validateBeaconBlockGloas: invalid execution parent" )
464+ if not (bid.parent_block_hash == parentHash):
465+ return dag.checkedReject (
466+ " validateBeaconBlockGloas: invalid execution parent" )
468467
469468 # [REJECT] The bid's parent (defined by `bid.parent_block_root`) equals the
470469 # block's parent (defined by `block.parent_root`).
471- if bid.parent_block_root != blck.parent_root:
472- return dag.checkedReject (" validateBeaconBlockGloas: parent block root mismatch" )
470+ if not ( bid.parent_block_root == blck.parent_root) :
471+ return dag.checkedReject (" validateBeaconBlockGloas: parent block mismatch" )
473472
474473# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id
475474proc validateBlobSidecar * (
@@ -851,6 +850,7 @@ proc validateDataColumnSidecar*(
851850
852851# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_block
853852# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#beacon_block
853+ # https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/gloas/p2p-interface.md#beacon_block
854854proc validateBeaconBlock * (
855855 dag: ChainDAGRef , quarantine: ref Quarantine ,
856856 signed_beacon_block: ForkySignedBeaconBlock ,
@@ -931,9 +931,10 @@ proc validateBeaconBlock*(
931931 quarantine[].addOrphan (dag.finalizedHead.slot, signed_beacon_block).isOkOr:
932932 # Queueing failed because the parent was unviable - this means this block
933933 # is unviable as well, for the same reason
934- return
935- case error
936- of UnviableKind .Invalid :
934+ case error
935+ of UnviableKind .Invalid :
936+ when typeof (signed_beacon_block).kind <= ConsensusFork .Fulu :
937+ # These checks are removed in Gloas.
937938 if signed_beacon_block.message.is_execution_block:
938939 # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#beacon_block
939940 #
@@ -960,11 +961,11 @@ proc validateBeaconBlock*(
960961 # whether it was marked unviable due to consensus (REJECT) or
961962 # execution (IGNORE) verification failure. We err on the IGNORE side.
962963 # TODO track this as a separate UnviableKind
963- errIgnore (" BeaconBlock: parent invalid" )
964+ return errIgnore (" BeaconBlock: parent invalid" )
964965 else :
965- errReject (" BeaconBlock: parent invalid" )
966- of UnviableKind .UnviableFork :
967- errIgnore (" BeaconBlock: parent from unviable fork" )
966+ return errReject (" BeaconBlock: parent invalid" )
967+ of UnviableKind .UnviableFork :
968+ return errIgnore (" BeaconBlock: parent from unviable fork" )
968969
969970 debug " Block quarantined" ,
970971 blockRoot = shortLog (signed_beacon_block.root),
@@ -980,7 +981,7 @@ proc validateBeaconBlock*(
980981
981982 dag.validateBeaconBlockDeneb (signed_beacon_block, wallTime)
982983
983- dag.validateBeaconBlockGloas (signed_beacon_block, parent )
984+ dag.validateBeaconBlockGloas (signed_beacon_block)
984985
985986 # [REJECT] The block is from a higher slot than its parent.
986987 if not (signed_beacon_block.message.slot > parent.bid.slot):
0 commit comments