|
13 | 13 | ../sszdump |
14 | 14 |
|
15 | 15 | from std/deques import Deque, addLast, contains, initDeque, items, len, shrink |
16 | | -from std/sequtils import mapIt |
| 16 | +from std/sequtils import anyIt, mapIt |
17 | 17 | from ../consensus_object_pools/consensus_manager import |
18 | 18 | ConsensusManager, checkNextProposer, optimisticExecutionBlockHash, |
19 | 19 | runProposalForkchoiceUpdated, shouldSyncOptimistically, updateHead, |
@@ -541,31 +541,32 @@ proc storeBlock( |
541 | 541 |
|
542 | 542 | if NewPayloadStatus.noResponse == payloadStatus: |
543 | 543 | # 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 |
558 | 547 | 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 != |
562 | 562 | 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." |
569 | 570 |
|
570 | 571 | let newPayloadTick = Moment.now() |
571 | 572 |
|
|
0 commit comments