Skip to content

Commit

Permalink
Add blob transactions to txpool_content (#160)
Browse files Browse the repository at this point in the history
* return blobs in txpool_contents

* Experiment no. 2

* Cleanup
  • Loading branch information
lukanus authored Feb 23, 2024
1 parent f084d40 commit 148f358
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type blobTxMeta struct {
evictionExecTip *uint256.Int // Worst gas tip across all previous nonces
evictionExecFeeJumps float64 // Worst base fee (converted to fee jumps) across all previous nonces
evictionBlobFeeJumps float64 // Worse blob fee (converted to fee jumps) across all previous nonces

// -------- BLOCKNATIVE MODIFICATION START -------------
blobHashes []common.Hash
// -------- BLOCKNATIVE MODIFICATION STOP -------------
}

// newBlobTxMeta retrieves the indexed metadata fields from a blob transaction
Expand All @@ -122,6 +126,10 @@ func newBlobTxMeta(id uint64, size uint32, tx *types.Transaction) *blobTxMeta {
blobFeeCap: uint256.MustFromBig(tx.BlobGasFeeCap()),
execGas: tx.Gas(),
blobGas: tx.BlobGas(),

// -------- BLOCKNATIVE MODIFICATION START -------------
blobHashes: tx.BlobHashes(),
// -------- BLOCKNATIVE MODIFICATION STOP -------------
}
meta.basefeeJumps = dynamicFeeJumps(meta.execFeeCap)
meta.blobfeeJumps = dynamicFeeJumps(meta.blobFeeCap)
Expand Down Expand Up @@ -1594,7 +1602,33 @@ func (p *BlobPool) Stats() (int, int) {
// For the blob pool, this method will return nothing for now.
// TODO(karalabe): Abstract out the returned metadata.
func (p *BlobPool) Content() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction) {
return make(map[common.Address][]*types.Transaction), make(map[common.Address][]*types.Transaction)

// -------- BLOCKNATIVE MODIFICATION START -------------

pending := make(map[common.Address][]*types.Transaction)
p.lock.RLock()
defer p.lock.RUnlock()

for addr, txs := range p.index {
var lazies []*types.Transaction
for _, tx := range txs {
lazies = append(lazies, types.NewTx(&types.BlobTx{
Gas: tx.execGas,
BlobFeeCap: tx.blobFeeCap,
Nonce: tx.nonce,
GasFeeCap: tx.execFeeCap,
GasTipCap: tx.execTipCap,
BlobHashes: tx.blobHashes,
}))
}
if len(lazies) > 0 {
pending[addr] = lazies
}

}

return pending, make(map[common.Address][]*types.Transaction)
// -------- BLOCKNATIVE MODIFICATION STOP --------------
}

// ContentFrom retrieves the data content of the transaction pool, returning the
Expand Down Expand Up @@ -1622,7 +1656,6 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
return txpool.TxStatusUnknown
}


// SubscribeDropTxsEvent registers a subscription of core.DropTxsEvent and
// starts sending event to the given channel.
func (pool *BlobPool) SubscribeDropTxsEvent(ch chan<- core.DropTxsEvent) event.Subscription {
Expand Down

0 comments on commit 148f358

Please sign in to comment.