From 5d16cc1c1b45efb16190dccc470377a5aab23695 Mon Sep 17 00:00:00 2001 From: Eugen Zalinescu Date: Wed, 27 Nov 2024 20:34:23 +0100 Subject: [PATCH 1/2] DAL/Node: add warning when get_attestable_slots for a future level --- src/bin_dal_node/RPC_server.ml | 35 +++++++++++++++++++++++++++++++--- src/bin_dal_node/event.ml | 14 +++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index b8acc7b12cc3..c7452d336591 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -341,6 +341,34 @@ module Profile_handlers = struct in Lwt.return_unit + let warn_if_lagging store ~attestation_level = + let open Lwt_result_syntax in + let*! last_processed_level = + Store.Last_processed_level.load store.Store.last_processed_level + in + match last_processed_level with + | Ok (Some lpl) -> + (* The L1 node's level is at least [current_level = lpl + 2], because the + DAL node processes blocks with a delay of two levels, to be sure that + processed blocks are final. *) + let current_level = Int32.add lpl 2l in + (* The baker's current level is the same as its L1 node and is the one + of the latest seen proposal (ie block). The baker asks for slots' + status when it has seen a proposal at [attestation_level - 1]. *) + let current_baker_level = Int32.sub attestation_level 1l in + (* We check that the baker is not in advance wrt the DAL node, which would + mean that the DAL node is lagging. We allow a slack of 1 level. *) + if Int32.succ current_level < current_baker_level then + Event.( + emit + get_attestable_slots_future_level_warning + (current_level, current_baker_level)) + else Lwt.return_unit + | _ -> + (* We simply don't do anything if we couldn't obtain the + [last_processed_level]. This should not happen though. *) + Lwt.return_unit + let get_attestable_slots ctxt pkh attested_level () () = let get_attestable_slots ~shard_indices store proto_parameters ~attested_level = @@ -393,12 +421,13 @@ module Profile_handlers = struct return (Types.Attestable_slots {slots = flags; published_level}) in call_handler1 (fun () -> + let open Lwt_result_syntax in let store = Node_context.get_store ctxt in + let attestation_level = Int32.pred attested_level in + let*! () = warn_if_lagging store ~attestation_level in (* For retrieving the assigned shard indexes, we consider the committee - at [attested_level - 1], because the (DAL) attestations in the blocks + at [attestation_level], because the (DAL) attestations in the blocks at level [attested_level] refer to the predecessor level. *) - let attestation_level = Int32.pred attested_level in - let open Lwt_result_syntax in let* shard_indices = Node_context.fetch_assigned_shard_indices ctxt diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index 4ed55ec5d42d..65dd16dce32f 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -626,7 +626,7 @@ let get_attestable_slots_ok_notice = let get_attestable_slots_not_ok_warning = declare_4 ~section - ~name:"get_attestable_slots_warning" + ~name:"get_attestable_slots_missing_shards_warning" ~msg: "For slots {slots_indices} published at level {published_level}, \ {attester} missed shards:\n\ @@ -649,6 +649,18 @@ let get_attestable_slots_not_ok_warning = stored_shards expected_shards)) +let get_attestable_slots_future_level_warning = + declare_2 + ~section + ~name:"get_attestable_slots_future_level_warning" + ~msg: + "It looks like the DAL node is lagging (its current level is \ + {current_level}, while the Layer1 node's level is \ + {current_baker_level})." + ~level:Warning + ("current_level", Data_encoding.int32) + ("current_baker_level", Data_encoding.int32) + let warn_attester_not_dal_attesting = declare_2 ~section -- GitLab From 5ad6e28ff9906acf99558fc93cc4f93cd21a75c3 Mon Sep 17 00:00:00 2001 From: Eugen Zalinescu Date: Thu, 28 Nov 2024 20:32:41 +0100 Subject: [PATCH 2/2] CHANGES: add entry --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index f403c6c42a4d..9cc0a5d73d6d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -155,6 +155,8 @@ Baker - Emit event at Notice level when the delegate is not in the DAL committee, that is, it has no assigned shards at the current level. (:gl:`!15846`) +- A warning has been introduced in case it is observed that the DAL node lags + behind the L1 node. (MR :gl:`!15756`) Miscellaneous ------------- -- GitLab