Skip to content

Commit d1c90c4

Browse files
authored
Merge pull request #486 from input-output-hk/djo/unify_aggregator_signer_state_machine_logs
Align & enhance signer & aggregator state machines logs + aggregator http server
2 parents b2704e1 + 624731d commit d1c90c4

File tree

10 files changed

+161
-113
lines changed

10 files changed

+161
-113
lines changed

mithril-aggregator/src/http_server/routes/certificate_routes.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mod handlers {
4444
pub async fn certificate_pending(
4545
certificate_pending_store: Arc<CertificatePendingStore>,
4646
) -> Result<impl warp::Reply, Infallible> {
47-
debug!("certificate_pending");
47+
debug!("⇄ HTTP SERVER: certificate_pending");
4848

4949
match certificate_pending_store.get().await {
5050
Ok(Some(certificate_pending)) => Ok(reply::json(&certificate_pending, StatusCode::OK)),
@@ -61,7 +61,10 @@ mod handlers {
6161
certificate_hash: String,
6262
certificate_store: Arc<CertificateStore>,
6363
) -> Result<impl warp::Reply, Infallible> {
64-
debug!("certificate_certificate_hash/{}", certificate_hash);
64+
debug!(
65+
"⇄ HTTP SERVER: certificate_certificate_hash/{}",
66+
certificate_hash
67+
);
6568

6669
match certificate_store.get_from_hash(&certificate_hash).await {
6770
Ok(Some(certificate)) => Ok(reply::json(&certificate, StatusCode::OK)),

mithril-aggregator/src/http_server/routes/epoch_routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mod handlers {
3737
protocol_parameters_store: Arc<ProtocolParametersStore>,
3838
multi_signer: MultiSignerWrapper,
3939
) -> Result<impl warp::Reply, Infallible> {
40-
debug!("epoch_settings");
40+
debug!("⇄ HTTP SERVER: epoch_settings");
4141

4242
match multi_signer.read().await.get_current_beacon().await {
4343
Some(beacon) => match protocol_parameters_store

mithril-aggregator/src/http_server/routes/signatures_routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod handlers {
3434
signature: entities::SingleSignatures,
3535
multi_signer: MultiSignerWrapper,
3636
) -> Result<impl warp::Reply, Infallible> {
37-
debug!("register_signatures/{:?}", signature);
37+
debug!("⇄ HTTP SERVER: register_signatures/{:?}", signature);
3838

3939
let mut multi_signer = multi_signer.write().await;
4040
match multi_signer.register_single_signature(&signature).await {

mithril-aggregator/src/http_server/routes/signer_routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod handlers {
3535
signer: entities::Signer,
3636
multi_signer: MultiSignerWrapper,
3737
) -> Result<impl warp::Reply, Infallible> {
38-
debug!("register_signer/{:?}", signer);
38+
debug!("⇄ HTTP SERVER: register_signer/{:?}", signer);
3939

4040
let mut multi_signer = multi_signer.write().await;
4141
match key_decode_hex(&signer.verification_key) {

mithril-aggregator/src/http_server/routes/snapshot_routes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ mod handlers {
6868
pub async fn snapshots(
6969
snapshot_store: Arc<dyn SnapshotStore>,
7070
) -> Result<impl warp::Reply, Infallible> {
71-
debug!("snapshots");
71+
debug!("⇄ HTTP SERVER: snapshots");
7272

7373
match snapshot_store.list_snapshots().await {
7474
Ok(snapshots) => Ok(reply::json(&snapshots, StatusCode::OK)),
@@ -86,7 +86,7 @@ mod handlers {
8686
) -> Result<impl warp::Reply, Infallible> {
8787
let filepath = reply.path().to_path_buf();
8888
debug!(
89-
"ensure_downloaded_file_is_a_snapshot / file: `{}`",
89+
"⇄ HTTP SERVER: ensure_downloaded_file_is_a_snapshot / file: `{}`",
9090
filepath.display()
9191
);
9292

@@ -115,7 +115,7 @@ mod handlers {
115115
config: Configuration,
116116
snapshot_store: Arc<dyn SnapshotStore>,
117117
) -> Result<impl warp::Reply, Infallible> {
118-
debug!("snapshot_download/{}", digest);
118+
debug!("⇄ HTTP SERVER: snapshot_download/{}", digest);
119119

120120
match snapshot_store.get_snapshot_details(digest).await {
121121
Ok(Some(snapshot)) => {
@@ -150,7 +150,7 @@ mod handlers {
150150
digest: String,
151151
snapshot_store: Arc<dyn SnapshotStore>,
152152
) -> Result<impl warp::Reply, Infallible> {
153-
debug!("snapshot_digest/{}", digest);
153+
debug!("⇄ HTTP SERVER: snapshot_digest/{}", digest);
154154

155155
match snapshot_store.get_snapshot_details(digest).await {
156156
Ok(snapshot) => match snapshot {

mithril-aggregator/src/runtime/runner.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,30 @@ impl AggregatorRunner {
152152
impl AggregatorRunnerTrait for AggregatorRunner {
153153
/// Return the current beacon from the chain
154154
async fn get_beacon_from_chain(&self) -> Result<Beacon, RuntimeError> {
155-
info!("RUNNER: get beacon from chain");
155+
debug!("RUNNER: get beacon from chain");
156156
Ok(self
157157
.dependencies
158158
.beacon_provider
159159
.get_current_beacon()
160160
.await?)
161161
}
162162

163+
async fn does_certificate_exist_for_beacon(
164+
&self,
165+
beacon: &Beacon,
166+
) -> Result<bool, RuntimeError> {
167+
debug!("RUNNER: does_certificate_exist_for_beacon");
168+
let certificate_exist = self
169+
.dependencies
170+
.certificate_store
171+
.get_from_beacon(beacon)
172+
.await?
173+
.is_some();
174+
Ok(certificate_exist)
175+
}
176+
163177
async fn is_certificate_chain_valid(&self) -> Result<bool, RuntimeError> {
164-
info!("RUNNER: is_certificate_chain_valid");
178+
debug!("RUNNER: is_certificate_chain_valid");
165179
let certificate_store = self.dependencies.certificate_store.clone();
166180
let latest_certificates = certificate_store.get_list(1).await?;
167181
let latest_certificate = latest_certificates.first();
@@ -181,44 +195,30 @@ impl AggregatorRunnerTrait for AggregatorRunner {
181195
{
182196
Ok(()) => Ok(true),
183197
Err(error) => {
184-
warn!("Invalid certificate chain"; "error" => ?error);
198+
warn!(" > invalid certificate chain"; "error" => ?error);
185199
Ok(false)
186200
}
187201
}
188202
}
189203

190-
async fn does_certificate_exist_for_beacon(
191-
&self,
192-
beacon: &Beacon,
193-
) -> Result<bool, RuntimeError> {
194-
info!("RUNNER: does_certificate_exist_for_beacon");
195-
let certificate_exist = self
196-
.dependencies
197-
.certificate_store
198-
.get_from_beacon(beacon)
199-
.await?
200-
.is_some();
201-
Ok(certificate_exist)
202-
}
203-
204204
async fn compute_digest(&self, new_beacon: &Beacon) -> Result<String, RuntimeError> {
205-
info!("RUNNER: compute_digest");
205+
debug!("RUNNER: compute_digest");
206206
let digester = self.dependencies.digester.clone();
207207

208-
debug!("computing digest"; "db_directory" => self.config.db_directory.display());
208+
debug!(" > computing digest"; "cardano_db_directory" => self.config.db_directory.display());
209209

210-
debug!("launching digester thread");
210+
debug!(" > launching digester thread");
211211
let digest = digester
212212
.compute_digest(new_beacon)
213213
.await
214214
.map_err(|e| RuntimeError::General(e.into()))?;
215-
debug!("computed digest: {}", digest);
215+
debug!(" > computed digest: {}", digest);
216216

217217
Ok(digest)
218218
}
219219

220220
async fn update_beacon(&self, new_beacon: &Beacon) -> Result<(), RuntimeError> {
221-
info!("RUNNER: update beacon"; "beacon" => #?new_beacon);
221+
debug!("RUNNER: update beacon"; "beacon" => #?new_beacon);
222222
self.dependencies
223223
.multi_signer
224224
.write()
@@ -229,7 +229,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
229229
}
230230

231231
async fn update_stake_distribution(&self, new_beacon: &Beacon) -> Result<(), RuntimeError> {
232-
info!("RUNNER: update stake distribution"; "beacon" => #?new_beacon);
232+
debug!("RUNNER: update stake distribution"; "beacon" => #?new_beacon);
233233
let stake_distribution = self
234234
.dependencies
235235
.chain_observer
@@ -254,7 +254,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
254254
&self,
255255
new_beacon: &Beacon,
256256
) -> Result<(), RuntimeError> {
257-
info!("RUNNER: update protocol parameters"; "beacon" => #?new_beacon);
257+
debug!("RUNNER: update protocol parameters"; "beacon" => #?new_beacon);
258258
let protocol_parameters = self.dependencies.config.protocol_parameters.clone();
259259
Ok(self
260260
.dependencies
@@ -266,7 +266,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
266266
}
267267

268268
async fn update_message_in_multisigner(&self, digest: String) -> Result<(), RuntimeError> {
269-
info!("RUNNER: update message in multisigner");
269+
debug!("RUNNER: update message in multisigner");
270270
let mut multi_signer = self.dependencies.multi_signer.write().await;
271271
let mut protocol_message = ProtocolMessage::new();
272272
protocol_message.set_message_part(ProtocolMessagePartKey::SnapshotDigest, digest);
@@ -288,7 +288,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
288288
&self,
289289
beacon: Beacon,
290290
) -> Result<CertificatePending, RuntimeError> {
291-
info!("RUNNER: create new pending certificate from multisigner");
291+
debug!("RUNNER: create new pending certificate from multisigner");
292292
let multi_signer = self.dependencies.multi_signer.read().await;
293293

294294
let signers = match multi_signer.get_signers().await {
@@ -328,7 +328,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
328328
&self,
329329
pending_certificate: CertificatePending,
330330
) -> Result<(), RuntimeError> {
331-
info!("RUNNER: saving pending certificate");
331+
debug!("RUNNER: saving pending certificate");
332332

333333
self.dependencies
334334
.certificate_pending_store
@@ -338,11 +338,11 @@ impl AggregatorRunnerTrait for AggregatorRunner {
338338
}
339339

340340
async fn drop_pending_certificate(&self) -> Result<Option<CertificatePending>, RuntimeError> {
341-
info!("RUNNER: drop pending certificate");
341+
debug!("RUNNER: drop pending certificate");
342342

343343
let certificate_pending = self.dependencies.certificate_pending_store.remove().await?;
344344
if certificate_pending.is_none() {
345-
warn!("drop_pending_certificate::no certificate pending in store, did the previous loop crashed ?");
345+
warn!(" > drop_pending_certificate::no certificate pending in store, did the previous loop crashed ?");
346346
}
347347

348348
Ok(certificate_pending)
@@ -351,7 +351,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
351351
/// Is a multi-signature ready?
352352
/// Can we create a multi-signature.
353353
async fn is_multisig_created(&self) -> Result<bool, RuntimeError> {
354-
info!("RUNNER: check if we can create a multi-signature");
354+
debug!("RUNNER: check if we can create a multi-signature");
355355
let has_multisig = self
356356
.dependencies
357357
.multi_signer
@@ -362,9 +362,9 @@ impl AggregatorRunnerTrait for AggregatorRunner {
362362
.is_some();
363363

364364
if has_multisig {
365-
debug!("new MULTISIG created");
365+
debug!(" > new multi-signature created");
366366
} else {
367-
info!("no multisig created");
367+
info!(" > no multi-signature created");
368368
}
369369
Ok(has_multisig)
370370
}
@@ -373,7 +373,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
373373
&self,
374374
beacon: &Beacon,
375375
) -> Result<OngoingSnapshot, RuntimeError> {
376-
info!("RUNNER: create snapshot archive");
376+
debug!("RUNNER: create snapshot archive");
377377

378378
let snapshotter = self.dependencies.snapshotter.clone();
379379
let protocol_message = self
@@ -401,7 +401,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
401401
.await
402402
.map_err(|e| RuntimeError::General(e.into()))??;
403403

404-
debug!("snapshot created: '{:?}'", ongoing_snapshot);
404+
debug!(" > snapshot created: '{:?}'", ongoing_snapshot);
405405

406406
Ok(ongoing_snapshot)
407407
}
@@ -410,7 +410,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
410410
&self,
411411
ongoing_snapshot: &OngoingSnapshot,
412412
) -> Result<Vec<SnapshotLocation>, RuntimeError> {
413-
info!("RUNNER: upload snapshot archive");
413+
debug!("RUNNER: upload snapshot archive");
414414
let location = self
415415
.dependencies
416416
.snapshot_uploader
@@ -420,7 +420,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
420420

421421
if let Err(error) = tokio::fs::remove_file(ongoing_snapshot.get_file_path()).await {
422422
warn!(
423-
"Post upload ongoing snapshot file removal failure: {}",
423+
" > Post upload ongoing snapshot file removal failure: {}",
424424
error
425425
);
426426
}
@@ -432,7 +432,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
432432
&self,
433433
beacon: &Beacon,
434434
) -> Result<Certificate, RuntimeError> {
435-
info!("RUNNER: create and save certificate");
435+
debug!("RUNNER: create and save certificate");
436436
let certificate_store = self.dependencies.certificate_store.clone();
437437
let latest_certificates = certificate_store.get_list(2).await?;
438438
let last_certificate = latest_certificates.get(0);
@@ -480,7 +480,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
480480
ongoing_snapshot: &OngoingSnapshot,
481481
remote_locations: Vec<String>,
482482
) -> Result<Snapshot, RuntimeError> {
483-
info!("RUNNER: create and save snapshot");
483+
debug!("RUNNER: create and save snapshot");
484484
let snapshot_digest = certificate
485485
.protocol_message
486486
.get_message_part(&ProtocolMessagePartKey::SnapshotDigest)

0 commit comments

Comments
 (0)