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

[node] Log less gossip #1780

Merged
merged 6 commits into from
May 5, 2022
Merged

[node] Log less gossip #1780

merged 6 commits into from
May 5, 2022

Conversation

gdanezis
Copy link
Collaborator

@gdanezis gdanezis commented May 4, 2022

The PR implements a mechanism for the active authority to keep track of failed peers and connections, as well as retries, and to slow down connecting to others when a quorum of nodes is not yet live, as when the network starts.

@gdanezis gdanezis added this to the TestNet milestone May 4, 2022
@@ -68,4 +70,26 @@ impl Committee {
// then (N + 2) / 3 = f + 1 + k/3 = f + 1
(self.total_votes + 2) / 3
}

/// Given a sequence of (AuthorityName, value) for values that are ordered, provide the
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Given a sequence of (AuthorityName, value) for values that are ordered, provide the
/// Given a sequence of (AuthorityName, value) for values, provide the


/// Given a sequence of (AuthorityName, value) for values that are ordered, provide the
/// value at the particular threshold by stake. This orders all provided values and pick
/// the appropriate value that has under it threshold stake. You may use the function
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably needs more explanation on the semantics of robust_value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added quite a bit more

/// Given a sequence of (AuthorityName, value) for values that are ordered, provide the
/// value at the particular threshold by stake. This orders all provided values and pick
/// the appropriate value that has under it threshold stake. You may use the function
/// `quorum_threshold` or `validity_threshold` to pick the f+1 or 2f+1 thresholds
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// `quorum_threshold` or `validity_threshold` to pick the f+1 or 2f+1 thresholds
/// `quorum_threshold` or `validity_threshold` to pick the 2f+1 or f+1 thresholds

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops.


let vec: Vec<_> = items
.map(|(a, v)| (v, self.voting_rights[a.borrow()], *a.borrow()))
.sorted()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we sort in descending order? What would be the difference between ascending and descending?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It really depends on the semantics of the value and what you need from the robust value. I have added more explanation on the function doc.

let vec: Vec<_> = items
.map(|(a, v)| (v, self.voting_rights[a.borrow()], *a.borrow()))
.sorted()
.collect();
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to call collect since we will be iterating


// Only try to connect 20 times, after that re-assess whether
// there are enough people to connect to.
if k > 20 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make 20 a constant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually added a proper check here instead of a hack: now we check if we already have used 2/3 stake in terms of who we follow, and exit the loop if we do. And wait for someone to be unfollowed to look again.

@gdanezis
Copy link
Collaborator Author

gdanezis commented May 4, 2022

Many thanks for the review @lxfind -- as ever super thorough! Going in to make changes.

@@ -41,46 +41,89 @@ pub async fn gossip_process<A>(active_authority: &ActiveAuthority<A>, degree: us
where
A: AuthorityAPI + Send + Sync + 'static + Clone,
{
// A copy of the committee
let committee = &active_authority.net.committee;

// Number of tasks at most "degree" and no more than committee - 1
let target_num_tasks: usize = usize::min(
active_authority.state.committee.voting_rights.len() - 1,
degree,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am concerned about capping the gossip peers at 4. If the number of gossip peers is too small, then we may form partitioned graphs and messages may not get synced across the network. How about we always choose this as a function of the total peer size?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If all peers were to have equal stake, then picking k*Log(N) for a small k should do the trick. However our peers have unequal stake, and we sample them accordingly, so we will need to work out the maths on the basis of stake to set this.

@lavindir lavindir self-requested a review May 4, 2022 21:39
@gdanezis
Copy link
Collaborator Author

gdanezis commented May 5, 2022

Thanks everyone for the comments + review!

@gdanezis gdanezis merged commit 52589f1 into main May 5, 2022
@gdanezis gdanezis deleted the log-less-gossip branch May 5, 2022 08:50
longbowlu pushed a commit that referenced this pull request May 12, 2022
* Implement backoff for gossip

Co-authored-by: George Danezis <george@danez.is>
punwai pushed a commit that referenced this pull request Jul 27, 2022
* Implement backoff for gossip

Co-authored-by: George Danezis <george@danez.is>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants