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

Batch call for retrieving blobs from RPC #8952

Closed

Conversation

StefanBratanov
Copy link
Contributor

@StefanBratanov StefanBratanov commented Dec 21, 2024

PR Description

When we need to retrieve blobs from RPC when following the head, we do one request per a sidecar. This PR changes this functionality to do one batch call. It will save bandwith (when used) and could help with rate limiting. Ideally, this should be merged after #8927

Fixed Issue(s)

fixes #8928

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

@StefanBratanov StefanBratanov force-pushed the batch_call_blobs_rpc branch 2 times, most recently from 6d1e538 to 68fa5c2 Compare December 30, 2024 11:01
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BlobIdentifier;

public class FetchBlobSidecarTask extends AbstractFetchTask<BlobIdentifier, BlobSidecar> {
public class FetchBlobSidecarsTask extends AbstractFetchTask<Bytes32, List<BlobSidecar>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have doubts here.
In principle K type should uniquely identify a task, so I think we should have a record(blockroot, List<BlobIdentifier>).

if (allTasks.putIfAbsent(blobIdentifier, task) != null) {
final FetchBlobSidecarsTask task =
fetchTaskFactory.createFetchBlobSidecarsTask(blockRoot, requiredBlobIdentifiers);
if (allTasks.putIfAbsent(blockRoot, task) != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so here we can have problems if we change our mind and we initiate a request with a different List<blobIdentifier> for the same block root.

Copy link
Contributor

@tbenr tbenr Jan 7, 2025

Choose a reason for hiding this comment

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

we could argue that the number of blobs identifier can only decrease with time, so we don't care if we take the initial request and cancel the new one, but:

  • introduces an assumption that needs to be handled here, and it is risky (if we don't check we may cancel the task containing what we really need)
  • anyway this approach breaks the design of the abstract class IMO

so if we move to the theoretical correct key we could and up requesting the same blob(s) in two different tasks, but at least we know that we will have them all executed despite the order of arrival

Copy link
Contributor

Choose a reason for hiding this comment

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

so at the end:

option 1:

  • change the key and allow multiple request for same blockRoot (potential duplication of blobs download)
  • cancel method still based on blockRoot (looping on allTasks)

option 2:

  • leave the key as blockRoot, adding some checks when adding a task for a blockRoot already present (logging an error if this is not supposed to happen, or some logic that compares the identifier list, cancel one and leave the other)
  • cancel method remains as is

@StefanBratanov
Copy link
Contributor Author

Had an internal discussion and decided to potentially revisit this idea in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch call for blobs RPC requests
2 participants