Source file registerer.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
module Source = struct
let hash =
Some (Tezos_crypto.Hashed.Protocol_hash.of_b58check_exn "ProtoDemoCounterDemoCounterDemoCounterDemoCou4LSpdT")
let sources = Tezos_base.Protocol.
{ expected_env = V11 ;
components = [{ name = "Error" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\n(** Exceptions used by the protocol, statically registered by the is module *)\n\ntype error += Demo_error of int\n\ntype error += Invalid_operation\n\ntype error += Failed_to_parse_parameter of bytes\n\ntype error += Invalid_protocol_parameters\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype error += Demo_error of int\n\ntype error += Invalid_operation\n\ntype error += Failed_to_parse_parameter of bytes\n\ntype error += Invalid_protocol_parameters\n\nlet () =\n let open Error_monad in\n let open Data_encoding in\n register_error_kind\n `Temporary\n ~id:\"demo.proto.failed_to_parse_parameter\"\n ~title:\"Failed to parse parameter\"\n ~description:\"The protocol parameters are not valid JSON.\"\n ~pp:(fun ppf bytes ->\n Format.fprintf\n ppf\n \"Cannot parse the protocol parameter: %s\"\n (Bytes.to_string bytes))\n (obj1 (req \"contents\" (bytes Hex)))\n (function Failed_to_parse_parameter data -> Some data | _ -> None)\n (fun data -> Failed_to_parse_parameter data) ;\n register_error_kind\n `Temporary\n ~id:\"demo.proto.invalid_protocol_parameters\"\n ~title:\"Invalid protocol parameters\"\n ~description:\"Unexpected JSON object.\"\n ~pp:(fun ppf () -> Format.fprintf ppf \"Invalid protocol parameters.\")\n (obj1 (req \"data\" empty))\n (function Invalid_protocol_parameters -> Some () | _ -> None)\n (fun () -> Invalid_protocol_parameters) ;\n register_error_kind\n `Permanent\n ~id:\"demo.proto.demo_error\"\n ~title:\"Demo Example Error\"\n ~description:\"Dummy error to illustrate error definition in the protocol.\"\n ~pp:(fun ppf i -> Format.fprintf ppf \"Expected demo error: %d.\" i)\n (obj1 (req \"data\" int31))\n (function Demo_error x -> Some x | _ -> None)\n (fun x -> Demo_error x) ;\n register_error_kind\n `Temporary\n ~id:\"demo.proto.invalid_operation\"\n ~title:\"Invalid Operation\"\n ~description:\"Operation can't be applied. A and B must remain positive.\"\n ~pp:(fun ppf () ->\n Format.fprintf\n ppf\n \"Operation can't be applied. A and B must remain positive.\")\n (obj1 (req \"data\" empty))\n (function Invalid_operation -> Some () | _ -> None)\n (fun () -> Invalid_operation)\n" ;
} ;
{ name = "Proto_params" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\n(** Constants of the demo protocol, passed at protocol activation.\n They defines the initial values of a and b *)\ntype t = {init_a : Int32.t; init_b : Int32.t}\n\nval default : t\n\n(** Create a [t] from a json structure of the form\n [{ 'init_a': int32, 'init_b': int32 }]. Fields are optional with default\n value 0. *)\nval from_json : Data_encoding.json -> t\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype t = {init_a : Int32.t; init_b : Int32.t}\n\nlet default = {init_a = 0l; init_b = 0l}\n\nlet encoding =\n let open Data_encoding in\n conv\n (fun {init_a; init_b} -> (init_a, init_b))\n (fun (init_a, init_b) -> {init_a; init_b})\n (obj2 (dft \"init_a\" int32 0l) (dft \"init_b\" int32 0l))\n\nlet from_json json = Data_encoding.Json.destruct encoding json\n" ;
} ;
{ name = "Header" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* Copyright (c) 2018 Nomadic Labs. <contact@nomadic-labs.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\n(* defines a protocol-specific block header *)\n\ntype t\n\nval encoding : t Data_encoding.t\n\nval create : string -> t\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* Copyright (c) 2018 Nomadic Labs. <contact@nomadic-labs.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype t = string\n\nlet encoding = Data_encoding.(obj1 (req \"demo_block_header_data\" (string Plain)))\n\nlet create s = s\n" ;
} ;
{ name = "State" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\n(** Demo protocol state *)\ntype t = {a : int32; b : int32}\n\n(** counter should be positive *)\nval invariant : t -> bool\n\nval create : int32 -> int32 -> t option\n\nval encoding : t Data_encoding.t\n\nval encoding_length : int\n\nval get_state : Context.t -> t Lwt.t\n\nval update_state : Context.t -> t -> Context.t Lwt.t\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype t = {a : int32; b : int32}\n\nlet invariant {a; b} = Compare.Int32.(a >= 0l && b >= 0l)\n\nlet create a b =\n let st = {a; b} in\n if invariant st then Some st else None\n\nlet encoding =\n Data_encoding.conv\n (fun {a; b} -> (a, b))\n (fun (a, b) -> {a; b})\n Data_encoding.(obj2 (req \"demo_a\" int32) (req \"demo_b\" int32))\n\nlet encoding_length =\n match Data_encoding.Binary.fixed_length encoding with\n | None ->\n assert false\n | Some length ->\n length\n\nlet state_key = [\"state\"]\n\nlet get_state context =\n let open Lwt_syntax in\n let+ state = Context.find context state_key in\n match state with\n | None ->\n assert false\n | Some encoded_state -> (\n match Data_encoding.Binary.of_bytes_opt encoding encoded_state with\n | Some x ->\n x\n | None ->\n assert false )\n\nlet update_state context state =\n let encoded_state = Data_encoding.Binary.to_bytes_exn encoding state in\n Context.add context state_key encoded_state\n" ;
} ;
{ name = "Proto_operation" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype t = IncrA | IncrB | Transfer of Int32.t\n\n(* transfer from A to B, possibly a negative amount *)\n\nval encoding : t Data_encoding.t\n\nval compare : t -> t -> int\n" ;
implementation = "(*****************************************************************************)\n\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype t = IncrA | IncrB | Transfer of Int32.t\n\nlet encoding =\n let open Data_encoding in\n let casea =\n let dest = function IncrA -> Some () | _ -> None in\n let const () = IncrA in\n case ~title:\"IncrA\" (Tag 0) (obj1 (req \"IncrA\" empty)) dest const\n in\n let caseb =\n let dest = function IncrB -> Some () | _ -> None in\n let const () = IncrB in\n case ~title:\"IncrB\" (Tag 1) (obj1 (req \"IncrB\" empty)) dest const\n in\n let casec =\n let dest = function Transfer i -> Some i | _ -> None in\n let const i = Transfer i in\n case ~title:\"Transfer\" (Tag 2) (obj1 (req \"Transfer\" int32)) dest const\n in\n union [casea; caseb; casec]\n\nlet to_pii t =\n match t with IncrA -> (0l, 0l) | IncrB -> (1l, 0l) | Transfer i -> (2l, i)\n\nlet compare x y =\n let (a, b) = to_pii x in\n let (u, v) = to_pii y in\n let open Compare.Int32 in\n if a = u then compare b v else compare a u\n" ;
} ;
{ name = "Receipt" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* Copyright (c) 2018 Nomadic Labs. <contact@nomadic-labs.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\n(** receipts are used to notify users of operation application. We use a\n a simple string but we could use a structured datatype... *)\ntype t\n\nval create : string -> t\n\nval to_string : t -> string\n\nval encoding : t Data_encoding.t\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* Copyright (c) 2018 Nomadic Labs. <contact@nomadic-labs.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\ntype t = string\n\nlet create t = t\n\nlet to_string t = t\n\nlet encoding = Data_encoding.(obj1 (req \"demo_operation_receipt\" (string Plain)))\n" ;
} ;
{ name = "Apply" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\nval apply : State.t -> Proto_operation.t -> State.t option\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\nlet apply State.{a; b} operation =\n let open Int32 in\n match operation with\n | Proto_operation.IncrA ->\n Some State.{a = add a 1l; b}\n | Proto_operation.IncrB ->\n Some State.{a; b = add b 1l}\n | Proto_operation.Transfer i ->\n let state = State.{a = sub a i; b = add b i} in\n if State.invariant state then Some state else None\n" ;
} ;
{ name = "Services" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\nval rpc_services : Updater.rpc_context RPC_directory.t\n\nval get_counter :\n 'a #RPC_context.simple -> 'a -> [`A | `B] -> int32 shell_tzresult Lwt.t\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\nmodule S = struct\n let path = RPC_path.open_root\n\n let service_counter_a =\n RPC_service.get_service\n ~description:\"Value of counter A\"\n ~query:RPC_query.empty\n ~output:Data_encoding.int32\n RPC_path.(path / \"counter\" / \"a\")\n\n let service_counter_b =\n RPC_service.get_service\n ~description:\"Value of counter B\"\n ~query:RPC_query.empty\n ~output:Data_encoding.int32\n RPC_path.(path / \"counter\" / \"b\")\nend\n\nlet rpc_services : Updater.rpc_context RPC_directory.t =\n let open Lwt_result_syntax in\n let dir = RPC_directory.empty in\n let dir =\n RPC_directory.register ~chunked:false dir S.service_counter_a (fun ctxt () () ->\n let context = ctxt.Updater.context in\n let*! state = State.get_state context in\n return state.State.a)\n in\n let dir =\n RPC_directory.register ~chunked:false dir S.service_counter_b (fun ctxt () () ->\n let context = ctxt.Updater.context in\n let*! state = State.get_state context in\n return state.State.b)\n in\n dir\n\nlet get_counter rpc_ctxt chain_blk counter_name =\n match counter_name with\n | `A ->\n RPC_context.make_call0 S.service_counter_a rpc_ctxt chain_blk () ()\n | `B ->\n RPC_context.make_call0 S.service_counter_b rpc_ctxt chain_blk () ()\n" ;
} ;
{ name = "Main" ;
interface = Some "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\n(** Tezos Protocol Implementation - Protocol Signature Instance.\n\n This module implements the economic protocol signature. It also\n exports the RPC services defined in module Services. *)\n\ninclude\n Updater.PROTOCOL\n with type block_header_data = Header.t\n and type operation_receipt = Receipt.t\n and type operation_data = Proto_operation.t\n" ;
implementation = "(*****************************************************************************)\n(* *)\n(* Open Source License *)\n(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)\n(* *)\n(* Permission is hereby granted, free of charge, to any person obtaining a *)\n(* copy of this software and associated documentation files (the \"Software\"),*)\n(* to deal in the Software without restriction, including without limitation *)\n(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)\n(* and/or sell copies of the Software, and to permit persons to whom the *)\n(* Software is furnished to do so, subject to the following conditions: *)\n(* *)\n(* The above copyright notice and this permission notice shall be included *)\n(* in all copies or substantial portions of the Software. *)\n(* *)\n(* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)\n(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)\n(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)\n(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)\n(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)\n(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)\n(* DEALINGS IN THE SOFTWARE. *)\n(* *)\n(*****************************************************************************)\n\nlet max_block_length = 100\n\nlet max_operation_data_length = 100\n\nlet validation_passes = Updater.[{max_size = 1000; max_op = None}]\n\nlet acceptable_pass _op = Some 0\n\ntype block_header_data = Header.t\n\ntype block_header = {\n shell : Block_header.shell_header;\n protocol_data : block_header_data;\n}\n\nlet block_header_data_encoding = Header.encoding\n\ntype block_header_metadata = State.t\n\nlet block_header_metadata_encoding_with_legacy_attestation_name =\n State.encoding\n\nlet block_header_metadata_encoding = State.encoding\n\ntype operation_data = Proto_operation.t\n\nlet operation_data_encoding = Proto_operation.encoding\n\nlet operation_data_encoding_with_legacy_attestation_name =\n operation_data_encoding\n\ntype operation_receipt = Receipt.t\n\nlet operation_receipt_encoding = Receipt.encoding\n\nlet operation_receipt_encoding_with_legacy_attestation_name =\n operation_receipt_encoding\n\nlet operation_data_and_receipt_encoding =\n (* we could merge data and receipt encoding for a lighter json *)\n Data_encoding.(\n obj2 (req \"data\" Proto_operation.encoding) (req \"receipt\" Receipt.encoding))\n\nlet operation_data_and_receipt_encoding_with_legacy_attestation_name =\n operation_data_and_receipt_encoding\n\ntype operation = {\n shell : Operation.shell_header;\n protocol_data : operation_data;\n}\n\ntype validation_state = {context : Context.t; fitness : Fitness.t}\n\ntype application_state = validation_state\n\ntype mode =\n | Application of block_header\n | Partial_validation of block_header\n | Construction of {\n predecessor_hash : Block_hash.t;\n timestamp : Time.t;\n block_header_data : block_header_data;\n }\n | Partial_construction of {\n predecessor_hash : Block_hash.t;\n timestamp : Time.t;\n }\n\nlet mode_str = function\n | Application _ -> \"application\"\n | Partial_validation _ -> \"partial_validation\"\n | Construction _ -> \"construction\"\n | Partial_construction _ -> \"partial_construction\"\n\nlet validation_or_application_str = function\n | `Validation -> \"validation\"\n | `Application -> \"application\"\n\nlet begin_any_application_mode validation_or_application mode context\n ~(predecessor : Block_header.shell_header) (block_header : block_header) =\n let fitness = block_header.shell.fitness in\n Logging.log\n Notice\n \"begin_%s (%s mode): pred_fitness = %a block_fitness = %a%!\"\n (validation_or_application_str validation_or_application)\n (mode_str mode)\n Fitness.pp\n predecessor.fitness\n Fitness.pp\n fitness ;\n (* Note: Logging is only available for debugging purposes and should\n not appear in a real protocol. *)\n return {context; fitness}\n\n(* we use here the same fitness format than proto alpha,\n but with higher [version_number] to allow testing\n migration from alpha to demo_counter. *)\nlet version_number = \"\\255\"\n\nlet int64_to_bytes i =\n let b = Bytes.make 8 '\\000' in\n TzEndian.set_int64 b 0 i ;\n b\n\nlet fitness_from_level level =\n [\n Bytes.of_string version_number;\n Bytes.of_string \"\\000\";\n Bytes.of_string \"\\000\";\n Bytes.of_string \"\\000\";\n int64_to_bytes level;\n ]\n\nlet begin_any_construction_mode validation_or_application mode context\n ~(predecessor : Block_header.shell_header) =\n let fitness = fitness_from_level Int64.(succ (of_int32 predecessor.level)) in\n Logging.log\n Notice\n \"begin_%s (%s mode): pred_fitness = %a constructed fitness = %a%!\"\n (validation_or_application_str validation_or_application)\n (mode_str mode)\n Fitness.pp\n predecessor.fitness\n Fitness.pp\n fitness ;\n return {context; fitness}\n\nlet begin_validation_or_application validation_or_application ctxt _chain_id\n mode ~predecessor =\n match mode with\n | Application block_header | Partial_validation block_header ->\n begin_any_application_mode\n validation_or_application\n mode\n ctxt\n ~predecessor\n block_header\n | Construction _ | Partial_construction _ ->\n begin_any_construction_mode\n validation_or_application\n mode\n ctxt\n ~predecessor\n\nlet begin_validation = begin_validation_or_application `Validation\n\nlet begin_application = begin_validation_or_application `Application\n\nlet apply_operation_aux application_state operation =\n let open Lwt_result_syntax in\n let {context; fitness} = application_state in\n let*! state = State.get_state context in\n match Apply.apply state operation.protocol_data with\n | None -> Error_monad.tzfail Error.Invalid_operation\n | Some state ->\n let*! context = State.update_state context state in\n return {context; fitness}\n\nlet validate_operation ?check_signature:_ validation_state _oph operation =\n Logging.log Notice \"validate_operation\" ;\n apply_operation_aux validation_state operation\n\nlet apply_operation application_state _oph operation =\n let open Lwt_result_syntax in\n Logging.log Notice \"apply_operation\" ;\n let* application_state = apply_operation_aux application_state operation in\n let receipt = Receipt.create \"operation applied successfully\" in\n return (application_state, receipt)\n\nlet log_finalize validation_or_application validation_state =\n Logging.log\n Notice\n \"finalize_%s: fitness = %a%!\"\n (validation_or_application_str validation_or_application)\n Fitness.pp\n validation_state.fitness\n\nlet finalize_validation validation_state =\n log_finalize `Validation validation_state ;\n return_unit\n\nlet finalize_application application_state _shell_header =\n let open Lwt_result_syntax in\n log_finalize `Application application_state ;\n let fitness = application_state.fitness in\n let message = Some (Format.asprintf \"fitness <- %a\" Fitness.pp fitness) in\n let context = application_state.context in\n let*! state = State.get_state context in\n return\n ( {\n Updater.message;\n context;\n fitness;\n max_operations_ttl = 0;\n last_allowed_fork_level = 0l;\n },\n state )\n\nlet decode_json json =\n match Proto_params.from_json json with\n | exception _ ->\n tzfail Error.Invalid_protocol_parameters\n | proto_params ->\n return proto_params\n\nlet get_init_state context : State.t tzresult Lwt.t =\n let open Lwt_result_syntax in\n let protocol_params_key = [\"protocol_parameters\"] in\n let*! params_bytes = Context.find context protocol_params_key in\n let* Proto_params.{init_a; init_b} =\n match params_bytes with\n | None ->\n return Proto_params.default\n | Some bytes -> (\n match Data_encoding.Binary.of_bytes_opt Data_encoding.json bytes with\n | None ->\n tzfail (Error.Failed_to_parse_parameter bytes)\n | Some json ->\n decode_json json )\n in\n match State.create init_a init_b with\n | None ->\n tzfail Error.Invalid_protocol_parameters\n | Some state ->\n return state\n\nlet init _chain_id context block_header =\n let open Lwt_result_syntax in\n let open Block_header in\n let fitness = block_header.fitness in\n Logging.log Notice \"init: fitness = %a%!\" Fitness.pp fitness ;\n let* init_state = get_init_state context in\n let*! init_context = State.update_state context init_state in\n return\n {\n Updater.message = None;\n context = init_context;\n fitness;\n max_operations_ttl = 0;\n last_allowed_fork_level = block_header.level;\n }\n\nlet compare_operations _ _ = 0\n\ntype Context.Cache.value += Demo of int\n\nlet value_of_key ~chain_id:_ ~predecessor_context:_ ~predecessor_timestamp:_\n ~predecessor_level:_ ~predecessor_fitness:_ ~predecessor:_ ~timestamp:_ =\n return (fun _ -> return (Demo 123))\n\nlet rpc_services = Services.rpc_services\n\nmodule Mempool = struct\n type t = State.t\n\n type validation_info = unit\n\n type conflict_handler =\n existing_operation:Operation_hash.t * operation ->\n new_operation:Operation_hash.t * operation ->\n [`Keep | `Replace]\n\n type operation_conflict =\n | Operation_conflict of {\n existing : Operation_hash.t;\n new_operation : Operation_hash.t;\n }\n\n type add_result =\n | Added\n | Replaced of {removed : Operation_hash.t}\n | Unchanged\n\n type add_error =\n | Validation_error of error trace\n | Add_conflict of operation_conflict\n\n type merge_error =\n | Incompatible_mempool\n | Merge_conflict of operation_conflict\n\n let init ctxt _chain_id ~head_hash:_ ~(head : Block_header.shell_header) =\n let open Lwt_result_syntax in\n Logging.log\n Notice\n \"Mempool.init: head fitness = %a%!\"\n Fitness.pp\n head.fitness ;\n let*! state = State.get_state ctxt in\n return ((), state)\n\n let encoding = State.encoding\n\n let add_operation ?check_signature:_ ?conflict_handler:_\n (_info : validation_info) state ((_oph : Operation_hash.t), op) =\n match Apply.apply state op.protocol_data with\n | None ->\n Lwt.return_error\n (Validation_error (trace_of_error Error.Invalid_operation))\n | Some state -> return (state, Added)\n\n (* This mempool does not currently support removing an operation. *)\n let remove_operation _ _ = assert false\n\n (* This mempool does not currently support merging. *)\n let merge ?conflict_handler:_ _ _ = assert false\n\n (* This function is not currently used in the context of\n [proto_demo_counter]. If it is needed in the future, the type [t]\n will need to be extended to remember all added operations. *)\n let operations _ = assert false\nend\n" ;
}] ;
}
end
module Registered =
Tezos_protocol_updater.Registered_protocol.Register_embedded_V11
(Tezos_protocol_demo_counter.Environment)
(Tezos_protocol_demo_counter.Protocol.Main)
(Source)