input-output-hk / jormungandr

privacy voting blockchain node
https://input-output-hk.github.io/jormungandr/
Apache License 2.0
365 stars 132 forks source link

partially received netboot stream should be kept in the blockchain state #1830

Open vincenthz opened 4 years ago

vincenthz commented 4 years ago

it seems that we don't update any storage state, so cancelling a partial netboot, seems to restart everything

eugene-babichenko commented 4 years ago

Currently we only update the main tag in storage so it gets lost if bootstrap is interrupted. I pushed https://github.com/input-output-hk/jormungandr/pull/1940/commits/a0907b523b419e900e6768bd6508d5c642c373e2 to address this issue but I'm not sure if this is exactly what you wanted.

If you meant shutting down the node in the midst of bootstrap, then we need to handle SIGINT and tell the bootstrap process to stop in some way. Probably by using channels or something like that.

eugene-babichenko commented 4 years ago

So, I tried 3 different approaches for that:

  1. Just update the tip for each new block. about 30% slower than what we have now.
  2. Catch SIGINT, update the tip and shutdown. No performance drop, works perfectly fine, but the code is a disaster.
  3. Update tip every n blocks. Looks like a good trade-off. Can be implemented by adding a few lines of code to bootstrap_from_stream. If we update tip on every 50-th or 100-th block we miss a reasonable number of block on interruption. At the same time no significant performance drop was observed.