Skip to content

Commit 6f7c4ff

Browse files
authored
Synchronously check all transactions to have non-zero length (#6491)
Reject blocks with zero length transactions early when no EL connected. - ethereum/consensus-specs#3885
1 parent ca8c2ce commit 6f7c4ff

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

beacon_chain/gossip_processing/block_processor.nim

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import
1313
../sszdump
1414

1515
from std/deques import Deque, addLast, contains, initDeque, items, len, shrink
16-
from std/sequtils import mapIt
16+
from std/sequtils import anyIt, mapIt
1717
from ../consensus_object_pools/consensus_manager import
1818
ConsensusManager, checkNextProposer, optimisticExecutionBlockHash,
1919
runProposalForkchoiceUpdated, shouldSyncOptimistically, updateHead,
@@ -541,31 +541,32 @@ proc storeBlock(
541541

542542
if NewPayloadStatus.noResponse == payloadStatus:
543543
# When the execution layer is not available to verify the payload, we do the
544-
# required check on the CL side instead and proceed as if the EL was syncing
545-
546-
# TODO run https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/beacon-chain.md#blob-kzg-commitments
547-
# https://github.com/ethereum/execution-apis/blob/main/src/engine/experimental/blob-extension.md#specification
548-
# "This validation MUST be instantly run in all cases even during active
549-
# sync process."
550-
#
551-
# Client software MUST validate `blockHash` value as being equivalent to
552-
# `Keccak256(RLP(ExecutionBlockHeader))`
553-
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#specification
554-
#
555-
# This should simulate an unsynced EL, which still must perform these
556-
# checks. This means it must be able to do so without context, beyond
557-
# whatever data the block itself contains.
544+
# required checks on the CL instead and proceed as if the EL was syncing
545+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/bellatrix/beacon-chain.md#verify_and_notify_new_payload
546+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/deneb/beacon-chain.md#modified-verify_and_notify_new_payload
558547
when typeof(signedBlock).kind >= ConsensusFork.Bellatrix:
559-
template payload(): auto = signedBlock.message.body.execution_payload
560-
if signedBlock.message.is_execution_block and
561-
payload.block_hash !=
548+
if signedBlock.message.is_execution_block:
549+
template payload(): auto = signedBlock.message.body.execution_payload
550+
551+
template returnWithError(msg: string): untyped =
552+
debug msg, executionPayload = shortLog(payload)
553+
self[].dumpInvalidBlock(signedBlock)
554+
doAssert strictVerification notin dag.updateFlags
555+
self.consensusManager.quarantine[].addUnviable(signedBlock.root)
556+
return err((VerifierError.Invalid, ProcessingStatus.completed))
557+
558+
if payload.transactions.anyIt(it.len == 0):
559+
returnWithError "Execution block contains zero length transactions"
560+
561+
if payload.block_hash !=
562562
signedBlock.message.compute_execution_block_hash():
563-
debug "Execution block hash validation failed",
564-
execution_payload = shortLog(payload)
565-
self[].dumpInvalidBlock(signedBlock)
566-
doAssert strictVerification notin dag.updateFlags
567-
self.consensusManager.quarantine[].addUnviable(signedBlock.root)
568-
return err((VerifierError.Invalid, ProcessingStatus.completed))
563+
returnWithError "Execution block hash validation failed"
564+
565+
# [New in Deneb:EIP4844]
566+
# TODO run https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/beacon-chain.md#blob-kzg-commitments
567+
# https://github.com/ethereum/execution-apis/blob/main/src/engine/experimental/blob-extension.md#specification
568+
# "This validation MUST be instantly run in all cases even during active
569+
# sync process."
569570

570571
let newPayloadTick = Moment.now()
571572

0 commit comments

Comments
 (0)