diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 25efc40478..4b9932b826 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -138,7 +138,7 @@ func newBlobTxMeta(id uint64, size uint64, storageSize uint32, tx *types.Transac version: tx.BlobTxSidecar().Version, id: id, storageSize: storageSize, // size of tx including cells - size: size, // size of tx only + size: size, // size of tx including blobs nonce: tx.Nonce(), costCap: uint256.MustFromBig(tx.Cost()), execTipCap: uint256.MustFromBig(tx.GasTipCap()), @@ -156,12 +156,14 @@ func newBlobTxMeta(id uint64, size uint64, storageSize uint32, tx *types.Transac type PooledBlobTx struct { Transaction *types.Transaction Sidecar *types.BlobTxCellSidecar + Size uint64 // original transaction size } -func NewPooledBlobTx(tx *types.Transaction, sidecar *types.BlobTxCellSidecar) *PooledBlobTx { +func NewPooledBlobTx(tx *types.Transaction, sidecar *types.BlobTxCellSidecar, size uint64) *PooledBlobTx { return &PooledBlobTx{ Transaction: tx, Sidecar: sidecar, + Size: size, } } @@ -1100,7 +1102,7 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error { } // Update the indices and metrics - meta := newBlobTxMeta(id, tx.Transaction.Size(), p.store.Size(id), tx.Transaction) + meta := newBlobTxMeta(id, tx.Size, p.store.Size(id), tx.Transaction) if _, ok := p.index[addr]; !ok { if err := p.reserver.Hold(addr); err != nil { log.Warn("Failed to reserve account for blob pool", "tx", tx.Transaction.Hash(), "from", addr, "err", err) @@ -1410,7 +1412,7 @@ func (p *BlobPool) GetRLP(hash common.Hash) []byte { // given transaction hash. // // The size refers the length of the 'rlp encoding' of a blob transaction -// excluding the attached blobs. +// including the attached blobs. func (p *BlobPool) GetMetadata(hash common.Hash) *txpool.TxMetadata { p.lock.RLock() defer p.lock.RUnlock() @@ -1564,7 +1566,7 @@ func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error { errs[i] = err continue } - errs[i] = p.add(tx.WithoutBlobTxSidecar(), cellSidecar) + errs[i] = p.add(tx.WithoutBlobTxSidecar(), cellSidecar, tx.Size()) if errs[i] == nil { adds = append(adds, tx.WithoutBlobTxSidecar()) } @@ -1578,7 +1580,7 @@ func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error { // add inserts a new blob transaction into the pool if it passes validation (both // consensus validity and pool restrictions). -func (p *BlobPool) add(tx *types.Transaction, cellSidecar *types.BlobTxCellSidecar) (err error) { +func (p *BlobPool) add(tx *types.Transaction, cellSidecar *types.BlobTxCellSidecar, size uint64) (err error) { // The blob pool blocks on adding a transaction. This is because blob txs are // only even pulled from the network, so this method will act as the overload // protection for fetches. @@ -1637,7 +1639,7 @@ func (p *BlobPool) add(tx *types.Transaction, cellSidecar *types.BlobTxCellSidec // Transaction permitted into the pool from a nonce and cost perspective, // insert it into the database and update the indices - pooledTx := NewPooledBlobTx(tx, cellSidecar) + pooledTx := NewPooledBlobTx(tx, cellSidecar, size) if pooledTx.RemoveParity() != nil { return err } @@ -1651,7 +1653,7 @@ func (p *BlobPool) add(tx *types.Transaction, cellSidecar *types.BlobTxCellSidec if err != nil { return err } - meta := newBlobTxMeta(id, tx.Size(), p.store.Size(id), tx) + meta := newBlobTxMeta(id, pooledTx.Size, p.store.Size(id), tx) var ( next = p.state.GetNonce(from)