avalanchego icon indicating copy to clipboard operation
avalanchego copied to clipboard

Cold bootstrap seems unnecessarily slow

Open ssg opened this issue 3 years ago • 1 comments

Describe the improvement Cold bootstrap takes a long time (hours) with Avalanche which makes recovery scenarios quite risky for validator nodes due to high uptime requirements.

Avalanchego shouldn't need to retrieve all blocks for a chain before executing state transitions. Executing state transitions as soon as the first set of blocks are received would make cold bootstrap times almost twice as fast as I understand from my own observation (on a low-end hardware).

Similarly, a new chain could be immediately fetched while state transitions are executed for the previous chain. Currently, it looks like this:

thread 1: [.....fetch P......][.......execute P.....][..........fetch X........][.......execute X]

This should be possible instead:

thread 1: [.....fetch P......][..........fetch X........]
thread 2:  [.......execute P.....]
thread 3:                      [.......execute X]

Obviously, this would increase the CPU-load of an Avalanche node during bootstrap, but I believe cut-down bootstrap times can easily make up for it.

Operating System Linux 3.10.108 x86_64 Braswell

By submitting this issue I agree to the Terms and Conditions of the Developer Accelerator Program.

ssg avatar Jan 23 '22 20:01 ssg

The P-chain must have actually finished bootstrapping before all other chains start fetching. This is because we use the P-chain's validator sets to initialize bootstrapping of the other chains. This is because other chains may not be validated by the nodes bootstrapping the P-chain (We could make a special case for the primary subnet here, but I'm not a super big fan of that tbh).

As for executing at the same time as fetching, currently blocks are actually fetched towards genesis, not from genesis to tip. There are some optimizations in the pipeline to improve this flow though :)

StephenButtolph avatar Feb 09 '22 00:02 StephenButtolph