Bug fixes and improvements for VDF daemon
Context
This MR fixes the following bugs in the VDF daemon:
- The function checking whether a new cycle has started only checked if the current cycle is the immediate successor of the previously known cycle. This was discovered while running it on testnets with different constants which can make the VDF computation take more than 1 full cycle, but shouldn't affect mainnet.
- The current cycle was computed using the current level and
blocks_per_cycle, instead of usinglevel_infodirectly. This resulted in the wrong cycle number being computed.
It includes other changes to the VDF daemon:
- Changing the verbosity of VDF internal events from
DebugtoNotice. Emitting an extra event at the end of a cycle if a VDF computation has not been submitted for that cycle (e.g., if the VDF daemon was started too late in the cycle). Recovery from this state for the following cycles is now also tested in Tezt. - Adding an extra check once a VDF has been computed: before injection, verify that the VDF setup used to derive it is still the VDF setup for the current cycle. Should that not be the case, a new
Invalidstate is reached in the state machine, skipping the current cycle. Reaching this state would indicate a bug, such as the one fixed by this MR. - Retrying to compute the VDF if the
provefunction from the external library throws an error. - Stopping the stream of blocks before starting the VDF computation instead of after
Manually testing the MR
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Victor Dumitrescu