diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index b2a53af3f53..88c0fe55435 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -63,17 +63,17 @@ var Eip1559FeeCalculator eip1559Calculator type eip1559Calculator struct{} -func (f eip1559Calculator) CurrentFees(chainConfig *chain.Config, db kv.Getter) (baseFee uint64, blobFee uint64, minBlobGasPrice uint64, err error) { +func (f eip1559Calculator) CurrentFees(chainConfig *chain.Config, db kv.Getter) (baseFee, blobFee, minBlobGasPrice, blockGasLimit uint64, err error) { hash := rawdb.ReadHeadHeaderHash(db) if hash == (libcommon.Hash{}) { - return 0, 0, 0, fmt.Errorf("can't get head header hash") + return 0, 0, 0, 0, fmt.Errorf("can't get head header hash") } currentHeader, err := rawdb.ReadHeaderByHash(db, hash) if err != nil { - return 0, 0, 0, err + return 0, 0, 0, 0, err } if chainConfig != nil { @@ -92,7 +92,7 @@ func (f eip1559Calculator) CurrentFees(chainConfig *chain.Config, db kv.Getter) minBlobGasPrice = chainConfig.GetMinBlobGasPrice() - return baseFee, blobFee, minBlobGasPrice, nil + return baseFee, blobFee, minBlobGasPrice, currentHeader.GasLimit, nil } // CalcBaseFee calculates the basefee of the header. diff --git a/erigon-lib/txpool/pool.go b/erigon-lib/txpool/pool.go index d56b4d7ccec..fa5a0b1b5b7 100644 --- a/erigon-lib/txpool/pool.go +++ b/erigon-lib/txpool/pool.go @@ -61,6 +61,8 @@ import ( "github.com/ledgerwatch/erigon-lib/types" ) +const DefaultBlockGasLimit = uint64(30000000) + var ( processBatchTxsTimer = metrics.NewSummary(`pool_process_remote_txs`) addRemoteTxsTimer = metrics.NewSummary(`pool_add_remote_txs`) @@ -229,7 +231,7 @@ type TxPool struct { } type FeeCalculator interface { - CurrentFees(chainConfig *chain.Config, db kv.Getter) (baseFee uint64, blobFee uint64, minBlobGasPrice uint64, err error) + CurrentFees(chainConfig *chain.Config, db kv.Getter) (baseFee uint64, blobFee uint64, minBlobGasPrice, blockGasLimit uint64, err error) } func New(newTxs chan types.Announcements, coreDB kv.RoDB, cfg txpoolcfg.Config, cache kvcache.Cache, @@ -1317,7 +1319,7 @@ func (p *TxPool) setBaseFee(baseFee uint64) (uint64, bool) { func (p *TxPool) setBlobFee(blobFee uint64) { if blobFee > 0 { - p.pendingBaseFee.Store(blobFee) + p.pendingBlobFee.Store(blobFee) } } @@ -2086,11 +2088,14 @@ func (p *TxPool) fromDB(ctx context.Context, tx kv.Tx, coreTx kv.Tx) error { i++ } - var pendingBaseFee, pendingBlobFee, minBlobGasPrice uint64 + var pendingBaseFee, pendingBlobFee, minBlobGasPrice, blockGasLimit uint64 if p.feeCalculator != nil { if chainConfig, _ := ChainConfig(tx); chainConfig != nil { - pendingBaseFee, pendingBlobFee, minBlobGasPrice, _ = p.feeCalculator.CurrentFees(chainConfig, coreTx) + pendingBaseFee, pendingBlobFee, minBlobGasPrice, blockGasLimit, err = p.feeCalculator.CurrentFees(chainConfig, coreTx) + if err != nil { + return err + } } } @@ -2118,16 +2123,21 @@ func (p *TxPool) fromDB(ctx context.Context, tx kv.Tx, coreTx kv.Tx) error { pendingBlobFee = minBlobGasPrice } + if blockGasLimit == 0 { + blockGasLimit = DefaultBlockGasLimit + } + err = p.senders.registerNewSenders(&txs, p.logger) if err != nil { return err } if _, _, err := p.addTxs(p.lastSeenBlock.Load(), cacheView, p.senders, txs, - pendingBaseFee, pendingBlobFee, math.MaxUint64 /* blockGasLimit */, false, p.logger); err != nil { + pendingBaseFee, pendingBlobFee, blockGasLimit, false, p.logger); err != nil { return err } p.pendingBaseFee.Store(pendingBaseFee) p.pendingBlobFee.Store(pendingBlobFee) + p.blockGasLimit.Store(blockGasLimit) return nil }