Sync fixes (#1716)

## Issue Addressed

chain state inconsistencies

## Proposed Changes
- a batch can be fake-failed by Range if it needs to move a peer to another chain. The peer will still send blocks/ errors / produce timeouts for those  requests, so check when we get a response from the RPC that the request id matches, instead of only the peer, since a re-request can be directed to the same peer.
- if an optimistic batch succeeds, store the attempt to avoid trying it again when quickly switching chains. Also, use it only if ahead of our current target, instead of the segment's start epoch
This commit is contained in:
divma
2020-10-04 23:49:14 +00:00
committed by Paul Hauner
parent e7eb99cb5e
commit 6997776494
5 changed files with 81 additions and 70 deletions

View File

@@ -214,7 +214,7 @@ impl<T: BeaconChainTypes> RangeSync<T> {
{
// check if this chunk removes the chain
match self.chains.call_by_id(chain_id, |chain| {
chain.on_block_response(network, batch_id, peer_id, beacon_block)
chain.on_block_response(network, batch_id, &peer_id, request_id, beacon_block)
}) {
Ok((removed_chain, sync_type)) => {
if let Some(removed_chain) = removed_chain {
@@ -228,7 +228,7 @@ impl<T: BeaconChainTypes> RangeSync<T> {
}
}
} else {
warn!(self.log, "Response/Error for non registered request"; "request_id" => request_id)
debug!(self.log, "Response/Error for non registered request"; "request_id" => request_id)
}
}
@@ -337,7 +337,7 @@ impl<T: BeaconChainTypes> RangeSync<T> {
if let Some((chain_id, batch_id)) = network.blocks_by_range_response(request_id, true) {
// check that this request is pending
match self.chains.call_by_id(chain_id, |chain| {
chain.inject_error(network, batch_id, peer_id)
chain.inject_error(network, batch_id, &peer_id, request_id)
}) {
Ok((removed_chain, sync_type)) => {
if let Some(removed_chain) = removed_chain {