Proto/tests: Tenderbrute - bruteforce seeds to obtain desired delegate selections in tests
Context
This MR removes the delegate_selection parameter of the protocol (which previously allowed to specify different strategies attributing baking rights, e.g. round-robin, in the tests of the consensus scenarios/baker) and introduces instead a new parameter initial_seed which allows to provide a seed to generate the first preserved_cycles seeds (this is only used when migrating from Genesis).
This MR also comes with a library (and binary) to bruteforce seeds to obtain a desired delegate selection. This mechanism is used in the "Mockup simulator" tests of the baker (the seeds have already been bruteforced) and will be used in Mitten as well.
Manually testing the MR
Tenderbrute binary
The following command should find an appropriate seed in about 400000 iterations (less than 6s on my machine):
dune exec src/proto_alpha/lib_delegate/test/tenderbrute/tenderbrute_main.exe -- '
[[1, [[0 , "bootstrap1"], [1 , "bootstrap2"], [2 , "bootstrap3"], [3 , "bootstrap4"]]],
[2, [[0 , "bootstrap2"], [1 , "bootstrap3"], [2 , "bootstrap4"], [3 , "bootstrap1"]]],
[3, [[0 , "bootstrap4"]]]]
'
should display rngGA5vREY5E6aonyENxCPKfNHt5GxoM517wiNxXJ2ELPVdSmASqJ.
Tenderbrute library as used in the tests of the Mockup simulator
All the tests should pass (some may be flaky, but unrelated to the delegate selection I think).
dune exec src/proto_alpha/lib_delegate/test/main.exe -- -e
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). - [NA] 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