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

feat: implement BeaconBlocksByRoot libp2p handler #471

Merged
merged 57 commits into from
Jan 16, 2024

Conversation

h3lio5
Copy link
Contributor

@h3lio5 h3lio5 commented Nov 29, 2023

Motivation

Implements the BeaconBlocksByRoot p2p handler.

Closes #446

@h3lio5 h3lio5 requested a review from a team as a code owner November 29, 2023 06:35
Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

LGTM. We should add the request to the list on LambdaEthereumConsensus.P2P.IncomingRequests.Receiver, so peers can use it.

MegaRedHand
MegaRedHand previously approved these changes Nov 30, 2023
Copy link
Collaborator

@mpaulucci mpaulucci left a comment

Choose a reason for hiding this comment

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

Could you add a "unit" test that makes an interaction between this function and https://github.com/lambdaclass/lambda_ethereum_consensus/blob/main/lib/lambda_ethereum_consensus/p2p/block_downloader.ex#L84 ?

You could patch Libp2pPort.send_request and make that one call the function you implemented. And then you could also patch Libp2pPort.send_response(message_id, response_chunk).

See: https://hexdocs.pm/patch/readme.html

@mpaulucci
Copy link
Collaborator

@h3lio5 is it clear what's being asked? We can have a call if not clear

test/unit/p2p_blocks_test.exs Outdated Show resolved Hide resolved
test/unit/p2p_blocks_test.exs Outdated Show resolved Hide resolved
BlockStore.store_block(signed_block_input)

# ssz serialize and snappy compress the block root
with {:ok, ssz_serialized} <- Ssz.to_ssz(BeaconBlocksByRootRequest{body: [block_root]}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
with {:ok, ssz_serialized} <- Ssz.to_ssz(BeaconBlocksByRootRequest{body: [block_root]}),
with {:ok, ssz_serialized} <- Ssz.to_ssz(%BeaconBlocksByRootRequest{body: [block_root]}),

alias LambdaEthereumConsensus.Store.Db

setup do
expose(Handler, :all)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to expose the Handler functions anymore.

@MegaRedHand
Copy link
Collaborator

You need to add the new types to the schema_match macro

Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

As talked in the daily, we should split this into two PRs: one with the new feature, and another with the tests

Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

Summarizing what's left to do in this PR:

  • remove test/unit/p2p_blocks_test.exs (it should be re-added in another PR)
  • merge main
  • address comments

Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
mpaulucci and others added 19 commits January 5, 2024 18:34
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
)

Co-authored-by: Martin Paulucci <martin.paulucci@lambdaclass.com>
Co-authored-by: Martin Paulucci <mpaulucci@Martins-MacBook-Pro.local>
lib/types/p2p/beacon_blocks_ by_root_request.ex Outdated Show resolved Hide resolved
lib/types/p2p/beacon_blocks_by_root_response.ex Outdated Show resolved Hide resolved
lib/types/p2p/beacon_blocks_ by_root_request.ex Outdated Show resolved Hide resolved
lib/types/p2p/beacon_blocks_by_root_response.ex Outdated Show resolved Hide resolved
native/ssz_nif/src/elx_types/p2p.rs Outdated Show resolved Hide resolved
native/ssz_nif/src/elx_types/p2p.rs Outdated Show resolved Hide resolved
@MegaRedHand
Copy link
Collaborator

Lints are failing. Could you run make fmt and push the changes?

@MegaRedHand MegaRedHand merged commit a14b387 into lambdaclass:main Jan 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Implement beacon_blocks_by_root/2 incoming request
7 participants