mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
core/txpool, eth/catalyst: call blob methods on blobpool
This commit is contained in:
parent
73687b9b52
commit
60aacd2519
5 changed files with 5 additions and 54 deletions
|
|
@ -1062,18 +1062,6 @@ func (pool *LegacyPool) GetMetadata(hash common.Hash) *txpool.TxMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
// GetBlobs is not supported by the legacy transaction pool, it is just here to
|
||||
// implement the txpool.SubPool interface.
|
||||
func (pool *LegacyPool) GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AvailableBlobs is not supported by the legacy transaction pool, it is just here to
|
||||
// implement the txpool.SubPool interface.
|
||||
func (pool *LegacyPool) AvailableBlobs(vhashes []common.Hash) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Has returns an indicator whether txpool has a transaction cached with the
|
||||
// given hash.
|
||||
func (pool *LegacyPool) Has(hash common.Hash) bool {
|
||||
|
|
|
|||
|
|
@ -132,15 +132,6 @@ type SubPool interface {
|
|||
// given transaction hash.
|
||||
GetMetadata(hash common.Hash) *TxMetadata
|
||||
|
||||
// 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.
|
||||
GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar
|
||||
|
||||
// AvailableBlobs returns number of blobs corresponding to the versioned hashes
|
||||
// that are available in the sub pool.
|
||||
AvailableBlobs(vhashes []common.Hash) int
|
||||
|
||||
// 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 a static check which can be performed without holding the
|
||||
|
|
|
|||
|
|
@ -307,36 +307,6 @@ func (p *TxPool) GetMetadata(hash common.Hash) *TxMetadata {
|
|||
return nil
|
||||
}
|
||||
|
||||
// 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 (p *TxPool) GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar {
|
||||
for _, subpool := range p.subpools {
|
||||
// It's an ugly to assume that only one pool will be capable of returning
|
||||
// anything meaningful for this call, but anything else requires merging
|
||||
// partial responses and that's too annoying to do until we get a second
|
||||
// blobpool (probably never).
|
||||
if sidecars := subpool.GetBlobs(vhashes); sidecars != nil {
|
||||
return sidecars
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AvailableBlobs will return the number of vhashes that are available in the same subpool.
|
||||
func (p *TxPool) AvailableBlobs(vhashes []common.Hash) int {
|
||||
for _, subpool := range p.subpools {
|
||||
// It's an ugly to assume that only one pool will be capable of returning
|
||||
// anything meaningful for this call, but anything else requires merging
|
||||
// partial responses and that's too annoying to do until we get a second
|
||||
// blobpool (probably never).
|
||||
if count := subpool.AvailableBlobs(vhashes); count != 0 {
|
||||
return count
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Add enqueues a batch of transactions into the pool if they are valid. Due
|
||||
// to the large transaction churn, add may postpone fully integrating the tx
|
||||
// to a later point to batch multiple ones together.
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ type Ethereum struct {
|
|||
// core protocol objects
|
||||
config *ethconfig.Config
|
||||
txPool *txpool.TxPool
|
||||
blobTxPool *blobpool.BlobPool
|
||||
localTxTracker *locals.TxTracker
|
||||
blockchain *core.BlockChain
|
||||
|
||||
|
|
@ -395,6 +396,7 @@ func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
|||
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
|
||||
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
|
||||
func (s *Ethereum) TxPool() *txpool.TxPool { return s.txPool }
|
||||
func (s *Ethereum) BlobTxPool() *blobpool.BlobPool { return s.blobTxPool }
|
||||
func (s *Ethereum) Engine() consensus.Engine { return s.engine }
|
||||
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
|
||||
func (s *Ethereum) IsListening() bool { return true } // Always listening
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
res = make([]*engine.BlobAndProofV1, len(hashes))
|
||||
hasher = sha256.New()
|
||||
index = make(map[common.Hash]int)
|
||||
sidecars = api.eth.TxPool().GetBlobs(hashes)
|
||||
sidecars = api.eth.BlobTxPool().GetBlobs(hashes)
|
||||
)
|
||||
|
||||
for i, hash := range hashes {
|
||||
|
|
@ -522,7 +522,7 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
|
||||
}
|
||||
|
||||
available := api.eth.TxPool().AvailableBlobs(hashes)
|
||||
available := api.eth.BlobTxPool().AvailableBlobs(hashes)
|
||||
getBlobsRequestedCounter.Inc(int64(len(hashes)))
|
||||
getBlobsAvailableCounter.Inc(int64(available))
|
||||
// Optimization: check first if all blobs are available, if not, return empty response
|
||||
|
|
@ -536,7 +536,7 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
var (
|
||||
res = make([]*engine.BlobAndProofV2, len(hashes))
|
||||
index = make(map[common.Hash][]int)
|
||||
sidecars = api.eth.TxPool().GetBlobs(hashes)
|
||||
sidecars = api.eth.BlobTxPool().GetBlobs(hashes)
|
||||
)
|
||||
|
||||
for i, hash := range hashes {
|
||||
|
|
|
|||
Loading…
Reference in a new issue