From 73687b9b528bb70d5204bf0e4b468ce2e7b576a6 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 7 Jun 2025 01:29:08 +0200 Subject: [PATCH] core/txpool: further reduce duplication in blobtx validation --- core/txpool/validation.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/core/txpool/validation.go b/core/txpool/validation.go index 2d136838bc..fef1a99f7b 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -171,6 +171,9 @@ func validateBlobTx(tx *types.Transaction, head *types.Header, opts *ValidationO if len(sidecar.Blobs) != len(hashes) { return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(sidecar.Blobs), len(hashes)) } + if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil { + return err + } // Fork-specific sidecar checks, including proof verification. if opts.Config.IsOsaka(head.Number, head.Time) { return validateBlobSidecarOsaka(sidecar, hashes) @@ -185,9 +188,6 @@ func validateBlobSidecarLegacy(sidecar *types.BlobTxSidecar, hashes []common.Has if len(sidecar.Proofs) != len(hashes) { return fmt.Errorf("invalid number of %d blob proofs expected %d", len(sidecar.Proofs), len(hashes)) } - if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil { - return err - } for i := range sidecar.Blobs { if err := kzg4844.VerifyBlobProof(&sidecar.Blobs[i], sidecar.Commitments[i], sidecar.Proofs[i]); err != nil { return fmt.Errorf("invalid blob %d: %v", i, err) @@ -203,13 +203,7 @@ func validateBlobSidecarOsaka(sidecar *types.BlobTxSidecar, hashes []common.Hash if len(sidecar.Proofs) != len(hashes)*kzg4844.CellProofsPerBlob { return fmt.Errorf("invalid number of %d blob proofs expected %d", len(sidecar.Proofs), len(hashes)*kzg4844.CellProofsPerBlob) } - if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil { - return err - } - if err := kzg4844.VerifyCellProofs(sidecar.Blobs, sidecar.Commitments, sidecar.Proofs); err != nil { - return err - } - return nil + return kzg4844.VerifyCellProofs(sidecar.Blobs, sidecar.Commitments, sidecar.Proofs) } // ValidationOptionsWithState define certain differences between stateful transaction