Skip to content

Commit b48f6e0

Browse files
committed
cleanup 🧹
1 parent b621ff9 commit b48f6e0

File tree

8 files changed

+283
-207
lines changed

8 files changed

+283
-207
lines changed

consensus/src/marshal/actor.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,13 @@ impl<
429429
let block = self.get_finalized_block(height).await;
430430
result.send(block).unwrap_or_else(|_| warn!(?height, "Failed to send block to orchestrator"));
431431
}
432-
Orchestration::Processed { height, digest } => {
432+
Orchestration::Processed { height, digest, commitment } => {
433433
// Update metrics
434434
self.processed_height.set(height as i64);
435435

436436
// Cancel any outstanding requests (by height and by digest)
437-
resolver.cancel(Request::<B>::Block(digest)).await;
437+
resolver.cancel(Request::<B>::Block(commitment)).await;
438+
resolver.cancel(Request::<B>::CodingCommitment { height, digest }).await;
438439
resolver.retain(Request::<B>::Finalized { height }.predicate()).await;
439440

440441
// If finalization exists, prune the archives
@@ -471,9 +472,9 @@ impl<
471472

472473
// Iterate backwards, repairing blocks as we go.
473474
while cursor.height() > height {
474-
let commitment = cursor.parent();
475-
let Some(commitment) = shard_layer.get_digest(&commitment).await else {
476-
dbg!("Missing block digest");
475+
let digest = cursor.parent();
476+
let Some(commitment) = shard_layer.get_commitment(&digest).await else {
477+
resolver.fetch(Request::<B>::CodingCommitment { digest, height: cursor.height().saturating_sub(1) }).await;
477478
break;
478479
};
479480

@@ -519,6 +520,14 @@ impl<
519520
};
520521
let _ = response.send(block.encode().into());
521522
}
523+
Request::CodingCommitment { digest, .. } => {
524+
// Check for coding commitment locally
525+
let Some(commitment) = shard_layer.get_commitment(&digest).await else {
526+
debug!(?digest, "coding commitment missing on request");
527+
continue;
528+
};
529+
let _ = response.send(commitment.encode().into());
530+
}
522531
Request::Finalized { height } => {
523532
// Get finalization
524533
let Some(finalization) = self.get_finalization_by_height(height).await else {
@@ -574,6 +583,24 @@ impl<
574583
debug!(?commitment, height, "received block");
575584
let _ = response.send(true);
576585
},
586+
Request::CodingCommitment { digest, height } => {
587+
// Parse block digest and height
588+
let Ok(commitment) = B::Commitment::decode_cfg(value.as_ref(), &()) else {
589+
let _ = response.send(false);
590+
continue;
591+
};
592+
593+
// Persist the commitment.
594+
shard_layer.put_commitment(height, digest, commitment).await;
595+
596+
// If we have the block, persist it and its finalization.
597+
if let Some(block) = self.find_block(&mut shard_layer, commitment).await {
598+
let finalization = self.cache.get_finalization_for(commitment).await;
599+
self.finalize(block.height(), commitment, block.clone(), finalization, &mut notifier_tx).await;
600+
}
601+
602+
let _ = response.send(true);
603+
},
577604
Request::Finalized { height } => {
578605
// Parse finalization
579606
let Ok((finalization, block)) = <(Finalization<V, B::Commitment>, B)>::decode_cfg(value, &((), self.codec_config.clone())) else {

consensus/src/marshal/envelope.rs

Lines changed: 0 additions & 177 deletions
This file was deleted.

consensus/src/marshal/finalizer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl<B: Block, R: Spawner + Clock + Metrics + Storage, Z: Reporter<Activity = B>
8181
// height is processed by the application), it is possible that the application may
8282
// be asked to process a block it has already seen (which it can simply ignore).
8383
let commitment = block.commitment();
84+
let digest = block.digest();
8485
self.application.report(block).await;
8586

8687
// Record that we have processed up through this height.
@@ -91,7 +92,9 @@ impl<B: Block, R: Spawner + Clock + Metrics + Storage, Z: Reporter<Activity = B>
9192
}
9293

9394
// Notify the orchestrator that the block has been processed.
94-
self.orchestrator.processed(height, commitment).await;
95+
self.orchestrator
96+
.processed(height, digest, commitment)
97+
.await;
9598

9699
// Loop again without waiting for a notification (there may be more to process).
97100
continue;

0 commit comments

Comments
 (0)