Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blob transactions to txpool_content #160

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading