Skip to content

Commit 1853b2f

Browse files
authored
Merge pull request #1062 from input-output-hk/ensemble/991-stress-test-aggregator
Aggregator Stress Test - Phase 1
2 parents a24b47c + e0ba120 commit 1853b2f

File tree

18 files changed

+1176
-63
lines changed

18 files changed

+1176
-63
lines changed

Cargo.lock

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.3.64"
3+
version = "0.3.65"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,12 +973,12 @@ impl DependenciesBuilder {
973973
.get_current_epoch()
974974
.await
975975
.map_err(|e| DependenciesBuilderError::Initialization {
976-
message: "cannot create aggregator runner".to_string(),
976+
message: "cannot create aggregator runner: failed to retrieve current epoch."
977+
.to_string(),
977978
error: Some(e.into()),
978979
})?
979980
.ok_or(DependenciesBuilderError::Initialization {
980-
message: "cannot build aggregator runner: impossible to retrieve current epoch"
981-
.to_string(),
981+
message: "cannot build aggregator runner: no epoch returned.".to_string(),
982982
error: None,
983983
})?;
984984
let (work_epoch, epoch_to_sign, next_epoch_to_sign) = match current_epoch {

mithril-common/Cargo.toml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-common"
3-
version = "0.2.87"
3+
version = "0.2.88"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
documentation = { workspace = true }
@@ -28,13 +28,17 @@ glob = "0.3"
2828
hex = "0.4.3"
2929
http = "0.2.6"
3030
jsonschema = "0.17.0"
31-
kes-summed-ed25519 = { version = "0.2.0", features = ["serde_enabled", "sk_clone_enabled"] }
31+
kes-summed-ed25519 = { version = "0.2.0", features = [
32+
"serde_enabled",
33+
"sk_clone_enabled",
34+
] }
3235
lazy_static = "1.4.0"
3336
mockall = "0.11.0"
3437
nom = "7.1"
3538
rand-chacha-dalek-compat = { package = "rand_chacha", version = "0.2" }
3639
rand_chacha = "0.3.1"
37-
rand_core = "0.6.3"
40+
rand_core = "0.6.3"
41+
rayon = "1.7.0"
3842
semver = "1.0"
3943
serde = { version = "1.0", features = ["derive"] }
4044
serde_bytes = "0.11.7"
@@ -43,7 +47,10 @@ serde_json = "1.0"
4347
serde_with = "3.0.0"
4448
serde_yaml = "0.9.10"
4549
sha2 = "0.10.2"
46-
slog = { version = "2.7.0", features = ["max_level_trace", "release_max_level_debug"] }
50+
slog = { version = "2.7.0", features = [
51+
"max_level_trace",
52+
"release_max_level_debug",
53+
] }
4754
slog-scope = "4.4.0"
4855
sqlite = { version = "0.31.0", features = ["bundled"] }
4956
strum = "0.25.0"
@@ -60,7 +67,9 @@ mithril-stm = { path = "../mithril-stm" }
6067

6168
[target.'cfg(windows)'.dependencies]
6269
# Windows doesn't support rug backend, fallback to num-integer
63-
mithril-stm = { path = "../mithril-stm", default-features = false, features = ["num-integer-backend"] }
70+
mithril-stm = { path = "../mithril-stm", default-features = false, features = [
71+
"num-integer-backend",
72+
] }
6473

6574
[dev-dependencies]
6675
criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] }
@@ -76,5 +85,7 @@ serde_yaml = "0.9.10"
7685

7786
[features]
7887
default = []
79-
portable = ["mithril-stm/portable"] # portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
88+
portable = [
89+
"mithril-stm/portable",
90+
] # portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
8091
allow_skip_signer_certification = []

mithril-common/src/crypto_helper/cardano/opcert.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ impl OpCert {
117117
.map_err(|_| OpCertError::PoolAddressEncoding)
118118
}
119119

120+
/// Compute protocol party id as hash
121+
pub fn compute_protocol_party_id_as_hash(&self) -> String {
122+
let mut hasher = Blake2b::<U28>::new();
123+
hasher.update(self.cold_vk.as_bytes());
124+
hex::encode(hasher.finalize())
125+
}
126+
120127
/// Compute the hash of an OpCert
121128
pub fn compute_hash(&self) -> String {
122129
let mut hasher = Sha256::new();
@@ -207,5 +214,11 @@ mod tests {
207214
"pool1mxyec46067n3querj9cxkk0g0zlag93pf3ya9vuyr3wgkq2e6t7".to_string(),
208215
party_id
209216
);
217+
218+
let party_id_as_hash = operational_certificate.compute_protocol_party_id_as_hash();
219+
assert_eq!(
220+
"d9899c574fd7a710732391706b59e878bfd416214c49d2b3841c5c8b".to_string(),
221+
party_id_as_hash
222+
);
210223
}
211224
}

mithril-common/src/digesters/dummy_immutable_db_builder.rs

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ pub struct DummyImmutableDb {
2424
pub non_immutables_files: Vec<PathBuf>,
2525
}
2626

