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

Reject duplicate sidecars in BlobSidecarsByRoot #7658

Merged
merged 8 commits into from
Mar 15, 2024

Conversation

jtraglia
Copy link
Contributor

@jtraglia jtraglia commented Nov 3, 2023

PR Description

After sending a BlobSidecarsByRoot request to a peer, it would be possible for the peer to send the same blob sidecar multiple times. Not necessarily a problem, but I think it would be a good idea to disallow this. We expect peers to send unique sidecars like they're supposed to.

I was initially concerned with this function because I thought it would be possible to send the same sidecar forever. This isn't possible though because Eth2OutgoingRequestHandler handles this properly. Nice.

if (chunksReceived > maximumResponseChunks) {
throw new ExtraDataAppendedException();
}

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.

Copy link
Contributor

@zilm13 zilm13 left a comment

Choose a reason for hiding this comment

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

LGTM

@zilm13
Copy link
Contributor

zilm13 commented Nov 6, 2023

Nice catch!
I was also thinking on checking the order, but decided it's too paranoid for now. And it's a bit complicated while delivering low value because we allow gaps in the response.

@tbenr
Copy link
Contributor

tbenr commented Nov 6, 2023

not super super about synchronization though

@jtraglia
Copy link
Contributor Author

jtraglia commented Nov 6, 2023

@zilm13: I was also thinking on checking the order, but decided it's too paranoid for now.

I also had this thought. I checked the specs and didn't see anything about ordering. I can imagine a situation where a peer returns the sidecars in a different order due to some optimizations or something.

@tbenr: not super super about synchronization though

Yeah I agree. Is there a better way to do this?

@tbenr
Copy link
Contributor

tbenr commented Nov 6, 2023

Since AsyncResponseProcessor is designed to run the response processing strictly one by one, we can avoid synchronization and just have a thread safe Set that can be used by different threads (threads can still change from one chunk to the other). I pushed a commit. WDYT @zilm13 @jtraglia ?

@jtraglia
Copy link
Contributor Author

jtraglia commented Nov 6, 2023

I think that looks good! But maybe we do need to check order after all. Chatting with colleagues some about it and it seems that it does matter. Checking order might simplify this too, as we wouldn't need to delete entries.

@jtraglia
Copy link
Contributor Author

jtraglia commented Nov 6, 2023

Made a PR to the consensus specs to bring this up:

@zilm13
Copy link
Contributor

zilm13 commented Nov 6, 2023

Ok let's freeze it for a while (until spec resolution) and we could do order check without any synchronization. volatile Optional<> previous could be enough

@rolfyone
Copy link
Contributor

rolfyone commented Dec 5, 2023

@StefanBratanov are we circling back on this one?

@StefanBratanov
Copy link
Contributor

@StefanBratanov are we circling back on this one?

There is a spec PR ethereum/consensus-specs#3544 that we would like to be closed/merged, before circling back on this one, so will leave this PR open for now.

@zilm13
Copy link
Contributor

zilm13 commented Dec 5, 2023

Btw I've checked our code and if we get a response in a wrong order we will fail on import because for BlobSidecars it could mean that you request [b0s0,b0s1,b0s2] and receive [b0s2, b0s0, b0s1]. So if MUST is not added to the spec, we need to add sorting somewhere.

@jtraglia
Copy link
Contributor Author

I've pulled in changes from master & addressed Stefan's review comments. If the team is still interested in merging this PR, it should be ready now. If not, happy to close it. I don't think we're going to make this change in the consensus-specs.

@StefanBratanov
Copy link
Contributor

Hi @jtraglia rejection of duplicates makes sense to me and I think it's a good one. @tbenr @zilm13 what's your take?

@zilm13
Copy link
Contributor

zilm13 commented Mar 14, 2024

It's better than nothing as otherwise we will add it twice here

private void processBlobSidecar(final BlobSidecar blobSidecar) {
blobSidecarsBySlotToImport
.computeIfAbsent(blobSidecar.getSlotAndBlockRoot(), __ -> new ArrayList<>())
.add(blobSidecar);
}

But I'm also concerning on this #7658 (comment) though we could address it separately

@zilm13
Copy link
Contributor

zilm13 commented Mar 14, 2024

By spec we cannot require what we really want, so we should do it in our HistoricalBatchFetcher instead, but I'm thinking on something like this, which is more or less up to the spec and looks like covering all needed validations
What do you think @StefanBratanov @jtraglia zilm13@7b140b7

Or we shouldn't require the same order?
If we cannot require the same order, existing PR by @jtraglia is good

@zilm13
Copy link
Contributor

zilm13 commented Mar 14, 2024

okay, I've reread your discussion in consensus-specs, looks like there is no consensus about the order, so I'm happy to merge this one PR
We just need extra sorting in HistoricalBatchFetcher, we cannot put all our needs in the spec.  Actually I see there is an area of possible improvements in the fetcher, so we will do it in some separate PR

Copy link
Contributor

@tbenr tbenr left a comment

Choose a reason for hiding this comment

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

LGTM

@tbenr tbenr enabled auto-merge (squash) March 15, 2024 09:56
@tbenr tbenr merged commit bec05a3 into Consensys:master Mar 15, 2024
15 of 16 checks passed
@jtraglia jtraglia deleted the duplicate-sidecars branch March 15, 2024 12:37
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.

5 participants