Alpha: fix bug where seed would stay the same if no nonces were revealed
This commit is contained in:
parent
46d053fdb3
commit
c46e731031
@ -56,7 +56,8 @@ let compute_for_cycle c ~revealed cycle =
|
|||||||
Storage.Seed.Nonce.delete c level >>=? fun c ->
|
Storage.Seed.Nonce.delete c level >>=? fun c ->
|
||||||
return (c, random_seed, u :: unrevealed)
|
return (c, random_seed, u :: unrevealed)
|
||||||
in
|
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) ->
|
fold_left_s combine (c, seed, []) levels >>=? fun (c, seed, unrevealed) ->
|
||||||
Storage.Seed.For_cycle.init c cycle seed >>=? fun c ->
|
Storage.Seed.For_cycle.init c cycle seed >>=? fun c ->
|
||||||
return (c, unrevealed)
|
return (c, unrevealed)
|
||||||
@ -102,6 +103,6 @@ let cycle_end ctxt last_cycle =
|
|||||||
end >>=? fun ctxt ->
|
end >>=? fun ctxt ->
|
||||||
match Cycle_repr.pred last_cycle with
|
match Cycle_repr.pred last_cycle with
|
||||||
| None -> return (ctxt, [])
|
| None -> return (ctxt, [])
|
||||||
| Some revealed ->
|
| Some revealed -> (* cycle with revelations *)
|
||||||
let inited_seed_cycle = Cycle_repr.add last_cycle (preserved+1) in
|
let inited_seed_cycle = Cycle_repr.add last_cycle (preserved+1) in
|
||||||
compute_for_cycle ctxt ~revealed inited_seed_cycle
|
compute_for_cycle ctxt ~revealed inited_seed_cycle
|
||||||
|
@ -12,6 +12,8 @@ type error +=
|
|||||||
cycle : Cycle_repr.t ;
|
cycle : Cycle_repr.t ;
|
||||||
latest : Cycle_repr.t } (* `Permanent *)
|
latest : Cycle_repr.t } (* `Permanent *)
|
||||||
|
|
||||||
|
(** Generates the first [preserved_cycles+2] seeds for which
|
||||||
|
there are no nonces. *)
|
||||||
val init:
|
val init:
|
||||||
Raw_context.t -> Raw_context.t tzresult Lwt.t
|
Raw_context.t -> Raw_context.t tzresult Lwt.t
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user