validate the blob tx at first to avoid unnecessary conversion

This commit is contained in:
maskpp 2025-09-02 23:00:06 +08:00
parent e67761ef35
commit d05f5bc341

View file

@ -1406,12 +1406,14 @@ func (p *BlobPool) convertSidecar(txs []*types.Transaction) ([]*types.Transactio
} }
var errs []error var errs []error
for _, tx := range txs { for _, tx := range txs {
sidecar := tx.BlobTxSidecar() // Validate the transaction at first to avoid unnecessary conversion.
if sidecar == nil { if err := p.validateTx(tx); err != nil {
errs = append(errs, errors.New("missing sidecar in blob transaction")) errs = append(errs, err)
continue continue
} }
if sidecar.Version == types.BlobSidecarVersion0 {
sidecar := tx.BlobTxSidecar()
if tx.BlobTxSidecar().Version == types.BlobSidecarVersion0 {
if err := sidecar.ToV1(); err != nil { if err := sidecar.ToV1(); err != nil {
errs = append(errs, err) errs = append(errs, err)
continue continue