Skip to content

Commit 73687b9

Browse files
committed
core/txpool: further reduce duplication in blobtx validation
1 parent 27177d2 commit 73687b9

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

core/txpool/validation.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ func validateBlobTx(tx *types.Transaction, head *types.Header, opts *ValidationO
171171
if len(sidecar.Blobs) != len(hashes) {
172172
return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(sidecar.Blobs), len(hashes))
173173
}
174+
if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil {
175+
return err
176+
}
174177
// Fork-specific sidecar checks, including proof verification.
175178
if opts.Config.IsOsaka(head.Number, head.Time) {
176179
return validateBlobSidecarOsaka(sidecar, hashes)
@@ -185,9 +188,6 @@ func validateBlobSidecarLegacy(sidecar *types.BlobTxSidecar, hashes []common.Has
185188
if len(sidecar.Proofs) != len(hashes) {
186189
return fmt.Errorf("invalid number of %d blob proofs expected %d", len(sidecar.Proofs), len(hashes))
187190
}
188-
if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil {
189-
return err
190-
}
191191
for i := range sidecar.Blobs {
192192
if err := kzg4844.VerifyBlobProof(&sidecar.Blobs[i], sidecar.Commitments[i], sidecar.Proofs[i]); err != nil {
193193
return fmt.Errorf("invalid blob %d: %v", i, err)
@@ -203,13 +203,7 @@ func validateBlobSidecarOsaka(sidecar *types.BlobTxSidecar, hashes []common.Hash
203203
if len(sidecar.Proofs) != len(hashes)*kzg4844.CellProofsPerBlob {
204204
return fmt.Errorf("invalid number of %d blob proofs expected %d", len(sidecar.Proofs), len(hashes)*kzg4844.CellProofsPerBlob)
205205
}
206-
if err := sidecar.ValidateBlobCommitmentHashes(hashes); err != nil {
207-
return err
208-
}
209-
if err := kzg4844.VerifyCellProofs(sidecar.Blobs, sidecar.Commitments, sidecar.Proofs); err != nil {
210-
return err
211-
}
212-
return nil
206+
return kzg4844.VerifyCellProofs(sidecar.Blobs, sidecar.Commitments, sidecar.Proofs)
213207
}
214208

215209
// ValidationOptionsWithState define certain differences between stateful transaction

0 commit comments

Comments
 (0)