@ -1013,6 +1013,56 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
return nil
return nil
}
}
func ( p * BlobPool ) flushTransactionsBelowTip ( tip * uint256 . Int ) {
for addr , txs := range p . index {
for i , tx := range txs {
if tx . execTipCap . Cmp ( tip ) < 0 {
// Drop the offending transaction
var (
ids = [ ] uint64 { tx . id }
nonces = [ ] uint64 { tx . nonce }
)
p . spent [ addr ] = new ( uint256 . Int ) . Sub ( p . spent [ addr ] , txs [ i ] . costCap )
p . stored -= uint64 ( tx . size )
delete ( p . lookup , tx . hash )
txs [ i ] = nil
// Drop everything afterwards, no gaps allowed
for j , tx := range txs [ i + 1 : ] {
ids = append ( ids , tx . id )
nonces = append ( nonces , tx . nonce )
p . spent [ addr ] = new ( uint256 . Int ) . Sub ( p . spent [ addr ] , tx . costCap )
p . stored -= uint64 ( tx . size )
delete ( p . lookup , tx . hash )
txs [ i + 1 + j ] = nil
}
// Clear out the dropped transactions from the index
if i > 0 {
p . index [ addr ] = txs [ : i ]
heap . Fix ( p . evict , p . evict . index [ addr ] )
} else {
delete ( p . index , addr )
delete ( p . spent , addr )
heap . Remove ( p . evict , p . evict . index [ addr ] )
p . reserve ( addr , false )
}
// Clear out the transactions from the data store
log . Warn ( "Dropping underpriced blob transaction" , "from" , addr , "rejected" , tx . nonce , "tip" , tx . execTipCap , "want" , tip , "drop" , nonces , "ids" , ids )
dropUnderpricedMeter . Mark ( int64 ( len ( ids ) ) )
for _ , id := range ids {
if err := p . store . Delete ( id ) ; err != nil {
log . Error ( "Failed to delete dropped transaction" , "id" , id , "err" , err )
}
}
break
}
}
}
}
// SetGasTip implements txpool.SubPool, allowing the blob pool's gas requirements
// SetGasTip implements txpool.SubPool, allowing the blob pool's gas requirements
// to be kept in sync with the main transaction pool's gas requirements.
// to be kept in sync with the main transaction pool's gas requirements.
func ( p * BlobPool ) SetGasTip ( tip * big . Int ) {
func ( p * BlobPool ) SetGasTip ( tip * big . Int ) {
@ -1025,59 +1075,20 @@ func (p *BlobPool) SetGasTip(tip *big.Int) {
// If the min miner fee increased, remove transactions below the new threshold
// If the min miner fee increased, remove transactions below the new threshold
if old == nil || p . gasTip . Cmp ( old ) > 0 {
if old == nil || p . gasTip . Cmp ( old ) > 0 {
for addr , txs := range p . index {
p . flushTransactionsBelowTip ( p . gasTip )
for i , tx := range txs {
if tx . execTipCap . Cmp ( p . gasTip ) < 0 {
// Drop the offending transaction
var (
ids = [ ] uint64 { tx . id }
nonces = [ ] uint64 { tx . nonce }
)
p . spent [ addr ] = new ( uint256 . Int ) . Sub ( p . spent [ addr ] , txs [ i ] . costCap )
p . stored -= uint64 ( tx . size )
delete ( p . lookup , tx . hash )
txs [ i ] = nil
// Drop everything afterwards, no gaps allowed
for j , tx := range txs [ i + 1 : ] {
ids = append ( ids , tx . id )
nonces = append ( nonces , tx . nonce )
p . spent [ addr ] = new ( uint256 . Int ) . Sub ( p . spent [ addr ] , tx . costCap )
p . stored -= uint64 ( tx . size )
delete ( p . lookup , tx . hash )
txs [ i + 1 + j ] = nil
}
// Clear out the dropped transactions from the index
if i > 0 {
p . index [ addr ] = txs [ : i ]
heap . Fix ( p . evict , p . evict . index [ addr ] )
} else {
delete ( p . index , addr )
delete ( p . spent , addr )
heap . Remove ( p . evict , p . evict . index [ addr ] )
p . reserve ( addr , false )
}
// Clear out the transactions from the data store
log . Warn ( "Dropping underpriced blob transaction" , "from" , addr , "rejected" , tx . nonce , "tip" , tx . execTipCap , "want" , tip , "drop" , nonces , "ids" , ids )
dropUnderpricedMeter . Mark ( int64 ( len ( ids ) ) )
for _ , id := range ids {
if err := p . store . Delete ( id ) ; err != nil {
log . Error ( "Failed to delete dropped transaction" , "id" , id , "err" , err )
}
}
break
}
}
}
}
}
log . Debug ( "Blobpool tip threshold updated" , "tip" , tip )
log . Debug ( "Blobpool tip threshold updated" , "tip" , tip )
pooltipGauge . Update ( tip . Int64 ( ) )
pooltipGauge . Update ( tip . Int64 ( ) )
p . updateStorageMetrics ( )
p . updateStorageMetrics ( )
}
}
func ( p * BlobPool ) FlushAllTransactions ( ) {
maxUint256 := uint256 . MustFromBig ( new ( big . Int ) . Sub ( new ( big . Int ) . Lsh ( common . Big1 , 256 ) , common . Big1 ) )
p . lock . Lock ( )
defer p . lock . Unlock ( )
p . flushTransactionsBelowTip ( maxUint256 )
}
// validateTx checks whether a transaction is valid according to the consensus
// validateTx checks whether a transaction is valid according to the consensus
// rules and adheres to some heuristic limits of the local node (price and size).
// rules and adheres to some heuristic limits of the local node (price and size).
func ( p * BlobPool ) validateTx ( tx * types . Transaction ) error {
func ( p * BlobPool ) validateTx ( tx * types . Transaction ) error {