Skip to content

Commit

Permalink
Remove remnants of requests from block body downloader (#12475)
Browse files Browse the repository at this point in the history
Cherry pick #12426 into `release/2.61`
  • Loading branch information
yperbasis authored Oct 25, 2024
1 parent b3b915d commit 6d92c11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion p2p/sentry/sentry_multi_client/sentry_multi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func (cs *MultiClient) blockBodies66(ctx context.Context, inreq *proto_sentry.In
// No point processing empty response
return nil
}
cs.Bd.DeliverBodies(txs, uncles, withdrawals, nil, uint64(len(inreq.Data)), sentry.ConvertH512ToPeerID(inreq.PeerId))
cs.Bd.DeliverBodies(txs, uncles, withdrawals, uint64(len(inreq.Data)), sentry.ConvertH512ToPeerID(inreq.PeerId))
return nil
}

Expand Down
10 changes: 3 additions & 7 deletions turbo/stages/bodydownload/body_algos.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB
}
if request {
if header.UncleHash == types.EmptyUncleHash && header.TxHash == types.EmptyRootHash &&
(header.WithdrawalsHash == nil || *header.WithdrawalsHash == types.EmptyRootHash) &&
(header.RequestsHash == nil || *header.RequestsHash == types.EmptyRequestsHash) {
(header.WithdrawalsHash == nil || *header.WithdrawalsHash == types.EmptyRootHash) {
// Empty block body
body := &types.RawBody{}
if header.WithdrawalsHash != nil {
Expand All @@ -170,14 +169,11 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB
if header.WithdrawalsHash != nil {
copy(bodyHashes[2*length.Hash:], header.WithdrawalsHash.Bytes())
}
if header.RequestsHash != nil {
copy(bodyHashes[3*length.Hash:], header.RequestsHash.Bytes())
}
bd.requestedMap[bodyHashes] = blockNum
blockNums = append(blockNums, blockNum)
hashes = append(hashes, hash)
} else {
// uncleHash, txHash, withdrawalsHash, and requestsHash are all empty (or block is prefetched), no need to request
// uncleHash, txHash, and withdrawalsHash are all empty (or block is prefetched), no need to request
bd.delivered.Add(blockNum)
}
}
Expand Down Expand Up @@ -231,7 +227,7 @@ func (bd *BodyDownload) RequestSent(bodyReq *BodyRequest, timeWithTimeout uint64

// DeliverBodies takes the block body received from a peer and adds it to the various data structures
func (bd *BodyDownload) DeliverBodies(txs [][][]byte, uncles [][]*types.Header, withdrawals []types.Withdrawals,
requests []types.FlatRequests, lenOfP2PMsg uint64, peerID [64]byte,
lenOfP2PMsg uint64, peerID [64]byte,
) {
bd.deliveryCh <- Delivery{txs: txs, uncles: uncles, withdrawals: withdrawals, lenOfP2PMessage: lenOfP2PMsg, peerID: peerID}

Expand Down
5 changes: 2 additions & 3 deletions turbo/stages/bodydownload/body_data_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/ledgerwatch/erigon/core/types"
)

// BodyHashes is to be used for the mapping between TxHash, UncleHash, WithdrawalsHash, and RequestRoot to the block header
type BodyHashes [4 * length.Hash]byte
// BodyHashes is to be used for the mapping between TxHash, UncleHash, and WithdrawalsHash to the block header
type BodyHashes [3 * length.Hash]byte

const MaxBodiesInRequest = 1024

Expand All @@ -22,7 +22,6 @@ type Delivery struct {
txs [][][]byte
uncles [][]*types.Header
withdrawals []types.Withdrawals
requests []types.FlatRequests
lenOfP2PMessage uint64
}

Expand Down

0 comments on commit 6d92c11

Please sign in to comment.