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

[NCC-EVJ] Use Committee stakes when determining the timestamp of a Subdag #2223

Merged
merged 9 commits into from
Jan 19, 2024

Conversation

raychu86
Copy link
Contributor

@raychu86 raychu86 commented Nov 30, 2023

Motivation

This PR updates the Subdag::timestamp function from a simple median timestamp to a weighed median timestamp that uses the committee member stakes as the weights.

Because quorum is determined by stake and not the number of validators, we must also use stake to determine the timestamp.

Audit Finding: [NCC EVJ] Timestamp Calculation Does Not Provide Byzantine Fault Tolerance

Comment on lines +87 to +90
#[cfg(not(feature = "serial"))]
timestamps_and_stake.par_sort_unstable_by_key(|(timestamp, _)| *timestamp);
#[cfg(feature = "serial")]
timestamps_and_stake.sort_unstable_by_key(|(timestamp, _)| *timestamp);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could make another one of these macros, more in line with existing code (I only know it from the algorithms crate)

timestamps[timestamps.len() / 2]
// Retrieve the timestamps and stakes of the certificates.
let timestamps_and_stakes = self
.values()
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 use the median of leader_certificate's parents or all certificates? It makes no sense to use the weighted median of all certificates.

@howardwu howardwu merged commit aa5e85e into mainnet Jan 19, 2024
@howardwu howardwu deleted the feat/weighted-median-timestamps branch January 19, 2024 01:15
@raychu86 raychu86 changed the title Use Committee stakes when determining the timestamp of a Subdag [NCC-EVJ] Use Committee stakes when determining the timestamp of a Subdag Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants