Skip to content

Conversation

@nalepae
Copy link
Contributor

@nalepae nalepae commented Jun 23, 2025

What type of PR is this?
Feature

What does this PR do? Why is it needed?

  • Implement SendDataColumnSidecarsByRangeRequest
  • Implement SendDataColumnSidecarsByRootRequest

Other notes for review
Depending on:

Acknowledgements

Base automatically changed from peerdas-various to develop June 23, 2025 15:12
@nalepae nalepae force-pushed the peerdas-send-data-columns-requests branch from caf659b to f86d723 Compare June 23, 2025 23:01
@nalepae nalepae changed the title Implement SendDataColumnSidecarsByRangeRequest. Implement SendDataColumnSidecarsByRangeRequest and `SendDataColumnSidecarsByRootRequest. Jun 23, 2025
@nalepae nalepae force-pushed the peerdas-send-data-columns-requests branch from f86d723 to 4d97894 Compare June 23, 2025 23:06
@nalepae nalepae marked this pull request as ready for review June 23, 2025 23:15
@nalepae nalepae changed the title Implement SendDataColumnSidecarsByRangeRequest and `SendDataColumnSidecarsByRootRequest. Implement SendDataColumnSidecarsByRangeRequest and SendDataColumnSidecarsByRootRequest. Jun 23, 2025
func isSidecarIndexRootRequested(request *p2ptypes.DataColumnsByRootIdentifiers) DataColumnResponseValidation {
columnsIndexFromRoot := make(map[[fieldparams.RootLength]byte]map[uint64]bool)

for _, sidecar := range *request {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is doing range *request safe? first time seeing someone do this in our codebase, surprised it's a pointer to an array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2fa137f.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix of the fix in d534a41.

// Read the data column sidecars from the stream.
roDataColumns := make([]blocks.RODataColumn, 0, totalCount)
for range totalCount {
roDataColumn, err := readChunkedDataColumnSidecar(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does readChunkedDataColumnSidecar handle context.Done()? if not it might be a good idea to handle it in stalled cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not. But yes it is a good idea not to loop if the context is canceled.
Fixed in 00cf5f9.


// Check if we do not request too many sidecars.
columnsCount := uint64(len(request.Columns))
totalCount := request.Count * columnsCount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it ever matters to do overflow checks on these numbers from request

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. If it starts to overflow, we'll have other bigger issues...

// isSidecarSlotWithinBounds verifies that the slot of the data column sidecar is within the bounds of the request.
func isSidecarSlotWithinBounds(request *ethpb.DataColumnSidecarsByRangeRequest) DataColumnResponseValidation {
// endSlot is exclusive (while request.StartSlot is inclusive).
endSlot := request.StartSlot + primitives.Slot(request.Count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another spot that could overflow? ( not sure if it matters, don't think we check for this elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b79b4fb.

func isSidecarIndexRequested(request *ethpb.DataColumnSidecarsByRangeRequest) DataColumnResponseValidation {
requestedIndices := make(map[uint64]bool)
for _, col := range request.Columns {
requestedIndices[col] = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there are duplicate columns requested?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they pass silently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's not an issue. Duplicates are ignored.

}

for _, column := range sidecar.Columns {
columnsIndexFromRoot[blockRoot][column] = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think duplicates silently pass again here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, duplicates are ignored.
If the peer asks twice for the same sidecar, we will only respond once.

}

// All requested sidecars were delivered by the peer. Expecting EOF.
if _, err := readChunkedDataColumnSidecar(stream, p2pApi, ctxMap); !errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is possibly brittle, if the peer leaves the stream open i think this will hang.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the peer is oversending what about just closing the stream when we think it's done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is possibly brittle, if the peer leaves the stream open i think this will hang.

Actually not, it will timeout if nothing is received after TTFB_TIMEOUT (default: 5 seconds).

if the peer is oversending what about just closing the stream when we think it's done?

Doing so is against the specification:

The response MUST contain no more than count * NUMBER_OF_COLUMNS data column sidecars.

@nalepae nalepae enabled auto-merge June 24, 2025 21:25
@nalepae nalepae added this pull request to the merge queue Jun 24, 2025
Merged via the queue into develop with commit 121914d Jun 24, 2025
15 checks passed
@nalepae nalepae deleted the peerdas-send-data-columns-requests branch June 24, 2025 21:46
fernantho pushed a commit to fernantho/prysm that referenced this pull request Sep 26, 2025
…idecarsByRootRequest`. (OffchainLabs#15430)

* Implement `SendDataColumnSidecarsByRangeRequest` and `SendDataColumnSidecarsByRootRequest`.

* Fix James's comment.

* Fix James's comment.

* Fix James' comment.

* Fix marshaller.
fernantho pushed a commit to fernantho/prysm that referenced this pull request Sep 26, 2025
…idecarsByRootRequest`. (OffchainLabs#15430)

* Implement `SendDataColumnSidecarsByRangeRequest` and `SendDataColumnSidecarsByRootRequest`.

* Fix James's comment.

* Fix James's comment.

* Fix James' comment.

* Fix marshaller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants