diff --git a/collector/tx_processor.go b/collector/tx_processor.go index f2e10a2..558b849 100644 --- a/collector/tx_processor.go +++ b/collector/tx_processor.go @@ -2,6 +2,7 @@ package collector import ( "context" + "errors" "fmt" "net/http" "os" @@ -24,6 +25,8 @@ const ( receiverTimeout = 5 * time.Second ) +var ErrBlobMissingSidecar = errors.New("missing blob sidecar") + type TxProcessorOpts struct { Log *zap.SugaredLogger OutDir string @@ -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 } @@ -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 +}