Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speeds up synchronisation of the blocks for the
fuel-core-sync
serv…
…ice (#1916) The change speeds up synchronisation and removes noise logs when the P2P request crashes. The synchronization speed improvement is done by: - Making all requests asynchronous. Before, the first request to fetch the blocked header was synchronous and required awaiting it because of `and_then`. - The process of block fetching is separated from block execution. Before, we fetched X blocks and waited for their execution before requesting new X blocks. The fetching is a new parallel task that uses the `batch_sender` variable for backpressure. The task fetches blocks in parallel and sends them into a channel with buffer `1`. The executor's task is to receive the batch from the channel and execute it, allowing the request for a new batch to be made in parallel. If the execution speed is faster than fetching, we request more than one batch in parallel, up to the buffer limit. Tests shows that. The change also handles cases better when a P2P request fails without a known `PeerId`. Without change, I was syncing 2M blocks for 4 hours. With this change, it takes me 20 minutes. ## Checklist - [x] New behavior is reflected in tests ### Before requesting review - [x] I have reviewed the code myself
- Loading branch information