Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[develop] Support simplified data reporting in node status service #15241

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ let setup_daemon logger =
and node_error_url =
flag "--node-error-url" ~aliases:[ "node-error-url" ] (optional string)
~doc:"URL of the node error collection service"
and simplified_node_stats =
flag "--simplified-node-stats"
~aliases:[ "simplified-node-stats" ]
no_arg ~doc:"whether to report simplified node stats (default: false)"
and contact_info =
flag "--contact-info" ~aliases:[ "contact-info" ] (optional string)
~doc:
Expand Down Expand Up @@ -1415,7 +1419,8 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ;
~start_filtered_logs ~upload_blocks_to_gcloud
~block_reward_threshold ~uptime_url ~uptime_submitter_keypair
~uptime_send_node_commit ~stop_time ~node_status_url
~graphql_control_port:itn_graphql_port () )
~graphql_control_port:itn_graphql_port ~simplified_node_stats
() )
in
{ mina
; client_trustlist
Expand Down
1 change: 1 addition & 0 deletions src/lib/mina_lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type t =
; upload_blocks_to_gcloud : bool
; block_reward_threshold : Currency.Amount.t option [@default None]
; node_status_url : string option [@default None]
; simplified_node_stats : bool [@default false]
; uptime_url : Uri.t option [@default None]
; uptime_submitter_keypair : Keypair.t option [@default None]
; uptime_send_node_commit : bool [@default false]
Expand Down
36 changes: 27 additions & 9 deletions src/lib/mina_lib/mina_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1327,15 +1327,33 @@ let start t =
let () =
match t.config.node_status_url with
| Some node_status_url ->
Node_status_service.start ~logger:t.config.logger ~node_status_url
~network:t.components.net
~transition_frontier:t.components.transition_frontier
~sync_status:t.sync_status ~chain_id:t.config.chain_id
~addrs_and_ports:t.config.gossip_net_params.addrs_and_ports
~start_time:t.config.start_time
~slot_duration:
(Block_time.Span.to_time_span
t.config.precomputed_values.consensus_constants.slot_duration_ms )
if t.config.simplified_node_stats then
let block_producer_public_key_base58 =
Option.map ~f:(fun (_, pk) ->
Public_key.Compressed.to_base58_check pk )
@@ Keypair.And_compressed_pk.Set.choose
t.config.block_production_keypairs
in
Node_status_service.start_simplified ~logger:t.config.logger
~node_status_url ~network:t.components.net
~chain_id:t.config.chain_id
~addrs_and_ports:t.config.gossip_net_params.addrs_and_ports
~slot_duration:
(Block_time.Span.to_time_span
t.config.precomputed_values.consensus_constants
.slot_duration_ms )
~block_producer_public_key_base58
else
Node_status_service.start ~logger:t.config.logger ~node_status_url
~network:t.components.net
~transition_frontier:t.components.transition_frontier
~sync_status:t.sync_status ~chain_id:t.config.chain_id
~addrs_and_ports:t.config.gossip_net_params.addrs_and_ports
~start_time:t.config.start_time
~slot_duration:
(Block_time.Span.to_time_span
t.config.precomputed_values.consensus_constants
.slot_duration_ms )
| None ->
()
in
Expand Down
44 changes: 42 additions & 2 deletions src/lib/node_status_service/node_status_service.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,22 @@ type node_status_data =
}
[@@deriving to_yojson]

let send_node_status_data ~logger ~url node_status_data =
module Simplified = struct
type t =
{ max_observed_block_height : int
; commit_hash : string
; git_branch : string
; chain_id : string
; peer_id : string
; peer_count : int
; timestamp : string
; block_producer_public_key : string option
}
[@@deriving to_yojson]
end

let send_node_status_data (type data) ~logger ~url (node_status_data : data)
(node_status_data_to_yojson : data -> Yojson.Safe.t) =
let node_status_json = node_status_data_to_yojson node_status_data in
let json = `Assoc [ ("data", node_status_json) ] in
let headers =
Expand Down Expand Up @@ -398,9 +413,34 @@ let start ~logger ~node_status_url ~transition_frontier ~sync_status ~chain_id
reset_gauges () ;
send_node_status_data ~logger
~url:(Uri.of_string node_status_url)
node_status_data
node_status_data node_status_data_to_yojson
| Error e ->
[%log info]
~metadata:[ ("error", `String (Error.to_string_hum e)) ]
"Failed to get bandwidth info from libp2p" ;
Deferred.unit )

let start_simplified ~logger ~node_status_url ~chain_id ~network
~addrs_and_ports ~slot_duration ~block_producer_public_key_base58 =
[%log info] "Starting simplified node status service using URL $url"
~metadata:[ ("url", `String node_status_url) ] ;
let five_slots = Time.Span.scale slot_duration 5. in
every ~start:(after five_slots) ~continue_on_error:true five_slots
@@ fun () ->
don't_wait_for
@@ let%bind peers = Mina_networking.peers network in
let node_status_data =
{ Simplified.max_observed_block_height =
!Mina_metrics.Transition_frontier.max_blocklength_observed
; commit_hash = Mina_version.commit_id
; git_branch = Mina_version.branch
; chain_id
; peer_id = (Node_addrs_and_ports.to_peer_exn addrs_and_ports).peer_id
; peer_count = List.length peers
; timestamp = Rfc3339_time.get_rfc3339_time ()
; block_producer_public_key = block_producer_public_key_base58
}
in
send_node_status_data ~logger
~url:(Uri.of_string node_status_url)
node_status_data Simplified.to_yojson