27+
impl DummyImmutableDb {
28+
/// Add an immutable chunk file and its primary & secondary to the dummy DB.
29+
pub fn add_immutable_file(&mut self) -> ImmutableFileNumber {
30+
let new_file_number = self.last_immutable_number().unwrap_or(0) + 1;
31+
let mut new_files = write_immutable_trio(None, &self.dir, new_file_number);
32+
33+
self.immutables_files.append(&mut new_files);
34+
35+
new_file_number
36+
}
37+
38+
/// Return the file number of the last immutable
39+
pub fn last_immutable_number(&self) -> Option<ImmutableFileNumber> {
40+
self.immutables_files.last().map(|f| f.number)
41+
}
42+
}
43+
2744
impl DummyImmutablesDbBuilder {
2845
/// [DummyImmutablesDbBuilder] factory, will create a folder with the given `dirname` in the
2946
/// system temp directory, if it exists already it will be cleaned.
@@ -73,21 +90,25 @@ impl DummyImmutablesDbBuilder {
7390
immutable_numbers.sort();
7491

7592
if self.append_uncompleted_trio {
76-
self.write_immutable_trio(match immutable_numbers.last() {
77-
None => 0,
78-
Some(last) => last + 1,
79-
});
93+
write_immutable_trio(
94+
self.file_size,
95+
&self.dir,
96+
match immutable_numbers.last() {
97+
None => 0,
98+
Some(last) => last + 1,
99+
},
100+
);
80101
}
81102

82103
for non_immutable in &self.non_immutables_to_write {
83-
non_immutables_files.push(self.write_dummy_file(non_immutable));
104+
non_immutables_files.push(write_dummy_file(self.file_size, &self.dir, non_immutable));
84105
}
85106

86107
DummyImmutableDb {
87108
dir: self.dir.clone(),
88109
immutables_files: immutable_numbers
89110
.into_iter()
90-
.flat_map(|ifn| self.write_immutable_trio(ifn))
111+
.flat_map(|ifn| write_immutable_trio(self.file_size, &self.dir, ifn))
91112
.collect::<Vec<_>>(),
92113
non_immutables_files,
93114
}
@@ -108,37 +129,41 @@ impl DummyImmutablesDbBuilder {
108129

109130
parent_dir
110131
}
132+
}
111133

112-
fn write_immutable_trio(&self, immutable: ImmutableFileNumber) -> Vec<ImmutableFile> {
113-
let mut result = vec![];
114-
for filename in [
115-
format!("{immutable:05}.chunk"),
116-
format!("{immutable:05}.primary"),
117-
format!("{immutable:05}.secondary"),
118-
] {
119-
let file = self.write_dummy_file(&filename);
120-
result.push(ImmutableFile {
121-
number: immutable.to_owned(),
122-
path: file,
123-
filename: filename.to_string(),
124-
});
125-
}
126-
result
134+
fn write_immutable_trio(
135+
optional_size: Option<u64>,
136+
dir: &Path,
137+
immutable: ImmutableFileNumber,
138+
) -> Vec<ImmutableFile> {
139+
let mut result = vec![];
140+
for filename in [
141+
format!("{immutable:05}.chunk"),
142+
format!("{immutable:05}.primary"),
143+
format!("{immutable:05}.secondary"),
144+
] {
145+
let file = write_dummy_file(optional_size, dir, &filename);
146+
result.push(ImmutableFile {
147+
number: immutable.to_owned(),
148+
path: file,
149+
filename: filename.to_string(),
150+
});
127151
}
152+
result
153+
}
128154

129-
/// Create a file with the given name in the given dir, write some text to it, and then
130-
/// return its path.
131-
fn write_dummy_file(&self, filename: &str) -> PathBuf {
132-
let file = self.dir.join(Path::new(filename));
133-
let mut source_file = File::create(&file).unwrap();
134-
135-
write!(source_file, "This is a test file named '{filename}'").unwrap();
155+
/// Create a file with the given name in the given dir, write some text to it, and then
156+
/// return its path.
157+
fn write_dummy_file(optional_size: Option<u64>, dir: &Path, filename: &str) -> PathBuf {
158+
let file = dir.join(Path::new(filename));
159+
let mut source_file = File::create(&file).unwrap();
136160

137-
if let Some(file_size) = self.file_size {
138-
writeln!(source_file).unwrap();
139-
source_file.set_len(file_size).unwrap();
140-
}
161+
write!(source_file, "This is a test file named '{filename}'").unwrap();
141162

142-
file
163+
if let Some(file_size) = optional_size {
164+
writeln!(source_file).unwrap();
165+
source_file.set_len(file_size).unwrap();
143166
}
167+
168+
file
144169
}

mithril-common/src/entities/mithril_stake_distribution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod tests {
7070

7171
use super::*;
7272

73-
const EXPECTED_HASH: &str = "093b4b8044c9b0f33ed678ac34096f4d5071768c8804bf98e9f239af0bbbfeeb";
73+
const EXPECTED_HASH: &str = "47675a6fad57040b194655b103bc0439ff9d6920a7ba86bd53756db7ce2952f5";
7474

7575
#[test]
7676
fn test_compute_hash() {

mithril-common/src/test_utils/fixture_builder.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,13 @@ impl MithrilFixtureBuilder {
151151
party_index: usize,
152152
kes_key_seed: &mut [u8],
153153
) -> PartyId {
154-
let cold_key_seed: Vec<u8> = self
155-
.party_id_seed
154+
let mut cold_key_seed: Vec<u8> = (party_index)
155+
.to_le_bytes()
156156
.iter()
157-
.copied()
158-
.map(|s| {
159-
s.saturating_mul(self.number_of_signers as u8)
160-
.saturating_add(party_index as u8)
161-
})
157+
.zip(self.party_id_seed)
158+
.map(|(v1, v2)| v1 + v2)
162159
.collect();
160+
cold_key_seed.resize(32, 0);
163161
let keypair =
164162
ColdKeyGenerator::create_deterministic_keypair(cold_key_seed.try_into().unwrap());
165163
let mut dummy_buffer = [0u8; Sum6Kes::SIZE + 4];

0 commit comments

Comments
 (0)