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

fix: fetch tipsets in a single request #5071

Merged
merged 7 commits into from
Dec 11, 2024
Merged

Conversation

lemmih
Copy link
Contributor

@lemmih lemmih commented Dec 10, 2024

Summary of changes

Changes introduced in this pull request:

  • Tipset messages were being fetched individually and from the general swarm. This PR changes the logic to fetch the messages as a single request directed to the owner of the tipset. This fixes an issue where we couldn't fetch the messages fast enough, and Forest would slowly fall out of sync.

Reference issue to close (if applicable)

Closes #5032

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@lemmih lemmih marked this pull request as ready for review December 11, 2024 06:59
@lemmih lemmih requested a review from a team as a code owner December 11, 2024 06:59
@lemmih lemmih requested review from LesnyRumcajs and sudo-shashank and removed request for a team December 11, 2024 06:59
@lemmih
Copy link
Contributor Author

lemmih commented Dec 11, 2024

I will do a patch release once this is reviewed and merged.

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

I'd love if our leading P2P expert could pronounce if we're not missing anything here. @hanabi1224

let tipset = Self::get_full_tipset(
network.clone(),
chain_store.clone(),
source,
Copy link
Contributor

Choose a reason for hiding this comment

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

In the previous logic, bitswap reqeusts are sent to all connected peers, should we fallback to non-source peers if it fails here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, if a peer tells us about a new block without having it themselves, we should ignore it.

Copy link
Contributor

@hanabi1224 hanabi1224 Dec 11, 2024

Choose a reason for hiding this comment

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

Oh wait, as I understand, in gossipsub source could be a proxy peer that does not actually own the block

Copy link
Contributor

@hanabi1224 hanabi1224 Dec 11, 2024

Choose a reason for hiding this comment

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

https://docs.rs/libp2p-gossipsub/latest/libp2p_gossipsub/enum.Event.html#variants

propagation_source: PeerId
The peer that forwarded us this message.

if let gossipsub::Event::Message {
        propagation_source: source,
        message,
        message_id: _,
    } = e
    {
        let topic = message.topic.as_str();
        let message = message.data;
        trace!("Got a Gossip Message from {:?}", source);
        if topic == pubsub_block_str {
            match from_slice_with_fallback::<GossipBlock>(&message) {
                Ok(b) => {
                    emit_event(
                        network_sender_out,
                        NetworkEvent::PubsubMessage {
                            source,
                            message: PubsubMessage::Block(b),
                        },
                    )
                    .await;
                }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Fixed" by broadcasting the chain_exchange request. Eventually, all of this code needs to be reworked.

@lemmih lemmih enabled auto-merge December 11, 2024 09:24
@lemmih lemmih added this pull request to the merge queue Dec 11, 2024
Merged via the queue into main with commit 713ce91 Dec 11, 2024
34 of 35 checks passed
@lemmih lemmih deleted the lemmih/faster-p2p-syncing branch December 11, 2024 09:52
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.

Forest slow sync on Mainnet network
3 participants