From d05f5bc34155c6ea8053a7d561d8b02b86323051 Mon Sep 17 00:00:00 2001 From: maskpp Date: Tue, 2 Sep 2025 23:00:06 +0800 Subject: [PATCH 1/4] validate the blob tx at first to avoid unnecessary conversion --- core/txpool/blobpool/blobpool.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 64ee3fcd9a6..6ff012b8817 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1406,12 +1406,14 @@ func (p *BlobPool) convertSidecar(txs []*types.Transaction) ([]*types.Transactio } var errs []error for _, tx := range txs { - sidecar := tx.BlobTxSidecar() - if sidecar == nil { - errs = append(errs, errors.New("missing sidecar in blob transaction")) + // Validate the transaction at first to avoid unnecessary conversion. + if err := p.validateTx(tx); err != nil { + errs = append(errs, err) continue } - if sidecar.Version == types.BlobSidecarVersion0 { + + sidecar := tx.BlobTxSidecar() + if tx.BlobTxSidecar().Version == types.BlobSidecarVersion0 { if err := sidecar.ToV1(); err != nil { errs = append(errs, err) continue From 409cfa557c1d74ee9cf733044ec90ee5cfdacf03 Mon Sep 17 00:00:00 2001 From: maskpp Date: Tue, 2 Sep 2025 23:02:48 +0800 Subject: [PATCH 2/4] validate the blob tx at first to avoid unnecessary conversion --- core/txpool/blobpool/blobpool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 6ff012b8817..7eb035660b0 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1413,7 +1413,7 @@ func (p *BlobPool) convertSidecar(txs []*types.Transaction) ([]*types.Transactio } sidecar := tx.BlobTxSidecar() - if tx.BlobTxSidecar().Version == types.BlobSidecarVersion0 { + if sidecar.Version == types.BlobSidecarVersion0 { if err := sidecar.ToV1(); err != nil { errs = append(errs, err) continue From d89b92ce1db93f2063f0fd25abc3f34f9428cfbc Mon Sep 17 00:00:00 2001 From: lightclient Date: Tue, 9 Sep 2025 09:48:58 -0600 Subject: [PATCH 3/4] core/txpool/blobpool: reject blob tx with with legacy sidecar --- core/txpool/blobpool/blobpool.go | 6 +----- core/txpool/blobpool/blobpool_test.go | 7 +++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 7eb035660b0..5b539cc9eeb 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1431,14 +1431,10 @@ func (p *BlobPool) convertSidecar(txs []*types.Transaction) ([]*types.Transactio // related to the add is finished. Only use this during tests for determinism. func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error { var ( - errs []error + errs = make([]error, len(txs)) adds = make([]*types.Transaction, 0, len(txs)) ) - txs, errs = p.convertSidecar(txs) for i, tx := range txs { - if errs[i] != nil { - continue - } errs[i] = p.add(tx) if errs[i] == nil { adds = append(adds, tx.WithoutBlobTxSidecar()) diff --git a/core/txpool/blobpool/blobpool_test.go b/core/txpool/blobpool/blobpool_test.go index 51ab27eb014..29e421c5abf 100644 --- a/core/txpool/blobpool/blobpool_test.go +++ b/core/txpool/blobpool/blobpool_test.go @@ -1689,8 +1689,7 @@ func TestAdd(t *testing.T) { } } -// Tests that adding the transactions with legacy sidecar and expect them to -// be converted to new format correctly. +// Tests adding transactions with legacy sidecars are correctly rejected. func TestAddLegacyBlobTx(t *testing.T) { var ( key1, _ = crypto.GenerateKey() @@ -1724,8 +1723,8 @@ func TestAddLegacyBlobTx(t *testing.T) { ) errs := pool.Add([]*types.Transaction{tx1, tx2, tx3}, true) for _, err := range errs { - if err != nil { - t.Fatalf("failed to add tx: %v", err) + if err == nil { + t.Fatalf("expected tx add to fail") } } verifyPoolInternals(t, pool) From ffd618c614ccf4c87925dc2afeb3258ee3be79aa Mon Sep 17 00:00:00 2001 From: lightclient Date: Tue, 9 Sep 2025 09:50:47 -0600 Subject: [PATCH 4/4] core/txpool/blobpool: remove unused convertSidecars function --- core/txpool/blobpool/blobpool.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 5b539cc9eeb..adc1ac711d6 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1397,33 +1397,6 @@ func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int { return available } -// convertSidecar converts the legacy sidecar in the submitted transactions -// if Osaka fork has been activated. -func (p *BlobPool) convertSidecar(txs []*types.Transaction) ([]*types.Transaction, []error) { - head := p.chain.CurrentBlock() - if !p.chain.Config().IsOsaka(head.Number, head.Time) { - return txs, make([]error, len(txs)) - } - var errs []error - for _, tx := range txs { - // Validate the transaction at first to avoid unnecessary conversion. - if err := p.validateTx(tx); err != nil { - errs = append(errs, err) - continue - } - - sidecar := tx.BlobTxSidecar() - if sidecar.Version == types.BlobSidecarVersion0 { - if err := sidecar.ToV1(); err != nil { - errs = append(errs, err) - continue - } - } - errs = append(errs, nil) - } - return txs, errs -} - // Add inserts a set of blob transactions into the pool if they pass validation (both // consensus validity and pool restrictions). //