mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
av-store: write meta for unknown finalized blocks (#6452)
* av-store: write meta for unknown finalized blocks * fix test
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user