From bb0f76cf7977bbb2f4e15625ded5f8c954da72dd Mon Sep 17 00:00:00 2001 From: islishude Date: Fri, 13 Sep 2024 10:23:06 +0800 Subject: [PATCH] core: add validation for Requests --- core/block_validator.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/block_validator.go b/core/block_validator.go index a944db0bf8..0c58737343 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -83,6 +83,18 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { return errors.New("withdrawals present in block body") } + if header.RequestsHash != nil { + if block.Requests() == nil { + return errors.New("missing requests in block body") + } + // todo: update after the #30425 is merged + if hash := types.DeriveSha(block.Requests(), trie.NewStackTrie(nil)); hash != *header.RequestsHash { + return fmt.Errorf("requests root hash mismatch (header value %x, calculated %x)", *header.RequestsHash, hash) + } + } else if block.Requests() != nil { + return errors.New("requests present in block body") + } + // Blob transactions may be present after the Cancun fork. var blobs int for i, tx := range block.Transactions() {