Alpha: fail on early revelations
We now fail when a nonce is revealed before the the expected revelation cycle.
This commit is contained in:
parent
3cb1c3c5e2
commit
74ec514fd2
@ -59,18 +59,20 @@ let () =
|
|||||||
(function Unexpected_nonce -> Some () | _ -> None)
|
(function Unexpected_nonce -> Some () | _ -> None)
|
||||||
(fun () -> Unexpected_nonce)
|
(fun () -> Unexpected_nonce)
|
||||||
|
|
||||||
|
let get_unrevealed ctxt level =
|
||||||
|
let revealed_cycle =
|
||||||
|
let cur_level = Level_storage.current ctxt in
|
||||||
match Cycle_repr.pred cur_level.cycle with
|
match Cycle_repr.pred cur_level.cycle with
|
||||||
| None -> Cycle_repr.root
|
| None -> Cycle_repr.root
|
||||||
| Some min_cycle -> min_cycle in
|
| Some min_cycle -> min_cycle in
|
||||||
fail_unless
|
if Cycle_repr.(revealed_cycle < level.Level_repr.cycle) then
|
||||||
Cycle_repr.(min_cycle <= level.Level_repr.cycle)
|
fail Too_early_revelation
|
||||||
Too_late_revelation >>=? fun () ->
|
else if Cycle_repr.(level.Level_repr.cycle < revealed_cycle) then
|
||||||
fail_unless
|
fail Too_late_revelation
|
||||||
Raw_level_repr.(level.level < cur_level.level)
|
else
|
||||||
Too_early_revelation >>=? fun () ->
|
Storage.Seed.Nonce.get ctxt level >>=? function
|
||||||
Storage.Seed.Nonce.get c level >>=? function
|
| Revealed _ -> fail Previously_revealed_nonce
|
||||||
| Revealed _ -> fail Previously_revealed_nonce
|
| Unrevealed status -> return status
|
||||||
| Unrevealed status -> return status
|
|
||||||
|
|
||||||
let record_hash ctxt unrevealed =
|
let record_hash ctxt unrevealed =
|
||||||
let level = Level_storage.current ctxt in
|
let level = Level_storage.current ctxt in
|
||||||
|
Loading…
Reference in New Issue
Block a user