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

Remove remnants of requests from block body downloader #12426

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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 @@ -475,7 +475,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 @@ -164,8 +164,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 @@ -192,14 +191,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 @@ -253,7 +249,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 @@ -29,8 +29,8 @@ import (
"github.com/erigontech/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 @@ -39,7 +39,6 @@ type Delivery struct {
txs [][][]byte
uncles [][]*types.Header
withdrawals []types.Withdrawals
requests []types.FlatRequests
lenOfP2PMessage uint64
}

Expand Down
Loading