Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions cmd/collect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ var cliFlags = []cli.Flag{
Category: "Collector Configuration",
},

// Blob (EIP-4844) tx handling
&cli.BoolFlag{
Name: "require-blob-sidecar",
EnvVars: []string{"REQUIRE_BLOB_SIDECAR"},
Value: false,
Usage: "Restore pre-v1.4 strict validation: reject EIP-4844 (type-3) txs whose blob sidecar is nil. Default is permissive (accept canonical-only blob txs as delivered by standard EL JSON-RPC subscriptions).",
Category: "Collector Configuration",
},

// SSE TX Subscription API
&cli.StringFlag{
Name: "api-listen-addr",
Expand Down Expand Up @@ -152,6 +161,7 @@ func runCollector(cCtx *cli.Context) error {
enablePprof = cCtx.Bool("pprof")
clickhouseDSN = cCtx.String("clickhouse-dsn")
redisEndpoint = cCtx.String("redis-endpoint")
requireBlobSidecar = cCtx.Bool("require-blob-sidecar")
)

// Logger setup
Expand Down Expand Up @@ -195,6 +205,7 @@ func runCollector(cCtx *cli.Context) error {
APIListenAddr: apiListenAddr,
MetricsListenAddr: metricsListenAddr,
EnablePprof: enablePprof,
RequireBlobSidecar: requireBlobSidecar,
})
collector.Start()

Expand Down
3 changes: 3 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type CollectorOpts struct {
APIListenAddr string
MetricsListenAddr string
EnablePprof bool // if true, enables pprof on the metrics server

RequireBlobSidecar bool // if true, restores pre-v1.4 strict rejection of sidecar-less type-3 txs
}

type Collector struct {
Expand Down Expand Up @@ -69,6 +71,7 @@ func (c *Collector) Start() {
HTTPReceivers: c.opts.Receivers,
ReceiversAllowedSources: c.opts.ReceiversAllowedSources,
APIServer: apiServer,
RequireBlobSidecar: c.opts.RequireBlobSidecar,
})

// Start the transaction processor, which kicks off background goroutines
Expand Down
25 changes: 19 additions & 6 deletions collector/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ type TxProcessorOpts struct {
HTTPReceivers []string
ReceiversAllowedSources []string
APIServer *api.Server
// RequireBlobSidecar, when true, restores the pre-v1.4 behavior of rejecting
// EIP-4844 (type-3) txs whose BlobTxSidecar is nil. Standard EL JSON-RPC
// subscriptions return canonical encoding only (sidecar lives in the txpool's
// blob store, not exposed over RPC), so enabling this drops blob txs from
// observability - useful only if the collector is consuming a source that
// guarantees full network-encoded blob txs.
RequireBlobSidecar bool
}

type TxProcessor struct {
Expand Down Expand Up @@ -79,6 +86,8 @@ type TxProcessor struct {

redisEndpoint string
redis *Redis

requireBlobSidecar bool
}

type OutFiles struct {
Expand Down Expand Up @@ -120,6 +129,8 @@ func NewTxProcessor(opts TxProcessorOpts) *TxProcessor {
receivers: receivers,
receiversAllowedSources: opts.ReceiversAllowedSources,
receiversAllowAllSources: len(opts.ReceiversAllowedSources) == 1 && opts.ReceiversAllowedSources[0] == "all",

requireBlobSidecar: opts.RequireBlobSidecar,
}
}

Expand Down Expand Up @@ -424,7 +435,11 @@ func (p *TxProcessor) validateTx(txIn common.TxIn) error { // inspired by https:
return core.ErrTipAboveFeeCap
}

// Ensure blob txs are correctly formed
// Blob txs: by default (RequireBlobSidecar=false) we accept type-3 txs with or
// without a sidecar - standard EL JSON-RPC subscriptions deliver canonical encoding
// only, and we store raw_tx as canonical RLP via tx.MarshalBinary(). Setting
// RequireBlobSidecar restores the pre-v1.4 strict behavior of rejecting
// sidecar-less blob txs.
if err := p.validateBlobTx(tx); err != nil {
log.Debugw("error: invalid blob transaction", "reason", err)
return err
Expand All @@ -434,18 +449,16 @@ func (p *TxProcessor) validateTx(txIn common.TxIn) error { // inspired by https:
return nil
}

// 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 !p.requireBlobSidecar {
return nil
}
if tx.Type() != types.BlobTxType {
Comment thread
curcio marked this conversation as resolved.
return nil
}

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

return nil
}

Expand Down
Loading