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: add retries to bridge gossip, with rfc network checks #1032

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

njgheorghita
Copy link
Collaborator

@njgheorghita njgheorghita commented Nov 10, 2023

What was wrong?

Bridges only made one gossip attempt, and gave up. This isn't ideal. The bridge gossip strategy has been updated to...

  • attempt a gossip
  • if no content was successfully transferred, make a rfc request
  • if content is found on the network, abort the gossip
  • if the bridge is unable to find the data on the network, wait 15 seconds and try another gossip / rfc cycle
  • repeat for a maximum of 3 times before giving up

Testing locally, I've seen all kinds of cases, which is encouraging. eg.

  • bridge successfully transfers data without retries
  • bridge unsuccessfully transfers data, but finds it on the network and aborts
  • bridge retries gossip multiple times, and makes a successful transfer on a retry
  • bridge retries gossip multiple times, but finds it on the network after a retry and aborts
  • bridge performs the gossip cycle 3 times w/ no success and aborts

How was it fixed?

Updated beacon and history bridge with the above functionality.

To-Do

@njgheorghita njgheorghita marked this pull request as ready for review November 10, 2023 15:11
@njgheorghita njgheorghita requested review from ogenev, carver, KolbyML and mrferris and removed request for ogenev and carver November 10, 2023 15:11
Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

🛥️

// don't double count an enr if multiple clients offered the same content
// to a peer
if !content_stats.offered.contains(&enr) {
content_stats.offered.push(enr);
Copy link
Member

Choose a reason for hiding this comment

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

nit: If we want the uniqueness of values, we can use HashSet instead of Vec for offered, accepted and transferred. This way, we can remove the if statement to check for existing Enr.

// if not, make rfc request to see if data is available on network
let result =
BeaconNetworkApiClient::recursive_find_content(&client, content_key.clone()).await;
if let Ok(PossibleBeaconContentValue::ContentPresent(_)) = result {
Copy link
Member

Choose a reason for hiding this comment

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

Beacon should return ContentInfo::Content (same as the history below). They have identical jsonr-rpc implementations: beacon | history.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed that the subnetwork returns the same type, but the rpc deserialization of the response are different for the two endpoints: beacon | history

@njgheorghita njgheorghita merged commit 718b1de into ethereum:master Nov 28, 2023
2 checks passed
@njgheorghita njgheorghita deleted the bridge-gossip-retry branch November 28, 2023 18:30
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