Solving issue of finalized meta after processed block (#365)

* Solving issue of finalized meta after processed block

* Fixing the broken test
This commit is contained in:
galactus 2024-03-22 12:04:46 +01:00 committed by GitHub
parent c687bf54eb
commit c09700fd79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -157,7 +157,7 @@ fn transaction_size_small() {
let rand_string = random_strings.first().unwrap();
let tx = BenchHelper::create_memo_tx_small(rand_string, &payer_keypair, blockhash);
assert_eq!(bincode::serialized_size(&tx).unwrap(), 179);
assert_eq!(bincode::serialized_size(&tx).unwrap(), 231);
}
#[test]
@ -172,5 +172,5 @@ fn transaction_size_large() {
let rand_string = random_strings.first().unwrap();
let tx = BenchHelper::create_memo_tx_large(rand_string, &payer_keypair, blockhash);
assert_eq!(bincode::serialized_size(&tx).unwrap(), 1186);
assert_eq!(bincode::serialized_size(&tx).unwrap(), 1230);
}

View File

@ -163,6 +163,7 @@ pub fn create_grpc_multiplex_blocks_subscription(
let mut cleanup_without_confirmed_recv_blocks_meta: u32 = 0;
let mut cleanup_without_finalized_recv_blocks_meta: u32 = 0;
let mut confirmed_block_not_yet_processed = HashSet::<String>::new();
let mut finalized_block_not_yet_processed = HashSet::<String>::new();
// start logging errors when we recieve first finalized block
let mut startup_completed = false;
@ -182,6 +183,11 @@ pub fn create_grpc_multiplex_blocks_subscription(
warn!("produced block channel has no receivers {e:?}");
}
}
if finalized_block_not_yet_processed.remove(&processed_block.blockhash) {
if let Err(e) = producedblock_sender.send(processed_block.to_finalized_block()) {
warn!("produced block channel has no receivers {e:?}");
}
}
recent_processed_blocks.insert(processed_block.blockhash.clone(), processed_block);
},
meta_confirmed = confirmed_blockmeta_stream.next() => {
@ -206,6 +212,7 @@ pub fn create_grpc_multiplex_blocks_subscription(
let finalized_block = cached_processed_block.to_finalized_block();
last_finalized_slot = finalized_block.slot;
startup_completed = true;
log::info!("sending finalized block");
debug!("got finalized blockmeta {} with blockhash {}",
finalized_block.slot, finalized_block.blockhash.clone());
if let Err(e) = producedblock_sender.send(finalized_block) {
@ -214,6 +221,7 @@ pub fn create_grpc_multiplex_blocks_subscription(
} else if startup_completed {
// this warning is ok for first few blocks when we start lrpc
log::warn!("finalized block meta received for blockhash {} which was never seen or already emitted", blockhash);
finalized_block_not_yet_processed.insert(blockhash);
}
},
_ = cleanup_tick.tick() => {