Shell: Time error printing with more details
This commit is contained in:
parent
2aeba212a7
commit
a7ef80fa34
@ -34,9 +34,11 @@ type t = {
|
||||
let assert_acceptable_header pipeline
|
||||
?(first = false) hash (header : Block_header.t) =
|
||||
let chain_state = Distributed_db.chain_state pipeline.chain_db in
|
||||
let time_now = Time.now () in
|
||||
fail_unless
|
||||
(Time.(add (now ()) 15L >= header.shell.timestamp))
|
||||
(Future_block_header hash) >>=? fun () ->
|
||||
(Time.(add time_now 15L >= header.shell.timestamp))
|
||||
(Future_block_header { block = hash; time = time_now;
|
||||
block_time = header.shell.timestamp }) >>=? fun () ->
|
||||
State.Chain.checkpoint chain_state >>= fun (level, checkpoint) ->
|
||||
fail_when
|
||||
(Int32.equal header.shell.level level &&
|
||||
@ -122,9 +124,12 @@ let headers_fetch_worker_loop pipeline =
|
||||
P2p_peer.Id.pp_short pipeline.peer_id >>= fun () ->
|
||||
Lwt_canceler.cancel pipeline.canceler >>= fun () ->
|
||||
Lwt.return_unit
|
||||
| Error [ Future_block_header bh ] ->
|
||||
lwt_log_notice "Block locator %a from peer %a contains future blocks."
|
||||
Block_hash.pp_short bh
|
||||
| Error [ Future_block_header { block; block_time; time } ] ->
|
||||
lwt_log_notice "Block locator %a from peer %a contains future blocks. \
|
||||
local time: %a, block time: %a"
|
||||
Block_hash.pp_short block
|
||||
Time.pp_hum time
|
||||
Time.pp_hum block_time
|
||||
P2p_peer.Id.pp_short pipeline.peer_id >>= fun () ->
|
||||
Lwt_canceler.cancel pipeline.canceler >>= fun () ->
|
||||
Lwt.return_unit
|
||||
|
@ -12,7 +12,7 @@
|
||||
type error += Parse_error
|
||||
type error += Too_many_operations
|
||||
type error += Oversized_operation of { size: int ; max: int }
|
||||
type error += Future_block_header of Block_hash.t
|
||||
type error += Future_block_header of { block: Block_hash.t ; block_time : Time.t ; time : Time.t }
|
||||
|
||||
let () =
|
||||
(* Parse error *)
|
||||
@ -50,7 +50,22 @@ let () =
|
||||
(req "size" int31)
|
||||
(req "max_size" int31))
|
||||
(function Oversized_operation { size ; max } -> Some (size, max) | _ -> None)
|
||||
(fun (size, max) -> Oversized_operation { size ; max })
|
||||
(fun (size, max) -> Oversized_operation { size ; max }) ;
|
||||
(* Block from the future *)
|
||||
register_error_kind
|
||||
`Temporary
|
||||
~id:"node.prevalidation.future_block_header"
|
||||
~title:"Future block header"
|
||||
~description:"The block was annotated with a time too far in the future."
|
||||
~pp:(fun ppf (block, block_time, time) ->
|
||||
Format.fprintf ppf "Future block header (block: %a, block_time: %a, time: %a)"
|
||||
Block_hash.pp block Time.pp_hum block_time Time.pp_hum time)
|
||||
Data_encoding.(obj3
|
||||
(req "block" Block_hash.encoding)
|
||||
(req "block_time" Time.encoding)
|
||||
(req "time" Time.encoding))
|
||||
(function Future_block_header { block ; block_time ; time } -> Some (block, block_time, time) | _ -> None)
|
||||
(fun (block, block_time, time) -> Future_block_header { block ; block_time ; time })
|
||||
|
||||
|
||||
(************************* State errors ***********************************)
|
||||
|
@ -12,7 +12,7 @@
|
||||
type error += Parse_error
|
||||
type error += Too_many_operations
|
||||
type error += Oversized_operation of { size: int ; max: int }
|
||||
type error += Future_block_header of Block_hash.t
|
||||
type error += Future_block_header of { block: Block_hash.t ; block_time : Time.t ; time : Time.t }
|
||||
|
||||
(************************* State errors ***********************************)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user