Skip to content

Implement Horizontally Sharded Blob Mempool #31995

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
18 changes: 15 additions & 3 deletions eth/protocols/eth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,14 +688,26 @@ func testGetPooledTransaction(t *testing.T, blobTx bool) {
}
}

// Send the hash request and verify the response
hashes := []common.Hash{tx.Hash()}

p2p.Send(peer.app, GetPooledTransactionsMsg, GetPooledTransactionsPacket{
RequestId: 123,
GetPooledTransactionsRequest: []common.Hash{tx.Hash()},
GetPooledTransactionsRequest: hashes,
})

var expectedTxs []*types.Transaction
peerIDLast4 := peer.ID()[len(peer.ID())-1] & 0x0F

for _, tx := range []*types.Transaction{tx} {
txHashLast4 := tx.Hash().Bytes()[len(tx.Hash().Bytes())-1] & 0x0F
if peerIDLast4 != txHashLast4 {
expectedTxs = append(expectedTxs, tx)
}
}

if err := p2p.ExpectMsg(peer.app, PooledTransactionsMsg, PooledTransactionsPacket{
RequestId: 123,
PooledTransactionsResponse: []*types.Transaction{tx},
PooledTransactionsResponse: expectedTxs,
}); err != nil {
t.Errorf("pooled transaction mismatch: %v", err)
}
Expand Down
22 changes: 21 additions & 1 deletion eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,36 @@ func handlePooledTransactions(backend Backend, msg Decoder, peer *Peer) error {
if err := msg.Decode(&txs); err != nil {
return err
}
peerID := peer.ID()
peerIDLast4 := peerID[len(peerID)-1] & 0x0F

var filteredTxs []*types.Transaction

for i, tx := range txs.PooledTransactionsResponse {
// Validate and mark the remote transaction
if tx == nil {
return fmt.Errorf("PooledTransactions: transaction %d is nil", i)
}
txHash := tx.Hash()
txHashLast4 := txHash[len(txHash)-1] & 0x0F

if txHashLast4 != peerIDLast4 && tx.Type() == types.BlobTxType {
continue
}

peer.markTransaction(tx.Hash())
filteredTxs = append(filteredTxs, tx)
}
requestTracker.Fulfil(peer.id, peer.version, PooledTransactionsMsg, txs.RequestId)

return backend.Handle(peer, &txs.PooledTransactionsResponse)
if len(filteredTxs) == 0 {
return nil
}

return backend.Handle(peer, &PooledTransactionsPacket{
PooledTransactionsResponse: filteredTxs,
RequestId: txs.RequestId,
})
}

func handleBlockRangeUpdate(backend Backend, msg Decoder, peer *Peer) error {
Expand Down