Skip to content

Commit c9a070c

Browse files
committed
Improve fast syncing reliability
- don't crash if no receipts received in whole batch - don't crash if no peers available for chain data download
1 parent 37bcdd7 commit c9a070c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

trinity/sync/full/chain.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ async def _load_and_process_headers(self) -> None:
9494
# TODO implement the maximum task size at each step instead of this magic number
9595
max_headers = min((MAX_BODIES_FETCH, MAX_RECEIPTS_FETCH)) * 4
9696
batch_id, headers = await self.header_queue.get(max_headers)
97-
await self._process_headers(headers)
98-
self.header_queue.complete(batch_id, headers)
97+
try:
98+
await self._process_headers(headers)
99+
except NoEligiblePeers:
100+
self.logger.info(
101+
f"No available peers to sync with, retrying in {self.NO_PEER_RETRY_PAUSE}s"
102+
)
103+
self.header_queue.complete(batch_id, tuple())
104+
await self.sleep(self.NO_PEER_RETRY_PAUSE)
105+
else:
106+
self.header_queue.complete(batch_id, headers)
99107

100108
async def _calculate_td(self, headers: Tuple[BlockHeader, ...]) -> int:
101109
"""Return the score (total difficulty) of the last header in the given list.
@@ -297,6 +305,9 @@ async def _download_receipts(self,
297305
receipt_bundles = tuple(concat(all_receipt_bundles))
298306
headers = tuple(concat(all_missing_headers))
299307

308+
if len(receipt_bundles) == 0:
309+
continue
310+
300311
# process all of the returned receipts, storing their trie data
301312
# dicts in the database
302313
receipts, trie_roots_and_data_dicts = zip(*receipt_bundles)

0 commit comments

Comments
 (0)