Node: listing of invalid blocks
This commit is contained in:
parent
42e29c8f4a
commit
9f45ae9126
@ -589,6 +589,9 @@ module RPC = struct
|
|||||||
heads >>= fun (_, blocks) ->
|
heads >>= fun (_, blocks) ->
|
||||||
Lwt.return (List.rev blocks)
|
Lwt.return (List.rev blocks)
|
||||||
|
|
||||||
|
let list_invalid node =
|
||||||
|
State.Block.list_invalid (Net_validator.net_state node.mainnet_validator)
|
||||||
|
|
||||||
let block_header_watcher node =
|
let block_header_watcher node =
|
||||||
Distributed_db.watch_block_header node.distributed_db
|
Distributed_db.watch_block_header node.distributed_db
|
||||||
|
|
||||||
|
@ -64,6 +64,9 @@ module RPC : sig
|
|||||||
val list:
|
val list:
|
||||||
t -> int -> Block_hash.t list -> block_info list list Lwt.t
|
t -> int -> Block_hash.t list -> block_info list list Lwt.t
|
||||||
|
|
||||||
|
val list_invalid:
|
||||||
|
t -> (Block_hash.t * int32 * error list) list Lwt.t
|
||||||
|
|
||||||
val block_info:
|
val block_info:
|
||||||
t -> block -> block_info Lwt.t
|
t -> block -> block_info Lwt.t
|
||||||
|
|
||||||
|
@ -329,6 +329,10 @@ let list_blocks
|
|||||||
RPC.Answer.return_stream { next ; shutdown }
|
RPC.Answer.return_stream { next ; shutdown }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let list_invalid node () =
|
||||||
|
Node.RPC.list_invalid node >>= fun l ->
|
||||||
|
RPC.Answer.return l
|
||||||
|
|
||||||
let list_protocols node {Services.Protocols.monitor; contents} =
|
let list_protocols node {Services.Protocols.monitor; contents} =
|
||||||
let monitor = match monitor with None -> false | Some x -> x in
|
let monitor = match monitor with None -> false | Some x -> x in
|
||||||
let include_contents = match contents with None -> false | Some x -> x in
|
let include_contents = match contents with None -> false | Some x -> x in
|
||||||
@ -369,6 +373,8 @@ let build_rpc_directory node =
|
|||||||
let dir = RPC.empty in
|
let dir = RPC.empty in
|
||||||
let dir =
|
let dir =
|
||||||
RPC.register0 dir Services.Blocks.list (list_blocks node) in
|
RPC.register0 dir Services.Blocks.list (list_blocks node) in
|
||||||
|
let dir =
|
||||||
|
RPC.register0 dir Services.Blocks.list_invalid (list_invalid node) in
|
||||||
let dir = register_bi_dir node dir in
|
let dir = register_bi_dir node dir in
|
||||||
let dir =
|
let dir =
|
||||||
let implementation block =
|
let implementation block =
|
||||||
|
@ -406,6 +406,19 @@ module Blocks = struct
|
|||||||
~output: (obj1 (req "blocks" (list (list block_info_encoding))))
|
~output: (obj1 (req "blocks" (list (list block_info_encoding))))
|
||||||
RPC.Path.(root / "blocks")
|
RPC.Path.(root / "blocks")
|
||||||
|
|
||||||
|
let list_invalid =
|
||||||
|
RPC.service
|
||||||
|
~description:
|
||||||
|
"Lists blocks that have been declared invalid along with the errors\
|
||||||
|
that led to them being declared invalid"
|
||||||
|
~input:empty
|
||||||
|
~output:(Data_encoding.list
|
||||||
|
(obj3
|
||||||
|
(req "block" Block_hash.encoding)
|
||||||
|
(req "level" int32)
|
||||||
|
(req "errors" (Data_encoding.list error_encoding))))
|
||||||
|
RPC.Path.(root / "invalid_blocks")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Protocols = struct
|
module Protocols = struct
|
||||||
|
@ -87,6 +87,9 @@ module Blocks : sig
|
|||||||
val list:
|
val list:
|
||||||
(unit, unit, list_param, block_info list list) RPC.service
|
(unit, unit, list_param, block_info list list) RPC.service
|
||||||
|
|
||||||
|
val list_invalid:
|
||||||
|
(unit, unit, unit, (Block_hash.t * int32 * error list) list) RPC.service
|
||||||
|
|
||||||
type preapply_param = {
|
type preapply_param = {
|
||||||
timestamp: Time.t ;
|
timestamp: Time.t ;
|
||||||
proto_header: MBytes.t ;
|
proto_header: MBytes.t ;
|
||||||
|
@ -380,6 +380,12 @@ module Block = struct
|
|||||||
Shared.use net_state.block_store begin fun store ->
|
Shared.use net_state.block_store begin fun store ->
|
||||||
Store.Block.Invalid_block.read_opt store hash
|
Store.Block.Invalid_block.read_opt store hash
|
||||||
end
|
end
|
||||||
|
let list_invalid net_state =
|
||||||
|
Shared.use net_state.block_store begin fun store ->
|
||||||
|
Store.Block.Invalid_block.fold store ~init:[]
|
||||||
|
~f:(fun hash { level ; errors } acc ->
|
||||||
|
Lwt.return ((hash, level, errors) :: acc))
|
||||||
|
end
|
||||||
|
|
||||||
let known net_state hash =
|
let known net_state hash =
|
||||||
Shared.use net_state.block_store begin fun store ->
|
Shared.use net_state.block_store begin fun store ->
|
||||||
|
@ -98,6 +98,7 @@ module Block : sig
|
|||||||
val known_valid: Net.t -> Block_hash.t -> bool Lwt.t
|
val known_valid: Net.t -> Block_hash.t -> bool Lwt.t
|
||||||
val known_invalid: Net.t -> Block_hash.t -> bool Lwt.t
|
val known_invalid: Net.t -> Block_hash.t -> bool Lwt.t
|
||||||
val read_invalid: Net.t -> Block_hash.t -> Store.Block.invalid_block option Lwt.t
|
val read_invalid: Net.t -> Block_hash.t -> Store.Block.invalid_block option Lwt.t
|
||||||
|
val list_invalid: Net.t -> (Block_hash.t * int32 * error list) list Lwt.t
|
||||||
|
|
||||||
val read: Net.t -> Block_hash.t -> block tzresult Lwt.t
|
val read: Net.t -> Block_hash.t -> block tzresult Lwt.t
|
||||||
val read_opt: Net.t -> Block_hash.t -> block option Lwt.t
|
val read_opt: Net.t -> Block_hash.t -> block option Lwt.t
|
||||||
|
Loading…
Reference in New Issue
Block a user