diff --git a/manifest/main.ml b/manifest/main.ml index 21bd11795d73db347435b355d60aa4f9cead422d..236348723486582ceb1ea0b341904f64a29a43f6 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -6175,6 +6175,7 @@ let hash = Protocol.hash octez_client_base |> open_; octez_client_base_unix |> open_; client |> if_some |> open_; + octez_smart_rollup_lib |> open_; octez_sc_rollup |> if_some |> open_; octez_sc_rollup_layer2 |> if_some |> open_; ] diff --git a/opam/octez-smart-rollup-client-Proxford.opam b/opam/octez-smart-rollup-client-Proxford.opam index 12fc810d8fb74b3aee393aa2dd12da954fecf360..09a96a570d780eadd04f0c6089faefc48fe8a2c1 100644 --- a/opam/octez-smart-rollup-client-Proxford.opam +++ b/opam/octez-smart-rollup-client-Proxford.opam @@ -16,6 +16,7 @@ depends: [ "tezos-client-base" "tezos-client-base-unix" "tezos-client-018-Proxford" + "octez-smart-rollup" "tezos-smart-rollup-018-Proxford" "tezos-smart-rollup-layer2-018-Proxford" "tezos-clic" diff --git a/opam/octez-smart-rollup-client-PtMumbai.opam b/opam/octez-smart-rollup-client-PtMumbai.opam index 7c16f3019469d976c2320edfff4f6506b1e9eb11..1d8c0381ee33087ca3b12253aadec4a34e1fb471 100644 --- a/opam/octez-smart-rollup-client-PtMumbai.opam +++ b/opam/octez-smart-rollup-client-PtMumbai.opam @@ -16,6 +16,7 @@ depends: [ "tezos-client-base" "tezos-client-base-unix" "tezos-client-016-PtMumbai" + "octez-smart-rollup" "tezos-smart-rollup-016-PtMumbai" "tezos-smart-rollup-layer2-016-PtMumbai" "tezos-clic" diff --git a/opam/octez-smart-rollup-client-PtNairob.opam b/opam/octez-smart-rollup-client-PtNairob.opam index 7c068bbffc78e23e1a01bd9a6e2065743f41e1dc..f97532643a4677e008b382895bb346621359b039 100644 --- a/opam/octez-smart-rollup-client-PtNairob.opam +++ b/opam/octez-smart-rollup-client-PtNairob.opam @@ -16,6 +16,7 @@ depends: [ "tezos-client-base" "tezos-client-base-unix" "tezos-client-017-PtNairob" + "octez-smart-rollup" "tezos-smart-rollup-017-PtNairob" "tezos-smart-rollup-layer2-017-PtNairob" "tezos-clic" diff --git a/opam/octez-smart-rollup-client-alpha.opam b/opam/octez-smart-rollup-client-alpha.opam index da1d10981ba3567033cb0b49e7fe59c1c7d23cbf..02dd0975ca57f1877979a70a85a8f2ac1c49485b 100644 --- a/opam/octez-smart-rollup-client-alpha.opam +++ b/opam/octez-smart-rollup-client-alpha.opam @@ -16,6 +16,7 @@ depends: [ "tezos-client-base" "tezos-client-base-unix" "tezos-client-alpha" + "octez-smart-rollup" "tezos-smart-rollup-alpha" "tezos-smart-rollup-layer2-alpha" "tezos-clic" diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.ml b/src/lib_smart_rollup/error.ml similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.ml rename to src/lib_smart_rollup/error.ml diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.mli b/src/lib_smart_rollup/error.mli similarity index 100% rename from src/proto_016_PtMumbai/lib_sc_rollup_layer2/error.mli rename to src/lib_smart_rollup/error.mli diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/daemon_event.ml b/src/lib_smart_rollup_node/daemon_event.ml similarity index 84% rename from src/proto_018_Proxford/lib_sc_rollup_node/daemon_event.ml rename to src/lib_smart_rollup_node/daemon_event.ml index 2969126bcaabe2c9bf31d2d9030529bb9a2c8081..eb97aef08e520a40f3e58d20717e49581118af12 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/daemon_event.ml +++ b/src/lib_smart_rollup_node/daemon_event.ml @@ -1,7 +1,9 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 TriliTech *) +(* Copyright (c) 2023 TriliTech *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -26,7 +28,7 @@ module Simple = struct include Internal_event.Simple - let section = [Protocol.name; "sc_rollup_node"; "daemon"] + let section = ["sc_rollup_node"; "daemon"] let head_processing = declare_2 @@ -97,12 +99,12 @@ module Simple = struct ("backtracked", `Backtracked); ("skipped", `Skipped); ]) ) - ("error", Data_encoding.option Environment.Error_monad.trace_encoding) + ("error", Data_encoding.option Error_monad.trace_encoding) ~pp1:L1_operation.pp ~pp3: (fun ppf -> function | None -> Format.pp_print_string ppf "none" - | Some e -> Environment.Error_monad.pp_trace ppf e) + | Some e -> Error_monad.pp_print_trace ppf e) let error = declare_1 @@ -146,23 +148,11 @@ let processing_heads_iteration = let new_heads_processed = new_heads_iteration Simple.new_heads_processed -let included_operation (type kind) - (operation : kind Protocol.Alpha_context.manager_operation) - (result : kind Protocol.Apply_results.manager_operation_result) = - match Sc_rollup_injector.injector_operation_of_manager operation with - | None -> Lwt.return_unit - | Some operation -> ( - match result with - | Applied _ -> Simple.(emit included_successful_operation) operation - | result -> - let status, errors = - match result with - | Applied _ -> assert false - | Failed (_, e) -> (`Failed, Some e) - | Backtracked (_, e) -> (`Backtracked, e) - | Skipped _ -> (`Skipped, None) - in - Simple.(emit included_failed_operation) (operation, status, errors)) +let included_operation ?errors status operation = + match status with + | `Applied -> Simple.(emit included_successful_operation) operation + | `Failed | `Backtracked | `Skipped -> + Simple.(emit included_failed_operation) (operation, status, errors) let error e = Simple.(emit error) e diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon_event.mli b/src/lib_smart_rollup_node/daemon_event.mli similarity index 90% rename from src/proto_alpha/lib_sc_rollup_node/daemon_event.mli rename to src/lib_smart_rollup_node/daemon_event.mli index 7feacd3b3f8b9c142c9498a6eb01f407e17a11fb..6598f34a86be59327ff5a29b8f3eca79a8557eaa 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_event.mli +++ b/src/lib_smart_rollup_node/daemon_event.mli @@ -1,7 +1,9 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2023 TriliTech *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -46,8 +48,9 @@ val new_heads_processed : Layer1.head list -> unit Lwt.t (** [included_operation op result] emits an event that an operation for the rollup was included in a block. *) val included_operation : - 'kind Protocol.Alpha_context.manager_operation -> - 'kind Protocol.Apply_results.manager_operation_result -> + ?errors:tztrace -> + [`Applied | `Backtracked | `Failed | `Skipped] -> + L1_operation.t -> unit Lwt.t (** Emit a fatal error for the daemon. *) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/event.ml b/src/lib_smart_rollup_node/event.ml similarity index 89% rename from src/proto_016_PtMumbai/lib_sc_rollup_node/event.ml rename to src/lib_smart_rollup_node/event.ml index c35631692bfb4f5e25e70842121564d11c104555..a3db476c88325af32b57ebf8f69b3bef9bbbd49b 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/event.ml +++ b/src/lib_smart_rollup_node/event.ml @@ -1,7 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2021 Nomadic Labs, *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -26,7 +27,7 @@ module Simple = struct include Internal_event.Simple - let section = [Protocol.name; "smart_rollup_node"] + let section = ["smart_rollup_node"] let starting_node = declare_0 @@ -60,7 +61,7 @@ module Simple = struct ~msg: "The smart rollup node is interacting with rollup {addr} of kind {kind}" ~level:Notice - ("addr", Protocol.Alpha_context.Sc_rollup.Address.encoding) + ("addr", Octez_smart_rollup.Address.encoding) ("kind", Data_encoding.string) let connection_lost = @@ -126,28 +127,21 @@ module Simple = struct () let waiting_first_block = - declare_0 + declare_1 ~section ~name:"waiting_first_block" ~level:Notice - ~msg: - (Format.asprintf - "Waiting for first block of protocol %a to appear." - Protocol_hash.pp - Protocol.hash) - () + ~msg:"Waiting for first block of protocol {protocol} to appear." + ("protocol", Protocol_hash.encoding) let received_first_block = - declare_1 + declare_2 ~section ~name:"received_first_block" ~level:Notice - ~msg: - (Format.asprintf - "First block of protocol %a received: {block}." - Protocol_hash.pp - Protocol.hash) + ~msg:"First block of protocol {protocol} received: {block}." ("block", Block_hash.encoding) + ("protocol", Protocol_hash.encoding) let detected_protocol_migration = declare_0 @@ -174,7 +168,7 @@ let node_is_ready ~rpc_addr ~rpc_port = Simple.(emit node_is_ready (rpc_addr, rpc_port)) let rollup_exists ~addr ~kind = - let kind = Protocol.Alpha_context.Sc_rollup.Kind.to_string kind in + let kind = Octez_smart_rollup.Kind.to_string kind in Simple.(emit rollup_exists (addr, kind)) let connection_lost () = Simple.(emit connection_lost) () @@ -198,9 +192,9 @@ let kernel_debug_dont_wait msg = let warn_dal_enabled_no_node () = Simple.(emit warn_dal_enabled_no_node) () -let waiting_first_block () = Simple.(emit waiting_first_block) () +let waiting_first_block p = Simple.(emit waiting_first_block) p -let received_first_block b = Simple.(emit received_first_block) b +let received_first_block b p = Simple.(emit received_first_block) (b, p) let detected_protocol_migration () = Simple.(emit detected_protocol_migration) () diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/event.mli b/src/lib_smart_rollup_node/event.mli similarity index 92% rename from src/proto_018_Proxford/lib_sc_rollup_node/event.mli rename to src/lib_smart_rollup_node/event.mli index cb90a98c4225db9d3cf45f4d1d6f9da755962118..b443252a3353de947c6d5be9797f905024cc60f2 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/event.mli +++ b/src/lib_smart_rollup_node/event.mli @@ -1,7 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -26,8 +27,6 @@ (** This module defines functions that emit the events used when the smart rollup node is running (see {!Daemon}). *) -open Protocol.Alpha_context - val starting_node : unit -> unit Lwt.t val node_is_ready : rpc_addr:string -> rpc_port:int -> unit Lwt.t @@ -35,7 +34,7 @@ val node_is_ready : rpc_addr:string -> rpc_port:int -> unit Lwt.t (** [rollup_exists addr kind] emits the event that the smart rollup node is interacting with the rollup at address [addr] and of the given [kind]. *) -val rollup_exists : addr:Sc_rollup.t -> kind:Sc_rollup.Kind.t -> unit Lwt.t +val rollup_exists : addr:Address.t -> kind:Kind.t -> unit Lwt.t (** [shutdown_node exit_status] emits the event that the smart rollup node is stopping with exit status [exit_status]. *) @@ -77,10 +76,10 @@ val kernel_debug_dont_wait : string -> unit val warn_dal_enabled_no_node : unit -> unit Lwt.t (** Emit event that the node is waiting for the first block of its protocol. *) -val waiting_first_block : unit -> unit Lwt.t +val waiting_first_block : Protocol_hash.t -> unit Lwt.t (** Emit event that the node received the first block of its protocol. *) -val received_first_block : Block_hash.t -> unit Lwt.t +val received_first_block : Block_hash.t -> Protocol_hash.t -> unit Lwt.t (** Emit event that the node will shutdown because of protocol migration. *) val detected_protocol_migration : unit -> unit Lwt.t diff --git a/src/lib_smart_rollup_node/metrics.ml b/src/lib_smart_rollup_node/metrics.ml index f3dc7e0787f3525bc008d597ee60dd70ce116dcd..7c5d690d7074344c9f9c584a1611d589b2c3d9f3 100644 --- a/src/lib_smart_rollup_node/metrics.ml +++ b/src/lib_smart_rollup_node/metrics.ml @@ -91,7 +91,7 @@ let metrics_serve metrics_addr = List.iter_p (fun (addr, port) -> let host = Ipaddr.V6.to_string addr in - let*! () = Node_events.starting_metrics_server ~host ~port in + let*! () = Event.starting_metrics_server ~host ~port in let*! ctx = Conduit_lwt_unix.init ~src:host () in let ctx = Cohttp_lwt_unix.Net.init ~ctx () in let mode = `TCP (`Port port) in diff --git a/src/lib_smart_rollup_node/node_events.ml b/src/lib_smart_rollup_node/node_events.ml deleted file mode 100644 index ec58ac949645ddcb18e414bbc0ea0838ca56f273..0000000000000000000000000000000000000000 --- a/src/lib_smart_rollup_node/node_events.ml +++ /dev/null @@ -1,56 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) -(* Copyright (c) 2023 Functori, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = ["smart_rollup_node"] - - let starting_metrics_server = - declare_2 - ~section - ~name:"starting_metrics_server" - ~msg:"starting metrics server on {host}:{port}" - ~level:Notice - ("host", Data_encoding.string) - ("port", Data_encoding.uint16) - - let metrics_ended = - declare_1 - ~section - ~name:"metrics_ended" - ~level:Error - ~msg:"metrics server ended with error {stacktrace}" - ("stacktrace", Data_encoding.string) -end - -let starting_metrics_server ~host ~port = - Simple.(emit starting_metrics_server) (host, port) - -let metrics_ended error = Simple.(emit metrics_ended) error - -let metrics_ended_dont_wait error = - Simple.(emit__dont_wait__use_with_care metrics_ended) error diff --git a/src/lib_smart_rollup_node/node_events.mli b/src/lib_smart_rollup_node/node_events.mli deleted file mode 100644 index 64fc3bb0ae75584bcea6d32c37e76c3436f6cfc9..0000000000000000000000000000000000000000 --- a/src/lib_smart_rollup_node/node_events.mli +++ /dev/null @@ -1,41 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) -(* Copyright (c) 2023 Functori, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used when the smart - rollup node is running. *) - -(** [starting_metrics_server ~metrics_addr ~metrics_port] emits the event - that the metrics server for the rollup node is starting. *) -val starting_metrics_server : host:string -> port:int -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. *) -val metrics_ended : string -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. - (Doesn't wait for event to be emited. *) -val metrics_ended_dont_wait : string -> unit diff --git a/src/lib_smart_rollup_node/rollup_node_errors.ml b/src/lib_smart_rollup_node/rollup_node_errors.ml new file mode 100644 index 0000000000000000000000000000000000000000..b2c24d61227b330b12752b4d2b2b8b4b9d6af1ab --- /dev/null +++ b/src/lib_smart_rollup_node/rollup_node_errors.ml @@ -0,0 +1,356 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +type lost_result = Draw | Timeout | Conflict_resolved + +let lost_result_to_string = function + | Draw -> "draw" + | Timeout -> "timeout" + | Conflict_resolved -> "conflict resolved" + +let lost_result_encoding = + Data_encoding.string_enum + (List.map + (fun r -> (lost_result_to_string r, r)) + [Draw; Timeout; Conflict_resolved]) + +type error += + | Cannot_produce_proof of {inbox_level : int32; start_tick : Z.t} + | Bad_minimal_fees of string + | Disagree_with_cemented of { + inbox_level : int32; + ours : Commitment.Hash.t option; + on_l1 : Commitment.Hash.t; + } + | Unreliable_tezos_node_returning_inconsistent_game + | Wrong_initial_pvm_state of { + initial_state_hash : State_hash.t; + expected_state_hash : State_hash.t; + } + | Inconsistent_inbox of { + layer1_inbox : Octez_smart_rollup.Inbox.t; + inbox : Octez_smart_rollup.Inbox.t; + } + | Missing_PVM_state of Block_hash.t * Int32.t + | Cannot_checkout_context of Block_hash.t * Smart_rollup_context_hash.t option + | No_batcher + | No_publisher + | Refutation_player_failed_to_start + | No_refutation_coordinator + | Could_not_acquire_lock of string + +type error += + | Lost_game of lost_result + | Unparsable_boot_sector of {path : string} + | Invalid_genesis_state of { + expected : Commitment.Hash.t; + actual : Commitment.Hash.t; + } + +let () = + register_error_kind + `Permanent + ~id:"bad_minimal_fees_arg" + ~title:"Bad -minimal-fees arg" + ~description:"invalid fee threshold in -fee-threshold" + ~pp:(fun ppf literal -> + Format.fprintf ppf "invalid minimal fees '%s'" literal) + Data_encoding.(obj1 (req "parameter" string)) + (function Bad_minimal_fees parameter -> Some parameter | _ -> None) + (fun parameter -> Bad_minimal_fees parameter) ; + + register_error_kind + `Permanent + ~id:"internal.node_disagrees_with_cemented" + ~title:"Internal error: The node disagrees with a cemented commitment on L1" + ~description: + "Internal error: The node disagrees with a cemented commitment on L1" + ~pp:(fun ppf (inbox_level, ours, on_l1) -> + Format.fprintf + ppf + "Internal error: The node has commitment %a for inbox level %ld but \ + this level is cemented on L1 with commitment %a" + (Format.pp_print_option + ~none:(fun ppf () -> Format.pp_print_string ppf "[None]") + Commitment.Hash.pp) + ours + inbox_level + Commitment.Hash.pp + on_l1) + Data_encoding.( + obj3 + (req "inbox_level" int32) + (req "ours" (option Commitment.Hash.encoding)) + (req "on_l1" Commitment.Hash.encoding)) + (function + | Disagree_with_cemented {inbox_level; ours; on_l1} -> + Some (inbox_level, ours, on_l1) + | _ -> None) + (fun (inbox_level, ours, on_l1) -> + Disagree_with_cemented {inbox_level; ours; on_l1}) ; + + let description = + "Internal error: The game invariant states that the dissection from the \ + opponent must contain a tick we disagree with. If the retrieved game does \ + not respect this, we cannot trust the Tezos node we are connected to and \ + prefer to stop here." + in + register_error_kind + `Permanent + ~id:"internal.unreliable_tezos_node" + ~title:"Internal error: Tezos node seems unreliable" + ~description + ~pp:(fun ppf () -> + Format.fprintf ppf "Unreliable Tezos node. %s" description) + Data_encoding.unit + (function + | Unreliable_tezos_node_returning_inconsistent_game -> Some () | _ -> None) + (fun () -> Unreliable_tezos_node_returning_inconsistent_game) ; + + register_error_kind + `Permanent + ~id:"internal.cannot_produce_proof" + ~title:"Internal error: rollup node cannot produce refutation proof" + ~description: + "The rollup node is in a state that prevents it from producing \ + refutation proofs." + ~pp:(fun ppf (inbox_level, start_tick) -> + Format.fprintf + ppf + "cannot produce proof for inbox level %ld starting at tick %a" + inbox_level + Z.pp_print + start_tick) + Data_encoding.(obj2 (req "inbox_level" int32) (req "start_tick" z)) + (function + | Cannot_produce_proof {inbox_level; start_tick} -> + Some (inbox_level, start_tick) + | _ -> None) + (fun (inbox_level, start_tick) -> + Cannot_produce_proof {inbox_level; start_tick}) ; + + register_error_kind + ~id:"sc_rollup.node.Wrong_initial_pvm_state" + ~title:"Initial state produced by PVM is incorrect" + ~description:"Initial state produced by PVM is incorrect." + ~pp:(fun ppf (actual, expected) -> + Format.fprintf + ppf + "The initial state hash produced by the PVM %a is not consistent\n\ + \ with the one expected by the Layer 1 PVM implementation %a" + State_hash.pp + actual + State_hash.pp + expected) + `Permanent + Data_encoding.( + obj2 + (req "initial_state_hash" State_hash.encoding) + (req "expected_state_hash" State_hash.encoding)) + (function + | Wrong_initial_pvm_state {initial_state_hash; expected_state_hash} -> + Some (initial_state_hash, expected_state_hash) + | _ -> None) + (fun (initial_state_hash, expected_state_hash) -> + Wrong_initial_pvm_state {initial_state_hash; expected_state_hash}) ; + + register_error_kind + ~id:"internal.inconsistent_inbox" + ~title:"Internal error: Rollup node has an inconsistent inbox" + ~description: + "The rollup node inbox should be the same as the layer 1 inbox." + ~pp:(fun ppf (layer1_inbox, inbox) -> + Format.fprintf + ppf + "@[Rollup inbox:@;%a@]@;should be equal to @[Layer1 inbox:@;%a@]" + Octez_smart_rollup.Inbox.pp + inbox + Octez_smart_rollup.Inbox.pp + layer1_inbox) + `Permanent + Data_encoding.( + obj2 + (req "layer1_inbox" Octez_smart_rollup.Inbox.encoding) + (req "inbox" Octez_smart_rollup.Inbox.encoding)) + (function + | Inconsistent_inbox {layer1_inbox; inbox} -> Some (layer1_inbox, inbox) + | _ -> None) + (fun (layer1_inbox, inbox) -> Inconsistent_inbox {layer1_inbox; inbox}) ; + + register_error_kind + `Permanent + ~id:"internal.missing_pvm_state" + ~title:"Internal error: Missing PVM state" + ~description:"The rollup node cannot retrieve the state of the PVM." + ~pp:(fun ppf (block, level) -> + Format.fprintf + ppf + "Cannot retrieve PVM state for block %a at level %ld" + Block_hash.pp + block + level) + Data_encoding.(obj2 (req "block" Block_hash.encoding) (req "level" int32)) + (function + | Missing_PVM_state (block, level) -> Some (block, level) | _ -> None) + (fun (block, level) -> Missing_PVM_state (block, level)) ; + + register_error_kind + `Permanent + ~id:"internal.cannot_checkout_context" + ~title:"Internal error: Cannot checkout context" + ~description: + "The rollup node cannot checkout the context registered for the block." + ~pp:(fun ppf (block, context_hash) -> + Format.fprintf + ppf + "The context %sfor block %a cannot be checkouted" + (Option.fold + ~none:"" + ~some:Smart_rollup_context_hash.to_b58check + context_hash) + Block_hash.pp + block) + Data_encoding.( + obj2 + (req "block" Block_hash.encoding) + (opt "context" Smart_rollup_context_hash.encoding)) + (function + | Cannot_checkout_context (block, context) -> Some (block, context) + | _ -> None) + (fun (block, context) -> Cannot_checkout_context (block, context)) ; + + register_error_kind + `Permanent + ~id:"sc_rollup.node.lost_game" + ~title:"Lost refutation game" + ~description:"The rollup node lost a refutation game." + ~pp:(fun ppf result -> + Format.fprintf + ppf + "The rollup node lost the refutation game (%s)" + (lost_result_to_string result)) + Data_encoding.(obj1 (req "result" lost_result_encoding)) + (function Lost_game result -> Some result | _ -> None) + (fun result -> Lost_game result) ; + + register_error_kind + `Permanent + ~id:"sc_rollup.node.unparsable_boot_sector" + ~title:"Unparsable boot sector" + ~description:"The boot sector provided is not parsable by the PVM." + ~pp:(fun ppf path -> + Format.fprintf ppf "The boot sector at path %S is unparsable" path) + Data_encoding.(obj1 (req "path" string)) + (function Unparsable_boot_sector {path} -> Some path | _ -> None) + (fun path -> Unparsable_boot_sector {path}) ; + + register_error_kind + `Permanent + ~id:"sc_rollup.node.invalid_genesis_state" + ~title:"Invalid genesis state" + ~description: + "The rollup node computed an invalid genesis state, it cannot continue." + ~pp:(fun ppf (expected, actual) -> + Format.fprintf + ppf + "Genesis commitment computed (%a) is not equal to the rollup genesis \ + (%a) commitment. The rollup node cannot continue. If you used the \ + argument `--boot-sector-file` you probably provided the wrong boot \ + sector. If not, please report the bug." + Commitment.Hash.pp + expected + Commitment.Hash.pp + actual) + Data_encoding.( + obj2 + (req "expected" Commitment.Hash.encoding) + (req "actual" Commitment.Hash.encoding)) + (function + | Invalid_genesis_state {expected; actual} -> Some (expected, actual) + | _ -> None) + (fun (expected, actual) -> Invalid_genesis_state {expected; actual}) ; + + register_error_kind + ~id:"sc_rollup.node.no_batcher" + ~title:"No batcher for this node" + ~description:"This node does not have a batcher" + ~pp:(fun ppf () -> + Format.fprintf ppf "This rollup node does not have batcher.") + `Permanent + Data_encoding.unit + (function No_batcher -> Some () | _ -> None) + (fun () -> No_batcher) ; + + register_error_kind + ~id:"sc_rollup.node.no_publisher" + ~title:"No publisher for this node" + ~description:"This node does not have an operator to publish commitments" + ~pp:(fun ppf () -> + Format.fprintf + ppf + "This rollup node does not have an operator to publish commitments.") + `Permanent + Data_encoding.unit + (function No_publisher -> Some () | _ -> None) + (fun () -> No_publisher) ; + + register_error_kind + ~id:"sc_rollup.node.no_refutation_coordinator" + ~title:"No refutation coordinator for this node" + ~description:"This node does not have a refutation game coordinator" + ~pp:(fun ppf () -> + Format.fprintf ppf "This node does not have a refutation game coordinator") + `Permanent + Data_encoding.unit + (function No_refutation_coordinator -> Some () | _ -> None) + (fun () -> No_refutation_coordinator) ; + + register_error_kind + ~id:"sc_rollup.node.no_refutation_player" + ~title:"A refutation player failed to start" + ~description:"A refutation player failed to start" + ~pp:(fun ppf () -> + Format.fprintf ppf "A refutation player failed to start.") + `Permanent + Data_encoding.unit + (function Refutation_player_failed_to_start -> Some () | _ -> None) + (fun () -> Refutation_player_failed_to_start) ; + + register_error_kind + `Permanent + ~id:"could_not_acquire_lock" + ~title:"Could not acquire lock on data dir" + ~description:"Could not acquire lock on data dir." + ~pp:(fun ppf f -> + Format.fprintf + ppf + "Could not acquire lock on data directory, another rollup node may \ + already be running with this data. If this is not the case, consider \ + removing manually the file %S" + f) + Data_encoding.(obj1 (req "lock_file" string)) + (function Could_not_acquire_lock f -> Some f | _ -> None) + (fun f -> Could_not_acquire_lock f) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_client/dune b/src/proto_016_PtMumbai/lib_sc_rollup_client/dune index e2ccc55150799676704e59c1f96157b5eb1d6415..485ee6013c0767a00af65a7d3dc955021c838b00 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_client/dune +++ b/src/proto_016_PtMumbai/lib_sc_rollup_client/dune @@ -12,6 +12,7 @@ tezos-client-base tezos-client-base-unix tezos-client-016-PtMumbai + octez-smart-rollup tezos-smart-rollup-016-PtMumbai tezos-smart-rollup-layer2-016-PtMumbai) (flags @@ -24,5 +25,6 @@ -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_016_PtMumbai + -open Octez_smart_rollup -open Tezos_smart_rollup_016_PtMumbai -open Tezos_smart_rollup_layer2_016_PtMumbai)) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon.ml index b05bb7cfdd91973d23d49d43985594ae0451c247..b8c9d40c8540acb842b5353a4b0b733234e23394 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon.ml @@ -155,21 +155,21 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | Sc_rollup_cement {commitment; _}, Sc_rollup_cement_result {inbox_level; _} -> (* Cemented commitment ---------------------------------------------- *) + let proto_inbox_level = inbox_level in + let proto_commitment = commitment in + let inbox_level = Raw_level.to_int32 inbox_level in let* inbox_block = - Node_context.get_l2_block_by_level - node_ctxt - (Raw_level.to_int32 inbox_level) + Node_context.get_l2_block_by_level node_ctxt inbox_level + in + let commitment = + Sc_rollup_proto_types.Commitment_hash.to_octez commitment in let*? () = (* We stop the node if we disagree with a cemented commitment *) - let our_commitment_hash = - Option.map - Sc_rollup_proto_types.Commitment_hash.of_octez - inbox_block.header.commitment_hash - in + let our_commitment_hash = inbox_block.header.commitment_hash in error_unless (Option.equal - Sc_rollup.Commitment.Hash.( = ) + Octez_smart_rollup.Commitment.Hash.( = ) our_commitment_hash (Some commitment)) (Sc_rollup_node_errors.Disagree_with_cemented @@ -177,11 +177,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in let lcc = Reference.get node_ctxt.lcc in let*! () = - if Raw_level.(inbox_level > lcc.level) then ( - Reference.set node_ctxt.lcc {commitment; level = inbox_level} ; + if inbox_level > Raw_level.to_int32 lcc.level then ( + Reference.set + node_ctxt.lcc + {commitment = proto_commitment; level = proto_inbox_level} ; Commitment_event.last_cemented_commitment_updated - commitment - inbox_level) + proto_commitment + proto_inbox_level) else Lwt.return_unit in return_unit @@ -190,8 +192,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; _} when Node_context.is_operator node_ctxt loser -> - tzfail (Sc_rollup_node_errors.Lost_game end_status) + | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + let result = + match reason with + | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved + | Timeout -> Timeout + in + tzfail (Sc_rollup_node_errors.Lost_game result) | Loser _ -> (* Other player lost *) return_unit @@ -204,7 +211,7 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in fail_when (List.exists (Node_context.is_operator node_ctxt) stakers) - (Sc_rollup_node_errors.Lost_game end_status)) + (Sc_rollup_node_errors.Lost_game Draw)) | Dal_publish_slot_header slot_header, Dal_publish_slot_header_result _ when Node_context.dal_supported node_ctxt -> let* () = @@ -245,7 +252,20 @@ let process_l1_operation (type kind) node_ctxt (head : Layer1.header) ~source if not (is_for_my_rollup operation) then return_unit else (* Only look at operations that are for the node's rollup *) - let*! () = Daemon_event.included_operation operation result in + let*! () = + match Sc_rollup_injector.injector_operation_of_manager operation with + | None -> Lwt.return_unit + | Some op -> + let status, errors = + match result with + | Applied _ -> (`Applied, None) + | Backtracked (_, e) -> + (`Backtracked, Option.map Environment.wrap_tztrace e) + | Failed (_, e) -> (`Failed, Some (Environment.wrap_tztrace e)) + | Skipped _ -> (`Skipped, None) + in + Daemon_event.included_operation ?errors status op + in match result with | Applied success_result -> process_included_l1_operation @@ -392,7 +412,10 @@ let rec process_head (daemon_components : (module Daemon_components.S)) in let* () = unless (catching_up && Option.is_none commitment_hash) @@ fun () -> - Inbox.same_as_layer_1 node_ctxt head.hash inbox + Inbox.same_as_layer_1 + node_ctxt + head.hash + (Sc_rollup_proto_types.Inbox.to_octez inbox) in let level = Raw_level.of_int32_exn head.level in let* previous_commitment_hash = @@ -565,8 +588,14 @@ let check_initial_state_hash {Node_context.cctxt; rollup_address; pvm; _} = let module PVM = (val pvm) in let*! s = PVM.initial_state ~empty:(PVM.State.empty ()) in let*! l2_initial_state_hash = PVM.state_hash s in + let l1_reference_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l1_reference_initial_state_hash + in + let l2_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l2_initial_state_hash + in fail_unless - Sc_rollup.State_hash.( + Octez_smart_rollup.State_hash.( l1_reference_initial_state_hash = l2_initial_state_hash) (Sc_rollup_node_errors.Wrong_initial_pvm_state { @@ -763,7 +792,7 @@ let run ()) configuration.sc_rollup_node_operators in - let*! () = Event.waiting_first_block () in + let*! () = Event.waiting_first_block Protocol.hash in let* l1_ctxt = Layer1.start ~name:"sc_rollup_node" @@ -777,7 +806,7 @@ let run let* predecessor = Layer1.fetch_tezos_shell_header l1_ctxt head.header.predecessor in - let*! () = Event.received_first_block head.hash in + let*! () = Event.received_first_block head.hash Protocol.hash in let* node_ctxt = Node_context.init cctxt diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon_event.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon_event.ml deleted file mode 100644 index 2969126bcaabe2c9bf31d2d9030529bb9a2c8081..0000000000000000000000000000000000000000 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon_event.ml +++ /dev/null @@ -1,169 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 TriliTech *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = [Protocol.name; "sc_rollup_node"; "daemon"] - - let head_processing = - declare_2 - ~section - ~name:"sc_rollup_daemon_process_head" - ~msg:"Processing head {hash} at level {level}" - ~level:Notice - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - - let new_head_processed = - declare_3 - ~section - ~name:"sc_rollup_node_layer_1_new_head_processed" - ~msg: - "Finished processing layer 1 head {hash} at level {level} in \ - {process_time}" - ~level:Notice - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - ("process_time", Time.System.Span.encoding) - ~pp3:Ptime.Span.pp - - let processing_heads_iteration = - declare_3 - ~section - ~name:"sc_rollup_daemon_processing_heads" - ~msg: - "A new iteration of process_heads has been triggered: processing \ - {number} heads from level {from} to level {to}" - ~level:Notice - ("number", Data_encoding.int31) - ("from", Data_encoding.int32) - ("to", Data_encoding.int32) - - let new_heads_processed = - declare_3 - ~section - ~name:"sc_rollup_node_layer_1_new_heads_processed" - ~msg: - "Finished processing {number} layer 1 heads for levels {from} to {to}" - ~level:Notice - ("number", Data_encoding.int31) - ("from", Data_encoding.int32) - ("to", Data_encoding.int32) - - let included_successful_operation = - declare_1 - ~section - ~name:"sc_rollup_daemon_included_successful_operation" - ~msg:"Operation {operation} was included as successful" - ~level:Debug - ("operation", L1_operation.encoding) - ~pp1:L1_operation.pp - - let included_failed_operation = - declare_3 - ~section - ~name:"sc_rollup_daemon_included_failed_operation" - ~msg:"Operation {operation} was included as {status} with error {error}" - ~level:Warning - ("operation", L1_operation.encoding) - ( "status", - Data_encoding.( - string_enum - [ - ("failed", `Failed); - ("backtracked", `Backtracked); - ("skipped", `Skipped); - ]) ) - ("error", Data_encoding.option Environment.Error_monad.trace_encoding) - ~pp1:L1_operation.pp - ~pp3: - (fun ppf -> function - | None -> Format.pp_print_string ppf "none" - | Some e -> Environment.Error_monad.pp_trace ppf e) - - let error = - declare_1 - ~section - ~name:"sc_rollup_daemon_error" - ~msg:"Fatal daemon error: {error}" - ~level:Fatal - ("error", trace_encoding) - ~pp1:pp_print_trace - - let degraded_mode = - declare_0 - ~section - ~name:"sc_rollup_daemon_degraded_mode" - ~msg: - "Entering degraded mode: only playing refutation game to defend \ - commitments." - ~level:Error - () -end - -let head_processing hash level = Simple.(emit head_processing (hash, level)) - -let new_head_processed hash level process_time = - Simple.(emit new_head_processed (hash, level, process_time)) - -let new_heads_iteration event = function - | oldest :: rest -> - let newest = - match List.rev rest with [] -> oldest | newest :: _ -> newest - in - let number = - Int32.sub newest.Layer1.level oldest.Layer1.level - |> Int32.succ |> Int32.to_int - in - Simple.emit event (number, oldest.level, newest.level) - | [] -> Lwt.return_unit - -let processing_heads_iteration = - new_heads_iteration Simple.processing_heads_iteration - -let new_heads_processed = new_heads_iteration Simple.new_heads_processed - -let included_operation (type kind) - (operation : kind Protocol.Alpha_context.manager_operation) - (result : kind Protocol.Apply_results.manager_operation_result) = - match Sc_rollup_injector.injector_operation_of_manager operation with - | None -> Lwt.return_unit - | Some operation -> ( - match result with - | Applied _ -> Simple.(emit included_successful_operation) operation - | result -> - let status, errors = - match result with - | Applied _ -> assert false - | Failed (_, e) -> (`Failed, Some e) - | Backtracked (_, e) -> (`Backtracked, e) - | Skipped _ -> (`Skipped, None) - in - Simple.(emit included_failed_operation) (operation, status, errors)) - -let error e = Simple.(emit error) e - -let degraded_mode () = Simple.(emit degraded_mode) () diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon_event.mli b/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon_event.mli deleted file mode 100644 index 7feacd3b3f8b9c142c9498a6eb01f407e17a11fb..0000000000000000000000000000000000000000 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/daemon_event.mli +++ /dev/null @@ -1,58 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used by the smart - rollup node daemon (see {!Daemon}). *) - -(** [head_processing hash level] emits the event that the - block of the given [hash] and at the given [level] is being processed. *) -val head_processing : Block_hash.t -> int32 -> unit Lwt.t - -(** [new_head_processed hash level process_time] emits the event that the daemon - has finished processing the head of the given [hash] and at the given - [level] in [process_time] seconds. *) -val new_head_processed : Block_hash.t -> int32 -> Ptime.Span.t -> unit Lwt.t - -(** [processing_heads_iteration heads] emits the event that the [heads] are - going to be processed. *) -val processing_heads_iteration : Layer1.head list -> unit Lwt.t - -(** [new_heads_processed heads] emits the event that the [heads] were - processed. *) -val new_heads_processed : Layer1.head list -> unit Lwt.t - -(** [included_operation op result] emits an event that an operation - for the rollup was included in a block. *) -val included_operation : - 'kind Protocol.Alpha_context.manager_operation -> - 'kind Protocol.Apply_results.manager_operation_result -> - unit Lwt.t - -(** Emit a fatal error for the daemon. *) -val error : tztrace -> unit Lwt.t - -(** Emit an event for when the node enters the degraded mode to only play - refutations. *) -val degraded_mode : unit -> unit Lwt.t diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/event.mli b/src/proto_016_PtMumbai/lib_sc_rollup_node/event.mli deleted file mode 100644 index cb90a98c4225db9d3cf45f4d1d6f9da755962118..0000000000000000000000000000000000000000 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/event.mli +++ /dev/null @@ -1,90 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used when the smart - rollup node is running (see {!Daemon}). *) - -open Protocol.Alpha_context - -val starting_node : unit -> unit Lwt.t - -val node_is_ready : rpc_addr:string -> rpc_port:int -> unit Lwt.t - -(** [rollup_exists addr kind] emits the event that the smart rollup - node is interacting with the rollup at address [addr] and of the given - [kind]. *) -val rollup_exists : addr:Sc_rollup.t -> kind:Sc_rollup.Kind.t -> unit Lwt.t - -(** [shutdown_node exit_status] emits the event that the smart rollup - node is stopping with exit status [exit_status]. *) -val shutdown_node : int -> unit Lwt.t - -(** Emits the event that the connection to the Tezos node has been lost. *) -val connection_lost : unit -> unit Lwt.t - -(** [cannot_connect ~count error] emits the event that the rollup node cannot - connect to the Tezos node because of [error] for the [count]'s time. *) -val cannot_connect : count:int -> tztrace -> unit Lwt.t - -(** [wait_reconnect delay] emits the event that the rollup will wait [delay] - seconds before attempting to reconnect to the Tezos node . *) -val wait_reconnect : float -> unit Lwt.t - -(** [starting_metrics_server ~metrics_addr ~metrics_port] emits the event - that the metrics server for the rollup node is starting. *) -val starting_metrics_server : host:string -> port:int -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. *) -val metrics_ended : string -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. - (Doesn't wait for event to be emited. *) -val metrics_ended_dont_wait : string -> unit - -(** [kernel_debug str] emits the event that the kernel has logged [str]. *) -val kernel_debug : string -> unit Lwt.t - -(** [kernel_debug str] emits the event that the kernel has logged [str]. - (Doesn't wait for event to be emitted) *) -val kernel_debug_dont_wait : string -> unit - -(** [warn_dal_enabled_no_node ()] emits a warning for when DAL is enabled in the - protocol but the rollup node has no DAL node. *) -val warn_dal_enabled_no_node : unit -> unit Lwt.t - -(** Emit event that the node is waiting for the first block of its protocol. *) -val waiting_first_block : unit -> unit Lwt.t - -(** Emit event that the node received the first block of its protocol. *) -val received_first_block : Block_hash.t -> unit Lwt.t - -(** Emit event that the node will shutdown because of protocol migration. *) -val detected_protocol_migration : unit -> unit Lwt.t - -(** [acquiring_lock ()] emits an event to indicate that the node is attempting - to acquire a lock on the data directory. *) -val acquiring_lock : unit -> unit Lwt.t diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.ml index 2eb75aa2daddaa9726b057886a7342f973572d45..3b258f344e5f722ab2c729fedfbb2febe99a9ef1 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.ml @@ -87,8 +87,9 @@ let same_as_layer_1 node_ctxt head_hash inbox = let* layer1_inbox = Plugin.RPC.Sc_rollup.inbox cctxt (cctxt#chain, head_block) in + let layer1_inbox = Sc_rollup_proto_types.Inbox.to_octez layer1_inbox in fail_unless - (Sc_rollup.Inbox.equal layer1_inbox inbox) + (Octez_smart_rollup.Inbox.equal layer1_inbox inbox) (Sc_rollup_node_errors.Inconsistent_inbox {layer1_inbox; inbox}) let add_messages ~predecessor_timestamp ~predecessor inbox messages = diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.mli b/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.mli index 53ecd5f8f98b0e203ef579ad640c354d9e7955d5..8c7ea9599a9f115d1feb74a8fea92e8d6b712f8a 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.mli +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/inbox.mli @@ -81,7 +81,10 @@ val payloads_history_of_messages : (** [same_as_layer_1 node_ctxt block node_inbox] ensures that the rollup node agrees with the L1 node that inbox for [block] is [node_inbox]. *) val same_as_layer_1 : - _ Node_context.t -> Block_hash.t -> Sc_rollup.Inbox.t -> unit tzresult Lwt.t + _ Node_context.t -> + Block_hash.t -> + Octez_smart_rollup.Inbox.t -> + unit tzresult Lwt.t (**/**) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/node_context.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/node_context.ml index d9c4667059be49ccfcde935086528574d2215613..448e714500716c154f804b508f78b818b511b00f 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/node_context.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/node_context.ml @@ -281,7 +281,7 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file mode l1_ctxt ~proto_level Configuration.( { - sc_rollup_address = rollup_address; + sc_rollup_address; sc_rollup_node_operators = operators; mode = operating_mode; fee_parameters; @@ -309,11 +309,13 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file let* context = Context.load mode (Configuration.default_context_dir data_dir) in - let* () = Context.Rollup.check_or_set_address mode context rollup_address in + let* () = + Context.Rollup.check_or_set_address mode context sc_rollup_address + in let publisher = Configuration.Operator_purpose_map.find Publish operators in let rollup_address = (* Convert to protocol rollup address *) - Sc_rollup_proto_types.Address.of_octez rollup_address + Sc_rollup_proto_types.Address.of_octez sc_rollup_address in let* protocol_constants = retrieve_constants cctxt and* lcc = get_last_cemented_commitment cctxt rollup_address @@ -326,7 +328,11 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file and* genesis_info = RPC.Sc_rollup.genesis_info cctxt (cctxt#chain, cctxt#block) rollup_address in - let*! () = Event.rollup_exists ~addr:rollup_address ~kind in + let*! () = + Event.rollup_exists + ~addr:sc_rollup_address + ~kind:(Sc_rollup_proto_types.Kind.to_octez kind) + in let*! () = if dal_cctxt = None && protocol_constants.parametric.dal.feature_enable then Event.warn_dal_enabled_no_node () diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/publisher.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/publisher.ml index 7febcaea817bfe2b8e7e5db671ada33aa4644d8f..e556dc6b9f31684d3062c51adf1fa4604e28530e 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/publisher.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/publisher.ml @@ -160,8 +160,11 @@ let genesis_commitment (node_ctxt : _ Node_context.t) ctxt = commitment_hash = node_ctxt.genesis_info.commitment_hash) (Sc_rollup_node_errors.Invalid_genesis_state { - expected = node_ctxt.genesis_info.commitment_hash; - actual = commitment_hash; + expected = + Sc_rollup_proto_types.Commitment_hash.to_octez + node_ctxt.genesis_info.commitment_hash; + actual = + Sc_rollup_proto_types.Commitment_hash.to_octez commitment_hash; }) in commitment diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/refutation_game.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/refutation_game.ml index e72c67e08c98bce6725443f118ea63c48296f877..3f0ca7c18fd7623c6c89e7672551c4bb43d061a3 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/refutation_game.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/refutation_game.ml @@ -270,8 +270,14 @@ let generate_proof (node_ctxt : _ Node_context.t) game start_state = end end in let metadata = Node_context.metadata node_ctxt in + let*! start_tick = PVM.get_tick start_state in let* proof = - trace (Sc_rollup_node_errors.Cannot_produce_proof game) + trace + (Sc_rollup_node_errors.Cannot_produce_proof + { + inbox_level = Raw_level.to_int32 game.inbox_level; + start_tick = Sc_rollup.Tick.to_z start_tick; + }) @@ (Sc_rollup.Proof.produce ~metadata (module P) game.inbox_level >|= Environment.wrap_tzresult) in diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/sc_rollup_node_errors.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/sc_rollup_node_errors.ml index f20e60b4cdc5ca34c89595cbed7ee3e2cf5db0b9..bf57c29eda9b498b56c5e7775eb30e5caaaf9e3e 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/sc_rollup_node_errors.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/sc_rollup_node_errors.ml @@ -1,7 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -23,315 +24,10 @@ (* *) (*****************************************************************************) -open Protocol.Alpha_context +include Rollup_node_errors + +(** Registering protocol specific errors *) let make_id id = String.concat "." [Protocol.name; id] let register_error_kind ~id = register_error_kind ~id:(make_id id) - -type error += - | Cannot_produce_proof of Sc_rollup.Game.t - | Bad_minimal_fees of string - | Disagree_with_cemented of { - inbox_level : Raw_level.t; - ours : Sc_rollup.Commitment.Hash.t option; - on_l1 : Sc_rollup.Commitment.Hash.t; - } - | Unreliable_tezos_node_returning_inconsistent_game - | Wrong_initial_pvm_state of { - initial_state_hash : Sc_rollup.State_hash.t; - expected_state_hash : Sc_rollup.State_hash.t; - } - | Inconsistent_inbox of { - layer1_inbox : Sc_rollup.Inbox.t; - inbox : Sc_rollup.Inbox.t; - } - | Missing_PVM_state of Block_hash.t * Int32.t - | Cannot_checkout_context of Block_hash.t * Smart_rollup_context_hash.t option - | No_batcher - | No_publisher - | Refutation_player_failed_to_start - | No_refutation_coordinator - | Could_not_acquire_lock of string - -type error += - | Lost_game of Protocol.Alpha_context.Sc_rollup.Game.game_result - | Invalid_genesis_state of { - expected : Sc_rollup.Commitment.Hash.t; - actual : Sc_rollup.Commitment.Hash.t; - } - -let () = - register_error_kind - `Permanent - ~id:"bad_minimal_fees_arg" - ~title:"Bad -minimal-fees arg" - ~description:"invalid fee threshold in -fee-threshold" - ~pp:(fun ppf literal -> - Format.fprintf ppf "invalid minimal fees '%s'" literal) - Data_encoding.(obj1 (req "parameter" string)) - (function Bad_minimal_fees parameter -> Some parameter | _ -> None) - (fun parameter -> Bad_minimal_fees parameter) ; - - register_error_kind - `Permanent - ~id:"internal.node_disagrees_with_cemented" - ~title:"Internal error: The node disagrees with a cemented commitment on L1" - ~description: - "Internal error: The node disagrees with a cemented commitment on L1" - ~pp:(fun ppf (inbox_level, ours, on_l1) -> - Format.fprintf - ppf - "Internal error: The node has commitment %a for inbox level %a but \ - this level is cemented on L1 with commitment %a" - (Format.pp_print_option - ~none:(fun ppf () -> Format.pp_print_string ppf "[None]") - Sc_rollup.Commitment.Hash.pp) - ours - Raw_level.pp - inbox_level - Sc_rollup.Commitment.Hash.pp - on_l1) - Data_encoding.( - obj3 - (req "inbox_level" Raw_level.encoding) - (req "ours" (option Sc_rollup.Commitment.Hash.encoding)) - (req "on_l1" Sc_rollup.Commitment.Hash.encoding)) - (function - | Disagree_with_cemented {inbox_level; ours; on_l1} -> - Some (inbox_level, ours, on_l1) - | _ -> None) - (fun (inbox_level, ours, on_l1) -> - Disagree_with_cemented {inbox_level; ours; on_l1}) ; - - let description = - "Internal error: The game invariant states that the dissection from the \ - opponent must contain a tick we disagree with. If the retrieved game does \ - not respect this, we cannot trust the Tezos node we are connected to and \ - prefer to stop here." - in - register_error_kind - `Permanent - ~id:"internal.unreliable_tezos_node" - ~title:"Internal error: Tezos node seems unreliable" - ~description - ~pp:(fun ppf () -> - Format.fprintf ppf "Unreliable Tezos node. %s" description) - Data_encoding.unit - (function - | Unreliable_tezos_node_returning_inconsistent_game -> Some () | _ -> None) - (fun () -> Unreliable_tezos_node_returning_inconsistent_game) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_produce_proof" - ~title:"Internal error: rollup node cannot produce refutation proof" - ~description: - "The rollup node is in a state that prevents it from producing \ - refutation proofs." - ~pp:(fun ppf game -> - Format.fprintf - ppf - "cannot produce proof for game %a" - Sc_rollup.Game.pp - game) - Data_encoding.(obj1 (req "game" Sc_rollup.Game.encoding)) - (function Cannot_produce_proof game -> Some game | _ -> None) - (fun game -> Cannot_produce_proof game) ; - - register_error_kind - ~id:"sc_rollup.node.Wrong_initial_pvm_state" - ~title:"Initial state produced by PVM is incorrect" - ~description:"Initial state produced by PVM is incorrect." - ~pp:(fun ppf (actual, expected) -> - Format.fprintf - ppf - "The initial state hash produced by the PVM %a is not consistent\n\ - \ with the one expected by the Layer 1 PVM implementation %a" - Sc_rollup.State_hash.pp - actual - Sc_rollup.State_hash.pp - expected) - `Permanent - Data_encoding.( - obj2 - (req "initial_state_hash" Sc_rollup.State_hash.encoding) - (req "expected_state_hash" Sc_rollup.State_hash.encoding)) - (function - | Wrong_initial_pvm_state {initial_state_hash; expected_state_hash} -> - Some (initial_state_hash, expected_state_hash) - | _ -> None) - (fun (initial_state_hash, expected_state_hash) -> - Wrong_initial_pvm_state {initial_state_hash; expected_state_hash}) ; - - register_error_kind - ~id:"internal.inconsistent_inbox" - ~title:"Internal error: Rollup node has an inconsistent inbox" - ~description: - "The rollup node inbox should be the same as the layer 1 inbox." - ~pp:(fun ppf (layer1_inbox, inbox) -> - Format.fprintf - ppf - "@[Rollup inbox:@;%a@]@;should be equal to @[Layer1 inbox:@;%a@]" - Sc_rollup.Inbox.pp - inbox - Sc_rollup.Inbox.pp - layer1_inbox) - `Permanent - Data_encoding.( - obj2 - (req "layer1_inbox" Sc_rollup.Inbox.encoding) - (req "inbox" Sc_rollup.Inbox.encoding)) - (function - | Inconsistent_inbox {layer1_inbox; inbox} -> Some (layer1_inbox, inbox) - | _ -> None) - (fun (layer1_inbox, inbox) -> Inconsistent_inbox {layer1_inbox; inbox}) ; - - register_error_kind - `Permanent - ~id:"internal.missing_pvm_state" - ~title:"Internal error: Missing PVM state" - ~description:"The rollup node cannot retrieve the state of the PVM." - ~pp:(fun ppf (block, level) -> - Format.fprintf - ppf - "Cannot retrieve PVM state for block %a at level %ld" - Block_hash.pp - block - level) - Data_encoding.(obj2 (req "block" Block_hash.encoding) (req "level" int32)) - (function - | Missing_PVM_state (block, level) -> Some (block, level) | _ -> None) - (fun (block, level) -> Missing_PVM_state (block, level)) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_checkout_context" - ~title:"Internal error: Cannot checkout context" - ~description: - "The rollup node cannot checkout the context registered for the block." - ~pp:(fun ppf (block, context_hash) -> - Format.fprintf - ppf - "The context %sfor block %a cannot be checkouted" - (Option.fold - ~none:"" - ~some:Smart_rollup_context_hash.to_b58check - context_hash) - Block_hash.pp - block) - Data_encoding.( - obj2 - (req "block" Block_hash.encoding) - (opt "context" Smart_rollup_context_hash.encoding)) - (function - | Cannot_checkout_context (block, context) -> Some (block, context) - | _ -> None) - (fun (block, context) -> Cannot_checkout_context (block, context)) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.lost_game" - ~title:"Lost refutation game" - ~description:"The rollup node lost a refutation game." - ~pp:(fun ppf result -> - Format.fprintf - ppf - "The rollup node lost the refutation game (%a)" - Protocol.Alpha_context.Sc_rollup.Game.pp_game_result - result) - Data_encoding.( - obj1 - (req - "result" - Protocol.Alpha_context.Sc_rollup.Game.game_result_encoding)) - (function Lost_game result -> Some result | _ -> None) - (fun result -> Lost_game result) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.invalid_genesis_state" - ~title:"Invalid genesis state" - ~description: - "The rollup node computed an invalid genesis state, it cannot continue." - ~pp:(fun ppf (expected, actual) -> - Format.fprintf - ppf - "Genesis commitment computed (%a) is not equal to the rollup genesis \ - (%a) commitment. Please report the bug." - Sc_rollup.Commitment.Hash.pp - expected - Sc_rollup.Commitment.Hash.pp - actual) - Data_encoding.( - obj2 - (req - "expected" - Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding) - (req "actual" Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding)) - (function - | Invalid_genesis_state {expected; actual} -> Some (expected, actual) - | _ -> None) - (fun (expected, actual) -> Invalid_genesis_state {expected; actual}) ; - - register_error_kind - ~id:"sc_rollup.node.no_batcher" - ~title:"No batcher for this node" - ~description:"This node does not have a batcher" - ~pp:(fun ppf () -> - Format.fprintf ppf "This rollup node does not have batcher.") - `Permanent - Data_encoding.unit - (function No_batcher -> Some () | _ -> None) - (fun () -> No_batcher) ; - - register_error_kind - ~id:"sc_rollup.node.no_publisher" - ~title:"No publisher for this node" - ~description:"This node does not have an operator to publish commitments" - ~pp:(fun ppf () -> - Format.fprintf - ppf - "This rollup node does not have an operator to publish commitments.") - `Permanent - Data_encoding.unit - (function No_publisher -> Some () | _ -> None) - (fun () -> No_publisher) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_coordinator" - ~title:"No refutation coordinator for this node" - ~description:"This node does not have a refutation game coordinator" - ~pp:(fun ppf () -> - Format.fprintf ppf "This node does not have a refutation game coordinator") - `Permanent - Data_encoding.unit - (function No_refutation_coordinator -> Some () | _ -> None) - (fun () -> No_refutation_coordinator) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_player" - ~title:"A refutation player failed to start" - ~description:"A refutation player failed to start" - ~pp:(fun ppf () -> - Format.fprintf ppf "A refutation player failed to start.") - `Permanent - Data_encoding.unit - (function Refutation_player_failed_to_start -> Some () | _ -> None) - (fun () -> Refutation_player_failed_to_start) ; - - register_error_kind - `Permanent - ~id:"could_not_acquire_lock" - ~title:"Could not acquire lock on data dir" - ~description:"Could not acquire lock on data dir." - ~pp:(fun ppf f -> - Format.fprintf - ppf - "Could not acquire lock on data directory, another rollup node may \ - already be running with this data. If this is not the case, consider \ - removing manually the file %S" - f) - Data_encoding.(obj1 (req "lock_file" string)) - (function Could_not_acquire_lock f -> Some f | _ -> None) - (fun f -> Could_not_acquire_lock f) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_client/dune b/src/proto_017_PtNairob/lib_sc_rollup_client/dune index 289dc70a43d309fbe8b1d38c2d2fa7d5b7dd3f85..66ae73cb0d90658edcee53b240af9f3670070746 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_client/dune +++ b/src/proto_017_PtNairob/lib_sc_rollup_client/dune @@ -12,6 +12,7 @@ tezos-client-base tezos-client-base-unix tezos-client-017-PtNairob + octez-smart-rollup tezos-smart-rollup-017-PtNairob tezos-smart-rollup-layer2-017-PtNairob) (flags @@ -24,5 +25,6 @@ -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_017_PtNairob + -open Octez_smart_rollup -open Tezos_smart_rollup_017_PtNairob -open Tezos_smart_rollup_layer2_017_PtNairob)) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_layer2/error.ml b/src/proto_017_PtNairob/lib_sc_rollup_layer2/error.ml deleted file mode 100644 index 1531f5fd9d70d630f62098d3a8afe4118dc2708d..0000000000000000000000000000000000000000 --- a/src/proto_017_PtNairob/lib_sc_rollup_layer2/error.ml +++ /dev/null @@ -1,35 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -let trace_lwt_with x = - let open Error_monad.Legacy_monad_globals in - Format.kasprintf - (fun s p -> trace (Exn (Failure s)) @@ protect @@ fun () -> p >>= return) - x - -let trace_lwt_result_with x = - Format.kasprintf - (fun s p -> trace (Exn (Failure s)) @@ protect @@ fun () -> p) - x diff --git a/src/proto_017_PtNairob/lib_sc_rollup_layer2/error.mli b/src/proto_017_PtNairob/lib_sc_rollup_layer2/error.mli deleted file mode 100644 index cf68299bd9ef089267ef049d679eef262b6740d4..0000000000000000000000000000000000000000 --- a/src/proto_017_PtNairob/lib_sc_rollup_layer2/error.mli +++ /dev/null @@ -1,31 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -val trace_lwt_with : - ('a, Format.formatter, unit, 'b Lwt.t -> 'b tzresult Lwt.t) format4 -> 'a - -val trace_lwt_result_with : - ('a, Format.formatter, unit, 'b tzresult Lwt.t -> 'b tzresult Lwt.t) format4 -> - 'a diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml index 5d89cafafb687e4d7666f90f3131d90b0bb7a44d..f748c83dcff64de841b951a6013beaeccc58cca9 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml @@ -155,21 +155,21 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_cement _, Sc_rollup_cement_result {inbox_level; commitment_hash; _} ) -> (* Cemented commitment ---------------------------------------------- *) + let proto_inbox_level = inbox_level in + let proto_commitment_hash = commitment_hash in + let inbox_level = Raw_level.to_int32 inbox_level in + let commitment_hash = + Sc_rollup_proto_types.Commitment_hash.to_octez commitment_hash + in let* inbox_block = - Node_context.get_l2_block_by_level - node_ctxt - (Raw_level.to_int32 inbox_level) + Node_context.get_l2_block_by_level node_ctxt inbox_level in let*? () = (* We stop the node if we disagree with a cemented commitment *) - let our_commitment_hash = - Option.map - Sc_rollup_proto_types.Commitment_hash.of_octez - inbox_block.header.commitment_hash - in + let our_commitment_hash = inbox_block.header.commitment_hash in error_unless (Option.equal - Sc_rollup.Commitment.Hash.( = ) + Octez_smart_rollup.Commitment.Hash.( = ) our_commitment_hash (Some commitment_hash)) (Sc_rollup_node_errors.Disagree_with_cemented @@ -177,13 +177,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in let lcc = Reference.get node_ctxt.lcc in let*! () = - if Raw_level.(inbox_level > lcc.level) then ( + if inbox_level > Raw_level.to_int32 lcc.level then ( Reference.set node_ctxt.lcc - {commitment = commitment_hash; level = inbox_level} ; + {commitment = proto_commitment_hash; level = proto_inbox_level} ; Commitment_event.last_cemented_commitment_updated - commitment_hash - inbox_level) + proto_commitment_hash + proto_inbox_level) else Lwt.return_unit in return_unit @@ -192,8 +192,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; _} when Node_context.is_operator node_ctxt loser -> - tzfail (Sc_rollup_node_errors.Lost_game end_status) + | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + let result = + match reason with + | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved + | Timeout -> Timeout + in + tzfail (Sc_rollup_node_errors.Lost_game result) | Loser _ -> (* Other player lost *) return_unit @@ -206,7 +211,7 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in fail_when (List.exists (Node_context.is_operator node_ctxt) stakers) - (Sc_rollup_node_errors.Lost_game end_status)) + (Sc_rollup_node_errors.Lost_game Draw)) | Dal_publish_slot_header _, Dal_publish_slot_header_result {slot_header; _} when Node_context.dal_supported node_ctxt -> let* () = @@ -243,7 +248,20 @@ let process_l1_operation (type kind) node_ctxt (head : Layer1.header) ~source if not (is_for_my_rollup operation) then return_unit else (* Only look at operations that are for the node's rollup *) - let*! () = Daemon_event.included_operation operation result in + let*! () = + match Sc_rollup_injector.injector_operation_of_manager operation with + | None -> Lwt.return_unit + | Some op -> + let status, errors = + match result with + | Applied _ -> (`Applied, None) + | Backtracked (_, e) -> + (`Backtracked, Option.map Environment.wrap_tztrace e) + | Failed (_, e) -> (`Failed, Some (Environment.wrap_tztrace e)) + | Skipped _ -> (`Skipped, None) + in + Daemon_event.included_operation ?errors status op + in match result with | Applied success_result -> process_included_l1_operation @@ -390,7 +408,10 @@ let rec process_head (daemon_components : (module Daemon_components.S)) in let* () = unless (catching_up && Option.is_none commitment_hash) @@ fun () -> - Inbox.same_as_layer_1 node_ctxt head.hash inbox + Inbox.same_as_layer_1 + node_ctxt + head.hash + (Sc_rollup_proto_types.Inbox.to_octez inbox) in let level = Raw_level.of_int32_exn head.level in let* previous_commitment_hash = @@ -563,8 +584,14 @@ let check_initial_state_hash {Node_context.cctxt; rollup_address; pvm; _} = let module PVM = (val pvm) in let*! s = PVM.initial_state ~empty:(PVM.State.empty ()) in let*! l2_initial_state_hash = PVM.state_hash s in + let l1_reference_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l1_reference_initial_state_hash + in + let l2_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l2_initial_state_hash + in fail_unless - Sc_rollup.State_hash.( + Octez_smart_rollup.State_hash.( l1_reference_initial_state_hash = l2_initial_state_hash) (Sc_rollup_node_errors.Wrong_initial_pvm_state { @@ -757,7 +784,7 @@ let run ()) configuration.sc_rollup_node_operators in - let*! () = Event.waiting_first_block () in + let*! () = Event.waiting_first_block Protocol.hash in let* l1_ctxt = Layer1.start ~name:"sc_rollup_node" @@ -771,7 +798,7 @@ let run let* predecessor = Layer1.fetch_tezos_shell_header l1_ctxt head.header.predecessor in - let*! () = Event.received_first_block head.hash in + let*! () = Event.received_first_block head.hash Protocol.hash in let* node_ctxt = Node_context.init cctxt diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_event.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_event.ml deleted file mode 100644 index 2969126bcaabe2c9bf31d2d9030529bb9a2c8081..0000000000000000000000000000000000000000 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_event.ml +++ /dev/null @@ -1,169 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 TriliTech *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = [Protocol.name; "sc_rollup_node"; "daemon"] - - let head_processing = - declare_2 - ~section - ~name:"sc_rollup_daemon_process_head" - ~msg:"Processing head {hash} at level {level}" - ~level:Notice - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - - let new_head_processed = - declare_3 - ~section - ~name:"sc_rollup_node_layer_1_new_head_processed" - ~msg: - "Finished processing layer 1 head {hash} at level {level} in \ - {process_time}" - ~level:Notice - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - ("process_time", Time.System.Span.encoding) - ~pp3:Ptime.Span.pp - - let processing_heads_iteration = - declare_3 - ~section - ~name:"sc_rollup_daemon_processing_heads" - ~msg: - "A new iteration of process_heads has been triggered: processing \ - {number} heads from level {from} to level {to}" - ~level:Notice - ("number", Data_encoding.int31) - ("from", Data_encoding.int32) - ("to", Data_encoding.int32) - - let new_heads_processed = - declare_3 - ~section - ~name:"sc_rollup_node_layer_1_new_heads_processed" - ~msg: - "Finished processing {number} layer 1 heads for levels {from} to {to}" - ~level:Notice - ("number", Data_encoding.int31) - ("from", Data_encoding.int32) - ("to", Data_encoding.int32) - - let included_successful_operation = - declare_1 - ~section - ~name:"sc_rollup_daemon_included_successful_operation" - ~msg:"Operation {operation} was included as successful" - ~level:Debug - ("operation", L1_operation.encoding) - ~pp1:L1_operation.pp - - let included_failed_operation = - declare_3 - ~section - ~name:"sc_rollup_daemon_included_failed_operation" - ~msg:"Operation {operation} was included as {status} with error {error}" - ~level:Warning - ("operation", L1_operation.encoding) - ( "status", - Data_encoding.( - string_enum - [ - ("failed", `Failed); - ("backtracked", `Backtracked); - ("skipped", `Skipped); - ]) ) - ("error", Data_encoding.option Environment.Error_monad.trace_encoding) - ~pp1:L1_operation.pp - ~pp3: - (fun ppf -> function - | None -> Format.pp_print_string ppf "none" - | Some e -> Environment.Error_monad.pp_trace ppf e) - - let error = - declare_1 - ~section - ~name:"sc_rollup_daemon_error" - ~msg:"Fatal daemon error: {error}" - ~level:Fatal - ("error", trace_encoding) - ~pp1:pp_print_trace - - let degraded_mode = - declare_0 - ~section - ~name:"sc_rollup_daemon_degraded_mode" - ~msg: - "Entering degraded mode: only playing refutation game to defend \ - commitments." - ~level:Error - () -end - -let head_processing hash level = Simple.(emit head_processing (hash, level)) - -let new_head_processed hash level process_time = - Simple.(emit new_head_processed (hash, level, process_time)) - -let new_heads_iteration event = function - | oldest :: rest -> - let newest = - match List.rev rest with [] -> oldest | newest :: _ -> newest - in - let number = - Int32.sub newest.Layer1.level oldest.Layer1.level - |> Int32.succ |> Int32.to_int - in - Simple.emit event (number, oldest.level, newest.level) - | [] -> Lwt.return_unit - -let processing_heads_iteration = - new_heads_iteration Simple.processing_heads_iteration - -let new_heads_processed = new_heads_iteration Simple.new_heads_processed - -let included_operation (type kind) - (operation : kind Protocol.Alpha_context.manager_operation) - (result : kind Protocol.Apply_results.manager_operation_result) = - match Sc_rollup_injector.injector_operation_of_manager operation with - | None -> Lwt.return_unit - | Some operation -> ( - match result with - | Applied _ -> Simple.(emit included_successful_operation) operation - | result -> - let status, errors = - match result with - | Applied _ -> assert false - | Failed (_, e) -> (`Failed, Some e) - | Backtracked (_, e) -> (`Backtracked, e) - | Skipped _ -> (`Skipped, None) - in - Simple.(emit included_failed_operation) (operation, status, errors)) - -let error e = Simple.(emit error) e - -let degraded_mode () = Simple.(emit degraded_mode) () diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_event.mli b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_event.mli deleted file mode 100644 index 7feacd3b3f8b9c142c9498a6eb01f407e17a11fb..0000000000000000000000000000000000000000 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon_event.mli +++ /dev/null @@ -1,58 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used by the smart - rollup node daemon (see {!Daemon}). *) - -(** [head_processing hash level] emits the event that the - block of the given [hash] and at the given [level] is being processed. *) -val head_processing : Block_hash.t -> int32 -> unit Lwt.t - -(** [new_head_processed hash level process_time] emits the event that the daemon - has finished processing the head of the given [hash] and at the given - [level] in [process_time] seconds. *) -val new_head_processed : Block_hash.t -> int32 -> Ptime.Span.t -> unit Lwt.t - -(** [processing_heads_iteration heads] emits the event that the [heads] are - going to be processed. *) -val processing_heads_iteration : Layer1.head list -> unit Lwt.t - -(** [new_heads_processed heads] emits the event that the [heads] were - processed. *) -val new_heads_processed : Layer1.head list -> unit Lwt.t - -(** [included_operation op result] emits an event that an operation - for the rollup was included in a block. *) -val included_operation : - 'kind Protocol.Alpha_context.manager_operation -> - 'kind Protocol.Apply_results.manager_operation_result -> - unit Lwt.t - -(** Emit a fatal error for the daemon. *) -val error : tztrace -> unit Lwt.t - -(** Emit an event for when the node enters the degraded mode to only play - refutations. *) -val degraded_mode : unit -> unit Lwt.t diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/event.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/event.ml deleted file mode 100644 index c35631692bfb4f5e25e70842121564d11c104555..0000000000000000000000000000000000000000 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/event.ml +++ /dev/null @@ -1,208 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2021 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = [Protocol.name; "smart_rollup_node"] - - let starting_node = - declare_0 - ~section - ~name:"starting_smart_rollup_node" - ~msg:"Starting the smart rollup node" - ~level:Notice - () - - let shutdown_node = - declare_1 - ~section - ~name:"stopping_smart_rollup_node" - ~msg:"Stopping the smart rollup node" - ~level:Notice - ("exit_status", Data_encoding.int8) - - let node_is_ready = - declare_2 - ~section - ~name:"smart_rollup_node_is_ready" - ~msg:"The smart rollup node is listening to {addr}:{port}" - ~level:Notice - ("addr", Data_encoding.string) - ("port", Data_encoding.uint16) - - let rollup_exists = - declare_2 - ~section - ~name:"smart_rollup_node_knows_its_rollup" - ~msg: - "The smart rollup node is interacting with rollup {addr} of kind {kind}" - ~level:Notice - ("addr", Protocol.Alpha_context.Sc_rollup.Address.encoding) - ("kind", Data_encoding.string) - - let connection_lost = - declare_0 - ~section - ~name:"smart_rollup_daemon_connection_lost" - ~msg:"connection to the node has been lost" - ~level:Warning - () - - let cannot_connect = - declare_2 - ~section - ~name:"smart_rollup_daemon_cannot_connect" - ~msg:"cannot connect to Tezos node ({count}) {error}" - ~level:Warning - ("count", Data_encoding.int31) - ("error", trace_encoding) - ~pp2:pp_print_trace - - let wait_reconnect = - declare_1 - ~section - ~name:"smart_rollup_daemon_wait_reconnect" - ~msg:"Retrying to connect in {delay}s" - ~level:Warning - ("delay", Data_encoding.float) - - let starting_metrics_server = - declare_2 - ~section - ~name:"starting_metrics_server" - ~msg:"starting metrics server on {host}:{port}" - ~level:Notice - ("host", Data_encoding.string) - ("port", Data_encoding.uint16) - - let metrics_ended = - declare_1 - ~section - ~name:"metrics_ended" - ~level:Error - ~msg:"metrics server ended with error {stacktrace}" - ("stacktrace", Data_encoding.string) - - let kernel_debug = - declare_1 - ~section - ~name:"kernel_debug" - ~level:Info - ~msg:"{log}" - ("log", Data_encoding.string) - ~pp1:Format.pp_print_string - - let warn_dal_enabled_no_node = - declare_0 - ~section - ~name:"dal_enabled_no_node" - ~level:Warning - ~msg: - "Warning: DAL is enabled in the protocol but no DAL node was provided \ - for the rollup node." - () - - let waiting_first_block = - declare_0 - ~section - ~name:"waiting_first_block" - ~level:Notice - ~msg: - (Format.asprintf - "Waiting for first block of protocol %a to appear." - Protocol_hash.pp - Protocol.hash) - () - - let received_first_block = - declare_1 - ~section - ~name:"received_first_block" - ~level:Notice - ~msg: - (Format.asprintf - "First block of protocol %a received: {block}." - Protocol_hash.pp - Protocol.hash) - ("block", Block_hash.encoding) - - let detected_protocol_migration = - declare_0 - ~section - ~name:"detected_protocol_migration" - ~level:Notice - ~msg:"Detected protocol migration, the rollup node will now stop." - () - - let acquiring_lock = - declare_0 - ~section - ~name:"acquiring_lock" - ~level:Notice - ~msg:"Acquiring lock on data directory." - () -end - -let starting_node = Simple.(emit starting_node) - -let shutdown_node exit_status = Simple.(emit shutdown_node exit_status) - -let node_is_ready ~rpc_addr ~rpc_port = - Simple.(emit node_is_ready (rpc_addr, rpc_port)) - -let rollup_exists ~addr ~kind = - let kind = Protocol.Alpha_context.Sc_rollup.Kind.to_string kind in - Simple.(emit rollup_exists (addr, kind)) - -let connection_lost () = Simple.(emit connection_lost) () - -let cannot_connect ~count error = Simple.(emit cannot_connect) (count, error) - -let wait_reconnect delay = Simple.(emit wait_reconnect) delay - -let starting_metrics_server ~host ~port = - Simple.(emit starting_metrics_server) (host, port) - -let metrics_ended error = Simple.(emit metrics_ended) error - -let metrics_ended_dont_wait error = - Simple.(emit__dont_wait__use_with_care metrics_ended) error - -let kernel_debug msg = Simple.(emit kernel_debug) msg - -let kernel_debug_dont_wait msg = - Simple.(emit__dont_wait__use_with_care kernel_debug) msg - -let warn_dal_enabled_no_node () = Simple.(emit warn_dal_enabled_no_node) () - -let waiting_first_block () = Simple.(emit waiting_first_block) () - -let received_first_block b = Simple.(emit received_first_block) b - -let detected_protocol_migration () = - Simple.(emit detected_protocol_migration) () - -let acquiring_lock () = Simple.(emit acquiring_lock) () diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/event.mli b/src/proto_017_PtNairob/lib_sc_rollup_node/event.mli deleted file mode 100644 index cb90a98c4225db9d3cf45f4d1d6f9da755962118..0000000000000000000000000000000000000000 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/event.mli +++ /dev/null @@ -1,90 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used when the smart - rollup node is running (see {!Daemon}). *) - -open Protocol.Alpha_context - -val starting_node : unit -> unit Lwt.t - -val node_is_ready : rpc_addr:string -> rpc_port:int -> unit Lwt.t - -(** [rollup_exists addr kind] emits the event that the smart rollup - node is interacting with the rollup at address [addr] and of the given - [kind]. *) -val rollup_exists : addr:Sc_rollup.t -> kind:Sc_rollup.Kind.t -> unit Lwt.t - -(** [shutdown_node exit_status] emits the event that the smart rollup - node is stopping with exit status [exit_status]. *) -val shutdown_node : int -> unit Lwt.t - -(** Emits the event that the connection to the Tezos node has been lost. *) -val connection_lost : unit -> unit Lwt.t - -(** [cannot_connect ~count error] emits the event that the rollup node cannot - connect to the Tezos node because of [error] for the [count]'s time. *) -val cannot_connect : count:int -> tztrace -> unit Lwt.t - -(** [wait_reconnect delay] emits the event that the rollup will wait [delay] - seconds before attempting to reconnect to the Tezos node . *) -val wait_reconnect : float -> unit Lwt.t - -(** [starting_metrics_server ~metrics_addr ~metrics_port] emits the event - that the metrics server for the rollup node is starting. *) -val starting_metrics_server : host:string -> port:int -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. *) -val metrics_ended : string -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. - (Doesn't wait for event to be emited. *) -val metrics_ended_dont_wait : string -> unit - -(** [kernel_debug str] emits the event that the kernel has logged [str]. *) -val kernel_debug : string -> unit Lwt.t - -(** [kernel_debug str] emits the event that the kernel has logged [str]. - (Doesn't wait for event to be emitted) *) -val kernel_debug_dont_wait : string -> unit - -(** [warn_dal_enabled_no_node ()] emits a warning for when DAL is enabled in the - protocol but the rollup node has no DAL node. *) -val warn_dal_enabled_no_node : unit -> unit Lwt.t - -(** Emit event that the node is waiting for the first block of its protocol. *) -val waiting_first_block : unit -> unit Lwt.t - -(** Emit event that the node received the first block of its protocol. *) -val received_first_block : Block_hash.t -> unit Lwt.t - -(** Emit event that the node will shutdown because of protocol migration. *) -val detected_protocol_migration : unit -> unit Lwt.t - -(** [acquiring_lock ()] emits an event to indicate that the node is attempting - to acquire a lock on the data directory. *) -val acquiring_lock : unit -> unit Lwt.t diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.ml index e756a7b9db7bc5240446d9ecaad5ddc763dae401..37458f1e0432d170d441d07be56ecd15047c0d37 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.ml @@ -87,8 +87,9 @@ let same_as_layer_1 node_ctxt head_hash inbox = let* layer1_inbox = Plugin.RPC.Sc_rollup.inbox cctxt (cctxt#chain, head_block) in + let layer1_inbox = Sc_rollup_proto_types.Inbox.to_octez layer1_inbox in fail_unless - (Sc_rollup.Inbox.equal layer1_inbox inbox) + (Octez_smart_rollup.Inbox.equal layer1_inbox inbox) (Sc_rollup_node_errors.Inconsistent_inbox {layer1_inbox; inbox}) let add_messages ~is_first_block ~predecessor_timestamp ~predecessor inbox diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.mli b/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.mli index 97035d95b40e7b212cfcee9db3d6a3a405dca0ec..cd78e43783e4e11b9c26df1065d7d6b0690583da 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.mli +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/inbox.mli @@ -85,7 +85,10 @@ val payloads_history_of_messages : (** [same_as_layer_1 node_ctxt block node_inbox] ensures that the rollup node agrees with the L1 node that inbox for [block] is [node_inbox]. *) val same_as_layer_1 : - _ Node_context.t -> Block_hash.t -> Sc_rollup.Inbox.t -> unit tzresult Lwt.t + _ Node_context.t -> + Block_hash.t -> + Octez_smart_rollup.Inbox.t -> + unit tzresult Lwt.t (**/**) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/node_context.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/node_context.ml index a40d1cec8df3bf4fd452c506c4ea9ed1e96cbaf9..920de832a917c81e1f9e2a41f38006a6eac1111f 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/node_context.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/node_context.ml @@ -281,7 +281,7 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file mode l1_ctxt ~proto_level Configuration.( { - sc_rollup_address = rollup_address; + sc_rollup_address; sc_rollup_node_operators = operators; mode = operating_mode; fee_parameters; @@ -309,11 +309,13 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file let* context = Context.load mode (Configuration.default_context_dir data_dir) in - let* () = Context.Rollup.check_or_set_address mode context rollup_address in + let* () = + Context.Rollup.check_or_set_address mode context sc_rollup_address + in let publisher = Configuration.Operator_purpose_map.find Publish operators in let rollup_address = (* Convert to protocol rollup address *) - Sc_rollup_proto_types.Address.of_octez rollup_address + Sc_rollup_proto_types.Address.of_octez sc_rollup_address in let* protocol_constants = retrieve_constants cctxt and* lcc = get_last_cemented_commitment cctxt rollup_address @@ -326,7 +328,11 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file and* genesis_info = RPC.Sc_rollup.genesis_info cctxt (cctxt#chain, cctxt#block) rollup_address in - let*! () = Event.rollup_exists ~addr:rollup_address ~kind in + let*! () = + Event.rollup_exists + ~addr:sc_rollup_address + ~kind:(Sc_rollup_proto_types.Kind.to_octez kind) + in let*! () = if dal_cctxt = None && protocol_constants.parametric.dal.feature_enable then Event.warn_dal_enabled_no_node () diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/publisher.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/publisher.ml index 7febcaea817bfe2b8e7e5db671ada33aa4644d8f..e556dc6b9f31684d3062c51adf1fa4604e28530e 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/publisher.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/publisher.ml @@ -160,8 +160,11 @@ let genesis_commitment (node_ctxt : _ Node_context.t) ctxt = commitment_hash = node_ctxt.genesis_info.commitment_hash) (Sc_rollup_node_errors.Invalid_genesis_state { - expected = node_ctxt.genesis_info.commitment_hash; - actual = commitment_hash; + expected = + Sc_rollup_proto_types.Commitment_hash.to_octez + node_ctxt.genesis_info.commitment_hash; + actual = + Sc_rollup_proto_types.Commitment_hash.to_octez commitment_hash; }) in commitment diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game.ml index 893bee817a0a98cdf7898b65d6ca5d24b0622187..c5d09dda2a1da8c43b0db2c3b5abe72878bfa8b8 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game.ml @@ -270,8 +270,14 @@ let generate_proof (node_ctxt : _ Node_context.t) game start_state = end end in let metadata = Node_context.metadata node_ctxt in + let*! start_tick = PVM.get_tick start_state in let* proof = - trace (Sc_rollup_node_errors.Cannot_produce_proof game) + trace + (Sc_rollup_node_errors.Cannot_produce_proof + { + inbox_level = Raw_level.to_int32 game.inbox_level; + start_tick = Sc_rollup.Tick.to_z start_tick; + }) @@ (Sc_rollup.Proof.produce ~metadata (module P) game.inbox_level >|= Environment.wrap_tzresult) in diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_node_errors.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_node_errors.ml index f20e60b4cdc5ca34c89595cbed7ee3e2cf5db0b9..bf57c29eda9b498b56c5e7775eb30e5caaaf9e3e 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_node_errors.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/sc_rollup_node_errors.ml @@ -1,7 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -23,315 +24,10 @@ (* *) (*****************************************************************************) -open Protocol.Alpha_context +include Rollup_node_errors + +(** Registering protocol specific errors *) let make_id id = String.concat "." [Protocol.name; id] let register_error_kind ~id = register_error_kind ~id:(make_id id) - -type error += - | Cannot_produce_proof of Sc_rollup.Game.t - | Bad_minimal_fees of string - | Disagree_with_cemented of { - inbox_level : Raw_level.t; - ours : Sc_rollup.Commitment.Hash.t option; - on_l1 : Sc_rollup.Commitment.Hash.t; - } - | Unreliable_tezos_node_returning_inconsistent_game - | Wrong_initial_pvm_state of { - initial_state_hash : Sc_rollup.State_hash.t; - expected_state_hash : Sc_rollup.State_hash.t; - } - | Inconsistent_inbox of { - layer1_inbox : Sc_rollup.Inbox.t; - inbox : Sc_rollup.Inbox.t; - } - | Missing_PVM_state of Block_hash.t * Int32.t - | Cannot_checkout_context of Block_hash.t * Smart_rollup_context_hash.t option - | No_batcher - | No_publisher - | Refutation_player_failed_to_start - | No_refutation_coordinator - | Could_not_acquire_lock of string - -type error += - | Lost_game of Protocol.Alpha_context.Sc_rollup.Game.game_result - | Invalid_genesis_state of { - expected : Sc_rollup.Commitment.Hash.t; - actual : Sc_rollup.Commitment.Hash.t; - } - -let () = - register_error_kind - `Permanent - ~id:"bad_minimal_fees_arg" - ~title:"Bad -minimal-fees arg" - ~description:"invalid fee threshold in -fee-threshold" - ~pp:(fun ppf literal -> - Format.fprintf ppf "invalid minimal fees '%s'" literal) - Data_encoding.(obj1 (req "parameter" string)) - (function Bad_minimal_fees parameter -> Some parameter | _ -> None) - (fun parameter -> Bad_minimal_fees parameter) ; - - register_error_kind - `Permanent - ~id:"internal.node_disagrees_with_cemented" - ~title:"Internal error: The node disagrees with a cemented commitment on L1" - ~description: - "Internal error: The node disagrees with a cemented commitment on L1" - ~pp:(fun ppf (inbox_level, ours, on_l1) -> - Format.fprintf - ppf - "Internal error: The node has commitment %a for inbox level %a but \ - this level is cemented on L1 with commitment %a" - (Format.pp_print_option - ~none:(fun ppf () -> Format.pp_print_string ppf "[None]") - Sc_rollup.Commitment.Hash.pp) - ours - Raw_level.pp - inbox_level - Sc_rollup.Commitment.Hash.pp - on_l1) - Data_encoding.( - obj3 - (req "inbox_level" Raw_level.encoding) - (req "ours" (option Sc_rollup.Commitment.Hash.encoding)) - (req "on_l1" Sc_rollup.Commitment.Hash.encoding)) - (function - | Disagree_with_cemented {inbox_level; ours; on_l1} -> - Some (inbox_level, ours, on_l1) - | _ -> None) - (fun (inbox_level, ours, on_l1) -> - Disagree_with_cemented {inbox_level; ours; on_l1}) ; - - let description = - "Internal error: The game invariant states that the dissection from the \ - opponent must contain a tick we disagree with. If the retrieved game does \ - not respect this, we cannot trust the Tezos node we are connected to and \ - prefer to stop here." - in - register_error_kind - `Permanent - ~id:"internal.unreliable_tezos_node" - ~title:"Internal error: Tezos node seems unreliable" - ~description - ~pp:(fun ppf () -> - Format.fprintf ppf "Unreliable Tezos node. %s" description) - Data_encoding.unit - (function - | Unreliable_tezos_node_returning_inconsistent_game -> Some () | _ -> None) - (fun () -> Unreliable_tezos_node_returning_inconsistent_game) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_produce_proof" - ~title:"Internal error: rollup node cannot produce refutation proof" - ~description: - "The rollup node is in a state that prevents it from producing \ - refutation proofs." - ~pp:(fun ppf game -> - Format.fprintf - ppf - "cannot produce proof for game %a" - Sc_rollup.Game.pp - game) - Data_encoding.(obj1 (req "game" Sc_rollup.Game.encoding)) - (function Cannot_produce_proof game -> Some game | _ -> None) - (fun game -> Cannot_produce_proof game) ; - - register_error_kind - ~id:"sc_rollup.node.Wrong_initial_pvm_state" - ~title:"Initial state produced by PVM is incorrect" - ~description:"Initial state produced by PVM is incorrect." - ~pp:(fun ppf (actual, expected) -> - Format.fprintf - ppf - "The initial state hash produced by the PVM %a is not consistent\n\ - \ with the one expected by the Layer 1 PVM implementation %a" - Sc_rollup.State_hash.pp - actual - Sc_rollup.State_hash.pp - expected) - `Permanent - Data_encoding.( - obj2 - (req "initial_state_hash" Sc_rollup.State_hash.encoding) - (req "expected_state_hash" Sc_rollup.State_hash.encoding)) - (function - | Wrong_initial_pvm_state {initial_state_hash; expected_state_hash} -> - Some (initial_state_hash, expected_state_hash) - | _ -> None) - (fun (initial_state_hash, expected_state_hash) -> - Wrong_initial_pvm_state {initial_state_hash; expected_state_hash}) ; - - register_error_kind - ~id:"internal.inconsistent_inbox" - ~title:"Internal error: Rollup node has an inconsistent inbox" - ~description: - "The rollup node inbox should be the same as the layer 1 inbox." - ~pp:(fun ppf (layer1_inbox, inbox) -> - Format.fprintf - ppf - "@[Rollup inbox:@;%a@]@;should be equal to @[Layer1 inbox:@;%a@]" - Sc_rollup.Inbox.pp - inbox - Sc_rollup.Inbox.pp - layer1_inbox) - `Permanent - Data_encoding.( - obj2 - (req "layer1_inbox" Sc_rollup.Inbox.encoding) - (req "inbox" Sc_rollup.Inbox.encoding)) - (function - | Inconsistent_inbox {layer1_inbox; inbox} -> Some (layer1_inbox, inbox) - | _ -> None) - (fun (layer1_inbox, inbox) -> Inconsistent_inbox {layer1_inbox; inbox}) ; - - register_error_kind - `Permanent - ~id:"internal.missing_pvm_state" - ~title:"Internal error: Missing PVM state" - ~description:"The rollup node cannot retrieve the state of the PVM." - ~pp:(fun ppf (block, level) -> - Format.fprintf - ppf - "Cannot retrieve PVM state for block %a at level %ld" - Block_hash.pp - block - level) - Data_encoding.(obj2 (req "block" Block_hash.encoding) (req "level" int32)) - (function - | Missing_PVM_state (block, level) -> Some (block, level) | _ -> None) - (fun (block, level) -> Missing_PVM_state (block, level)) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_checkout_context" - ~title:"Internal error: Cannot checkout context" - ~description: - "The rollup node cannot checkout the context registered for the block." - ~pp:(fun ppf (block, context_hash) -> - Format.fprintf - ppf - "The context %sfor block %a cannot be checkouted" - (Option.fold - ~none:"" - ~some:Smart_rollup_context_hash.to_b58check - context_hash) - Block_hash.pp - block) - Data_encoding.( - obj2 - (req "block" Block_hash.encoding) - (opt "context" Smart_rollup_context_hash.encoding)) - (function - | Cannot_checkout_context (block, context) -> Some (block, context) - | _ -> None) - (fun (block, context) -> Cannot_checkout_context (block, context)) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.lost_game" - ~title:"Lost refutation game" - ~description:"The rollup node lost a refutation game." - ~pp:(fun ppf result -> - Format.fprintf - ppf - "The rollup node lost the refutation game (%a)" - Protocol.Alpha_context.Sc_rollup.Game.pp_game_result - result) - Data_encoding.( - obj1 - (req - "result" - Protocol.Alpha_context.Sc_rollup.Game.game_result_encoding)) - (function Lost_game result -> Some result | _ -> None) - (fun result -> Lost_game result) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.invalid_genesis_state" - ~title:"Invalid genesis state" - ~description: - "The rollup node computed an invalid genesis state, it cannot continue." - ~pp:(fun ppf (expected, actual) -> - Format.fprintf - ppf - "Genesis commitment computed (%a) is not equal to the rollup genesis \ - (%a) commitment. Please report the bug." - Sc_rollup.Commitment.Hash.pp - expected - Sc_rollup.Commitment.Hash.pp - actual) - Data_encoding.( - obj2 - (req - "expected" - Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding) - (req "actual" Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding)) - (function - | Invalid_genesis_state {expected; actual} -> Some (expected, actual) - | _ -> None) - (fun (expected, actual) -> Invalid_genesis_state {expected; actual}) ; - - register_error_kind - ~id:"sc_rollup.node.no_batcher" - ~title:"No batcher for this node" - ~description:"This node does not have a batcher" - ~pp:(fun ppf () -> - Format.fprintf ppf "This rollup node does not have batcher.") - `Permanent - Data_encoding.unit - (function No_batcher -> Some () | _ -> None) - (fun () -> No_batcher) ; - - register_error_kind - ~id:"sc_rollup.node.no_publisher" - ~title:"No publisher for this node" - ~description:"This node does not have an operator to publish commitments" - ~pp:(fun ppf () -> - Format.fprintf - ppf - "This rollup node does not have an operator to publish commitments.") - `Permanent - Data_encoding.unit - (function No_publisher -> Some () | _ -> None) - (fun () -> No_publisher) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_coordinator" - ~title:"No refutation coordinator for this node" - ~description:"This node does not have a refutation game coordinator" - ~pp:(fun ppf () -> - Format.fprintf ppf "This node does not have a refutation game coordinator") - `Permanent - Data_encoding.unit - (function No_refutation_coordinator -> Some () | _ -> None) - (fun () -> No_refutation_coordinator) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_player" - ~title:"A refutation player failed to start" - ~description:"A refutation player failed to start" - ~pp:(fun ppf () -> - Format.fprintf ppf "A refutation player failed to start.") - `Permanent - Data_encoding.unit - (function Refutation_player_failed_to_start -> Some () | _ -> None) - (fun () -> Refutation_player_failed_to_start) ; - - register_error_kind - `Permanent - ~id:"could_not_acquire_lock" - ~title:"Could not acquire lock on data dir" - ~description:"Could not acquire lock on data dir." - ~pp:(fun ppf f -> - Format.fprintf - ppf - "Could not acquire lock on data directory, another rollup node may \ - already be running with this data. If this is not the case, consider \ - removing manually the file %S" - f) - Data_encoding.(obj1 (req "lock_file" string)) - (function Could_not_acquire_lock f -> Some f | _ -> None) - (fun f -> Could_not_acquire_lock f) diff --git a/src/proto_018_Proxford/lib_sc_rollup_client/dune b/src/proto_018_Proxford/lib_sc_rollup_client/dune index 1c515c1b461ef5b137f4fe1b582f6f16c2bf6ffb..3253c29a92e780d8ed200aa03248fbf318a3e97f 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_client/dune +++ b/src/proto_018_Proxford/lib_sc_rollup_client/dune @@ -12,6 +12,7 @@ tezos-client-base tezos-client-base-unix tezos-client-018-Proxford + octez-smart-rollup tezos-smart-rollup-018-Proxford tezos-smart-rollup-layer2-018-Proxford) (flags @@ -24,5 +25,6 @@ -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_018_Proxford + -open Octez_smart_rollup -open Tezos_smart_rollup_018_Proxford -open Tezos_smart_rollup_layer2_018_Proxford)) diff --git a/src/proto_018_Proxford/lib_sc_rollup_layer2/error.ml b/src/proto_018_Proxford/lib_sc_rollup_layer2/error.ml deleted file mode 100644 index 1531f5fd9d70d630f62098d3a8afe4118dc2708d..0000000000000000000000000000000000000000 --- a/src/proto_018_Proxford/lib_sc_rollup_layer2/error.ml +++ /dev/null @@ -1,35 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -let trace_lwt_with x = - let open Error_monad.Legacy_monad_globals in - Format.kasprintf - (fun s p -> trace (Exn (Failure s)) @@ protect @@ fun () -> p >>= return) - x - -let trace_lwt_result_with x = - Format.kasprintf - (fun s p -> trace (Exn (Failure s)) @@ protect @@ fun () -> p) - x diff --git a/src/proto_018_Proxford/lib_sc_rollup_layer2/error.mli b/src/proto_018_Proxford/lib_sc_rollup_layer2/error.mli deleted file mode 100644 index cf68299bd9ef089267ef049d679eef262b6740d4..0000000000000000000000000000000000000000 --- a/src/proto_018_Proxford/lib_sc_rollup_layer2/error.mli +++ /dev/null @@ -1,31 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -val trace_lwt_with : - ('a, Format.formatter, unit, 'b Lwt.t -> 'b tzresult Lwt.t) format4 -> 'a - -val trace_lwt_result_with : - ('a, Format.formatter, unit, 'b tzresult Lwt.t -> 'b tzresult Lwt.t) format4 -> - 'a diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/daemon.ml b/src/proto_018_Proxford/lib_sc_rollup_node/daemon.ml index bf66812a90f44752f0a8dcabb3c41ad80a019f7a..17d3c733c5810ef251af9f0e329d9122ca27def9 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/daemon.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/daemon.ml @@ -155,21 +155,21 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_cement _, Sc_rollup_cement_result {inbox_level; commitment_hash; _} ) -> (* Cemented commitment ---------------------------------------------- *) + let proto_inbox_level = inbox_level in + let proto_commitment_hash = commitment_hash in + let inbox_level = Raw_level.to_int32 inbox_level in + let commitment_hash = + Sc_rollup_proto_types.Commitment_hash.to_octez commitment_hash + in let* inbox_block = - Node_context.get_l2_block_by_level - node_ctxt - (Raw_level.to_int32 inbox_level) + Node_context.get_l2_block_by_level node_ctxt inbox_level in let*? () = (* We stop the node if we disagree with a cemented commitment *) - let our_commitment_hash = - Option.map - Sc_rollup_proto_types.Commitment_hash.of_octez - inbox_block.header.commitment_hash - in + let our_commitment_hash = inbox_block.header.commitment_hash in error_unless (Option.equal - Sc_rollup.Commitment.Hash.( = ) + Octez_smart_rollup.Commitment.Hash.( = ) our_commitment_hash (Some commitment_hash)) (Sc_rollup_node_errors.Disagree_with_cemented @@ -177,13 +177,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in let lcc = Reference.get node_ctxt.lcc in let*! () = - if Raw_level.(inbox_level > lcc.level) then ( + if inbox_level > Raw_level.to_int32 lcc.level then ( Reference.set node_ctxt.lcc - {commitment = commitment_hash; level = inbox_level} ; + {commitment = proto_commitment_hash; level = proto_inbox_level} ; Commitment_event.last_cemented_commitment_updated - commitment_hash - inbox_level) + proto_commitment_hash + proto_inbox_level) else Lwt.return_unit in return_unit @@ -192,8 +192,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; _} when Node_context.is_operator node_ctxt loser -> - tzfail (Sc_rollup_node_errors.Lost_game end_status) + | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + let result = + match reason with + | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved + | Timeout -> Timeout + in + tzfail (Sc_rollup_node_errors.Lost_game result) | Loser _ -> (* Other player lost *) return_unit @@ -206,7 +211,7 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in fail_when (List.exists (Node_context.is_operator node_ctxt) stakers) - (Sc_rollup_node_errors.Lost_game end_status)) + (Sc_rollup_node_errors.Lost_game Draw)) | Dal_publish_slot_header _, Dal_publish_slot_header_result {slot_header; _} when Node_context.dal_supported node_ctxt -> let* () = @@ -243,7 +248,20 @@ let process_l1_operation (type kind) node_ctxt (head : Layer1.header) ~source if not (is_for_my_rollup operation) then return_unit else (* Only look at operations that are for the node's rollup *) - let*! () = Daemon_event.included_operation operation result in + let*! () = + match Sc_rollup_injector.injector_operation_of_manager operation with + | None -> Lwt.return_unit + | Some op -> + let status, errors = + match result with + | Applied _ -> (`Applied, None) + | Backtracked (_, e) -> + (`Backtracked, Option.map Environment.wrap_tztrace e) + | Failed (_, e) -> (`Failed, Some (Environment.wrap_tztrace e)) + | Skipped _ -> (`Skipped, None) + in + Daemon_event.included_operation ?errors status op + in match result with | Applied success_result -> process_included_l1_operation @@ -390,7 +408,10 @@ let rec process_head (daemon_components : (module Daemon_components.S)) in let* () = unless (catching_up && Option.is_none commitment_hash) @@ fun () -> - Inbox.same_as_layer_1 node_ctxt head.hash inbox + Inbox.same_as_layer_1 + node_ctxt + head.hash + (Sc_rollup_proto_types.Inbox.to_octez inbox) in let level = Raw_level.of_int32_exn head.level in let* previous_commitment_hash = @@ -564,8 +585,14 @@ let check_initial_state_hash {Node_context.cctxt; rollup_address; pvm; _} = in let*! s = PVM.initial_state ~empty:(PVM.State.empty ()) in let*! l2_initial_state_hash = PVM.state_hash s in + let l1_reference_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l1_reference_initial_state_hash + in + let l2_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l2_initial_state_hash + in fail_unless - Sc_rollup.State_hash.( + Octez_smart_rollup.State_hash.( l1_reference_initial_state_hash = l2_initial_state_hash) (Sc_rollup_node_errors.Wrong_initial_pvm_state { @@ -759,7 +786,7 @@ let run ()) configuration.sc_rollup_node_operators in - let*! () = Event.waiting_first_block () in + let*! () = Event.waiting_first_block Protocol.hash in let* l1_ctxt = Layer1.start ~name:"sc_rollup_node" @@ -773,7 +800,7 @@ let run let* predecessor = Layer1.fetch_tezos_shell_header l1_ctxt head.header.predecessor in - let*! () = Event.received_first_block head.hash in + let*! () = Event.received_first_block head.hash Protocol.hash in let* node_ctxt = Node_context.init cctxt diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/daemon_event.mli b/src/proto_018_Proxford/lib_sc_rollup_node/daemon_event.mli deleted file mode 100644 index 7feacd3b3f8b9c142c9498a6eb01f407e17a11fb..0000000000000000000000000000000000000000 --- a/src/proto_018_Proxford/lib_sc_rollup_node/daemon_event.mli +++ /dev/null @@ -1,58 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used by the smart - rollup node daemon (see {!Daemon}). *) - -(** [head_processing hash level] emits the event that the - block of the given [hash] and at the given [level] is being processed. *) -val head_processing : Block_hash.t -> int32 -> unit Lwt.t - -(** [new_head_processed hash level process_time] emits the event that the daemon - has finished processing the head of the given [hash] and at the given - [level] in [process_time] seconds. *) -val new_head_processed : Block_hash.t -> int32 -> Ptime.Span.t -> unit Lwt.t - -(** [processing_heads_iteration heads] emits the event that the [heads] are - going to be processed. *) -val processing_heads_iteration : Layer1.head list -> unit Lwt.t - -(** [new_heads_processed heads] emits the event that the [heads] were - processed. *) -val new_heads_processed : Layer1.head list -> unit Lwt.t - -(** [included_operation op result] emits an event that an operation - for the rollup was included in a block. *) -val included_operation : - 'kind Protocol.Alpha_context.manager_operation -> - 'kind Protocol.Apply_results.manager_operation_result -> - unit Lwt.t - -(** Emit a fatal error for the daemon. *) -val error : tztrace -> unit Lwt.t - -(** Emit an event for when the node enters the degraded mode to only play - refutations. *) -val degraded_mode : unit -> unit Lwt.t diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/event.ml b/src/proto_018_Proxford/lib_sc_rollup_node/event.ml deleted file mode 100644 index c35631692bfb4f5e25e70842121564d11c104555..0000000000000000000000000000000000000000 --- a/src/proto_018_Proxford/lib_sc_rollup_node/event.ml +++ /dev/null @@ -1,208 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2021 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = [Protocol.name; "smart_rollup_node"] - - let starting_node = - declare_0 - ~section - ~name:"starting_smart_rollup_node" - ~msg:"Starting the smart rollup node" - ~level:Notice - () - - let shutdown_node = - declare_1 - ~section - ~name:"stopping_smart_rollup_node" - ~msg:"Stopping the smart rollup node" - ~level:Notice - ("exit_status", Data_encoding.int8) - - let node_is_ready = - declare_2 - ~section - ~name:"smart_rollup_node_is_ready" - ~msg:"The smart rollup node is listening to {addr}:{port}" - ~level:Notice - ("addr", Data_encoding.string) - ("port", Data_encoding.uint16) - - let rollup_exists = - declare_2 - ~section - ~name:"smart_rollup_node_knows_its_rollup" - ~msg: - "The smart rollup node is interacting with rollup {addr} of kind {kind}" - ~level:Notice - ("addr", Protocol.Alpha_context.Sc_rollup.Address.encoding) - ("kind", Data_encoding.string) - - let connection_lost = - declare_0 - ~section - ~name:"smart_rollup_daemon_connection_lost" - ~msg:"connection to the node has been lost" - ~level:Warning - () - - let cannot_connect = - declare_2 - ~section - ~name:"smart_rollup_daemon_cannot_connect" - ~msg:"cannot connect to Tezos node ({count}) {error}" - ~level:Warning - ("count", Data_encoding.int31) - ("error", trace_encoding) - ~pp2:pp_print_trace - - let wait_reconnect = - declare_1 - ~section - ~name:"smart_rollup_daemon_wait_reconnect" - ~msg:"Retrying to connect in {delay}s" - ~level:Warning - ("delay", Data_encoding.float) - - let starting_metrics_server = - declare_2 - ~section - ~name:"starting_metrics_server" - ~msg:"starting metrics server on {host}:{port}" - ~level:Notice - ("host", Data_encoding.string) - ("port", Data_encoding.uint16) - - let metrics_ended = - declare_1 - ~section - ~name:"metrics_ended" - ~level:Error - ~msg:"metrics server ended with error {stacktrace}" - ("stacktrace", Data_encoding.string) - - let kernel_debug = - declare_1 - ~section - ~name:"kernel_debug" - ~level:Info - ~msg:"{log}" - ("log", Data_encoding.string) - ~pp1:Format.pp_print_string - - let warn_dal_enabled_no_node = - declare_0 - ~section - ~name:"dal_enabled_no_node" - ~level:Warning - ~msg: - "Warning: DAL is enabled in the protocol but no DAL node was provided \ - for the rollup node." - () - - let waiting_first_block = - declare_0 - ~section - ~name:"waiting_first_block" - ~level:Notice - ~msg: - (Format.asprintf - "Waiting for first block of protocol %a to appear." - Protocol_hash.pp - Protocol.hash) - () - - let received_first_block = - declare_1 - ~section - ~name:"received_first_block" - ~level:Notice - ~msg: - (Format.asprintf - "First block of protocol %a received: {block}." - Protocol_hash.pp - Protocol.hash) - ("block", Block_hash.encoding) - - let detected_protocol_migration = - declare_0 - ~section - ~name:"detected_protocol_migration" - ~level:Notice - ~msg:"Detected protocol migration, the rollup node will now stop." - () - - let acquiring_lock = - declare_0 - ~section - ~name:"acquiring_lock" - ~level:Notice - ~msg:"Acquiring lock on data directory." - () -end - -let starting_node = Simple.(emit starting_node) - -let shutdown_node exit_status = Simple.(emit shutdown_node exit_status) - -let node_is_ready ~rpc_addr ~rpc_port = - Simple.(emit node_is_ready (rpc_addr, rpc_port)) - -let rollup_exists ~addr ~kind = - let kind = Protocol.Alpha_context.Sc_rollup.Kind.to_string kind in - Simple.(emit rollup_exists (addr, kind)) - -let connection_lost () = Simple.(emit connection_lost) () - -let cannot_connect ~count error = Simple.(emit cannot_connect) (count, error) - -let wait_reconnect delay = Simple.(emit wait_reconnect) delay - -let starting_metrics_server ~host ~port = - Simple.(emit starting_metrics_server) (host, port) - -let metrics_ended error = Simple.(emit metrics_ended) error - -let metrics_ended_dont_wait error = - Simple.(emit__dont_wait__use_with_care metrics_ended) error - -let kernel_debug msg = Simple.(emit kernel_debug) msg - -let kernel_debug_dont_wait msg = - Simple.(emit__dont_wait__use_with_care kernel_debug) msg - -let warn_dal_enabled_no_node () = Simple.(emit warn_dal_enabled_no_node) () - -let waiting_first_block () = Simple.(emit waiting_first_block) () - -let received_first_block b = Simple.(emit received_first_block) b - -let detected_protocol_migration () = - Simple.(emit detected_protocol_migration) () - -let acquiring_lock () = Simple.(emit acquiring_lock) () diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/inbox.ml b/src/proto_018_Proxford/lib_sc_rollup_node/inbox.ml index d711228ed16683fefcb1fd7f450fbcd2e9b2eb44..a99e1218bca8f3c9da87f441236e7813ed00269e 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/inbox.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/inbox.ml @@ -87,8 +87,9 @@ let same_as_layer_1 node_ctxt head_hash inbox = let* layer1_inbox = Plugin.RPC.Sc_rollup.inbox cctxt (cctxt#chain, head_block) in + let layer1_inbox = Sc_rollup_proto_types.Inbox.to_octez layer1_inbox in fail_unless - (Sc_rollup.Inbox.equal layer1_inbox inbox) + (Octez_smart_rollup.Inbox.equal layer1_inbox inbox) (Sc_rollup_node_errors.Inconsistent_inbox {layer1_inbox; inbox}) let add_messages ~is_first_block ~predecessor_timestamp ~predecessor inbox diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/inbox.mli b/src/proto_018_Proxford/lib_sc_rollup_node/inbox.mli index 95408d9c74f7267643793668ff6f4603c53038b1..fed5e050307197bc341897206891a4f574a5cef0 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/inbox.mli +++ b/src/proto_018_Proxford/lib_sc_rollup_node/inbox.mli @@ -85,7 +85,10 @@ val payloads_history_of_messages : (** [same_as_layer_1 node_ctxt block node_inbox] ensures that the rollup node agrees with the L1 node that inbox for [block] is [node_inbox]. *) val same_as_layer_1 : - _ Node_context.t -> Block_hash.t -> Sc_rollup.Inbox.t -> unit tzresult Lwt.t + _ Node_context.t -> + Block_hash.t -> + Octez_smart_rollup.Inbox.t -> + unit tzresult Lwt.t (**/**) diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/node_context.ml b/src/proto_018_Proxford/lib_sc_rollup_node/node_context.ml index cf10bbfed4858b6f0b5636bd3098c95e932a2e11..757c35a0aa3e0f18d54ca0626836ff54f66d1204 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/node_context.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/node_context.ml @@ -314,7 +314,11 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file and* genesis_info = RPC.Sc_rollup.genesis_info cctxt (cctxt#chain, cctxt#block) rollup_address in - let*! () = Event.rollup_exists ~addr:rollup_address ~kind in + let*! () = + Event.rollup_exists + ~addr:rollup_address + ~kind:(Sc_rollup_proto_types.Kind.to_octez kind) + in let*! () = if dal_cctxt = None && protocol_constants.parametric.dal.feature_enable then Event.warn_dal_enabled_no_node () diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game.ml b/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game.ml index fdd814a08990b1e95b996d53b7f16621d84c9198..d62b831205cfdeeb1ca9f61122377eeb62b9344a 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game.ml @@ -272,8 +272,14 @@ let generate_proof (node_ctxt : _ Node_context.t) game start_state = end end in let metadata = Node_context.metadata node_ctxt in + let*! start_tick = PVM.get_tick start_state in let* proof = - trace (Sc_rollup_node_errors.Cannot_produce_proof game) + trace + (Sc_rollup_node_errors.Cannot_produce_proof + { + inbox_level = Raw_level.to_int32 game.inbox_level; + start_tick = Sc_rollup.Tick.to_z start_tick; + }) @@ (Sc_rollup.Proof.produce ~metadata (module P) game.inbox_level >|= Environment.wrap_tzresult) in diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_node_errors.ml b/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_node_errors.ml index 2949749abd34e12b06f4322e5f4299a3a402720c..bf57c29eda9b498b56c5e7775eb30e5caaaf9e3e 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_node_errors.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/sc_rollup_node_errors.ml @@ -1,7 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -23,329 +24,10 @@ (* *) (*****************************************************************************) -open Protocol.Alpha_context +include Rollup_node_errors + +(** Registering protocol specific errors *) let make_id id = String.concat "." [Protocol.name; id] let register_error_kind ~id = register_error_kind ~id:(make_id id) - -type error += - | Cannot_produce_proof of Sc_rollup.Game.t - | Bad_minimal_fees of string - | Disagree_with_cemented of { - inbox_level : Raw_level.t; - ours : Sc_rollup.Commitment.Hash.t option; - on_l1 : Sc_rollup.Commitment.Hash.t; - } - | Unreliable_tezos_node_returning_inconsistent_game - | Wrong_initial_pvm_state of { - initial_state_hash : Sc_rollup.State_hash.t; - expected_state_hash : Sc_rollup.State_hash.t; - } - | Inconsistent_inbox of { - layer1_inbox : Sc_rollup.Inbox.t; - inbox : Sc_rollup.Inbox.t; - } - | Missing_PVM_state of Block_hash.t * Int32.t - | Cannot_checkout_context of Block_hash.t * Smart_rollup_context_hash.t option - | No_batcher - | No_publisher - | Refutation_player_failed_to_start - | No_refutation_coordinator - | Could_not_acquire_lock of string - -type error += - | Lost_game of Protocol.Alpha_context.Sc_rollup.Game.game_result - | Unparsable_boot_sector of {path : string} - | Invalid_genesis_state of { - expected : Sc_rollup.Commitment.Hash.t; - actual : Sc_rollup.Commitment.Hash.t; - } - -let () = - register_error_kind - `Permanent - ~id:"bad_minimal_fees_arg" - ~title:"Bad -minimal-fees arg" - ~description:"invalid fee threshold in -fee-threshold" - ~pp:(fun ppf literal -> - Format.fprintf ppf "invalid minimal fees '%s'" literal) - Data_encoding.(obj1 (req "parameter" string)) - (function Bad_minimal_fees parameter -> Some parameter | _ -> None) - (fun parameter -> Bad_minimal_fees parameter) ; - - register_error_kind - `Permanent - ~id:"internal.node_disagrees_with_cemented" - ~title:"Internal error: The node disagrees with a cemented commitment on L1" - ~description: - "Internal error: The node disagrees with a cemented commitment on L1" - ~pp:(fun ppf (inbox_level, ours, on_l1) -> - Format.fprintf - ppf - "Internal error: The node has commitment %a for inbox level %a but \ - this level is cemented on L1 with commitment %a" - (Format.pp_print_option - ~none:(fun ppf () -> Format.pp_print_string ppf "[None]") - Sc_rollup.Commitment.Hash.pp) - ours - Raw_level.pp - inbox_level - Sc_rollup.Commitment.Hash.pp - on_l1) - Data_encoding.( - obj3 - (req "inbox_level" Raw_level.encoding) - (req "ours" (option Sc_rollup.Commitment.Hash.encoding)) - (req "on_l1" Sc_rollup.Commitment.Hash.encoding)) - (function - | Disagree_with_cemented {inbox_level; ours; on_l1} -> - Some (inbox_level, ours, on_l1) - | _ -> None) - (fun (inbox_level, ours, on_l1) -> - Disagree_with_cemented {inbox_level; ours; on_l1}) ; - - let description = - "Internal error: The game invariant states that the dissection from the \ - opponent must contain a tick we disagree with. If the retrieved game does \ - not respect this, we cannot trust the Tezos node we are connected to and \ - prefer to stop here." - in - register_error_kind - `Permanent - ~id:"internal.unreliable_tezos_node" - ~title:"Internal error: Tezos node seems unreliable" - ~description - ~pp:(fun ppf () -> - Format.fprintf ppf "Unreliable Tezos node. %s" description) - Data_encoding.unit - (function - | Unreliable_tezos_node_returning_inconsistent_game -> Some () | _ -> None) - (fun () -> Unreliable_tezos_node_returning_inconsistent_game) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_produce_proof" - ~title:"Internal error: rollup node cannot produce refutation proof" - ~description: - "The rollup node is in a state that prevents it from producing \ - refutation proofs." - ~pp:(fun ppf game -> - Format.fprintf - ppf - "cannot produce proof for game %a" - Sc_rollup.Game.pp - game) - Data_encoding.(obj1 (req "game" Sc_rollup.Game.encoding)) - (function Cannot_produce_proof game -> Some game | _ -> None) - (fun game -> Cannot_produce_proof game) ; - - register_error_kind - ~id:"sc_rollup.node.Wrong_initial_pvm_state" - ~title:"Initial state produced by PVM is incorrect" - ~description:"Initial state produced by PVM is incorrect." - ~pp:(fun ppf (actual, expected) -> - Format.fprintf - ppf - "The initial state hash produced by the PVM %a is not consistent\n\ - \ with the one expected by the Layer 1 PVM implementation %a" - Sc_rollup.State_hash.pp - actual - Sc_rollup.State_hash.pp - expected) - `Permanent - Data_encoding.( - obj2 - (req "initial_state_hash" Sc_rollup.State_hash.encoding) - (req "expected_state_hash" Sc_rollup.State_hash.encoding)) - (function - | Wrong_initial_pvm_state {initial_state_hash; expected_state_hash} -> - Some (initial_state_hash, expected_state_hash) - | _ -> None) - (fun (initial_state_hash, expected_state_hash) -> - Wrong_initial_pvm_state {initial_state_hash; expected_state_hash}) ; - - register_error_kind - ~id:"internal.inconsistent_inbox" - ~title:"Internal error: Rollup node has an inconsistent inbox" - ~description: - "The rollup node inbox should be the same as the layer 1 inbox." - ~pp:(fun ppf (layer1_inbox, inbox) -> - Format.fprintf - ppf - "@[Rollup inbox:@;%a@]@;should be equal to @[Layer1 inbox:@;%a@]" - Sc_rollup.Inbox.pp - inbox - Sc_rollup.Inbox.pp - layer1_inbox) - `Permanent - Data_encoding.( - obj2 - (req "layer1_inbox" Sc_rollup.Inbox.encoding) - (req "inbox" Sc_rollup.Inbox.encoding)) - (function - | Inconsistent_inbox {layer1_inbox; inbox} -> Some (layer1_inbox, inbox) - | _ -> None) - (fun (layer1_inbox, inbox) -> Inconsistent_inbox {layer1_inbox; inbox}) ; - - register_error_kind - `Permanent - ~id:"internal.missing_pvm_state" - ~title:"Internal error: Missing PVM state" - ~description:"The rollup node cannot retrieve the state of the PVM." - ~pp:(fun ppf (block, level) -> - Format.fprintf - ppf - "Cannot retrieve PVM state for block %a at level %ld" - Block_hash.pp - block - level) - Data_encoding.(obj2 (req "block" Block_hash.encoding) (req "level" int32)) - (function - | Missing_PVM_state (block, level) -> Some (block, level) | _ -> None) - (fun (block, level) -> Missing_PVM_state (block, level)) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_checkout_context" - ~title:"Internal error: Cannot checkout context" - ~description: - "The rollup node cannot checkout the context registered for the block." - ~pp:(fun ppf (block, context_hash) -> - Format.fprintf - ppf - "The context %sfor block %a cannot be checkouted" - (Option.fold - ~none:"" - ~some:Smart_rollup_context_hash.to_b58check - context_hash) - Block_hash.pp - block) - Data_encoding.( - obj2 - (req "block" Block_hash.encoding) - (opt "context" Smart_rollup_context_hash.encoding)) - (function - | Cannot_checkout_context (block, context) -> Some (block, context) - | _ -> None) - (fun (block, context) -> Cannot_checkout_context (block, context)) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.lost_game" - ~title:"Lost refutation game" - ~description:"The rollup node lost a refutation game." - ~pp:(fun ppf result -> - Format.fprintf - ppf - "The rollup node lost the refutation game (%a)" - Protocol.Alpha_context.Sc_rollup.Game.pp_game_result - result) - Data_encoding.( - obj1 - (req - "result" - Protocol.Alpha_context.Sc_rollup.Game.game_result_encoding)) - (function Lost_game result -> Some result | _ -> None) - (fun result -> Lost_game result) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.unparsable_boot_sector" - ~title:"Unparsable boot sector" - ~description:"The boot sector provided is not parsable by the PVM." - ~pp:(fun ppf path -> - Format.fprintf ppf "The boot sector at path %S is unparsable" path) - Data_encoding.(obj1 (req "path" string)) - (function Unparsable_boot_sector {path} -> Some path | _ -> None) - (fun path -> Unparsable_boot_sector {path}) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.invalid_genesis_state" - ~title:"Invalid genesis state" - ~description: - "The rollup node computed an invalid genesis state, it cannot continue." - ~pp:(fun ppf (expected, actual) -> - Format.fprintf - ppf - "Genesis commitment computed (%a) is not equal to the rollup genesis \ - (%a) commitment. The rollup node cannot continue. If you used the \ - argument `--boot-sector-file` you probably provided the wrong boot \ - sector. If not, please report the bug." - Sc_rollup.Commitment.Hash.pp - expected - Sc_rollup.Commitment.Hash.pp - actual) - Data_encoding.( - obj2 - (req - "expected" - Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding) - (req "actual" Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding)) - (function - | Invalid_genesis_state {expected; actual} -> Some (expected, actual) - | _ -> None) - (fun (expected, actual) -> Invalid_genesis_state {expected; actual}) ; - - register_error_kind - ~id:"sc_rollup.node.no_batcher" - ~title:"No batcher for this node" - ~description:"This node does not have a batcher" - ~pp:(fun ppf () -> - Format.fprintf ppf "This rollup node does not have batcher.") - `Permanent - Data_encoding.unit - (function No_batcher -> Some () | _ -> None) - (fun () -> No_batcher) ; - - register_error_kind - ~id:"sc_rollup.node.no_publisher" - ~title:"No publisher for this node" - ~description:"This node does not have an operator to publish commitments" - ~pp:(fun ppf () -> - Format.fprintf - ppf - "This rollup node does not have an operator to publish commitments.") - `Permanent - Data_encoding.unit - (function No_publisher -> Some () | _ -> None) - (fun () -> No_publisher) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_coordinator" - ~title:"No refutation coordinator for this node" - ~description:"This node does not have a refutation game coordinator" - ~pp:(fun ppf () -> - Format.fprintf ppf "This node does not have a refutation game coordinator") - `Permanent - Data_encoding.unit - (function No_refutation_coordinator -> Some () | _ -> None) - (fun () -> No_refutation_coordinator) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_player" - ~title:"A refutation player failed to start" - ~description:"A refutation player failed to start" - ~pp:(fun ppf () -> - Format.fprintf ppf "A refutation player failed to start.") - `Permanent - Data_encoding.unit - (function Refutation_player_failed_to_start -> Some () | _ -> None) - (fun () -> Refutation_player_failed_to_start) ; - - register_error_kind - `Permanent - ~id:"could_not_acquire_lock" - ~title:"Could not acquire lock on data dir" - ~description:"Could not acquire lock on data dir." - ~pp:(fun ppf f -> - Format.fprintf - ppf - "Could not acquire lock on data directory, another rollup node may \ - already be running with this data. If this is not the case, consider \ - removing manually the file %S" - f) - Data_encoding.(obj1 (req "lock_file" string)) - (function Could_not_acquire_lock f -> Some f | _ -> None) - (fun f -> Could_not_acquire_lock f) diff --git a/src/proto_alpha/lib_sc_rollup_client/dune b/src/proto_alpha/lib_sc_rollup_client/dune index c04fc5e10fcf1a849d384e94a73441725f9cdbe7..0522715ac7cc0201073a5abdffd0f5b38e80ba58 100644 --- a/src/proto_alpha/lib_sc_rollup_client/dune +++ b/src/proto_alpha/lib_sc_rollup_client/dune @@ -12,6 +12,7 @@ tezos-client-base tezos-client-base-unix tezos-client-alpha + octez-smart-rollup tezos-smart-rollup-alpha tezos-smart-rollup-layer2-alpha) (flags @@ -24,5 +25,6 @@ -open Tezos_client_base -open Tezos_client_base_unix -open Tezos_client_alpha + -open Octez_smart_rollup -open Tezos_smart_rollup_alpha -open Tezos_smart_rollup_layer2_alpha)) diff --git a/src/proto_alpha/lib_sc_rollup_layer2/error.ml b/src/proto_alpha/lib_sc_rollup_layer2/error.ml deleted file mode 100644 index 1531f5fd9d70d630f62098d3a8afe4118dc2708d..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_sc_rollup_layer2/error.ml +++ /dev/null @@ -1,35 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -let trace_lwt_with x = - let open Error_monad.Legacy_monad_globals in - Format.kasprintf - (fun s p -> trace (Exn (Failure s)) @@ protect @@ fun () -> p >>= return) - x - -let trace_lwt_result_with x = - Format.kasprintf - (fun s p -> trace (Exn (Failure s)) @@ protect @@ fun () -> p) - x diff --git a/src/proto_alpha/lib_sc_rollup_layer2/error.mli b/src/proto_alpha/lib_sc_rollup_layer2/error.mli deleted file mode 100644 index cf68299bd9ef089267ef049d679eef262b6740d4..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_sc_rollup_layer2/error.mli +++ /dev/null @@ -1,31 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -val trace_lwt_with : - ('a, Format.formatter, unit, 'b Lwt.t -> 'b tzresult Lwt.t) format4 -> 'a - -val trace_lwt_result_with : - ('a, Format.formatter, unit, 'b tzresult Lwt.t -> 'b tzresult Lwt.t) format4 -> - 'a diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon.ml b/src/proto_alpha/lib_sc_rollup_node/daemon.ml index bf66812a90f44752f0a8dcabb3c41ad80a019f7a..17d3c733c5810ef251af9f0e329d9122ca27def9 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon.ml +++ b/src/proto_alpha/lib_sc_rollup_node/daemon.ml @@ -155,21 +155,21 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_cement _, Sc_rollup_cement_result {inbox_level; commitment_hash; _} ) -> (* Cemented commitment ---------------------------------------------- *) + let proto_inbox_level = inbox_level in + let proto_commitment_hash = commitment_hash in + let inbox_level = Raw_level.to_int32 inbox_level in + let commitment_hash = + Sc_rollup_proto_types.Commitment_hash.to_octez commitment_hash + in let* inbox_block = - Node_context.get_l2_block_by_level - node_ctxt - (Raw_level.to_int32 inbox_level) + Node_context.get_l2_block_by_level node_ctxt inbox_level in let*? () = (* We stop the node if we disagree with a cemented commitment *) - let our_commitment_hash = - Option.map - Sc_rollup_proto_types.Commitment_hash.of_octez - inbox_block.header.commitment_hash - in + let our_commitment_hash = inbox_block.header.commitment_hash in error_unless (Option.equal - Sc_rollup.Commitment.Hash.( = ) + Octez_smart_rollup.Commitment.Hash.( = ) our_commitment_hash (Some commitment_hash)) (Sc_rollup_node_errors.Disagree_with_cemented @@ -177,13 +177,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in let lcc = Reference.get node_ctxt.lcc in let*! () = - if Raw_level.(inbox_level > lcc.level) then ( + if inbox_level > Raw_level.to_int32 lcc.level then ( Reference.set node_ctxt.lcc - {commitment = commitment_hash; level = inbox_level} ; + {commitment = proto_commitment_hash; level = proto_inbox_level} ; Commitment_event.last_cemented_commitment_updated - commitment_hash - inbox_level) + proto_commitment_hash + proto_inbox_level) else Lwt.return_unit in return_unit @@ -192,8 +192,13 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) | ( Sc_rollup_timeout _, Sc_rollup_timeout_result {game_status = Ended end_status; _} ) -> ( match end_status with - | Loser {loser; _} when Node_context.is_operator node_ctxt loser -> - tzfail (Sc_rollup_node_errors.Lost_game end_status) + | Loser {loser; reason} when Node_context.is_operator node_ctxt loser -> + let result = + match reason with + | Conflict_resolved -> Sc_rollup_node_errors.Conflict_resolved + | Timeout -> Timeout + in + tzfail (Sc_rollup_node_errors.Lost_game result) | Loser _ -> (* Other player lost *) return_unit @@ -206,7 +211,7 @@ let process_included_l1_operation (type kind) (node_ctxt : Node_context.rw) in fail_when (List.exists (Node_context.is_operator node_ctxt) stakers) - (Sc_rollup_node_errors.Lost_game end_status)) + (Sc_rollup_node_errors.Lost_game Draw)) | Dal_publish_slot_header _, Dal_publish_slot_header_result {slot_header; _} when Node_context.dal_supported node_ctxt -> let* () = @@ -243,7 +248,20 @@ let process_l1_operation (type kind) node_ctxt (head : Layer1.header) ~source if not (is_for_my_rollup operation) then return_unit else (* Only look at operations that are for the node's rollup *) - let*! () = Daemon_event.included_operation operation result in + let*! () = + match Sc_rollup_injector.injector_operation_of_manager operation with + | None -> Lwt.return_unit + | Some op -> + let status, errors = + match result with + | Applied _ -> (`Applied, None) + | Backtracked (_, e) -> + (`Backtracked, Option.map Environment.wrap_tztrace e) + | Failed (_, e) -> (`Failed, Some (Environment.wrap_tztrace e)) + | Skipped _ -> (`Skipped, None) + in + Daemon_event.included_operation ?errors status op + in match result with | Applied success_result -> process_included_l1_operation @@ -390,7 +408,10 @@ let rec process_head (daemon_components : (module Daemon_components.S)) in let* () = unless (catching_up && Option.is_none commitment_hash) @@ fun () -> - Inbox.same_as_layer_1 node_ctxt head.hash inbox + Inbox.same_as_layer_1 + node_ctxt + head.hash + (Sc_rollup_proto_types.Inbox.to_octez inbox) in let level = Raw_level.of_int32_exn head.level in let* previous_commitment_hash = @@ -564,8 +585,14 @@ let check_initial_state_hash {Node_context.cctxt; rollup_address; pvm; _} = in let*! s = PVM.initial_state ~empty:(PVM.State.empty ()) in let*! l2_initial_state_hash = PVM.state_hash s in + let l1_reference_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l1_reference_initial_state_hash + in + let l2_initial_state_hash = + Sc_rollup_proto_types.State_hash.to_octez l2_initial_state_hash + in fail_unless - Sc_rollup.State_hash.( + Octez_smart_rollup.State_hash.( l1_reference_initial_state_hash = l2_initial_state_hash) (Sc_rollup_node_errors.Wrong_initial_pvm_state { @@ -759,7 +786,7 @@ let run ()) configuration.sc_rollup_node_operators in - let*! () = Event.waiting_first_block () in + let*! () = Event.waiting_first_block Protocol.hash in let* l1_ctxt = Layer1.start ~name:"sc_rollup_node" @@ -773,7 +800,7 @@ let run let* predecessor = Layer1.fetch_tezos_shell_header l1_ctxt head.header.predecessor in - let*! () = Event.received_first_block head.hash in + let*! () = Event.received_first_block head.hash Protocol.hash in let* node_ctxt = Node_context.init cctxt diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon_event.ml b/src/proto_alpha/lib_sc_rollup_node/daemon_event.ml deleted file mode 100644 index 2969126bcaabe2c9bf31d2d9030529bb9a2c8081..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_event.ml +++ /dev/null @@ -1,169 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 TriliTech *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = [Protocol.name; "sc_rollup_node"; "daemon"] - - let head_processing = - declare_2 - ~section - ~name:"sc_rollup_daemon_process_head" - ~msg:"Processing head {hash} at level {level}" - ~level:Notice - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - - let new_head_processed = - declare_3 - ~section - ~name:"sc_rollup_node_layer_1_new_head_processed" - ~msg: - "Finished processing layer 1 head {hash} at level {level} in \ - {process_time}" - ~level:Notice - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - ("process_time", Time.System.Span.encoding) - ~pp3:Ptime.Span.pp - - let processing_heads_iteration = - declare_3 - ~section - ~name:"sc_rollup_daemon_processing_heads" - ~msg: - "A new iteration of process_heads has been triggered: processing \ - {number} heads from level {from} to level {to}" - ~level:Notice - ("number", Data_encoding.int31) - ("from", Data_encoding.int32) - ("to", Data_encoding.int32) - - let new_heads_processed = - declare_3 - ~section - ~name:"sc_rollup_node_layer_1_new_heads_processed" - ~msg: - "Finished processing {number} layer 1 heads for levels {from} to {to}" - ~level:Notice - ("number", Data_encoding.int31) - ("from", Data_encoding.int32) - ("to", Data_encoding.int32) - - let included_successful_operation = - declare_1 - ~section - ~name:"sc_rollup_daemon_included_successful_operation" - ~msg:"Operation {operation} was included as successful" - ~level:Debug - ("operation", L1_operation.encoding) - ~pp1:L1_operation.pp - - let included_failed_operation = - declare_3 - ~section - ~name:"sc_rollup_daemon_included_failed_operation" - ~msg:"Operation {operation} was included as {status} with error {error}" - ~level:Warning - ("operation", L1_operation.encoding) - ( "status", - Data_encoding.( - string_enum - [ - ("failed", `Failed); - ("backtracked", `Backtracked); - ("skipped", `Skipped); - ]) ) - ("error", Data_encoding.option Environment.Error_monad.trace_encoding) - ~pp1:L1_operation.pp - ~pp3: - (fun ppf -> function - | None -> Format.pp_print_string ppf "none" - | Some e -> Environment.Error_monad.pp_trace ppf e) - - let error = - declare_1 - ~section - ~name:"sc_rollup_daemon_error" - ~msg:"Fatal daemon error: {error}" - ~level:Fatal - ("error", trace_encoding) - ~pp1:pp_print_trace - - let degraded_mode = - declare_0 - ~section - ~name:"sc_rollup_daemon_degraded_mode" - ~msg: - "Entering degraded mode: only playing refutation game to defend \ - commitments." - ~level:Error - () -end - -let head_processing hash level = Simple.(emit head_processing (hash, level)) - -let new_head_processed hash level process_time = - Simple.(emit new_head_processed (hash, level, process_time)) - -let new_heads_iteration event = function - | oldest :: rest -> - let newest = - match List.rev rest with [] -> oldest | newest :: _ -> newest - in - let number = - Int32.sub newest.Layer1.level oldest.Layer1.level - |> Int32.succ |> Int32.to_int - in - Simple.emit event (number, oldest.level, newest.level) - | [] -> Lwt.return_unit - -let processing_heads_iteration = - new_heads_iteration Simple.processing_heads_iteration - -let new_heads_processed = new_heads_iteration Simple.new_heads_processed - -let included_operation (type kind) - (operation : kind Protocol.Alpha_context.manager_operation) - (result : kind Protocol.Apply_results.manager_operation_result) = - match Sc_rollup_injector.injector_operation_of_manager operation with - | None -> Lwt.return_unit - | Some operation -> ( - match result with - | Applied _ -> Simple.(emit included_successful_operation) operation - | result -> - let status, errors = - match result with - | Applied _ -> assert false - | Failed (_, e) -> (`Failed, Some e) - | Backtracked (_, e) -> (`Backtracked, e) - | Skipped _ -> (`Skipped, None) - in - Simple.(emit included_failed_operation) (operation, status, errors)) - -let error e = Simple.(emit error) e - -let degraded_mode () = Simple.(emit degraded_mode) () diff --git a/src/proto_alpha/lib_sc_rollup_node/event.ml b/src/proto_alpha/lib_sc_rollup_node/event.ml deleted file mode 100644 index c35631692bfb4f5e25e70842121564d11c104555..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_sc_rollup_node/event.ml +++ /dev/null @@ -1,208 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2021 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module Simple = struct - include Internal_event.Simple - - let section = [Protocol.name; "smart_rollup_node"] - - let starting_node = - declare_0 - ~section - ~name:"starting_smart_rollup_node" - ~msg:"Starting the smart rollup node" - ~level:Notice - () - - let shutdown_node = - declare_1 - ~section - ~name:"stopping_smart_rollup_node" - ~msg:"Stopping the smart rollup node" - ~level:Notice - ("exit_status", Data_encoding.int8) - - let node_is_ready = - declare_2 - ~section - ~name:"smart_rollup_node_is_ready" - ~msg:"The smart rollup node is listening to {addr}:{port}" - ~level:Notice - ("addr", Data_encoding.string) - ("port", Data_encoding.uint16) - - let rollup_exists = - declare_2 - ~section - ~name:"smart_rollup_node_knows_its_rollup" - ~msg: - "The smart rollup node is interacting with rollup {addr} of kind {kind}" - ~level:Notice - ("addr", Protocol.Alpha_context.Sc_rollup.Address.encoding) - ("kind", Data_encoding.string) - - let connection_lost = - declare_0 - ~section - ~name:"smart_rollup_daemon_connection_lost" - ~msg:"connection to the node has been lost" - ~level:Warning - () - - let cannot_connect = - declare_2 - ~section - ~name:"smart_rollup_daemon_cannot_connect" - ~msg:"cannot connect to Tezos node ({count}) {error}" - ~level:Warning - ("count", Data_encoding.int31) - ("error", trace_encoding) - ~pp2:pp_print_trace - - let wait_reconnect = - declare_1 - ~section - ~name:"smart_rollup_daemon_wait_reconnect" - ~msg:"Retrying to connect in {delay}s" - ~level:Warning - ("delay", Data_encoding.float) - - let starting_metrics_server = - declare_2 - ~section - ~name:"starting_metrics_server" - ~msg:"starting metrics server on {host}:{port}" - ~level:Notice - ("host", Data_encoding.string) - ("port", Data_encoding.uint16) - - let metrics_ended = - declare_1 - ~section - ~name:"metrics_ended" - ~level:Error - ~msg:"metrics server ended with error {stacktrace}" - ("stacktrace", Data_encoding.string) - - let kernel_debug = - declare_1 - ~section - ~name:"kernel_debug" - ~level:Info - ~msg:"{log}" - ("log", Data_encoding.string) - ~pp1:Format.pp_print_string - - let warn_dal_enabled_no_node = - declare_0 - ~section - ~name:"dal_enabled_no_node" - ~level:Warning - ~msg: - "Warning: DAL is enabled in the protocol but no DAL node was provided \ - for the rollup node." - () - - let waiting_first_block = - declare_0 - ~section - ~name:"waiting_first_block" - ~level:Notice - ~msg: - (Format.asprintf - "Waiting for first block of protocol %a to appear." - Protocol_hash.pp - Protocol.hash) - () - - let received_first_block = - declare_1 - ~section - ~name:"received_first_block" - ~level:Notice - ~msg: - (Format.asprintf - "First block of protocol %a received: {block}." - Protocol_hash.pp - Protocol.hash) - ("block", Block_hash.encoding) - - let detected_protocol_migration = - declare_0 - ~section - ~name:"detected_protocol_migration" - ~level:Notice - ~msg:"Detected protocol migration, the rollup node will now stop." - () - - let acquiring_lock = - declare_0 - ~section - ~name:"acquiring_lock" - ~level:Notice - ~msg:"Acquiring lock on data directory." - () -end - -let starting_node = Simple.(emit starting_node) - -let shutdown_node exit_status = Simple.(emit shutdown_node exit_status) - -let node_is_ready ~rpc_addr ~rpc_port = - Simple.(emit node_is_ready (rpc_addr, rpc_port)) - -let rollup_exists ~addr ~kind = - let kind = Protocol.Alpha_context.Sc_rollup.Kind.to_string kind in - Simple.(emit rollup_exists (addr, kind)) - -let connection_lost () = Simple.(emit connection_lost) () - -let cannot_connect ~count error = Simple.(emit cannot_connect) (count, error) - -let wait_reconnect delay = Simple.(emit wait_reconnect) delay - -let starting_metrics_server ~host ~port = - Simple.(emit starting_metrics_server) (host, port) - -let metrics_ended error = Simple.(emit metrics_ended) error - -let metrics_ended_dont_wait error = - Simple.(emit__dont_wait__use_with_care metrics_ended) error - -let kernel_debug msg = Simple.(emit kernel_debug) msg - -let kernel_debug_dont_wait msg = - Simple.(emit__dont_wait__use_with_care kernel_debug) msg - -let warn_dal_enabled_no_node () = Simple.(emit warn_dal_enabled_no_node) () - -let waiting_first_block () = Simple.(emit waiting_first_block) () - -let received_first_block b = Simple.(emit received_first_block) b - -let detected_protocol_migration () = - Simple.(emit detected_protocol_migration) () - -let acquiring_lock () = Simple.(emit acquiring_lock) () diff --git a/src/proto_alpha/lib_sc_rollup_node/event.mli b/src/proto_alpha/lib_sc_rollup_node/event.mli deleted file mode 100644 index cb90a98c4225db9d3cf45f4d1d6f9da755962118..0000000000000000000000000000000000000000 --- a/src/proto_alpha/lib_sc_rollup_node/event.mli +++ /dev/null @@ -1,90 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** This module defines functions that emit the events used when the smart - rollup node is running (see {!Daemon}). *) - -open Protocol.Alpha_context - -val starting_node : unit -> unit Lwt.t - -val node_is_ready : rpc_addr:string -> rpc_port:int -> unit Lwt.t - -(** [rollup_exists addr kind] emits the event that the smart rollup - node is interacting with the rollup at address [addr] and of the given - [kind]. *) -val rollup_exists : addr:Sc_rollup.t -> kind:Sc_rollup.Kind.t -> unit Lwt.t - -(** [shutdown_node exit_status] emits the event that the smart rollup - node is stopping with exit status [exit_status]. *) -val shutdown_node : int -> unit Lwt.t - -(** Emits the event that the connection to the Tezos node has been lost. *) -val connection_lost : unit -> unit Lwt.t - -(** [cannot_connect ~count error] emits the event that the rollup node cannot - connect to the Tezos node because of [error] for the [count]'s time. *) -val cannot_connect : count:int -> tztrace -> unit Lwt.t - -(** [wait_reconnect delay] emits the event that the rollup will wait [delay] - seconds before attempting to reconnect to the Tezos node . *) -val wait_reconnect : float -> unit Lwt.t - -(** [starting_metrics_server ~metrics_addr ~metrics_port] emits the event - that the metrics server for the rollup node is starting. *) -val starting_metrics_server : host:string -> port:int -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. *) -val metrics_ended : string -> unit Lwt.t - -(** [metrics_ended error] emits the event that the metrics server - has ended with a failure. - (Doesn't wait for event to be emited. *) -val metrics_ended_dont_wait : string -> unit - -(** [kernel_debug str] emits the event that the kernel has logged [str]. *) -val kernel_debug : string -> unit Lwt.t - -(** [kernel_debug str] emits the event that the kernel has logged [str]. - (Doesn't wait for event to be emitted) *) -val kernel_debug_dont_wait : string -> unit - -(** [warn_dal_enabled_no_node ()] emits a warning for when DAL is enabled in the - protocol but the rollup node has no DAL node. *) -val warn_dal_enabled_no_node : unit -> unit Lwt.t - -(** Emit event that the node is waiting for the first block of its protocol. *) -val waiting_first_block : unit -> unit Lwt.t - -(** Emit event that the node received the first block of its protocol. *) -val received_first_block : Block_hash.t -> unit Lwt.t - -(** Emit event that the node will shutdown because of protocol migration. *) -val detected_protocol_migration : unit -> unit Lwt.t - -(** [acquiring_lock ()] emits an event to indicate that the node is attempting - to acquire a lock on the data directory. *) -val acquiring_lock : unit -> unit Lwt.t diff --git a/src/proto_alpha/lib_sc_rollup_node/inbox.ml b/src/proto_alpha/lib_sc_rollup_node/inbox.ml index d711228ed16683fefcb1fd7f450fbcd2e9b2eb44..a99e1218bca8f3c9da87f441236e7813ed00269e 100644 --- a/src/proto_alpha/lib_sc_rollup_node/inbox.ml +++ b/src/proto_alpha/lib_sc_rollup_node/inbox.ml @@ -87,8 +87,9 @@ let same_as_layer_1 node_ctxt head_hash inbox = let* layer1_inbox = Plugin.RPC.Sc_rollup.inbox cctxt (cctxt#chain, head_block) in + let layer1_inbox = Sc_rollup_proto_types.Inbox.to_octez layer1_inbox in fail_unless - (Sc_rollup.Inbox.equal layer1_inbox inbox) + (Octez_smart_rollup.Inbox.equal layer1_inbox inbox) (Sc_rollup_node_errors.Inconsistent_inbox {layer1_inbox; inbox}) let add_messages ~is_first_block ~predecessor_timestamp ~predecessor inbox diff --git a/src/proto_alpha/lib_sc_rollup_node/inbox.mli b/src/proto_alpha/lib_sc_rollup_node/inbox.mli index 95408d9c74f7267643793668ff6f4603c53038b1..fed5e050307197bc341897206891a4f574a5cef0 100644 --- a/src/proto_alpha/lib_sc_rollup_node/inbox.mli +++ b/src/proto_alpha/lib_sc_rollup_node/inbox.mli @@ -85,7 +85,10 @@ val payloads_history_of_messages : (** [same_as_layer_1 node_ctxt block node_inbox] ensures that the rollup node agrees with the L1 node that inbox for [block] is [node_inbox]. *) val same_as_layer_1 : - _ Node_context.t -> Block_hash.t -> Sc_rollup.Inbox.t -> unit tzresult Lwt.t + _ Node_context.t -> + Block_hash.t -> + Octez_smart_rollup.Inbox.t -> + unit tzresult Lwt.t (**/**) diff --git a/src/proto_alpha/lib_sc_rollup_node/node_context.ml b/src/proto_alpha/lib_sc_rollup_node/node_context.ml index 1d6fe3d0a0d34d34a423c9b3d97cd7e08c62ebfa..39790d0df0e9cdb75387e4ad65d7af6029ac887f 100644 --- a/src/proto_alpha/lib_sc_rollup_node/node_context.ml +++ b/src/proto_alpha/lib_sc_rollup_node/node_context.ml @@ -318,7 +318,11 @@ let init (cctxt : Protocol_client_context.full) ~data_dir ?log_kernel_debug_file and* genesis_info = RPC.Sc_rollup.genesis_info cctxt (cctxt#chain, cctxt#block) rollup_address in - let*! () = Event.rollup_exists ~addr:rollup_address ~kind in + let*! () = + Event.rollup_exists + ~addr:rollup_address + ~kind:(Sc_rollup_proto_types.Kind.to_octez kind) + in let*! () = if dal_cctxt = None && protocol_constants.parametric.dal.feature_enable then Event.warn_dal_enabled_no_node () diff --git a/src/proto_alpha/lib_sc_rollup_node/refutation_game.ml b/src/proto_alpha/lib_sc_rollup_node/refutation_game.ml index 2332cf76ee66b7c3ce8748b9627071456ee60553..7f7dfb8347ed5ad046500df000f14f3d743e0816 100644 --- a/src/proto_alpha/lib_sc_rollup_node/refutation_game.ml +++ b/src/proto_alpha/lib_sc_rollup_node/refutation_game.ml @@ -273,11 +273,17 @@ let generate_proof (node_ctxt : _ Node_context.t) game start_state = end end in let metadata = Node_context.metadata node_ctxt in + let*! start_tick = PVM.get_tick start_state in (* TODO: https://gitlab.com/tezos/tezos/-/issues/5880 Fetch the real `is_reveal_enabled` definition from the context *) let is_reveal_enabled _ _ = true in let* proof = - trace (Sc_rollup_node_errors.Cannot_produce_proof game) + trace + (Sc_rollup_node_errors.Cannot_produce_proof + { + inbox_level = Raw_level.to_int32 game.inbox_level; + start_tick = Sc_rollup.Tick.to_z start_tick; + }) @@ (Sc_rollup.Proof.produce ~metadata (module P) diff --git a/src/proto_alpha/lib_sc_rollup_node/sc_rollup_node_errors.ml b/src/proto_alpha/lib_sc_rollup_node/sc_rollup_node_errors.ml index 2949749abd34e12b06f4322e5f4299a3a402720c..bf57c29eda9b498b56c5e7775eb30e5caaaf9e3e 100644 --- a/src/proto_alpha/lib_sc_rollup_node/sc_rollup_node_errors.ml +++ b/src/proto_alpha/lib_sc_rollup_node/sc_rollup_node_errors.ml @@ -1,7 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs, *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -23,329 +24,10 @@ (* *) (*****************************************************************************) -open Protocol.Alpha_context +include Rollup_node_errors + +(** Registering protocol specific errors *) let make_id id = String.concat "." [Protocol.name; id] let register_error_kind ~id = register_error_kind ~id:(make_id id) - -type error += - | Cannot_produce_proof of Sc_rollup.Game.t - | Bad_minimal_fees of string - | Disagree_with_cemented of { - inbox_level : Raw_level.t; - ours : Sc_rollup.Commitment.Hash.t option; - on_l1 : Sc_rollup.Commitment.Hash.t; - } - | Unreliable_tezos_node_returning_inconsistent_game - | Wrong_initial_pvm_state of { - initial_state_hash : Sc_rollup.State_hash.t; - expected_state_hash : Sc_rollup.State_hash.t; - } - | Inconsistent_inbox of { - layer1_inbox : Sc_rollup.Inbox.t; - inbox : Sc_rollup.Inbox.t; - } - | Missing_PVM_state of Block_hash.t * Int32.t - | Cannot_checkout_context of Block_hash.t * Smart_rollup_context_hash.t option - | No_batcher - | No_publisher - | Refutation_player_failed_to_start - | No_refutation_coordinator - | Could_not_acquire_lock of string - -type error += - | Lost_game of Protocol.Alpha_context.Sc_rollup.Game.game_result - | Unparsable_boot_sector of {path : string} - | Invalid_genesis_state of { - expected : Sc_rollup.Commitment.Hash.t; - actual : Sc_rollup.Commitment.Hash.t; - } - -let () = - register_error_kind - `Permanent - ~id:"bad_minimal_fees_arg" - ~title:"Bad -minimal-fees arg" - ~description:"invalid fee threshold in -fee-threshold" - ~pp:(fun ppf literal -> - Format.fprintf ppf "invalid minimal fees '%s'" literal) - Data_encoding.(obj1 (req "parameter" string)) - (function Bad_minimal_fees parameter -> Some parameter | _ -> None) - (fun parameter -> Bad_minimal_fees parameter) ; - - register_error_kind - `Permanent - ~id:"internal.node_disagrees_with_cemented" - ~title:"Internal error: The node disagrees with a cemented commitment on L1" - ~description: - "Internal error: The node disagrees with a cemented commitment on L1" - ~pp:(fun ppf (inbox_level, ours, on_l1) -> - Format.fprintf - ppf - "Internal error: The node has commitment %a for inbox level %a but \ - this level is cemented on L1 with commitment %a" - (Format.pp_print_option - ~none:(fun ppf () -> Format.pp_print_string ppf "[None]") - Sc_rollup.Commitment.Hash.pp) - ours - Raw_level.pp - inbox_level - Sc_rollup.Commitment.Hash.pp - on_l1) - Data_encoding.( - obj3 - (req "inbox_level" Raw_level.encoding) - (req "ours" (option Sc_rollup.Commitment.Hash.encoding)) - (req "on_l1" Sc_rollup.Commitment.Hash.encoding)) - (function - | Disagree_with_cemented {inbox_level; ours; on_l1} -> - Some (inbox_level, ours, on_l1) - | _ -> None) - (fun (inbox_level, ours, on_l1) -> - Disagree_with_cemented {inbox_level; ours; on_l1}) ; - - let description = - "Internal error: The game invariant states that the dissection from the \ - opponent must contain a tick we disagree with. If the retrieved game does \ - not respect this, we cannot trust the Tezos node we are connected to and \ - prefer to stop here." - in - register_error_kind - `Permanent - ~id:"internal.unreliable_tezos_node" - ~title:"Internal error: Tezos node seems unreliable" - ~description - ~pp:(fun ppf () -> - Format.fprintf ppf "Unreliable Tezos node. %s" description) - Data_encoding.unit - (function - | Unreliable_tezos_node_returning_inconsistent_game -> Some () | _ -> None) - (fun () -> Unreliable_tezos_node_returning_inconsistent_game) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_produce_proof" - ~title:"Internal error: rollup node cannot produce refutation proof" - ~description: - "The rollup node is in a state that prevents it from producing \ - refutation proofs." - ~pp:(fun ppf game -> - Format.fprintf - ppf - "cannot produce proof for game %a" - Sc_rollup.Game.pp - game) - Data_encoding.(obj1 (req "game" Sc_rollup.Game.encoding)) - (function Cannot_produce_proof game -> Some game | _ -> None) - (fun game -> Cannot_produce_proof game) ; - - register_error_kind - ~id:"sc_rollup.node.Wrong_initial_pvm_state" - ~title:"Initial state produced by PVM is incorrect" - ~description:"Initial state produced by PVM is incorrect." - ~pp:(fun ppf (actual, expected) -> - Format.fprintf - ppf - "The initial state hash produced by the PVM %a is not consistent\n\ - \ with the one expected by the Layer 1 PVM implementation %a" - Sc_rollup.State_hash.pp - actual - Sc_rollup.State_hash.pp - expected) - `Permanent - Data_encoding.( - obj2 - (req "initial_state_hash" Sc_rollup.State_hash.encoding) - (req "expected_state_hash" Sc_rollup.State_hash.encoding)) - (function - | Wrong_initial_pvm_state {initial_state_hash; expected_state_hash} -> - Some (initial_state_hash, expected_state_hash) - | _ -> None) - (fun (initial_state_hash, expected_state_hash) -> - Wrong_initial_pvm_state {initial_state_hash; expected_state_hash}) ; - - register_error_kind - ~id:"internal.inconsistent_inbox" - ~title:"Internal error: Rollup node has an inconsistent inbox" - ~description: - "The rollup node inbox should be the same as the layer 1 inbox." - ~pp:(fun ppf (layer1_inbox, inbox) -> - Format.fprintf - ppf - "@[Rollup inbox:@;%a@]@;should be equal to @[Layer1 inbox:@;%a@]" - Sc_rollup.Inbox.pp - inbox - Sc_rollup.Inbox.pp - layer1_inbox) - `Permanent - Data_encoding.( - obj2 - (req "layer1_inbox" Sc_rollup.Inbox.encoding) - (req "inbox" Sc_rollup.Inbox.encoding)) - (function - | Inconsistent_inbox {layer1_inbox; inbox} -> Some (layer1_inbox, inbox) - | _ -> None) - (fun (layer1_inbox, inbox) -> Inconsistent_inbox {layer1_inbox; inbox}) ; - - register_error_kind - `Permanent - ~id:"internal.missing_pvm_state" - ~title:"Internal error: Missing PVM state" - ~description:"The rollup node cannot retrieve the state of the PVM." - ~pp:(fun ppf (block, level) -> - Format.fprintf - ppf - "Cannot retrieve PVM state for block %a at level %ld" - Block_hash.pp - block - level) - Data_encoding.(obj2 (req "block" Block_hash.encoding) (req "level" int32)) - (function - | Missing_PVM_state (block, level) -> Some (block, level) | _ -> None) - (fun (block, level) -> Missing_PVM_state (block, level)) ; - - register_error_kind - `Permanent - ~id:"internal.cannot_checkout_context" - ~title:"Internal error: Cannot checkout context" - ~description: - "The rollup node cannot checkout the context registered for the block." - ~pp:(fun ppf (block, context_hash) -> - Format.fprintf - ppf - "The context %sfor block %a cannot be checkouted" - (Option.fold - ~none:"" - ~some:Smart_rollup_context_hash.to_b58check - context_hash) - Block_hash.pp - block) - Data_encoding.( - obj2 - (req "block" Block_hash.encoding) - (opt "context" Smart_rollup_context_hash.encoding)) - (function - | Cannot_checkout_context (block, context) -> Some (block, context) - | _ -> None) - (fun (block, context) -> Cannot_checkout_context (block, context)) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.lost_game" - ~title:"Lost refutation game" - ~description:"The rollup node lost a refutation game." - ~pp:(fun ppf result -> - Format.fprintf - ppf - "The rollup node lost the refutation game (%a)" - Protocol.Alpha_context.Sc_rollup.Game.pp_game_result - result) - Data_encoding.( - obj1 - (req - "result" - Protocol.Alpha_context.Sc_rollup.Game.game_result_encoding)) - (function Lost_game result -> Some result | _ -> None) - (fun result -> Lost_game result) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.unparsable_boot_sector" - ~title:"Unparsable boot sector" - ~description:"The boot sector provided is not parsable by the PVM." - ~pp:(fun ppf path -> - Format.fprintf ppf "The boot sector at path %S is unparsable" path) - Data_encoding.(obj1 (req "path" string)) - (function Unparsable_boot_sector {path} -> Some path | _ -> None) - (fun path -> Unparsable_boot_sector {path}) ; - - register_error_kind - `Permanent - ~id:"sc_rollup.node.invalid_genesis_state" - ~title:"Invalid genesis state" - ~description: - "The rollup node computed an invalid genesis state, it cannot continue." - ~pp:(fun ppf (expected, actual) -> - Format.fprintf - ppf - "Genesis commitment computed (%a) is not equal to the rollup genesis \ - (%a) commitment. The rollup node cannot continue. If you used the \ - argument `--boot-sector-file` you probably provided the wrong boot \ - sector. If not, please report the bug." - Sc_rollup.Commitment.Hash.pp - expected - Sc_rollup.Commitment.Hash.pp - actual) - Data_encoding.( - obj2 - (req - "expected" - Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding) - (req "actual" Protocol.Alpha_context.Sc_rollup.Commitment.Hash.encoding)) - (function - | Invalid_genesis_state {expected; actual} -> Some (expected, actual) - | _ -> None) - (fun (expected, actual) -> Invalid_genesis_state {expected; actual}) ; - - register_error_kind - ~id:"sc_rollup.node.no_batcher" - ~title:"No batcher for this node" - ~description:"This node does not have a batcher" - ~pp:(fun ppf () -> - Format.fprintf ppf "This rollup node does not have batcher.") - `Permanent - Data_encoding.unit - (function No_batcher -> Some () | _ -> None) - (fun () -> No_batcher) ; - - register_error_kind - ~id:"sc_rollup.node.no_publisher" - ~title:"No publisher for this node" - ~description:"This node does not have an operator to publish commitments" - ~pp:(fun ppf () -> - Format.fprintf - ppf - "This rollup node does not have an operator to publish commitments.") - `Permanent - Data_encoding.unit - (function No_publisher -> Some () | _ -> None) - (fun () -> No_publisher) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_coordinator" - ~title:"No refutation coordinator for this node" - ~description:"This node does not have a refutation game coordinator" - ~pp:(fun ppf () -> - Format.fprintf ppf "This node does not have a refutation game coordinator") - `Permanent - Data_encoding.unit - (function No_refutation_coordinator -> Some () | _ -> None) - (fun () -> No_refutation_coordinator) ; - - register_error_kind - ~id:"sc_rollup.node.no_refutation_player" - ~title:"A refutation player failed to start" - ~description:"A refutation player failed to start" - ~pp:(fun ppf () -> - Format.fprintf ppf "A refutation player failed to start.") - `Permanent - Data_encoding.unit - (function Refutation_player_failed_to_start -> Some () | _ -> None) - (fun () -> Refutation_player_failed_to_start) ; - - register_error_kind - `Permanent - ~id:"could_not_acquire_lock" - ~title:"Could not acquire lock on data dir" - ~description:"Could not acquire lock on data dir." - ~pp:(fun ppf f -> - Format.fprintf - ppf - "Could not acquire lock on data directory, another rollup node may \ - already be running with this data. If this is not the case, consider \ - removing manually the file %S" - f) - Data_encoding.(obj1 (req "lock_file" string)) - (function Could_not_acquire_lock f -> Some f | _ -> None) - (fun f -> Could_not_acquire_lock f)