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

Parallel gossip verification and block unblinding #4647

Closed

Conversation

michaelsproul
Copy link
Member

Issue Addressed

Closes #4473
Replaces #4643

Proposed Changes

  • Check gossip validity of blinded blocks in parallel with the request to unblind. This should ensure that the gossip duplicate check almost always completes before we receive the block on gossip from the relay.
  • Gossip verification is refactored to abstract over Payload: AbstractExecPayload<E> to enable the checking of blinded blocks.
  • Updated the V2 SSZ endpoint to use the task_spawner (a small omission caused by conflicts between several recently merged PRs).

@michaelsproul michaelsproul added ready-for-review The code is ready for review builder API v4.4.1 ETA August 2023 labels Aug 22, 2023

// Complete gossip verification and publication to the relay in parallel.
// This avoids tripping the gossip duplicate filter.
let block_to_verify = Arc::new(block.clone());
Copy link
Member Author

Choose a reason for hiding this comment

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

This clone of the blinded block is a bit unfortunate but I think unavoidable as we need an Arc block for most functions, but reconstruct_payload needs a full block. Because the block is blinded, cloning it should be quite fast!

@michaelsproul
Copy link
Member Author

I'm going to deploy this on Goerli and see if it solves the issue. If it doesn't, I'll consider added a 202 code for the duplicates as well.

task_spawner
.clone()
.spawn_async_with_rejection(Priority::P0, async move {
let block = SignedBlindedBeaconBlock::<T::EthSpec>::from_ssz_bytes(
Copy link
Member

Choose a reason for hiding this comment

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

Ah nice, the type alias is better - there's another reference in the v1 endpoint if you don't mind updating that one as well.

Comment on lines +250 to +257
let provenanced_gossip_verified_block = match full_block {
ProvenancedBlock::Local(block, phantom) => {
ProvenancedBlock::Local(gossip_verified_blinded_block.unblind(block), phantom)
}
ProvenancedBlock::Builder(block, phantom) => {
ProvenancedBlock::Builder(gossip_verified_blinded_block.unblind(block), phantom)
}
};
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be worth adding a comment on why we're passing the gossip verified block (so that it doesn't verify again after publishing block) because the code would still compile and run fine without this - just to prevent it from getting removed by accident. I wasn't familiar with gossip verification and had to navigate around to understand why we needed this.

@jimmygchen
Copy link
Member

Looks great! 👍 I only have some minor nitpicks / comments!

@michaelsproul
Copy link
Member Author

I have second thoughts about this now, because by making gossip verification succeed it means we will try to process the block twice: the one from gossip and the one from the HTTP API. This is likely to mess with the snapshot cache (only one of the blocks will get the snapshot) and wastes processing time.

I'm starting to think we should just hack the status code to a 202 and call it a day...

@michaelsproul
Copy link
Member Author

Binning this in favour of #4655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builder API ready-for-review The code is ready for review v4.4.1 ETA August 2023
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants