Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blobs): Limit blob txs to ones with full network representation #39

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading