Fix bug in SimpleSync queue.
It was not completing partials with bodies.
This commit is contained in:
parent
5cc2fdd3d4
commit
c99a742aae
@ -113,13 +113,6 @@ impl ImportQueue {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the index of the first new root in the list of block roots.
|
||||
pub fn first_new_root(&mut self, roots: &[BlockRootSlot]) -> Option<usize> {
|
||||
roots
|
||||
.iter()
|
||||
.position(|brs| self.is_new_block(&brs.block_root))
|
||||
}
|
||||
|
||||
/// Adds the `block_roots` to the partials queue.
|
||||
///
|
||||
/// If a `block_root` is not in the queue and has not been processed by the chain it is added
|
||||
@ -203,8 +196,17 @@ impl ImportQueue {
|
||||
.iter()
|
||||
.position(|p| p.block_root == block_root)
|
||||
{
|
||||
// Case 1: there already exists a partial with a matching block root.
|
||||
//
|
||||
// The `inserted` time is set to now and the header is replaced, regardless of whether
|
||||
// it existed or not.
|
||||
self.partials[i].header = Some(header);
|
||||
self.partials[i].inserted = Instant::now();
|
||||
} else {
|
||||
// Case 2: there was no partial with a matching block root.
|
||||
//
|
||||
// A new partial is added. This case permits adding a header without already known the
|
||||
// root -- this is not possible in the wire protocol however we support it anyway.
|
||||
self.partials.push(PartialBeaconBlock {
|
||||
slot: header.slot,
|
||||
block_root,
|
||||
|
@ -374,7 +374,9 @@ impl SimpleSync {
|
||||
return;
|
||||
}
|
||||
|
||||
let new_roots = self.import_queue.enqueue_block_roots(&res.roots, peer_id.clone());
|
||||
let new_roots = self
|
||||
.import_queue
|
||||
.enqueue_block_roots(&res.roots, peer_id.clone());
|
||||
|
||||
// No new roots means nothing to do.
|
||||
//
|
||||
|
@ -543,7 +543,7 @@ fn sync_two_nodes() {
|
||||
// A provides block bodies to B.
|
||||
node_a.tee_block_body_response(&node_b);
|
||||
|
||||
std::thread::sleep(Duration::from_secs(10));
|
||||
std::thread::sleep(Duration::from_secs(20));
|
||||
|
||||
node_b.harness.run_fork_choice();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user