From 2aeba212a7f9b7321e3352d32058a07a4bc18043 Mon Sep 17 00:00:00 2001 From: Pierre Chambart Date: Wed, 13 Jun 2018 22:56:48 +0200 Subject: [PATCH] Shell: Quick and dirty allowance of time shift The right solution being to wait for the messages to be valid. --- src/lib_shell/bootstrap_pipeline.ml | 2 +- src/lib_shell/distributed_db.ml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib_shell/bootstrap_pipeline.ml b/src/lib_shell/bootstrap_pipeline.ml index 323f8b3d5..021e8f44e 100644 --- a/src/lib_shell/bootstrap_pipeline.ml +++ b/src/lib_shell/bootstrap_pipeline.ml @@ -35,7 +35,7 @@ let assert_acceptable_header pipeline ?(first = false) hash (header : Block_header.t) = let chain_state = Distributed_db.chain_state pipeline.chain_db in fail_unless - (Time.(now () >= header.shell.timestamp)) + (Time.(add (now ()) 15L >= header.shell.timestamp)) (Future_block_header hash) >>=? fun () -> State.Chain.checkpoint chain_state >>= fun (level, checkpoint) -> fail_when diff --git a/src/lib_shell/distributed_db.ml b/src/lib_shell/distributed_db.ml index d77eea659..eff7551ec 100644 --- a/src/lib_shell/distributed_db.ml +++ b/src/lib_shell/distributed_db.ml @@ -494,7 +494,7 @@ module P2p_reader = struct (* TODO Kick *) P2p.greylist_peer global_db.p2p state.gid ; Lwt.return_unit - end else if Time.(now () < head.shell.timestamp) then begin + end else if Time.(add (now ()) 15L < head.shell.timestamp) then begin (* TODO some penalty *) lwt_log_notice "Received future block %a from peer %a." Block_hash.pp_short (Block_header.hash head) @@ -545,7 +545,7 @@ module P2p_reader = struct (* TODO Kick *) P2p.greylist_peer global_db.p2p state.gid ; Lwt.return_unit - end else if Time.(now () < header.shell.timestamp) then begin + end else if Time.(add (now ()) 15L < header.shell.timestamp) then begin (* TODO some penalty *) lwt_log_notice "Received future block %a from peer %a." Block_hash.pp_short head