Skip to content
Merged
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
31 changes: 1 addition & 30 deletions core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,46 +1397,17 @@ 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 {
sidecar := tx.BlobTxSidecar()
if sidecar == nil {
errs = append(errs, errors.New("missing sidecar in blob transaction"))
continue
}
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).
//
// Note, if sync is set the method will block until all internal maintenance
// 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())
Expand Down
7 changes: 3 additions & 4 deletions core/txpool/blobpool/blobpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Loading