av-store: write meta for unknown finalized blocks (#6452)

* av-store: write meta for unknown finalized blocks

* fix test
This commit is contained in:
ordian
2023-01-05 18:25:21 +01:00
committed by GitHub
parent f0106b30fa
commit 45acf6e402
2 changed files with 51 additions and 2 deletions
+8
View File
@@ -570,6 +570,14 @@ async fn run_iteration<Context>(
FromOrchestra::Signal(OverseerSignal::BlockFinalized(hash, number)) => {
let _timer = subsystem.metrics.time_process_block_finalized();
if !subsystem.known_blocks.is_known(&hash) {
// If we haven't processed this block yet,
// make sure we write the metadata about the
// candidates backed in this finalized block.
// Otherwise, we won't be able to store our chunk
// for these candidates.
process_block_activated(ctx, subsystem, hash).await?;
}
subsystem.finalized_number = Some(number);
subsystem.known_blocks.prune_finalized(number);
process_block_finalized(
+43 -2
View File
@@ -732,8 +732,49 @@ fn we_dont_miss_anything_if_import_notifications_are_missed() {
let test_state = TestState::default();
test_harness(test_state.clone(), store.clone(), |mut virtual_overseer| async move {
overseer_signal(&mut virtual_overseer, OverseerSignal::BlockFinalized(Hash::zero(), 1))
.await;
let block_hash = Hash::repeat_byte(1);
overseer_signal(&mut virtual_overseer, OverseerSignal::BlockFinalized(block_hash, 1)).await;
let header = Header {
parent_hash: Hash::repeat_byte(0),
number: 1,
state_root: Hash::zero(),
extrinsics_root: Hash::zero(),
digest: Default::default(),
};
assert_matches!(
overseer_recv(&mut virtual_overseer).await,
AllMessages::ChainApi(ChainApiMessage::BlockHeader(
relay_parent,
tx,
)) => {
assert_eq!(relay_parent, block_hash);
tx.send(Ok(Some(header))).unwrap();
}
);
assert_matches!(
overseer_recv(&mut virtual_overseer).await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
relay_parent,
RuntimeApiRequest::CandidateEvents(tx),
)) => {
assert_eq!(relay_parent, block_hash);
tx.send(Ok(Vec::new())).unwrap();
}
);
assert_matches!(
overseer_recv(&mut virtual_overseer).await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
relay_parent,
RuntimeApiRequest::Validators(tx),
)) => {
assert_eq!(relay_parent, Hash::zero());
tx.send(Ok(Vec::new())).unwrap();
}
);
let header = Header {
parent_hash: Hash::repeat_byte(3),