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

dataColumnsByRange: Sort data columns by index. #14542

Merged
merged 1 commit into from
Oct 16, 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
14 changes: 8 additions & 6 deletions beacon-chain/sync/rpc_data_column_sidecars_by_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sync

import (
"context"
"slices"
"time"

libp2pcore "github.com/libp2p/go-libp2p/core"
Expand All @@ -19,7 +20,7 @@ import (
"github.com/sirupsen/logrus"
)

func (s *Service) streamDataColumnBatch(ctx context.Context, batch blockBatch, wQuota uint64, wantedDataColumnIndices map[uint64]bool, stream libp2pcore.Stream) (uint64, error) {
func (s *Service) streamDataColumnBatch(ctx context.Context, batch blockBatch, wQuota uint64, wantedDataColumnIndices []uint64, stream libp2pcore.Stream) (uint64, error) {
_, span := trace.StartSpan(ctx, "sync.streamDataColumnBatch")
defer span.End()

Expand All @@ -40,7 +41,7 @@ func (s *Service) streamDataColumnBatch(ctx context.Context, batch blockBatch, w
return wQuota, errors.Wrapf(err, "could not retrieve data columns indice for block root %#x", blockRoot)
}

for dataColumnIndex := range wantedDataColumnIndices {
for _, dataColumnIndex := range wantedDataColumnIndices {
isDataColumnStored := storedDataColumnsIndices[dataColumnIndex]

// Skip if the data column is not stored.
Expand Down Expand Up @@ -157,10 +158,11 @@ func (s *Service) dataColumnSidecarsByRangeRPCHandler(ctx context.Context, msg i
}

// Derive the wanted columns for the request.
wantedColumns := make(map[uint64]bool, len(r.Columns))
for _, c := range r.Columns {
wantedColumns[c] = true
}
wantedColumns := make([]uint64, len(r.Columns))
copy(wantedColumns, r.Columns)

// Sort the wanted columns.
slices.Sort[[]uint64](wantedColumns)

var batch blockBatch
wQuota := params.BeaconConfig().MaxRequestDataColumnSidecars
Expand Down
Loading