package blobpool

import "github.com/ethereum/go-ethereum/core/txpool/blobpool"

Package blobpool implements the EIP-4844 blob transaction pool.

Index

Variables

var DefaultConfig = Config{
	Datadir:   "blobpool",
	Datacap:   10 * 1024 * 1024 * 1024 / 4,
	PriceBump: 100,
}

DefaultConfig contains the default configurations for the transaction pool.

Types

type BlobPool

type BlobPool struct {
	// contains filtered or unexported fields
}

BlobPool is the transaction pool dedicated to EIP-4844 blob transactions.

Blob transactions are special snowflakes that are designed for a very specific purpose (rollups) and are expected to adhere to that specific use case. These behavioural expectations allow us to design a transaction pool that is more robust (i.e. resending issues) and more resilient to DoS attacks (e.g. replace-flush attacks) than the generic tx pool. These improvements will also mean, however, that we enforce a significantly more aggressive strategy on entering and exiting the pool:

Whilst some constraints above might sound overly aggressive, the general idea is that the blob pool should work robustly for its intended use case and whilst anyone is free to use blob transactions for arbitrary non-rollup use cases, they should not be allowed to run amok the network.

Implementation wise there are a few interesting design choices:

When the pool eventually reaches saturation, some old transactions - that may never execute - will need to be evicted in favor of newer ones. The eviction strategy is quite complex:

Optimisation tradeoffs:

func New

func New(config Config, chain BlockChain, hasPendingAuth func(common.Address) bool) *BlobPool

New creates a new blob transaction pool to gather, sort and filter inbound blob transactions from the network.

func (*BlobPool) Add

func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error

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 (*BlobPool) Clear

func (p *BlobPool) Clear()

Clear implements txpool.SubPool, removing all tracked transactions from the blob pool and persistent store.

Note, do not use this in production / live code. In live code, the pool is meant to reset on a separate thread to avoid DoS vectors.

func (*BlobPool) Close

func (p *BlobPool) Close() error

Close closes down the underlying persistent store.

func (*BlobPool) Content

func (p *BlobPool) Content() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction)

Content retrieves the data content of the transaction pool, returning all the pending as well as queued transactions, grouped by account and sorted by nonce.

For the blob pool, this method will return nothing for now. TODO(karalabe): Abstract out the returned metadata.

func (*BlobPool) ContentFrom

func (p *BlobPool) ContentFrom(addr common.Address) ([]*types.Transaction, []*types.Transaction)

ContentFrom retrieves the data content of the transaction pool, returning the pending as well as queued transactions of this address, grouped by nonce.

For the blob pool, this method will return nothing for now. TODO(karalabe): Abstract out the returned metadata.

func (*BlobPool) Filter

func (p *BlobPool) Filter(tx *types.Transaction) bool

Filter returns whether the given transaction can be consumed by the blob pool.

func (*BlobPool) Get

func (p *BlobPool) Get(hash common.Hash) *types.Transaction

Get returns a transaction if it is contained in the pool, or nil otherwise.

func (*BlobPool) GetBlobs

func (p *BlobPool) GetBlobs(vhashes []common.Hash) ([]*kzg4844.Blob, []*kzg4844.Proof)

GetBlobs returns a number of blobs are proofs for the given versioned hashes. This is a utility method for the engine API, enabling consensus clients to retrieve blobs from the pools directly instead of the network.

func (*BlobPool) GetMetadata

func (p *BlobPool) GetMetadata(hash common.Hash) *txpool.TxMetadata

GetMetadata returns the transaction type and transaction size with the given transaction hash.

The size refers the length of the 'rlp encoding' of a blob transaction including the attached blobs.

func (*BlobPool) GetRLP

func (p *BlobPool) GetRLP(hash common.Hash) []byte

GetRLP returns a RLP-encoded transaction if it is contained in the pool.

func (*BlobPool) Has

func (p *BlobPool) Has(hash common.Hash) bool

Has returns an indicator whether subpool has a transaction cached with the given hash.

func (*BlobPool) Init

func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reserver) error

Init sets the gas price needed to keep a transaction in the pool and the chain head to allow balance / nonce checks. The transaction journal will be loaded from disk and filtered based on the provided starting settings.

func (*BlobPool) Nonce

func (p *BlobPool) Nonce(addr common.Address) uint64

Nonce returns the next nonce of an account, with all transactions executable by the pool already applied on top.

func (*BlobPool) Pending

func (p *BlobPool) Pending(filter txpool.PendingFilter) map[common.Address][]*txpool.LazyTransaction

Pending retrieves all currently processable transactions, grouped by origin account and sorted by nonce.

The transactions can also be pre-filtered by the dynamic fee components to reduce allocations and load on downstream subsystems.

func (*BlobPool) Reset

func (p *BlobPool) Reset(oldHead, newHead *types.Header)

Reset implements txpool.SubPool, allowing the blob pool's internal state to be kept in sync with the main transaction pool's internal state.

func (*BlobPool) SetGasTip

func (p *BlobPool) SetGasTip(tip *big.Int)

SetGasTip implements txpool.SubPool, allowing the blob pool's gas requirements to be kept in sync with the main transaction pool's gas requirements.

func (*BlobPool) Stats

func (p *BlobPool) Stats() (int, int)

Stats retrieves the current pool stats, namely the number of pending and the number of queued (non-executable) transactions.

func (*BlobPool) Status

func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus

Status returns the known status (unknown/pending/queued) of a transaction identified by their hashes.

func (*BlobPool) SubscribeTransactions

func (p *BlobPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription

SubscribeTransactions registers a subscription for new transaction events, supporting feeding only newly seen or also resurrected transactions.

func (*BlobPool) ValidateTxBasics

func (p *BlobPool) ValidateTxBasics(tx *types.Transaction) error

ValidateTxBasics checks whether a transaction is valid according to the consensus rules, but does not check state-dependent validation such as sufficient balance. This check is meant as an early check which only needs to be performed once, and does not require the pool mutex to be held.

type BlockChain

type BlockChain interface {
	// Config retrieves the chain's fork configuration.
	Config() *params.ChainConfig

	// CurrentBlock returns the current head of the chain.
	CurrentBlock() *types.Header

	// CurrentFinalBlock returns the current block below which blobs should not
	// be maintained anymore for reorg purposes.
	CurrentFinalBlock() *types.Header

	// GetBlock retrieves a specific block, used during pool resets.
	GetBlock(hash common.Hash, number uint64) *types.Block

	// StateAt returns a state database for a given root hash (generally the head).
	StateAt(root common.Hash) (*state.StateDB, error)
}

BlockChain defines the minimal set of methods needed to back a blob pool with a chain. Exists to allow mocking the live chain out of tests.

type Config

type Config struct {
	Datadir   string // Data directory containing the currently executable blobs
	Datacap   uint64 // Soft-cap of database storage (hard cap is larger due to overhead)
	PriceBump uint64 // Minimum price bump percentage to replace an already existing nonce
}

Config are the configuration parameters of the blob transaction pool.

Source Files

blobpool.go config.go evictheap.go interface.go limbo.go lookup.go metrics.go priority.go slotter.go

Version
v1.15.11 (latest)
Published
May 5, 2025
Platform
linux/amd64
Imports
28 packages
Last checked
1 day ago

Tools for package owners.