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

Handle sync lookup request streams in network context #5583

Merged
merged 8 commits into from
Apr 22, 2024

Conversation

dapplion
Copy link
Collaborator

Issue Addressed

Part of

Currently the sync lookup request states deal with tracking streams, retries and their own sync logic (parent chains, etc). The complexities of streams can be abstracted up into the network context to simplify downstream code.

This abstraction would have avoided the previous month bug regarding ExtraBlocks

Proposed Changes

Adopt the same accumulator pattern used today for range blocks + blobs for lookup requests. Allow to merge error handling into the same codepath and remove the concept of response validation from the RequestState trait.

In draft to wait for #5563

@dapplion dapplion force-pushed the handle-sync-lookup-requests branch from 38d21f0 to 2ef22b3 Compare April 15, 2024 15:26
realbigsean and others added 2 commits April 16, 2024 13:58
@dapplion dapplion marked this pull request as ready for review April 16, 2024 05:27
@realbigsean realbigsean added the ready-for-review The code is ready for review label Apr 16, 2024
@jimmygchen jimmygchen self-assigned this Apr 17, 2024
@realbigsean realbigsean added under-review A reviewer has only partially completed a review. and removed ready-for-review The code is ready for review labels Apr 17, 2024
Copy link
Member

@realbigsean realbigsean left a comment

Choose a reason for hiding this comment

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

Already finding this much easier to follow!


let blocks = self.add_child_block_to_chain(chain_hash, blocks, cx).into();

let process_id = ChainSegmentProcessId::ParentLookup(chain_hash);
Copy link
Member

Choose a reason for hiding this comment

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

Is the ordering change here meant to drop the child lookup when the beacon processor is not available? makes sense

Copy link
Member

Choose a reason for hiding this comment

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

no change requested

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The change is motivated by the borrow checker, but as you say the change also makes sense to drop the lookup completely on that case

beacon_node/network/src/sync/block_lookups/mod.rs Outdated Show resolved Hide resolved
beacon_node/network/src/sync/network_context.rs Outdated Show resolved Hide resolved
beacon_node/network/src/sync/block_lookups/mod.rs Outdated Show resolved Hide resolved
beacon_node/network/src/sync/network_context.rs Outdated Show resolved Hide resolved
beacon_node/network/src/sync/network_context.rs Outdated Show resolved Hide resolved
@realbigsean realbigsean added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed under-review A reviewer has only partially completed a review. labels Apr 17, 2024
}
}
}
RpcEvent::StreamTermination => match request.remove().terminate() {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to handle the scenario where a peer doesn't send stream termination? (ActiveBlocksByRootRequest stored is quite small in size though)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Current sync codebase expects the stream termination to always appear when syncing or doing blob lookups. The API contract with network's ReqResp behaviour is that you always get either an error or stream termination. There are timeouts in place in case the peer leaves the stream open and doesn't send the termination.

dapplion added a commit to dapplion/lighthouse that referenced this pull request Apr 22, 2024
@dapplion dapplion mentioned this pull request Apr 22, 2024
* add bad state warn log

* add rust docs to new fields in `SyncNetworkContext`

* remove timestamp todo

* add back lookup verify error

* remove TODOs
Copy link
Member

@realbigsean realbigsean left a comment

Choose a reason for hiding this comment

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

woop woop

@realbigsean realbigsean added ready-for-merge This PR is ready to merge. and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Apr 22, 2024
@realbigsean
Copy link
Member

@mergify queue

Copy link

mergify bot commented Apr 22, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at f7aca97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants