mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
miner: skip v1 transactions post-prague
This commit is contained in:
parent
66a585c589
commit
6b5bfbe9fd
6 changed files with 67 additions and 0 deletions
|
|
@ -1325,6 +1325,19 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar {
|
||||||
return sidecars
|
return sidecars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *BlobPool) HasBlobs(vhashes []common.Hash) bool {
|
||||||
|
for _, vhash := range vhashes {
|
||||||
|
// Retrieve the datastore item (in a short lock)
|
||||||
|
p.lock.RLock()
|
||||||
|
_, exists := p.lookup.storeidOfBlob(vhash)
|
||||||
|
p.lock.RUnlock()
|
||||||
|
if !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Add inserts a set of blob transactions into the pool if they pass validation (both
|
// Add inserts a set of blob transactions into the pool if they pass validation (both
|
||||||
// consensus validity and pool restrictions).
|
// consensus validity and pool restrictions).
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1068,6 +1068,12 @@ func (pool *LegacyPool) GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasBlobs is not supported by the legacy transaction pool, it is just here to
|
||||||
|
// implement the txpool.SubPool interface.
|
||||||
|
func (pool *LegacyPool) HasBlobs(vhashes []common.Hash) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Has returns an indicator whether txpool has a transaction cached with the
|
// Has returns an indicator whether txpool has a transaction cached with the
|
||||||
// given hash.
|
// given hash.
|
||||||
func (pool *LegacyPool) Has(hash common.Hash) bool {
|
func (pool *LegacyPool) Has(hash common.Hash) bool {
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,10 @@ type SubPool interface {
|
||||||
// retrieve blobs from the pools directly instead of the network.
|
// retrieve blobs from the pools directly instead of the network.
|
||||||
GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar
|
GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar
|
||||||
|
|
||||||
|
// HasBlobs returns true if all blobs corresponding to the versioned hashes
|
||||||
|
// are in the sub pool.
|
||||||
|
HasBlobs(vhashes []common.Hash) bool
|
||||||
|
|
||||||
// ValidateTxBasics checks whether a transaction is valid according to the consensus
|
// ValidateTxBasics checks whether a transaction is valid according to the consensus
|
||||||
// rules, but does not check state-dependent validation such as sufficient balance.
|
// 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
|
// This check is meant as a static check which can be performed without holding the
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,31 @@ func (p *TxPool) GetBlobs(vhashes []common.Hash) []*types.BlobTxSidecar {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasBlobs will return true if all the vhashes are available in the same subpool.
|
||||||
|
func (p *TxPool) HasBlobs(vhashes []common.Hash) bool {
|
||||||
|
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 subpool.HasBlobs(vhashes) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateTxBasics checks whether a transaction is valid according to the consensus
|
||||||
|
// rules, but does not check state-dependent validation such as sufficient balance.
|
||||||
|
func (p *TxPool) ValidateTxBasics(tx *types.Transaction) error {
|
||||||
|
for _, subpool := range p.subpools {
|
||||||
|
if subpool.Filter(tx) {
|
||||||
|
return subpool.ValidateTxBasics(tx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("%w: received type %d", core.ErrTxTypeNotSupported, tx.Type())
|
||||||
|
}
|
||||||
|
|
||||||
// Add enqueues a batch of transactions into the pool if they are valid. Due
|
// 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 the large transaction churn, add may postpone fully integrating the tx
|
||||||
// to a later point to batch multiple ones together.
|
// to a later point to batch multiple ones together.
|
||||||
|
|
|
||||||
|
|
@ -593,6 +593,13 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
||||||
if len(hashes) > 128 {
|
if len(hashes) > 128 {
|
||||||
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
|
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimization: check first if all blobs are available, if not, return empty response
|
||||||
|
if !api.eth.TxPool().HasBlobs(hashes) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// pull up the blob hashes
|
||||||
var (
|
var (
|
||||||
res = make([]*engine.BlobAndProofV2, len(hashes))
|
res = make([]*engine.BlobAndProofV2, len(hashes))
|
||||||
index = make(map[common.Hash]int)
|
index = make(map[common.Hash]int)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/txpool"
|
"github.com/ethereum/go-ethereum/core/txpool"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
|
|
@ -390,6 +391,17 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if miner.chainConfig.IsOsaka(env.header.Number, env.header.Time) {
|
||||||
|
if sidecar := tx.BlobTxSidecar(); sidecar != nil {
|
||||||
|
if len(sidecar.Blobs) != len(sidecar.Proofs)*kzg4844.CellProofsPerBlob {
|
||||||
|
log.Warn("Ignoring V1 blob transaction post-Osaka", "hash", ltx.Hash)
|
||||||
|
txs.Pop()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Error may be ignored here. The error has already been checked
|
// Error may be ignored here. The error has already been checked
|
||||||
// during transaction acceptance in the transaction pool.
|
// during transaction acceptance in the transaction pool.
|
||||||
from, _ := types.Sender(env.signer, tx)
|
from, _ := types.Sender(env.signer, tx)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue