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

Body downloader structure #630

Merged
merged 20 commits into from
Apr 19, 2022
Merged

Body downloader structure #630

merged 20 commits into from
Apr 19, 2022

Conversation

mriccobene
Copy link
Member

@mriccobene mriccobene commented Apr 6, 2022

This PR introduces changes in the structure of the header downloader and adds the structure of the body downloader.

The following diagram depicts the overall architecture:
architecture

The old header downloader is splitted in two classes:

  • HeadersStage: it governs the header downloading process and save headers on the db using the read-write tx received from the stage-loop; it has forward() and unwind_to() methods
  • BlockDownloader: it receive messages (new headers, requested headers, request for headers, ...) from remote peers and messages from the HeadersStage; it process messages (using the "command pattern") acting on HeaderChain

In the same manner the body downloader is divided in two classes:

  • BodiesStage: it governs the body downloading process and save bodies on the db using the read-write tx received from the stage-loop; it has forward() and unwind_to() methods
  • BlockDownloader: it receive messages (new bodies, requested bodies, request for bodies, ...) from remote peers and messages from the BodiesStage and acts on BodySequence

Two classes have the responsibility to implement headers and body downloading algorithms: HeaderChain and BodySequence. They are members of BlockDownloader whose responsibility is to receive messages and process them. Incoming messages (from remote peers) carry informations to HeaderChain and BodySequence (for example: hash announcemens, headers, bodies, ...). Also outgoing messages request information to HeaderChain and BodySequence (for example: new header or bodies needed) and send it to remote peers. Internal messages are a way for the objects in different thread to communicate.

Threading model:

  • stage classes run in the same thread of the stage-loop
  • BlockDownloader runs in its own thread and uses message-passing as communication mechanism with the other threads
  • SentryClient runs in its own thread

@mriccobene mriccobene changed the title Body downloader structure [WIP] Body downloader structure Apr 7, 2022
@codecov
Copy link

codecov bot commented Apr 7, 2022

Codecov Report

Merging #630 (71a24a4) into master (f2a7a59) will decrease coverage by 0.02%.
The diff coverage is 63.79%.

@@            Coverage Diff             @@
##           master     #630      +/-   ##
==========================================
- Coverage   82.16%   82.13%   -0.03%     
==========================================
  Files         173      173              
  Lines       14425    14424       -1     
==========================================
- Hits        11852    11847       -5     
- Misses       2573     2577       +4     
Impacted Files Coverage Δ
...ilkworm/downloader/packets/block_bodies_packet.hpp 0.00% <ø> (ø)
...lkworm/downloader/packets/block_headers_packet.hpp 0.00% <ø> (ø)
...orm/downloader/packets/get_block_bodies_packet.hpp 0.00% <ø> (ø)
...rm/downloader/packets/get_block_headers_packet.hpp 0.00% <ø> (ø)
...ode/silkworm/downloader/packets/hash_or_number.hpp 63.15% <ø> (ø)
...orm/downloader/packets/new_block_hashes_packet.hpp 0.00% <ø> (ø)
...e/silkworm/downloader/packets/new_block_packet.hpp 0.00% <ø> (ø)
node/silkworm/downloader/packets/rlp_decoding.cpp 64.21% <ø> (ø)
node/silkworm/downloader/packets/rlp_encoding.cpp 96.87% <ø> (ø)
...orm/downloader/packets/rlp_eth66_packet_coding.hpp 80.48% <ø> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2a7a59...71a24a4. Read the comment docs.

@mriccobene mriccobene requested a review from canepat April 8, 2022 10:14
@mriccobene mriccobene changed the title [WIP] Body downloader structure Body downloader structure Apr 8, 2022
@mriccobene mriccobene marked this pull request as ready for review April 8, 2022 10:15
@mriccobene mriccobene requested a review from yperbasis April 8, 2022 10:22
@canepat canepat merged commit d8260f2 into master Apr 19, 2022
@canepat canepat deleted the body_downloader_structure branch April 19, 2022 15:23
@mriccobene mriccobene mentioned this pull request Apr 19, 2022
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.

2 participants