Alpha: fix bug where seed would stay the same if no nonces were revealed

This commit is contained in:
Marco Stronati 2018-06-18 16:05:07 +02:00 committed by Grégoire Henry
parent 46d053fdb3
commit c46e731031
2 changed files with 5 additions and 2 deletions

View File

@ -56,7 +56,8 @@ let compute_for_cycle c ~revealed cycle =
Storage.Seed.Nonce.delete c level >>=? fun c ->
return (c, random_seed, u :: unrevealed)
in
Storage.Seed.For_cycle.get c previous_cycle >>=? fun seed ->
Storage.Seed.For_cycle.get c previous_cycle >>=? fun prev_seed ->
let seed = Seed_repr.deterministic_seed prev_seed in
fold_left_s combine (c, seed, []) levels >>=? fun (c, seed, unrevealed) ->
Storage.Seed.For_cycle.init c cycle seed >>=? fun c ->
return (c, unrevealed)
@ -102,6 +103,6 @@ let cycle_end ctxt last_cycle =
end >>=? fun ctxt ->
match Cycle_repr.pred last_cycle with
| None -> return (ctxt, [])
| Some revealed ->
| Some revealed -> (* cycle with revelations *)
let inited_seed_cycle = Cycle_repr.add last_cycle (preserved+1) in
compute_for_cycle ctxt ~revealed inited_seed_cycle

View File

@ -12,6 +12,8 @@ type error +=
cycle : Cycle_repr.t ;
latest : Cycle_repr.t } (* `Permanent *)
(** Generates the first [preserved_cycles+2] seeds for which
there are no nonces. *)
val init:
Raw_context.t -> Raw_context.t tzresult Lwt.t