Skip to content

Commit

Permalink
feat(blobs): Limit blob txs to ones with full network representation
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanschneider committed Jun 21, 2024
1 parent e37af6f commit eb2f007
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions collector/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package collector

import (
"context"
"errors"
"fmt"
"net/http"
"os"
Expand All @@ -24,6 +25,8 @@ const (
receiverTimeout = 5 * time.Second
)

var ErrBlobMissingSidecar = errors.New("missing blob sidecar")

type TxProcessorOpts struct {
Log *zap.SugaredLogger
OutDir string
Expand Down Expand Up @@ -285,6 +288,13 @@ func (p *TxProcessor) validateTx(fTrash *os.File, txIn TxIn) error { // inspired
return core.ErrTipAboveFeeCap
}

// Ensure blob txs are correctly formed
if err := p.validateBlobTx(tx); err != nil {
log.Debugw("error: invalid blob transaction", "reason", err)
p.writeTrash(fTrash, txIn, "invalid blob transaction", "")
return err
}

// all good
return nil
}
Expand Down Expand Up @@ -440,3 +450,18 @@ func (p *TxProcessor) healthCheckCall() {
}
resp.Body.Close()
}

// validateBlobTx ensures that a blob tx is capable of being consumed
// by our system. Namely, the blob tx should be in the "full" PooledTransactions
// network representation with the full sidecar available.
func (p *TxProcessor) validateBlobTx(tx *types.Transaction) error {
if tx.Type() != types.BlobTxType {
return nil
}

if tx.BlobTxSidecar() == nil {
return ErrBlobMissingSidecar
}

return nil
}

0 comments on commit eb2f007

Please sign in to comment.