Shell: fix checkpoint checks in bootstrap pipeline
This commit is contained in:
parent
aa1450d8e6
commit
bba88743df
@ -39,20 +39,23 @@ let assert_acceptable_header pipeline
|
|||||||
(Time.(add time_now 15L >= header.shell.timestamp))
|
(Time.(add time_now 15L >= header.shell.timestamp))
|
||||||
(Future_block_header { block = hash; time = time_now;
|
(Future_block_header { block = hash; time = time_now;
|
||||||
block_time = header.shell.timestamp }) >>=? fun () ->
|
block_time = header.shell.timestamp }) >>=? fun () ->
|
||||||
State.Chain.checkpoint chain_state >>= fun (level, checkpoint) ->
|
State.Chain.checkpoint chain_state >>= fun (checkpoint_level, checkpoint) ->
|
||||||
fail_when
|
fail_when
|
||||||
(Int32.equal header.shell.level level &&
|
(Int32.equal header.shell.level checkpoint_level &&
|
||||||
not (Block_hash.equal checkpoint hash))
|
not (Block_hash.equal checkpoint hash))
|
||||||
(Checkpoint_error (hash, Some pipeline.peer_id)) >>=? fun () ->
|
(Checkpoint_error (hash, Some pipeline.peer_id)) >>=? fun () ->
|
||||||
Chain.head chain_state >>= fun head ->
|
Chain.head chain_state >>= fun head ->
|
||||||
let checkpoint_reached = (State.Block.header head).shell.level >= level in
|
let checkpoint_reached = (State.Block.header head).shell.level >= checkpoint_level in
|
||||||
if checkpoint_reached then
|
if checkpoint_reached then
|
||||||
(* If reached the checkpoint, every block before the checkpoint
|
(* If reached the checkpoint, every block before the checkpoint
|
||||||
must be part of the chain. *)
|
must be part of the chain. *)
|
||||||
Chain.mem chain_state hash >>= fun in_chain ->
|
if header.shell.level <= checkpoint_level then
|
||||||
fail_unless in_chain
|
Chain.mem chain_state hash >>= fun in_chain ->
|
||||||
(Checkpoint_error (hash, Some pipeline.peer_id)) >>=? fun () ->
|
fail_unless in_chain
|
||||||
return ()
|
(Checkpoint_error (hash, Some pipeline.peer_id)) >>=? fun () ->
|
||||||
|
return ()
|
||||||
|
else
|
||||||
|
return ()
|
||||||
else
|
else
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user