mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/txpool, eth, miner: pass gas limit infos in lazy tx for mienr filtering
This commit is contained in:
parent
6dc42f5545
commit
cdc0e1d865
6 changed files with 31 additions and 5 deletions
|
|
@ -97,6 +97,8 @@ type blobTxMeta struct {
|
||||||
execTipCap *uint256.Int // Needed to prioritize inclusion order across accounts and validate replacement price bump
|
execTipCap *uint256.Int // Needed to prioritize inclusion order across accounts and validate replacement price bump
|
||||||
execFeeCap *uint256.Int // Needed to validate replacement price bump
|
execFeeCap *uint256.Int // Needed to validate replacement price bump
|
||||||
blobFeeCap *uint256.Int // Needed to validate replacement price bump
|
blobFeeCap *uint256.Int // Needed to validate replacement price bump
|
||||||
|
execGas uint64 // Needed to check inclusion validity before reading the blob
|
||||||
|
blobGas uint64 // Needed to check inclusion validity before reading the blob
|
||||||
|
|
||||||
basefeeJumps float64 // Absolute number of 1559 fee adjustments needed to reach the tx's fee cap
|
basefeeJumps float64 // Absolute number of 1559 fee adjustments needed to reach the tx's fee cap
|
||||||
blobfeeJumps float64 // Absolute number of 4844 fee adjustments needed to reach the tx's blob fee cap
|
blobfeeJumps float64 // Absolute number of 4844 fee adjustments needed to reach the tx's blob fee cap
|
||||||
|
|
@ -118,6 +120,8 @@ func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta {
|
||||||
execTipCap: uint256.MustFromBig(tx.GasTipCap()),
|
execTipCap: uint256.MustFromBig(tx.GasTipCap()),
|
||||||
execFeeCap: uint256.MustFromBig(tx.GasFeeCap()),
|
execFeeCap: uint256.MustFromBig(tx.GasFeeCap()),
|
||||||
blobFeeCap: uint256.MustFromBig(tx.BlobGasFeeCap()),
|
blobFeeCap: uint256.MustFromBig(tx.BlobGasFeeCap()),
|
||||||
|
execGas: tx.Gas(),
|
||||||
|
blobGas: tx.BlobGas(),
|
||||||
}
|
}
|
||||||
meta.basefeeJumps = dynamicFeeJumps(meta.execFeeCap)
|
meta.basefeeJumps = dynamicFeeJumps(meta.execFeeCap)
|
||||||
meta.blobfeeJumps = dynamicFeeJumps(meta.blobFeeCap)
|
meta.blobfeeJumps = dynamicFeeJumps(meta.blobFeeCap)
|
||||||
|
|
@ -1399,6 +1403,8 @@ func (p *BlobPool) Pending(enforceTips bool) map[common.Address][]*txpool.LazyTr
|
||||||
Time: time.Now(), // TODO(karalabe): Maybe save these and use that?
|
Time: time.Now(), // TODO(karalabe): Maybe save these and use that?
|
||||||
GasFeeCap: tx.execFeeCap.ToBig(),
|
GasFeeCap: tx.execFeeCap.ToBig(),
|
||||||
GasTipCap: tx.execTipCap.ToBig(),
|
GasTipCap: tx.execTipCap.ToBig(),
|
||||||
|
Gas: tx.execGas,
|
||||||
|
BlobGas: tx.blobGas,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(lazies) > 0 {
|
if len(lazies) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -552,6 +552,8 @@ func (pool *LegacyPool) Pending(enforceTips bool) map[common.Address][]*txpool.L
|
||||||
Time: txs[i].Time(),
|
Time: txs[i].Time(),
|
||||||
GasFeeCap: txs[i].GasFeeCap(),
|
GasFeeCap: txs[i].GasFeeCap(),
|
||||||
GasTipCap: txs[i].GasTipCap(),
|
GasTipCap: txs[i].GasTipCap(),
|
||||||
|
Gas: txs[i].Gas(),
|
||||||
|
BlobGas: txs[i].BlobGas(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pending[addr] = lazies
|
pending[addr] = lazies
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ type LazyTransaction struct {
|
||||||
Time time.Time // Time when the transaction was first seen
|
Time time.Time // Time when the transaction was first seen
|
||||||
GasFeeCap *big.Int // Maximum fee per gas the transaction may consume
|
GasFeeCap *big.Int // Maximum fee per gas the transaction may consume
|
||||||
GasTipCap *big.Int // Maximum miner tip per gas the transaction can pay
|
GasTipCap *big.Int // Maximum miner tip per gas the transaction can pay
|
||||||
|
|
||||||
|
Gas uint64 // Amount of gas required by the transaction
|
||||||
|
BlobGas uint64 // Amount of blob gas required by the transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve retrieves the full transaction belonging to a lazy handle if it is still
|
// Resolve retrieves the full transaction belonging to a lazy handle if it is still
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,8 @@ func (p *testTxPool) Pending(enforceTips bool) map[common.Address][]*txpool.Lazy
|
||||||
Time: tx.Time(),
|
Time: tx.Time(),
|
||||||
GasFeeCap: tx.GasFeeCap(),
|
GasFeeCap: tx.GasFeeCap(),
|
||||||
GasTipCap: tx.GasTipCap(),
|
GasTipCap: tx.GasTipCap(),
|
||||||
|
Gas: tx.Gas(),
|
||||||
|
BlobGas: tx.BlobGas(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,8 @@ func testTransactionPriceNonceSort(t *testing.T, baseFee *big.Int) {
|
||||||
Time: tx.Time(),
|
Time: tx.Time(),
|
||||||
GasFeeCap: tx.GasFeeCap(),
|
GasFeeCap: tx.GasFeeCap(),
|
||||||
GasTipCap: tx.GasTipCap(),
|
GasTipCap: tx.GasTipCap(),
|
||||||
|
Gas: tx.Gas(),
|
||||||
|
BlobGas: tx.BlobGas(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
expectedCount += count
|
expectedCount += count
|
||||||
|
|
@ -157,6 +159,8 @@ func TestTransactionTimeSort(t *testing.T) {
|
||||||
Time: tx.Time(),
|
Time: tx.Time(),
|
||||||
GasFeeCap: tx.GasFeeCap(),
|
GasFeeCap: tx.GasFeeCap(),
|
||||||
GasTipCap: tx.GasTipCap(),
|
GasTipCap: tx.GasTipCap(),
|
||||||
|
Gas: tx.Gas(),
|
||||||
|
BlobGas: tx.BlobGas(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Sort the transactions and cross check the nonce ordering
|
// Sort the transactions and cross check the nonce ordering
|
||||||
|
|
|
||||||
|
|
@ -543,10 +543,11 @@ func (w *worker) mainLoop() {
|
||||||
acc, _ := types.Sender(w.current.signer, tx)
|
acc, _ := types.Sender(w.current.signer, tx)
|
||||||
txs[acc] = append(txs[acc], &txpool.LazyTransaction{
|
txs[acc] = append(txs[acc], &txpool.LazyTransaction{
|
||||||
Hash: tx.Hash(),
|
Hash: tx.Hash(),
|
||||||
Tx: tx.WithoutBlobTxSidecar(),
|
|
||||||
Time: tx.Time(),
|
Time: tx.Time(),
|
||||||
GasFeeCap: tx.GasFeeCap(),
|
GasFeeCap: tx.GasFeeCap(),
|
||||||
GasTipCap: tx.GasTipCap(),
|
GasTipCap: tx.GasTipCap(),
|
||||||
|
Gas: tx.Gas(),
|
||||||
|
BlobGas: tx.BlobGas(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
txset := newTransactionsByPriceAndNonce(w.current.signer, txs, w.current.header.BaseFee)
|
txset := newTransactionsByPriceAndNonce(w.current.signer, txs, w.current.header.BaseFee)
|
||||||
|
|
@ -742,7 +743,6 @@ func (w *worker) commitTransaction(env *environment, tx *types.Transaction) ([]*
|
||||||
if tx.Type() == types.BlobTxType {
|
if tx.Type() == types.BlobTxType {
|
||||||
return w.commitBlobTransaction(env, tx)
|
return w.commitBlobTransaction(env, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
receipt, err := w.applyTransaction(env, tx)
|
receipt, err := w.applyTransaction(env, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -764,7 +764,6 @@ func (w *worker) commitBlobTransaction(env *environment, tx *types.Transaction)
|
||||||
if (env.blobs+len(sc.Blobs))*params.BlobTxBlobGasPerBlob > params.MaxBlobGasPerBlock {
|
if (env.blobs+len(sc.Blobs))*params.BlobTxBlobGasPerBlob > params.MaxBlobGasPerBlock {
|
||||||
return nil, errors.New("max data blobs reached")
|
return nil, errors.New("max data blobs reached")
|
||||||
}
|
}
|
||||||
|
|
||||||
receipt, err := w.applyTransaction(env, tx)
|
receipt, err := w.applyTransaction(env, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -815,13 +814,24 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
|
||||||
if ltx == nil {
|
if ltx == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
// If we don't have enough space for the next transaction, skip the account.
|
||||||
|
if env.gasPool.Gas() < ltx.Gas {
|
||||||
|
log.Trace("Not enough gas left for transaction", "left", env.gasPool.Gas(), "needed", ltx.Gas)
|
||||||
|
txs.Pop()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if left := uint64(params.MaxBlobGasPerBlock - env.blobs*params.BlobTxBlobGasPerBlob); left < ltx.BlobGas {
|
||||||
|
log.Trace("Not enough blob gas left for transaction", "left", left, "needed", ltx.BlobGas)
|
||||||
|
txs.Pop()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Transaction seems to fit, pull it up from the pool
|
||||||
tx := ltx.Resolve()
|
tx := ltx.Resolve()
|
||||||
if tx == nil {
|
if tx == nil {
|
||||||
log.Warn("Ignoring evicted transaction")
|
log.Warn("Ignoring evicted transaction")
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
continue
|
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 is the transaction pool.
|
// during transaction acceptance is the transaction pool.
|
||||||
from, _ := types.Sender(env.signer, tx)
|
from, _ := types.Sender(env.signer, tx)
|
||||||
|
|
@ -833,7 +843,6 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
|
||||||
txs.Pop()
|
txs.Pop()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start executing the transaction
|
// Start executing the transaction
|
||||||
env.state.SetTxContext(tx.Hash(), env.tcount)
|
env.state.SetTxContext(tx.Hash(), env.tcount)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue