Skip to content

Commit

Permalink
[consensus] Switch to certified vote scoring & incrementally score su…
Browse files Browse the repository at this point in the history
…bdags (MystenLabs#18806)

After analyzing the results of our Leader Scoring Strategy
experimentation. We will be switching from a Vote scoring strategy to a
Certified Vote Scoring Strategy. This has shown improvements of about
~90ms for P50 latency with 6K mixed TPS in private-testnet. We can see
that this scoring strategy gives us the best distribution of scores, as
scores are distributed together across major geographic regions which
improves our quorum latency.

As part of this change we also moved to an incremental scoring process
with a new struct called ScoringSubdag that keeps track of the votes for
leaders and relevant stake for eventual reputation score calculation.

Also removed the ReputationScoreCalculator & LeaderScoringStrategy
components as we are now finalizing on the scoring strategy we will be
using.

Full experiment results :
https://www.notion.so/mystenlabs/Leader-Scoring-Strategy-f11bbbd1055e453f9f0f5490544941ed?pvs=4

## Testing
- [x] unit tests & simtests
- [ ] run certified vote v2 & v3 with incremental scoring in
private-testnet and finalize on one
- [ ] run upgrade test from vote scoring to certified vote scoring
  • Loading branch information
arun-koshy authored Sep 9, 2024
1 parent 00e2d71 commit 072fcfb
Show file tree
Hide file tree
Showing 13 changed files with 1,527 additions and 534 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ overflow-checks = true
opt-level = 1

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(msim)', 'cfg(fail_points)'] }
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(msim)',
'cfg(fail_points)',
] }

# Dependencies that should be kept in sync through the whole workspace
[workspace.dependencies]
Expand Down Expand Up @@ -347,7 +350,12 @@ http-body = "1"
humantime = "2.1.0"
hyper = "1"
hyper-util = "0.1.6"
hyper-rustls = { version = "0.27", default-features = false, features = ["webpki-roots", "http2", "ring", "tls12"] }
hyper-rustls = { version = "0.27", default-features = false, features = [
"webpki-roots",
"http2",
"ring",
"tls12",
] }
im = "15"
impl-trait-for-tuples = "0.2.0"
indexmap = { version = "2.1.0", features = ["serde"] }
Expand Down Expand Up @@ -408,7 +416,7 @@ proptest-derive = "0.3.0"
prost = "0.13"
prost-build = "0.13"
protobuf = { version = "2.28", features = ["with-bytes"] }
quinn-proto = "0.11.6"
quinn-proto = "0.11.7"
quote = "1.0.23"
rand = "0.8.5"
rayon = "1.5.3"
Expand All @@ -431,7 +439,11 @@ rusoto_kms = { version = "0.48.0", default-features = false, features = [
russh = "0.38.0"
russh-keys = "0.38.0"
rust-version = "1.56.1"
rustls = { version = "0.23", default-features = false, features = ["std", "tls12", "ring"] }
rustls = { version = "0.23", default-features = false, features = [
"std",
"tls12",
"ring",
] }
rustls-pemfile = "2"
rustversion = "1.0.9"
rustyline = "9.1.2"
Expand Down Expand Up @@ -472,7 +484,10 @@ thiserror = "1.0.40"
tiny-bip39 = "1.0.0"
tokio = "1.36.0"
tokio-retry = "0.3"
tokio-rustls = { version = "0.26", default-features = false, features = ["tls12", "ring"] }
tokio-rustls = { version = "0.26", default-features = false, features = [
"tls12",
"ring",
] }
tokio-stream = { version = "0.1.14", features = ["sync", "net"] }
tokio-util = "0.7.10"
toml = { version = "0.7.4", features = ["preserve_order"] }
Expand Down Expand Up @@ -558,7 +573,9 @@ move-analyzer = { path = "external-crates/move/crates/move-analyzer" }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "5f2c63266a065996d53f98156f0412782b468597" }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "5f2c63266a065996d53f98156f0412782b468597" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "5f2c63266a065996d53f98156f0412782b468597", package = "fastcrypto-zkp" }
fastcrypto-vdf = { git = "https://github.com/MystenLabs/fastcrypto", rev = "5f2c63266a065996d53f98156f0412782b468597", features = ["experimental"] }
fastcrypto-vdf = { git = "https://github.com/MystenLabs/fastcrypto", rev = "5f2c63266a065996d53f98156f0412782b468597", features = [
"experimental",
] }
passkey-types = { version = "0.2.0" }
passkey-client = { version = "0.2.0" }
passkey-authenticator = { version = "0.2.0" }
Expand All @@ -572,7 +589,11 @@ anemo-cli = { git = "https://github.com/mystenlabs/anemo.git", rev = "e609f7697e
anemo-tower = { git = "https://github.com/mystenlabs/anemo.git", rev = "e609f7697ed6169bf0760882a0b6c032a57e4f3b" }

# core-types with json format for REST api
sui-sdk2 = { package = "sui-sdk", git = "https://github.com/mystenlabs/sui-rust-sdk.git", rev = "bd233b6879b917fb95e17f21927c198e7a60c924", features = ["hash", "serde", "schemars"] }
sui-sdk2 = { package = "sui-sdk", git = "https://github.com/mystenlabs/sui-rust-sdk.git", rev = "bd233b6879b917fb95e17f21927c198e7a60c924", features = [
"hash",
"serde",
"schemars",
] }

### Workspace Members ###
anemo-benchmark = { path = "crates/anemo-benchmark" }
Expand Down
34 changes: 32 additions & 2 deletions consensus/core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,22 @@ impl CommitRange {
self.0.end.saturating_sub(1)
}

pub(crate) fn extend_to(&mut self, other: CommitIndex) {
let new_end = other.saturating_add(1);
assert!(self.0.end <= new_end);
self.0 = self.0.start..new_end;
}

pub(crate) fn size(&self) -> usize {
self.0
.end
.checked_sub(self.0.start)
.expect("Range should never have end < start") as usize
}

/// Check whether the two ranges have the same size.
pub(crate) fn is_equal_size(&self, other: &Self) -> bool {
self.0.end.wrapping_sub(self.0.start) == other.0.end.wrapping_sub(other.0.start)
self.size() == other.size()
}

/// Check if the provided range is sequentially after this range.
Expand Down Expand Up @@ -669,15 +682,21 @@ mod tests {
#[tokio::test]
async fn test_commit_range() {
telemetry_subscribers::init_for_testing();
let range1 = CommitRange::new(1..=5);
let mut range1 = CommitRange::new(1..=5);
let range2 = CommitRange::new(2..=6);
let range3 = CommitRange::new(5..=10);
let range4 = CommitRange::new(6..=10);
let range5 = CommitRange::new(6..=9);
let range6 = CommitRange::new(1..=1);

assert_eq!(range1.start(), 1);
assert_eq!(range1.end(), 5);

// Test range size
assert_eq!(range1.size(), 5);
assert_eq!(range3.size(), 6);
assert_eq!(range6.size(), 1);

// Test next range check
assert!(!range1.is_next_range(&range2));
assert!(!range1.is_next_range(&range3));
Expand All @@ -695,5 +714,16 @@ mod tests {
assert!(range2 < range3);
assert!(range3 < range4);
assert!(range5 < range4);

// Test extending range
range1.extend_to(10);
assert_eq!(range1.start(), 1);
assert_eq!(range1.end(), 10);
assert_eq!(range1.size(), 10);

range1.extend_to(20);
assert_eq!(range1.start(), 1);
assert_eq!(range1.end(), 20);
assert_eq!(range1.size(), 20);
}
}
Loading

0 comments on commit 072fcfb

Please sign in to comment.