Fix history mode switch while updating additional cycles
Context
(1) This MR aims to fix an issue occurring while trying to change the additional cycles of a node's history mode. The savepoint set was wrong as it was not considering the availability of the metadata nor the block. It was resulting in a unknown block failure for rolling nodes and a consistency failure for full nodes as the metadata of the new savepoint was missing.
(2) Additionally, this MR fixes a wrong behavior when merging the store just after a rolling snapshot import. Indeed, after a snapshot import the caboose was set to N and, at the next merge, the lowest bound of the RW was computed based on the M = lafl(head) - max_op_ttl(head). In that particular case, we were dropping blocks from N to M from the RW and the new RW was populated with blocks above M. The caboose was "lost".
Manually testing the MR
(1) Import a snapshot and immediately run the node with --history-mode:10 --force-history-mode-switch. It should now work.
(2) Import a rolling snapshot, run the node and wait the node.store: merging store up to block level xx (at Notice level), stop the node, start the node. It should end up with a missing caboose error from the consistency check (which is automatically fixed but which was quite sad).
Closes: #1720 (closed) #1760 (closed)
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment, theDevelopment Versionsection ofCHANGES.mdfor everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR