package octez-protocol-017-PtNairob-libs
Octez protocol 017-PtNairob libraries
Install
Dune Dependency
Authors
Maintainers
Sources
octez-19.1.tar.gz
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053
doc/src/octez-protocol-017-PtNairob-libs.dal/dal_plugin_registration.ml.html
Source file dal_plugin_registration.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *) (* *) (* 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. *) (* *) (*****************************************************************************) open Protocol open Alpha_context module Plugin = struct module Proto = Registerer.Registered type block_info = Protocol_client_context.Alpha_block_services.block_info let parametric_constants chain block ctxt = let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in Protocol.Constants_services.parametric cpctxt (chain, block) let get_constants chain block ctxt = let open Lwt_result_syntax in let* parametric = parametric_constants chain block ctxt in let { Constants.Parametric.feature_enable; number_of_slots; attestation_lag; attestation_threshold; cryptobox_parameters; blocks_per_epoch; } = parametric.dal in return { Dal_plugin.feature_enable; number_of_slots; attestation_lag; attestation_threshold; cryptobox_parameters; blocks_per_epoch; } let block_info ?chain ?block ~metadata ctxt = let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in Protocol_client_context.Alpha_block_services.info cpctxt ?chain ?block ~metadata () (* Turn the given value of type {!Protocol.Apply_operation_result.operation_result} into a value of type {!Dal_plugin.operation_application_result}. *) let status_of_result = function | Protocol.Apply_operation_result.Applied _ -> Dal_plugin.Succeeded | _ -> Dal_plugin.Failed let get_published_slot_headers (block : block_info) = let open Lwt_result_syntax in let open Protocol.Alpha_context in let apply_internal acc ~source:_ _op _res = acc in let apply (type kind) acc ~source:_ (op : kind manager_operation) (result : (kind, _, _) Protocol.Apply_operation_result.operation_result) = match op with | Dal_publish_slot_header operation -> ( operation.published_level, operation.slot_index, operation.commitment, status_of_result result ) :: acc | _ -> acc in Layer1_services.( process_manager_operations [] block.operations {apply; apply_internal}) |> List.map_es (fun (published_level, slot_index, commitment, status) -> let published_level = Raw_level.to_int32 published_level in let slot_index = Dal.Slot_index.to_int slot_index in return Dal_plugin.({published_level; slot_index; commitment}, status)) let get_committee ctxt ~level = let open Lwt_result_syntax in let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in let*? level = Raw_level.of_int32 level |> Environment.wrap_tzresult in let+ pkh_to_shards = Plugin.RPC.Dal.dal_shards cpctxt (`Main, `Head 0) ~level () in List.fold_left (fun acc (pkh, s) -> Signature.Public_key_hash.Map.add pkh s acc) Signature.Public_key_hash.Map.empty pkh_to_shards let attested_slot_headers (block : block_info) ~number_of_slots = let open Result_syntax in let* metadata = Option.to_result block.metadata ~none: (TzTrace.make @@ Layer1_services.Cannot_read_block_metadata block.hash) in let confirmed_slots = Option.value ~default:Dal.Attestation.empty metadata.protocol_data.dal_attestation in let* all_slots = Dal.Slot_index.slots_range ~lower:0 ~upper:(number_of_slots - 1) |> Environment.wrap_tzresult in List.filter (Dal.Attestation.is_attested confirmed_slots) all_slots |> Dal.Slot_index.to_int_list |> return end let () = Dal_plugin.register (module Plugin)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>