From a311e20de88965b0f49f1e792cffde2c65679dfd Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Wed, 9 Feb 2022 10:13:21 +0000 Subject: [PATCH 1/7] Add global counter to context --- src/proto_alpha/lib_protocol/TEZOS_PROTOCOL | 1 + src/proto_alpha/lib_protocol/alpha_context.ml | 4 ++++ src/proto_alpha/lib_protocol/alpha_context.mli | 8 ++++++++ src/proto_alpha/lib_protocol/counter_storage.ml | 9 +++++++++ src/proto_alpha/lib_protocol/counter_storage.mli | 5 +++++ src/proto_alpha/lib_protocol/dune.inc | 5 +++++ src/proto_alpha/lib_protocol/init_storage.ml | 1 + src/proto_alpha/lib_protocol/storage.ml | 7 +++++++ src/proto_alpha/lib_protocol/storage.mli | 2 ++ 9 files changed, 42 insertions(+) create mode 100644 src/proto_alpha/lib_protocol/counter_storage.ml create mode 100644 src/proto_alpha/lib_protocol/counter_storage.mli diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index 47a5d4e973f7..c08627d08e2c 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -91,6 +91,7 @@ "Vote_storage", "Fees_storage", "Ticket_storage", + "Counter_storage", "Liquidity_baking_repr", "Liquidity_baking_cpmm", "Liquidity_baking_lqt", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 4321bb3f17a0..91740e3b4e82 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -63,6 +63,10 @@ module Sc_rollup = struct module Inbox = Sc_rollup_inbox end +module Global_counter = struct + include Counter_storage +end + module Entrypoint = Entrypoint_repr include Operation_repr diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 0e7d04883ad5..4e82921d85eb 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1796,6 +1796,14 @@ module Sc_rollup : sig val inbox : context -> t -> (Inbox.t * context) tzresult Lwt.t end +module Global_counter : sig + val inc : context -> Z.t -> (Z.t * context) tzresult Lwt.t + + val get : context -> (Z.t * context) tzresult Lwt.t + + val init : context -> (Z.t * context) tzresult Lwt.t +end + module Block_payload : sig val hash : predecessor:Block_hash.t -> diff --git a/src/proto_alpha/lib_protocol/counter_storage.ml b/src/proto_alpha/lib_protocol/counter_storage.ml new file mode 100644 index 000000000000..ade89957eae1 --- /dev/null +++ b/src/proto_alpha/lib_protocol/counter_storage.ml @@ -0,0 +1,9 @@ +let init ctxt = + Storage.Global_counter.init ctxt Z.zero >|=? fun context -> (Z.zero, context) + +let get ctxt = Storage.Global_counter.get ctxt >|=? fun v -> (v, ctxt) + +let inc ctxt v = + Storage.Global_counter.get ctxt >>=? fun c_val -> + let v' = Z.add v c_val in + Storage.Global_counter.update ctxt v' >|=? fun ctxt' -> (v', ctxt') diff --git a/src/proto_alpha/lib_protocol/counter_storage.mli b/src/proto_alpha/lib_protocol/counter_storage.mli new file mode 100644 index 000000000000..b2fa036167da --- /dev/null +++ b/src/proto_alpha/lib_protocol/counter_storage.mli @@ -0,0 +1,5 @@ +val init : Raw_context.t -> (Z.t * Raw_context.t) tzresult Lwt.t + +val inc : Raw_context.t -> Z.t -> (Z.t * Raw_context.t) tzresult Lwt.t + +val get : Raw_context.t -> (Z.t * Raw_context.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/dune.inc b/src/proto_alpha/lib_protocol/dune.inc index 5f36b23d4a2b..a17dd4668939 100644 --- a/src/proto_alpha/lib_protocol/dune.inc +++ b/src/proto_alpha/lib_protocol/dune.inc @@ -114,6 +114,7 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end vote_storage.mli vote_storage.ml fees_storage.mli fees_storage.ml ticket_storage.mli ticket_storage.ml + counter_storage.mli counter_storage.ml liquidity_baking_repr.mli liquidity_baking_repr.ml liquidity_baking_cpmm.ml liquidity_baking_lqt.ml @@ -265,6 +266,7 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end vote_storage.mli vote_storage.ml fees_storage.mli fees_storage.ml ticket_storage.mli ticket_storage.ml + counter_storage.mli counter_storage.ml liquidity_baking_repr.mli liquidity_baking_repr.ml liquidity_baking_cpmm.ml liquidity_baking_lqt.ml @@ -416,6 +418,7 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end vote_storage.mli vote_storage.ml fees_storage.mli fees_storage.ml ticket_storage.mli ticket_storage.ml + counter_storage.mli counter_storage.ml liquidity_baking_repr.mli liquidity_baking_repr.ml liquidity_baking_cpmm.ml liquidity_baking_lqt.ml @@ -589,6 +592,7 @@ include Tezos_raw_protocol_alpha.Main Vote_storage Fees_storage Ticket_storage + Counter_storage Liquidity_baking_repr Liquidity_baking_cpmm Liquidity_baking_lqt @@ -781,6 +785,7 @@ include Tezos_raw_protocol_alpha.Main vote_storage.mli vote_storage.ml fees_storage.mli fees_storage.ml ticket_storage.mli ticket_storage.ml + counter_storage.mli counter_storage.ml liquidity_baking_repr.mli liquidity_baking_repr.ml liquidity_baking_cpmm.ml liquidity_baking_lqt.ml diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 300345ec8d3d..e85fe762af0f 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -101,6 +101,7 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp = ctxt ~start_position:(Level_storage.current ctxt).level_position >>=? fun ctxt -> + Counter_storage.init ctxt >>=? fun (_, ctxt) -> Vote_storage.update_listings ctxt >>=? fun ctxt -> (* Must be called after other originations since it unsets the origination nonce. *) Liquidity_baking_migration.init ctxt ~typecheck diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 5422c5866798..12d572c87841 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -100,6 +100,13 @@ module Legacy_block_priority : end) (Encoding.UInt16) +module Global_counter : Simple_single_data_storage with type value = Z.t = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["global_counter"] + end) + (Encoding.Z) + module Block_round : Simple_single_data_storage with type value = Round_repr.t = Make_single_data_storage (Registered) (Raw_context) (struct diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 8b64604818ed..227a87117049 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -49,6 +49,8 @@ end module Legacy_block_priority : Simple_single_data_storage with type value = int +module Global_counter : Simple_single_data_storage with type value = Z.t + module Block_round : Simple_single_data_storage with type value = Round_repr.t module Roll_legacy : sig -- GitLab From 0cd4e714d6d9914d90298d7ae6672143bde4626a Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Wed, 9 Feb 2022 10:44:07 +0000 Subject: [PATCH 2/7] Add global counter manager operations --- src/proto_alpha/lib_client/injection.ml | 6 + .../lib_client/operation_result.ml | 40 +++++- .../lib_protocol/alpha_context.mli | 20 +++ src/proto_alpha/lib_protocol/apply.ml | 12 +- src/proto_alpha/lib_protocol/apply_results.ml | 136 ++++++++++++++++++ .../lib_protocol/apply_results.mli | 8 ++ .../lib_protocol/operation_repr.ml | 55 +++++++ .../lib_protocol/operation_repr.mli | 20 +++ .../lib_protocol/test/helpers/block.ml | 8 +- .../lib_protocol/ticket_operations_diff.ml | 2 + 10 files changed, 303 insertions(+), 4 deletions(-) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index b7386271af65..3fd0d302cd9f 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -328,6 +328,8 @@ let estimated_gas_single (type kind) | Applied (Sc_rollup_originate_result {consumed_gas; _}) -> Ok consumed_gas | Applied (Sc_rollup_add_messages_result {consumed_gas; _}) -> Ok consumed_gas + | Applied (Global_counter_increment_result _) -> Ok Gas.Arith.zero + | Applied (Global_counter_get_result _) -> Ok Gas.Arith.zero | Skipped _ -> assert false | Backtracked (_, None) -> Ok Gas.Arith.zero (* there must be another error for this to happen *) @@ -369,6 +371,8 @@ let estimated_storage_single (type kind) ~tx_rollup_origination_size Ok Z.zero | Applied (Sc_rollup_originate_result {size; _}) -> Ok size | Applied (Sc_rollup_add_messages_result _) -> Ok Z.zero + | Applied (Global_counter_increment_result _) -> Ok Z.zero + | Applied (Global_counter_get_result _) -> Ok Z.zero | Skipped _ -> assert false | Backtracked (_, None) -> Ok Z.zero (* there must be another error for this to happen *) @@ -421,6 +425,8 @@ let originated_contracts_single (type kind) | Applied (Tx_rollup_submit_batch_result _) -> Ok [] | Applied (Sc_rollup_originate_result _) -> Ok [] | Applied (Sc_rollup_add_messages_result _) -> Ok [] + | Applied (Global_counter_increment_result _) -> Ok [] + | Applied (Global_counter_get_result _) -> Ok [] | Skipped _ -> assert false | Backtracked (_, None) -> Ok [] (* there must be another error for this to happen *) diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 2b73c4aca0f7..0607912b1d62 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -206,7 +206,14 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Sc_rollup.Address.pp rollup pp_result - result) ; + result + | Global_counter_increment {value} -> + Format.fprintf + ppf + "@[Incrementing global counter %s@]" + (Z.to_string value) + | Global_counter_get -> + Format.fprintf ppf "@[Fetching value of global counter @]") ; Format.fprintf ppf "@]" @@ -468,6 +475,13 @@ let pp_manager_operation_contents_and_result ppf Sc_rollup.Inbox.pp inbox_after in + let pp_global_counter_increment_result + (Global_counter_increment_result {value}) = + Format.fprintf ppf "@,New value for global counter: %s" (Z.to_string value) + in + let pp_global_counter_get_result (Global_counter_get_result {value}) = + Format.fprintf ppf "@,Value of global counter: %s" (Z.to_string value) + in let pp_result (type kind) ppf (result : kind manager_operation_result) = Format.fprintf ppf "@," ; match result with @@ -572,6 +586,30 @@ let pp_manager_operation_contents_and_result ppf was BACKTRACKED, its expected effects (as follow) were NOT \ applied.@]" ; pp_sc_rollup_add_messages_result op + | Applied (Global_counter_increment_result _ as op) -> + Format.fprintf + ppf + "@[This operation updating the global counter was successfully \ + applied" ; + pp_global_counter_increment_result op + | Backtracked ((Global_counter_increment_result _ as op), _errs) -> + Format.fprintf + ppf + "@[This operation updating the global counter was BACKTRACKED \ + its expected effects (as follows) were NOT applied @]" ; + pp_global_counter_increment_result op + | Applied (Global_counter_get_result _ as op) -> + Format.fprintf + ppf + "@[This operation fetching the value of the global counter was \ + successfully applied" ; + pp_global_counter_get_result op + | Backtracked ((Global_counter_get_result _ as op), _errs) -> + Format.fprintf + ppf + "@[This operation fetching the value of the global counter was \ + BACKTRACKED its expected effects (as follows) were NOT applied @]" ; + pp_global_counter_get_result op in Format.fprintf diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 4e82921d85eb..d99a37f68556 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2173,6 +2173,10 @@ module Kind : sig type sc_rollup_add_messages = Sc_rollup_add_messages_kind + type global_counter_increment = Global_counter_increment_kind + + type global_counter_get = Global_counter_get_kind + type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager @@ -2184,6 +2188,8 @@ module Kind : sig | Tx_rollup_submit_batch_manager_kind : tx_rollup_submit_batch manager | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager + | Global_counter_increment_manager_kind : global_counter_increment manager + | Global_counter_get_manager_kind : global_counter_get manager end type 'a consensus_operation_type = @@ -2317,6 +2323,11 @@ and _ manager_operation = messages : string list; } -> Kind.sc_rollup_add_messages manager_operation + | Global_counter_increment : { + value : Z.t; + } + -> Kind.global_counter_increment manager_operation + | Global_counter_get : Kind.global_counter_get manager_operation and counter = Z.t @@ -2470,6 +2481,11 @@ module Operation : sig val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages Kind.manager case + val global_counter_increment_case : + Kind.global_counter_increment Kind.manager case + + val global_counter_get_case : Kind.global_counter_get Kind.manager case + module Manager_operations : sig type 'b case = | MCase : { @@ -2501,6 +2517,10 @@ module Operation : sig val sc_rollup_originate_case : Kind.sc_rollup_originate case val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages case + + val global_counter_increment_case : Kind.global_counter_increment case + + val global_counter_get_case : Kind.global_counter_get case end end diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 19effe035bbb..1f4a34138578 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1201,6 +1201,13 @@ let apply_manager_operation_content : let consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt in let result = Sc_rollup_add_messages_result {consumed_gas; inbox_after} in return (ctxt, result, []) + | Global_counter_increment {value} -> + Global_counter.inc ctxt value >>=? fun (value, ctxt) -> + let result = Global_counter_increment_result {value} in + return (ctxt, result, []) + | Global_counter_get -> + Global_counter.get ctxt >>=? fun (value, ctxt) -> + return (ctxt, Global_counter_get_result {value}, []) type success_or_failure = Success of context | Failure @@ -1328,7 +1335,8 @@ let precheck_manager_contents (type kind) ctxt (op : kind Kind.manager contents) Tx_rollup_inbox.Tx_rollup_message_size_exceeds_limit >|=? fun () -> ctxt | Sc_rollup_originate _ | Sc_rollup_add_messages _ -> - assert_sc_rollup_feature_enabled ctxt >|=? fun () -> ctxt) + assert_sc_rollup_feature_enabled ctxt >|=? fun () -> ctxt + | Global_counter_increment _ | Global_counter_get -> return ctxt) >>=? fun ctxt -> Contract.increment_counter ctxt source >>=? fun ctxt -> Token.transfer ctxt (`Contract source_contract) `Block_fees fee @@ -1443,6 +1451,8 @@ let burn_storage_fees : let result = Sc_rollup_originate_result {payload with balance_updates} in return (ctxt, storage_limit, result) | Sc_rollup_add_messages_result _ -> return (ctxt, storage_limit, smopr) + | Global_counter_increment_result _ | Global_counter_get_result _ -> + return (ctxt, storage_limit, smopr) let apply_manager_contents (type kind) ctxt mode chain_id ~gas_consumed_in_precheck (op : kind Kind.manager contents) : diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index 6cf254e2004a..cf8febe2d738 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -113,6 +113,14 @@ type _ successful_manager_operation_result = inbox_after : Sc_rollup.Inbox.t; } -> Kind.sc_rollup_add_messages successful_manager_operation_result + | Global_counter_increment_result : { + value : Z.t; + } + -> Kind.global_counter_increment successful_manager_operation_result + | Global_counter_get_result : { + value : Z.t; + } + -> Kind.global_counter_get successful_manager_operation_result let migration_origination_result_to_successful_manager_operation_result ({ @@ -628,6 +636,41 @@ module Manager_result = struct assert (Gas.Arith.(equal (ceil consumed_milligas) consumed_gas)) ; Sc_rollup_add_messages_result {consumed_gas = consumed_milligas; inbox_after}) + + let global_counter_increment_case = + make + ~op_case: + Operation.Encoding.Manager_operations.global_counter_increment_case + ~encoding:(obj1 (req "value" Data_encoding.z)) + ~iselect:(function + | Internal_operation_result + (({operation = Global_counter_increment _; _} as op), res) -> + Some (op, res) + | _ -> None) + ~select:(function + | Successful_manager_result (Global_counter_increment_result _ as op) -> + Some op + | _ -> None) + ~proj:(function Global_counter_increment_result {value} -> value) + ~kind:Kind.Global_counter_increment_manager_kind + ~inj:(fun value -> Global_counter_increment_result {value}) + + let global_counter_get_case = + make + ~op_case:Operation.Encoding.Manager_operations.global_counter_get_case + ~encoding:(obj1 (req "value" Data_encoding.z)) + ~iselect:(function + | Internal_operation_result + (({operation = Global_counter_get; _} as op), res) -> + Some (op, res) + | _ -> None) + ~select:(function + | Successful_manager_result (Global_counter_get_result _ as op) -> + Some op + | _ -> None) + ~proj:(function Global_counter_get_result {value} -> value) + ~kind:Kind.Global_counter_get_manager_kind + ~inj:(fun value -> Global_counter_get_result {value}) end let internal_operation_result_encoding : @@ -668,6 +711,8 @@ let internal_operation_result_encoding : make Manager_result.tx_rollup_submit_batch_case; make Manager_result.sc_rollup_originate_case; make Manager_result.sc_rollup_add_messages_case; + make Manager_result.global_counter_increment_case; + make Manager_result.global_counter_get_case; ] let successful_manager_operation_result_encoding : @@ -696,6 +741,8 @@ let successful_manager_operation_result_encoding : make Manager_result.delegation_case; make Manager_result.set_deposits_limit_case; make Manager_result.sc_rollup_originate_case; + make Manager_result.global_counter_increment_case; + make Manager_result.global_counter_get_case; ] type 'kind contents_result = @@ -781,6 +828,14 @@ let equal_manager_kind : Kind.Sc_rollup_add_messages_manager_kind ) -> Some Eq | (Kind.Sc_rollup_add_messages_manager_kind, _) -> None + | ( Kind.Global_counter_increment_manager_kind, + Kind.Global_counter_increment_manager_kind ) -> + Some Eq + | (Kind.Global_counter_increment_manager_kind, _) -> None + | (Kind.Global_counter_get_manager_kind, Kind.Global_counter_get_manager_kind) + -> + Some Eq + | (Kind.Global_counter_get_manager_kind, _) -> None module Encoding = struct type 'kind case = @@ -1175,6 +1230,29 @@ module Encoding = struct res ) -> Some (op, res) | _ -> None) + + let[@coq_axiom_with_reason "gadt"] global_counter_increment_case = + make_manager_case + Operation.Encoding.global_counter_increment_case + Manager_result.global_counter_increment_case + (function + | Contents_and_result + ( (Manager_operation {operation = Global_counter_increment _; _} as + op), + res ) -> + Some (op, res) + | _ -> None) + + let[@coq_axiom_with_reason "gadt"] global_counter_get_case = + make_manager_case + Operation.Encoding.global_counter_get_case + Manager_result.global_counter_get_case + (function + | Contents_and_result + ((Manager_operation {operation = Global_counter_get; _} as op), res) + -> + Some (op, res) + | _ -> None) end let contents_result_encoding = @@ -1215,6 +1293,8 @@ let contents_result_encoding = make tx_rollup_submit_batch_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; + make global_counter_increment_case; + make global_counter_get_case; ] let contents_and_result_encoding = @@ -1260,6 +1340,8 @@ let contents_and_result_encoding = make tx_rollup_submit_batch_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; + make global_counter_increment_case; + make global_counter_get_case; ] type 'kind contents_result_list = @@ -1641,6 +1723,60 @@ let kind_equal : } ) -> Some Eq | (Manager_operation {operation = Sc_rollup_add_messages _; _}, _) -> None + | ( Manager_operation {operation = Global_counter_increment _; _}, + Manager_operation_result + {operation_result = Applied (Global_counter_increment_result _); _} ) -> + Some Eq + | ( Manager_operation {operation = Global_counter_increment _; _}, + Manager_operation_result + { + operation_result = Backtracked (Global_counter_increment_result _, _); + _; + } ) -> + Some Eq + | ( Manager_operation {operation = Global_counter_increment _; _}, + Manager_operation_result + { + operation_result = + Failed (Alpha_context.Kind.Global_counter_increment_manager_kind, _); + _; + } ) -> + Some Eq + | ( Manager_operation {operation = Global_counter_increment _; _}, + Manager_operation_result + { + operation_result = + Skipped Alpha_context.Kind.Global_counter_increment_manager_kind; + _; + } ) -> + Some Eq + | (Manager_operation {operation = Global_counter_increment _; _}, _) -> None + | ( Manager_operation {operation = Global_counter_get; _}, + Manager_operation_result + {operation_result = Applied (Global_counter_get_result _); _} ) -> + Some Eq + | ( Manager_operation {operation = Global_counter_get; _}, + Manager_operation_result + {operation_result = Backtracked (Global_counter_get_result _, _); _} ) + -> + Some Eq + | ( Manager_operation {operation = Global_counter_get; _}, + Manager_operation_result + { + operation_result = + Failed (Alpha_context.Kind.Global_counter_get_manager_kind, _); + _; + } ) -> + Some Eq + | ( Manager_operation {operation = Global_counter_get; _}, + Manager_operation_result + { + operation_result = + Skipped Alpha_context.Kind.Global_counter_get_manager_kind; + _; + } ) -> + Some Eq + | (Manager_operation {operation = Global_counter_get; _}, _) -> None let rec kind_equal_list : type kind kind2. diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index 47a7cafc2952..2dd75e011702 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -186,6 +186,14 @@ and _ successful_manager_operation_result = inbox_after : Sc_rollup.Inbox.t; } -> Kind.sc_rollup_add_messages successful_manager_operation_result + | Global_counter_increment_result : { + value : Z.t; + } + -> Kind.global_counter_increment successful_manager_operation_result + | Global_counter_get_result : { + value : Z.t; + } + -> Kind.global_counter_get successful_manager_operation_result and packed_successful_manager_operation_result = | Successful_manager_result : diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 24b882ddbcf6..08f8cdb459cb 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -79,6 +79,10 @@ module Kind = struct type sc_rollup_add_messages = Sc_rollup_add_messages_kind + type global_counter_increment = Global_counter_increment_kind + + type global_counter_get = Global_counter_get_kind + type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager @@ -90,6 +94,8 @@ module Kind = struct | Tx_rollup_submit_batch_manager_kind : tx_rollup_submit_batch manager | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager + | Global_counter_increment_manager_kind : global_counter_increment manager + | Global_counter_get_manager_kind : global_counter_get manager end type 'a consensus_operation_type = @@ -283,6 +289,11 @@ and _ manager_operation = messages : string list; } -> Kind.sc_rollup_add_messages manager_operation + | Global_counter_increment : { + value : Z.t; + } + -> Kind.global_counter_increment manager_operation + | Global_counter_get : Kind.global_counter_get manager_operation and counter = Z.t @@ -298,6 +309,8 @@ let manager_kind : type kind. kind manager_operation -> kind Kind.manager = | Tx_rollup_submit_batch _ -> Kind.Tx_rollup_submit_batch_manager_kind | Sc_rollup_originate _ -> Kind.Sc_rollup_originate_manager_kind | Sc_rollup_add_messages _ -> Kind.Sc_rollup_add_messages_manager_kind + | Global_counter_increment _ -> Kind.Global_counter_increment_manager_kind + | Global_counter_get -> Kind.Global_counter_get_manager_kind type 'kind internal_operation = { source : Contract_repr.contract; @@ -582,6 +595,32 @@ module Encoding = struct Sc_rollup_add_messages {rollup; messages}); } + let[@coq_axiom_with_reason "gadt"] global_counter_increment_case = + MCase + { + tag = 6; + name = "increment_global_counter"; + encoding = obj1 (req "value" Data_encoding.z); + select = + (function + | Manager (Global_counter_increment _ as op) -> Some op | _ -> None); + proj = (function Global_counter_increment {value} -> value); + inj = (fun value -> Global_counter_increment {value}); + } + + let[@coq_axiom_with_reason "gadt"] global_counter_get_case = + MCase + { + tag = 7; + name = "get_global_counter"; + encoding = obj1 (req "dummy" Data_encoding.unit); + select = + (function + | Manager (Global_counter_get as op) -> Some op | _ -> None); + proj = (function Global_counter_get -> ()); + inj = (fun _ -> Global_counter_get); + } + let encoding = let make (MCase {tag; name; encoding; select; proj; inj}) = case @@ -605,6 +644,8 @@ module Encoding = struct make tx_rollup_submit_batch_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; + make global_counter_increment_case; + make global_counter_get_case; ] end @@ -903,6 +944,12 @@ module Encoding = struct let set_deposits_limit_case = make_manager_case 112 Manager_operations.set_deposits_limit_case + let global_counter_increment_case = + make_manager_case 113 Manager_operations.global_counter_increment_case + + let global_counter_get_case = + make_manager_case 114 Manager_operations.global_counter_get_case + let tx_rollup_origination_case = make_manager_case tx_rollup_operation_tag_offset @@ -955,6 +1002,8 @@ module Encoding = struct make tx_rollup_submit_batch_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; + make global_counter_increment_case; + make global_counter_get_case; ] let contents_list_encoding = @@ -1162,6 +1211,10 @@ let equal_manager_operation_kind : | (Sc_rollup_originate _, _) -> None | (Sc_rollup_add_messages _, Sc_rollup_add_messages _) -> Some Eq | (Sc_rollup_add_messages _, _) -> None + | (Global_counter_increment _, Global_counter_increment _) -> Some Eq + | (Global_counter_increment _, _) -> None + | (Global_counter_get, Global_counter_get) -> Some Eq + | (Global_counter_get, _) -> None let equal_contents_kind : type a b. a contents -> b contents -> (a, b) eq option = @@ -1270,6 +1323,8 @@ let internal_manager_operation_size (type a) (op : a manager_operation) = | Tx_rollup_submit_batch _ -> (* Tx_rollup_submit_batch operation can’t occur as internal operations *) assert false + | Global_counter_increment _ -> assert false + | Global_counter_get -> assert false let packed_internal_operation_in_memory_size : packed_internal_operation -> nodes_and_size = function diff --git a/src/proto_alpha/lib_protocol/operation_repr.mli b/src/proto_alpha/lib_protocol/operation_repr.mli index 022990d2e977..7eaf37332b3f 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/operation_repr.mli @@ -105,6 +105,10 @@ module Kind : sig type sc_rollup_add_messages = Sc_rollup_add_messages_kind + type global_counter_increment = Global_counter_increment_kind + + type global_counter_get = Global_counter_get_kind + type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager @@ -116,6 +120,8 @@ module Kind : sig | Tx_rollup_submit_batch_manager_kind : tx_rollup_submit_batch manager | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager + | Global_counter_increment_manager_kind : global_counter_increment manager + | Global_counter_get_manager_kind : global_counter_get manager end type 'a consensus_operation_type = @@ -262,6 +268,11 @@ and _ manager_operation = messages : string list; } -> Kind.sc_rollup_add_messages manager_operation + | Global_counter_increment : { + value : Z.t; + } + -> Kind.global_counter_increment manager_operation + | Global_counter_get : Kind.global_counter_get manager_operation and counter = Z.t @@ -391,6 +402,11 @@ module Encoding : sig val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages Kind.manager case + val global_counter_increment_case : + Kind.global_counter_increment Kind.manager case + + val global_counter_get_case : Kind.global_counter_get Kind.manager case + module Manager_operations : sig type 'b case = | MCase : { @@ -422,5 +438,9 @@ module Encoding : sig val sc_rollup_originate_case : Kind.sc_rollup_originate case val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages case + + val global_counter_increment_case : Kind.global_counter_increment case + + val global_counter_get_case : Kind.global_counter_get case end end diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 8cfc77e35431..0744b16ac158 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -701,7 +701,9 @@ let bake_n_with_all_balance_updates ?(baking_mode = Application) ?policy | Reveal_result _ | Delegation_result _ | Set_deposits_limit_result _ | Tx_rollup_origination_result _ | Tx_rollup_submit_batch_result _ | Sc_rollup_originate_result _ - | Sc_rollup_add_messages_result _ -> + | Sc_rollup_add_messages_result _ + | Global_counter_increment_result _ | Global_counter_get_result _ + -> balance_updates_rev | Transaction_result (Transaction_to_contract_result {balance_updates; _}) @@ -733,7 +735,9 @@ let bake_n_with_origination_results ?(baking_mode = Application) ?policy n b = | Successful_manager_result (Tx_rollup_origination_result _) | Successful_manager_result (Tx_rollup_submit_batch_result _) | Successful_manager_result (Sc_rollup_originate_result _) - | Successful_manager_result (Sc_rollup_add_messages_result _) -> + | Successful_manager_result (Sc_rollup_add_messages_result _) + | Successful_manager_result (Global_counter_increment_result _) + | Successful_manager_result (Global_counter_get_result _) -> origination_results_rev | Successful_manager_result (Origination_result x) -> Origination_result x :: origination_results_rev) diff --git a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml index dffafb095a9c..9a2d1cca581f 100644 --- a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml @@ -250,6 +250,8 @@ let tickets_of_operation ctxt | Tx_rollup_submit_batch _ -> return (None, ctxt) | Sc_rollup_originate {kind = _; boot_sector = _} -> return (None, ctxt) | Sc_rollup_add_messages {rollup = _; messages = _} -> return (None, ctxt) + | Global_counter_increment {value = _} -> return (None, ctxt) + | Global_counter_get -> return (None, ctxt) let add_transfer_to_token_map ctxt token_map {destination; tickets} = List.fold_left_es -- GitLab From 6294a1b90063e9b68b8eb9dd6d96f2305571dde8 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Wed, 9 Feb 2022 10:46:31 +0000 Subject: [PATCH 3/7] Test global counter increment in alpha context --- .../lib_protocol/test/helpers/op.ml | 30 ++++++++++ .../lib_protocol/test/helpers/op.mli | 21 +++++++ .../test/integration/operations/main.ml | 1 + .../operations/test_global_counter.ml | 60 +++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 src/proto_alpha/lib_protocol/test/integration/operations/test_global_counter.ml diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 3b53df76d054..9254d242065d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -332,6 +332,36 @@ let contract_origination ?counter ?delegate ~script ?(preorigination = None) let op = sign account.sk ctxt sop in (op, originated_contract op) +let global_counter_increment ?counter ?public_key ?fee ?gas_limit ?storage_limit + ?(value = Z.one) ctxt source = + Context.Contract.manager ctxt source >>=? fun account -> + let operation = Global_counter_increment {value} in + manager_operation + ?counter + ?public_key + ?fee + ?gas_limit + ?storage_limit + ~source + ctxt + operation + >|=? fun sop -> sign account.sk ctxt sop + +let global_counter_get ?counter ?public_key ?fee ?gas_limit ?storage_limit ctxt + source = + Context.Contract.manager ctxt source >>=? fun account -> + let operation = Global_counter_get in + manager_operation + ?counter + ?public_key + ?fee + ?gas_limit + ?storage_limit + ~source + ctxt + operation + >|=? fun sop -> sign account.sk ctxt sop + let register_global_constant ?counter ?public_key ?fee ?gas_limit ?storage_limit ctxt ~source ~value = Context.Contract.manager ctxt source >>=? fun account -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index ea51e7812696..389560f7c3af 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -109,6 +109,27 @@ val contract_origination : Contract.contract -> (Operation.packed * Contract.contract) tzresult Lwt.t +val global_counter_increment : + ?counter:Z.t -> + ?public_key:public_key -> + ?fee:Tez.tez -> + ?gas_limit:Gas.Arith.integral -> + ?storage_limit:Z.t -> + ?value:Z.t -> + Context.t -> + Contract.contract -> + Operation.packed tzresult Lwt.t + +val global_counter_get : + ?counter:Z.t -> + ?public_key:public_key -> + ?fee:Tez.tez -> + ?gas_limit:Gas.Arith.integral -> + ?storage_limit:Z.t -> + Context.t -> + Contract.contract -> + Operation.packed tzresult Lwt.t + val originated_contract : Operation.packed -> Contract.contract val register_global_constant : diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/main.ml b/src/proto_alpha/lib_protocol/test/integration/operations/main.ml index f9699cfd18b1..017222554e84 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/main.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/main.ml @@ -43,5 +43,6 @@ let () = ("failing_noop operation", Test_failing_noop.tests); ("tx rollup", Test_tx_rollup.tests); ("sc rollup", Test_sc_rollup.tests); + ("global_counter", Test_global_counter.tests); ] |> Lwt_main.run diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_global_counter.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_global_counter.ml new file mode 100644 index 000000000000..4e3f05ba65f4 --- /dev/null +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_global_counter.ml @@ -0,0 +1,60 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Testing + ------- + Component: Protocol (origination) + Invocation: dune exec \ + src/proto_alpha/lib_protocol/test/integration/operations/main.exe \ + -- test "^global_counter$" + Subject: Global counter. +*) + +open Protocol +open Alpha_context + +let wrap m = m >|= Environment.wrap_tzresult + +let increment_global_counter_and_check ~loc b ?(fee = Tez.zero) source = + let open Lwt_tzresult_syntax in + let* op = Op.global_counter_increment (I b) ~fee source in + let* b = Incremental.add_operation b op in + let* (value, _) = wrap (Global_counter.get (Incremental.alpha_ctxt b)) in + Assert.equal_int ~loc (Z.to_int value) 1 + +let test_global_counter_increment () = + Context.init1 () >>=? fun (b, contract) -> + Incremental.begin_construction b >>=? fun b -> + increment_global_counter_and_check ~loc:__LOC__ b contract + +(******************************************************) + +let tests = + [ + Tztest.tztest + "get_counter_increment_fee" + `Quick + test_global_counter_increment; + ] -- GitLab From 9bbd470063587d959b615bfb95a3bcd885f1a8de Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Wed, 9 Feb 2022 10:46:59 +0000 Subject: [PATCH 4/7] Add client commands for global counter manager operations --- .../lib_client/client_proto_context.ml | 66 +++++++++++++ .../lib_client/client_proto_context.mli | 33 +++++++ .../client_proto_context_commands.ml | 94 +++++++++++++++++++ 3 files changed, 193 insertions(+) diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index dae426ee3a1d..735abac058e8 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -248,6 +248,72 @@ let delegate_contract cctxt ~chain ~block ?branch ?confirmations ?dry_run | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> return (oph, op, result) +let increment_global_counter cctxt ~chain ~block ?confirmations ?dry_run + ?verbose_signing ?simulation ?gas_limit ?fee contract ~src_pk ~manager_sk + ~fee_parameter value = + let operation = Global_counter_increment {value} in + let operation = + Injection.prepare_manager_operation + ~fee:(Limit.of_option fee) + ~gas_limit:(Limit.of_option gas_limit) + ~storage_limit:Limit.unknown + operation + in + let operation = Annotated_manager_operation.Single_manager operation in + Injection.inject_manager_operation + cctxt + ~chain + ~block + ?confirmations + ?dry_run + ?verbose_signing + ?simulation + ~source:contract + ~fee:(Limit.of_option fee) + ~gas_limit:Limit.unknown + ~storage_limit:Limit.unknown + ~src_pk + ~src_sk:manager_sk + ~fee_parameter + operation + >>=? fun (oph, op, result) -> + match Apply_results.pack_contents_list op result with + | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> + return (oph, op, result) + +let get_global_counter cctxt ~chain ~block ?confirmations ?dry_run + ?verbose_signing ?simulation ?gas_limit ?fee contract ~src_pk ~manager_sk + ~fee_parameter = + let operation = Global_counter_get in + let operation = + Injection.prepare_manager_operation + ~fee:(Limit.of_option fee) + ~gas_limit:(Limit.of_option gas_limit) + ~storage_limit:Limit.unknown + operation + in + let operation = Annotated_manager_operation.Single_manager operation in + Injection.inject_manager_operation + cctxt + ~chain + ~block + ?confirmations + ?dry_run + ?verbose_signing + ?simulation + ~source:contract + ~fee:(Limit.of_option fee) + ~gas_limit:Limit.unknown + ~storage_limit:Limit.unknown + ~src_pk + ~src_sk:manager_sk + ~fee_parameter + operation + >>=? fun (oph, op, result) -> + match Apply_results.pack_contents_list op result with + | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> + return (oph, op, result) + let list_contract_labels cctxt ~chain ~block = Alpha_services.Contract.list cctxt (chain, block) >>=? fun contracts -> List.rev_map_es diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index 13de9cbe9a8f..a51672e0ad5f 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -130,6 +130,39 @@ val set_delegate : public_key_hash option -> Kind.delegation Kind.manager Injection.result tzresult Lwt.t +val increment_global_counter : + #Protocol_client_context.full -> + chain:Shell_services.chain -> + block:Shell_services.block -> + ?confirmations:int -> + ?dry_run:bool -> + ?verbose_signing:bool -> + ?simulation:bool -> + ?gas_limit:Gas.Arith.integral -> + ?fee:Tez.tez -> + public_key_hash -> + src_pk:public_key -> + manager_sk:Client_keys.sk_uri -> + fee_parameter:Injection.fee_parameter -> + Z.t -> + Kind.global_counter_increment Kind.manager Injection.result tzresult Lwt.t + +val get_global_counter : + #Protocol_client_context.full -> + chain:Shell_services.chain -> + block:Shell_services.block -> + ?confirmations:int -> + ?dry_run:bool -> + ?verbose_signing:bool -> + ?simulation:bool -> + ?gas_limit:Gas.Arith.integral -> + ?fee:Tez.tez -> + public_key_hash -> + src_pk:public_key -> + manager_sk:Client_keys.sk_uri -> + fee_parameter:Injection.fee_parameter -> + Kind.global_counter_get Kind.manager Injection.result tzresult Lwt.t + val set_deposits_limit : #Protocol_client_context.full -> chain:Shell_services.chain -> diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index fba5705a49ae..74b8d26acc9e 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -213,6 +213,34 @@ let commands_ro () = cctxt#message "%a %d" Alpha_context.Contract.pp key size) keys >>= fun () -> return_unit); + command + ~group + ~desc:"Get the global counter" + no_options + (prefixes ["get"; "global"; "counter"] + @@ prefix "from" + @@ ContractAlias.destination_param + ~name:"source" + ~desc:"name of the contract getting the counter" + @@ stop) + (fun () (_, source) (cctxt : Protocol_client_context.full) -> + match Contract.is_implicit source with + | Some source -> + Client_keys.get_key cctxt source >>=? fun (_, src_pk, src_sk) -> + get_global_counter + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + ~gas_limit:(Gas.Arith.integral_of_int_exn 60_000) + ~fee_parameter:Injection.dummy_fee_parameter + source + ~src_pk + ~manager_sk:src_sk + >>=? fun _ -> return_unit + | None -> + failwith + "only implicit accounts can be the source of a get global \ + counter request"); command ~group ~desc:"Get the key rank of a cache key." @@ -2408,6 +2436,72 @@ let commands_rw () = ~fee_parameter () >>=? fun _res -> return_unit); + command + ~group + ~desc:"Increment the global counter" + (args11 + fee_arg + dry_run_switch + verbose_signing_switch + simulate_switch + gas_limit_arg + minimal_fees_arg + minimal_nanotez_per_byte_arg + minimal_nanotez_per_gas_unit_arg + force_low_fee_arg + fee_cap_arg + burn_cap_arg) + (prefixes ["increment"; "global"; "counter"] + @@ prefix "from" + @@ ContractAlias.destination_param + ~name:"source" + ~desc:"name of the contract incrementing the counter" + @@ stop) + (fun ( fee, + dry_run, + verbose_signing, + simulation, + gas_limit, + minimal_fees, + minimal_nanotez_per_byte, + minimal_nanotez_per_gas_unit, + force_low_fee, + fee_cap, + burn_cap ) + (_, source) + (cctxt : Protocol_client_context.full) -> + match Contract.is_implicit source with + | Some source -> + let fee_parameter = + { + Injection.minimal_fees; + minimal_nanotez_per_byte; + minimal_nanotez_per_gas_unit; + force_low_fee; + fee_cap; + burn_cap; + } + in + + Client_keys.get_key cctxt source >>=? fun (_, src_pk, src_sk) -> + increment_global_counter + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + ~fee_parameter + source + ~src_pk + ~manager_sk:src_sk + Z.one + ?fee + ?gas_limit + ?dry_run:(Some dry_run) + ?verbose_signing:(Some verbose_signing) + ?confirmations:cctxt#confirmations + ?simulation:(Some simulation) + >>=? fun _ -> return_unit + | None -> + failwith "only implicit accounts can increment the global counter"); ] let commands network () = -- GitLab From 2c62debec1b5f77e591abed3f956de7d3ed274e6 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Wed, 9 Feb 2022 18:41:42 +0000 Subject: [PATCH 5/7] Add michelson instructions for manipulating global counter --- .../lib_benchmarks_proto/interpreter_model.ml | 2 +- .../lib_benchmarks_proto/interpreter_workload.ml | 13 +++++++++++++ src/proto_alpha/lib_protocol/alpha_context.mli | 2 ++ .../lib_protocol/michelson_v1_primitives.ml | 12 +++++++++++- .../lib_protocol/michelson_v1_primitives.mli | 2 ++ .../lib_protocol/script_interpreter.ml | 16 +++++++++++++++- .../lib_protocol/script_interpreter_defs.ml | 2 ++ .../lib_protocol/script_ir_translator.ml | 11 +++++++++++ src/proto_alpha/lib_protocol/script_typed_ir.ml | 13 +++++++++++++ src/proto_alpha/lib_protocol/script_typed_ir.mli | 9 +++++++++ .../lib_protocol/script_typed_ir_size.ml | 2 ++ 11 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml index 9231a9156768..e0afa28ee4d7 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml @@ -374,7 +374,7 @@ let ir_model ?specialization instr_or_cont = | N_ISource | N_ISender | N_ISelf | N_IAmount | N_IChainId | N_ILevel | N_ISelf_address | N_INever | N_IUnpair | N_IVoting_power | N_ITotal_voting_power | N_IList_size | N_ISet_size | N_IMap_size - | N_ISapling_empty_state -> + | N_ISapling_empty_state | N_IGbl_ctr_get | N_IGbl_ctr_inc -> model_0 instr_or_cont (const1_model name) | N_ISet_mem | N_ISet_update | N_IMap_mem | N_IMap_get | N_IMap_update | N_IBig_map_mem | N_IBig_map_get | N_IBig_map_update diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml index d2db3d792bfb..d64a85641c5d 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml @@ -219,6 +219,9 @@ type instruction_name = | N_ILog (* Timelock*) | N_IOpen_chest + (* Global counter *) + | N_IGbl_ctr_inc + | N_IGbl_ctr_get type continuation_name = | N_KNil @@ -403,6 +406,8 @@ let string_of_instruction_name : instruction_name -> string = | N_IHalt -> "N_IHalt" | N_ILog -> "N_ILog" | N_IOpen_chest -> "N_IOpen_chest" + | N_IGbl_ctr_get -> "N_IGbl_ctr_get" + | N_IGbl_ctr_inc -> "N_IgGbl_ctr_inc" let string_of_continuation_name : continuation_name -> string = fun c -> @@ -622,6 +627,8 @@ let all_instructions = N_IHalt; N_ILog; N_IOpen_chest; + N_IGbl_ctr_get; + N_IGbl_ctr_inc; ] let all_continuations = @@ -1079,6 +1086,10 @@ module Instructions = struct N_IMap_get_and_update (binary "key_size" key_size "map_size" map_size) + let gbl_ctr_get = ir_sized_step N_IGbl_ctr_get nullary + + let gbl_ctr_inc = ir_sized_step N_IGbl_ctr_inc nullary + let halt = ir_sized_step N_IHalt nullary let log = ir_sized_step N_ILog nullary @@ -1439,6 +1450,8 @@ let extract_ir_sized_step : let plaintext_size = Script_timelock.get_plaintext_size chest - 1 in let log_time = Z.log2 Z.(one + Script_int_repr.to_zint time) in Instructions.open_chest log_time plaintext_size + | (IGbl_ctr_get (_, _), _) -> Instructions.gbl_ctr_get + | (IGbl_ctr_inc (_, _), _) -> Instructions.gbl_ctr_inc let extract_control_trace (type bef_top bef aft_top aft) (cont : (bef_top, bef, aft_top, aft) Script_typed_ir.continuation) = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index d99a37f68556..c9a1c916b646 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -546,6 +546,8 @@ module Script : sig | I_EXEC | I_APPLY | I_FAILWITH + | I_GBL_CTR_GET + | I_GBL_CTR_INC | I_GE | I_GET | I_GET_AND_UPDATE diff --git a/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml index c1434b14ec14..a9b5e3238aca 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml +++ b/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml @@ -80,6 +80,8 @@ type prim = | I_EXEC | I_APPLY | I_FAILWITH + | I_GBL_CTR_GET + | I_GBL_CTR_INC | I_GE | I_GET | I_GET_AND_UPDATE @@ -213,7 +215,8 @@ let namespace = function | I_SENDER | I_SET_DELEGATE | I_SHA256 | I_SHA512 | I_SHA3 | I_SIZE | I_SLICE | I_SOME | I_SOURCE | I_SPLIT_TICKET | I_STEPS_TO_QUOTA | I_SUB | I_SUB_MUTEZ | I_SWAP | I_TICKET | I_TOTAL_VOTING_POWER | I_TRANSFER_TOKENS | I_UNIT - | I_UNPACK | I_UNPAIR | I_UPDATE | I_VOTING_POWER | I_XOR | I_OPEN_CHEST -> + | I_UNPACK | I_UNPAIR | I_UPDATE | I_VOTING_POWER | I_XOR | I_OPEN_CHEST + | I_GBL_CTR_GET | I_GBL_CTR_INC -> Instr_namespace | T_address | T_big_map | T_bool | T_bytes | T_chain_id | T_contract | T_int | T_key | T_key_hash | T_lambda | T_list | T_map | T_mutez | T_nat | T_never @@ -283,6 +286,8 @@ let string_of_prim = function | I_EXEC -> "EXEC" | I_APPLY -> "APPLY" | I_FAILWITH -> "FAILWITH" + | I_GBL_CTR_GET -> "GBL_CTR_GET" + | I_GBL_CTR_INC -> "GBL_CTR_INC" | I_GE -> "GE" | I_GET -> "GET" | I_GET_AND_UPDATE -> "GET_AND_UPDATE" @@ -434,6 +439,8 @@ let prim_of_string = function | "EXEC" -> ok I_EXEC | "APPLY" -> ok I_APPLY | "FAILWITH" -> ok I_FAILWITH + | "GBL_CTR_GET" -> ok I_GBL_CTR_GET + | "GBL_CTR_INC" -> ok I_GBL_CTR_INC | "GE" -> ok I_GE | "GET" -> ok I_GET | "GET_AND_UPDATE" -> ok I_GET_AND_UPDATE @@ -748,6 +755,9 @@ let prim_encoding = ("constant", H_constant); (* Alpha_012 addition *) ("SUB_MUTEZ", I_SUB_MUTEZ); + (* Global counter additon *) + ("GBL_CTR_GET", I_GBL_CTR_GET); + ("GBL_CTR_INC", I_GBL_CTR_INC); (* New instructions must be added here, for backward compatibility of the encoding. *) (* Keep the comment above at the end of the list *) ] diff --git a/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli b/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli index 3c2a65db73dd..a3024017adf2 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli +++ b/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli @@ -93,6 +93,8 @@ type prim = | I_EXEC | I_APPLY | I_FAILWITH + | I_GBL_CTR_GET + | I_GBL_CTR_INC | I_GE | I_GET | I_GET_AND_UPDATE diff --git a/src/proto_alpha/lib_protocol/script_interpreter.ml b/src/proto_alpha/lib_protocol/script_interpreter.ml index a4548b7ef5cf..5cdaf8e7d0e2 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter.ml @@ -1481,7 +1481,21 @@ and step : type a s b t r f. (a, s, b, t, r, f) step_type = | Bogus_cipher -> R false | Bogus_opening -> R true) in - (step [@ocaml.tailcall]) g gas k ks accu stack) + (step [@ocaml.tailcall]) g gas k ks accu stack + | IGbl_ctr_inc (_, k) -> + let ctxt = update_context gas ctxt in + let accu = Script_int.to_zint accu in + Global_counter.inc ctxt accu >>=? fun (_, ctxt) -> + let (gas, ctxt) = local_gas_counter_and_outdated_context ctxt in + let (accu, stack) = stack in + (step [@ocaml.tailcall]) (ctxt, sc) gas k ks accu stack + | IGbl_ctr_get (_, k) -> + let ctxt = update_context gas ctxt in + Global_counter.get ctxt >>=? fun (v, ctxt) -> + let (gas, ctxt) = local_gas_counter_and_outdated_context ctxt in + let stack = (accu, stack) in + let accu = Script_int.abs (Script_int.of_zint v) in + (step [@ocaml.tailcall]) (ctxt, sc) gas k ks accu stack) (* diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index 188378173072..c03d8990017d 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -330,6 +330,8 @@ let cost_of_instr : type a s r f. (a, s, r, f) kinstr -> a -> s -> Gas.cost = ~chest ~time:(Alpha_context.Script_int.to_zint time) | ILog _ -> Gas.free + | IGbl_ctr_get _ -> Gas.free + | IGbl_ctr_inc _ -> Gas.free [@@ocaml.inline always] [@@coq_axiom_with_reason "unreachable expression `.` not handled"] diff --git a/src/proto_alpha/lib_protocol/script_ir_translator.ml b/src/proto_alpha/lib_protocol/script_ir_translator.ml index 34df3e5aaa5e..5f728cfaef99 100644 --- a/src/proto_alpha/lib_protocol/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/script_ir_translator.ml @@ -4828,6 +4828,15 @@ and[@coq_axiom_with_reason "gadt"] parse_instr : Lwt.return (let stack = serialize_stack_for_error ctxt stack in error (Bad_stack (loc, name, 2, stack))) + (* Global counter operations *) + | (Prim (loc, I_GBL_CTR_INC, [], annot), Item_t (Nat_t, rest)) -> + check_var_annot loc annot >>?= fun () -> + let instr = {apply = (fun kinfo k -> IGbl_ctr_inc (kinfo, k))} in + typed ctxt loc instr rest + | (Prim (loc, I_GBL_CTR_GET, [], annot), stack) -> + check_var_annot loc annot >>?= fun () -> + let instr = {apply = (fun kinfo k -> IGbl_ctr_get (kinfo, k))} in + typed ctxt loc instr (Item_t (Nat_t, stack)) (* Generic parsing errors *) | (expr, _) -> fail @@ -4853,6 +4862,8 @@ and[@coq_axiom_with_reason "gadt"] parse_instr : I_UPDATE; I_MAP; I_ITER; + I_GBL_CTR_INC; + I_GBL_CTR_GET; I_GET; I_GET_AND_UPDATE; I_EXEC; diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.ml b/src/proto_alpha/lib_protocol/script_typed_ir.ml index fb9243e515b6..acf564b8ca5a 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir.ml @@ -1180,6 +1180,13 @@ and ('before_top, 'before, 'result_top, 'result) kinstr = 'r, 'f ) kinstr + (* Global counter manipulation instruction *) + | IGbl_ctr_inc : + (n num, 'a * 's) kinfo * ('a, 's, 'r, 'f) kinstr + -> (n num, 'a * 's, 'r, 'f) kinstr + | IGbl_ctr_get : + ('a, 's) kinfo * (n num, 'a * 's, 'r, 'f) kinstr + -> ('a, 's, 'r, 'f) kinstr (* Internal control instructions ----------------------------- @@ -1551,6 +1558,8 @@ let kinfo_of_kinstr : type a s b f. (a, s, b, f) kinstr -> (a, s) kinfo = | IHalt kinfo -> kinfo | ILog (kinfo, _, _, _) -> kinfo | IOpen_chest (kinfo, _) -> kinfo + | IGbl_ctr_inc (kinfo, _) -> kinfo + | IGbl_ctr_get (kinfo, _) -> kinfo type kinstr_rewritek = { apply : 'b 'u 'r 'f. ('b, 'u, 'r, 'f) kinstr -> ('b, 'u, 'r, 'f) kinstr; @@ -1758,6 +1767,8 @@ let kinstr_rewritek : | IHalt kinfo -> IHalt kinfo | ILog (kinfo, event, logger, k) -> ILog (kinfo, event, logger, k) | IOpen_chest (kinfo, k) -> IOpen_chest (kinfo, f.apply k) + | IGbl_ctr_get (kinfo, k) -> IGbl_ctr_get (kinfo, f.apply k) + | IGbl_ctr_inc (kinfo, k) -> IGbl_ctr_inc (kinfo, f.apply k) let ty_metadata : type a. a ty -> a ty_metadata = function | Unit_t | Never_t | Int_t | Nat_t | Signature_t | String_t | Bytes_t @@ -2076,6 +2087,8 @@ let kinstr_traverse i init f = | IOpen_chest (_, k) -> (next [@ocaml.tailcall]) k | IHalt _ -> (return [@ocaml.tailcall]) () | ILog (_, _, _, k) -> (next [@ocaml.tailcall]) k + | IGbl_ctr_get (_, k) -> (next [@ocaml.tailcall]) k + | IGbl_ctr_inc (_, k) -> (next [@ocaml.tailcall]) k in aux init i (fun accu -> accu) diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.mli b/src/proto_alpha/lib_protocol/script_typed_ir.mli index e7301a56005a..b3006568c7d4 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.mli +++ b/src/proto_alpha/lib_protocol/script_typed_ir.mli @@ -1177,6 +1177,15 @@ and ('before_top, 'before, 'result_top, 'result) kinstr = 'f ) kinstr (* + Global counter instructions + *) + | IGbl_ctr_inc : + (n num, 'a * 's) kinfo * ('a, 's, 'r, 'f) kinstr + -> (n num, 'a * 's, 'r, 'f) kinstr + | IGbl_ctr_get : + ('a, 's) kinfo * (n num, 'a * 's, 'r, 'f) kinstr + -> ('a, 's, 'r, 'f) kinstr + (* Internal control instructions ============================= diff --git a/src/proto_alpha/lib_protocol/script_typed_ir_size.ml b/src/proto_alpha/lib_protocol/script_typed_ir_size.ml index 43470acd66b0..d8be05a69981 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir_size.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir_size.ml @@ -655,6 +655,8 @@ and kinstr_size : (base kinfo +! word_size) | IOpen_chest (kinfo, _) -> ret_succ_adding accu (base kinfo) | IHalt kinfo -> ret_succ_adding accu (h1w +! kinfo_size kinfo) + | IGbl_ctr_get (kinfo, _) -> ret_succ_adding accu (base kinfo) + | IGbl_ctr_inc (kinfo, _) -> ret_succ_adding accu (base kinfo) | ILog (_, _, _, _) -> (* This instruction is ignored because it is only used for testing. *) accu -- GitLab From 89084f37d794d5bbf7620b81c15b9016ff6215e6 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Thu, 10 Feb 2022 14:55:20 +0000 Subject: [PATCH 6/7] Tests for michelson global counter expression --- .../test/integration/michelson/main.ml | 1 + .../michelson/test_global_counter.ml | 104 ++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/proto_alpha/lib_protocol/test/integration/michelson/test_global_counter.ml diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/main.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/main.ml index 3f8640e3c9e9..d756779e85f2 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/main.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/main.ml @@ -48,5 +48,6 @@ let () = ("timelock", Test_timelock.tests); ("typechecking", Test_typechecking.tests); ("script cache", Test_script_cache.tests); + ("global counter", Test_global_counter.tests); ] |> Lwt_main.run diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_global_counter.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_global_counter.ml new file mode 100644 index 000000000000..0fe5e52ce872 --- /dev/null +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_global_counter.ml @@ -0,0 +1,104 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2021 Trili Tech *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Testing + ------- + Component: Protocol (global counter) + Invocation: dune exec \ + src/proto_alpha/lib_protocol/test/integration/michelson/main.exe \ + -- test "^global counter$" + Subject: This module tests that the global counter + can be written to and read from across blocks. +*) +open Protocol + +open Alpha_context +open Script_interpreter +open Micheline + +let test_context () = + Context.init 1 >>=? fun (b, _cs) -> + Incremental.begin_construction b >>=? fun v -> + return (Incremental.alpha_ctxt v) + +let get_next_context b = + Incremental.begin_construction b >>=? fun b -> + return (Incremental.alpha_ctxt b) + +let register_contract ?consensus_threshold () = + Context.init ?consensus_threshold 1 >|=? function + | (_, []) | (_, _ :: _ :: _) -> assert false + | (b, contract_1 :: _) -> (b, contract_1) + +let wrap m = m >|= Environment.wrap_tzresult + +let get_ctxt (res : execution_result) = res.ctxt + +let get_storage (res : execution_result) = res.storage + +let test_global_counter_increment () = + test_context () >>=? fun ctx -> + (* Get sure that multiplication deals with numbers between 2^62 and + 2^63 without overflowing *) + Contract_helpers.run_script + ctx + "{parameter nat;storage unit;code {UNPAIR; GBL_CTR_INC; DROP; UNIT; NIL \ + operation; PAIR}}" + ~storage:"Unit" + ~parameter:"1" + () + >>=? fun (res, _) -> + wrap (Global_counter.get (get_ctxt res)) >>=? fun (v, _) -> + if v = Z.one then return_unit else Alcotest.fail "Counter was not incremented" + +let test_global_counter_get () = + test_context () >>=? fun ctxt -> + wrap (Global_counter.inc ctxt Z.one) >>=? fun (_, ctxt) -> + Contract_helpers.run_script + ctxt + "{parameter unit; storage nat; code {DROP; GBL_CTR_GET ; NIL operation; \ + PAIR}}" + ~storage:"0" + ~parameter:"Unit" + () + >>=? fun (res, _) -> + match Micheline.root (get_storage res) with + | Int (_, z) -> + if z = Z.one then return_unit + else Alcotest.failf "Unexpected value of counter: %d" (Z.to_int z) + | result -> + Alcotest.failf + "Unexpected result of operation: %a" + Michelson_v1_printer.print_expr + (Micheline.strip_locations result) + +let tests = + [ + Tztest.tztest + "Increment script succeeds" + `Quick + test_global_counter_increment; + Tztest.tztest "Get script succeeds" `Quick test_global_counter_get; + ] -- GitLab From 7694a366860974ef1863d7430e8f116d144015b2 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Thu, 10 Feb 2022 14:56:06 +0000 Subject: [PATCH 7/7] Fix regression tests --- .../_regressions/rpc/alpha.client.mempool.out | 927 ++++++++++++------ tezt/_regressions/rpc/alpha.proxy.mempool.out | 927 ++++++++++++------ 2 files changed, 1266 insertions(+), 588 deletions(-) diff --git a/tezt/_regressions/rpc/alpha.client.mempool.out b/tezt/_regressions/rpc/alpha.client.mempool.out index 14db1d7e7cbd..6483b8eb5102 100644 --- a/tezt/_regressions/rpc/alpha.client.mempool.out +++ b/tezt/_regressions/rpc/alpha.client.mempool.out @@ -856,152 +856,154 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "type": "string", "enum": [ "ABS", - "IF", - "SENDER", - "NEVER", - "False", - "DUG", + "GT", + "SOME", "DIG", - "chest_key", + "False", + "SAPLING_VERIFY_UPDATE", + "SAPLING_EMPTY_STATE", + "bls12_381_fr", "BLAKE2B", - "list", - "bls12_381_g1", + "key_hash", + "chain_id", "Pair", - "INT", - "nat", - "never", + "IF_LEFT", + "map", + "sapling_state", "storage", - "SIZE", + "PUSH", "view", "SHA256", "AND", "VIEW", - "bytes", - "NIL", - "map", - "SUB", - "SAPLING_EMPTY_STATE", + "signature", + "NEG", + "lambda", + "SLICE", + "CAST", "CHECK_SIGNATURE", - "VOTING_POWER", - "operation", - "MAP", - "option", - "bls12_381_fr", + "DUG", + "timestamp", + "LSR", + "big_map", + "bls12_381_g1", "ADD", "IMPLICIT_ACCOUNT", "SHA512", - "int", - "LSL", + "bool", + "LEVEL", + "never", "bls12_381_g2", - "ticket", - "sapling_transaction", + "operation", "COMPARE", - "SWAP", - "STEPS_TO_QUOTA", + "SUB", + "SELF_ADDRESS", "DROP", - "pair", + "option", "BALANCE", "CONCAT", - "MUL", + "chest", + "MAP", "FAILWITH", "Elt", - "lambda", - "OR", + "key", + "NOT", "DIP", - "MEM", - "ITER", - "key_hash", - "XOR", + "LT", + "UPDATE", + "int", + "UNIT", "Some", "parameter", - "address", + "unit", "EMPTY_MAP", "None", - "TRANSFER_TOKENS", - "or", + "SUB_MUTEZ", + "nat", "AMOUNT", - "signature", - "SHA3", - "string", + "pair", + "TOTAL_VOTING_POWER", + "set", "CHAIN_ID", - "HASH_KEY", - "IF_LEFT", + "IF", + "GET_AND_UPDATE", "CREATE_ACCOUNT", - "LT", - "TOTAL_VOTING_POWER", + "LSL", + "NEVER", "UNPACK", - "READ_TICKET", - "SELF_ADDRESS", - "timestamp", - "SET_DELEGATE", - "LE", - "SOURCE", + "PAIRING_CHECK", + "SENDER", + "bytes", + "SWAP", + "INT", + "SIZE", "CREATE_CONTRACT", "Unit", - "SAPLING_VERIFY_UPDATE", - "NONE", - "CONTRACT", - "GE", - "SOME", - "key", - "SELF", - "set", - "CAR", - "NOT", - "unit", - "CDR", + "RENAME", + "NEQ", "LOOP_LEFT", - "PAIRING_CHECK", + "GBL_CTR_GET", "RIGHT", - "LEFT", - "CAST", + "contract", + "SOURCE", + "or", + "CAR", + "NIL", + "mutez", + "CDR", + "XOR", + "KECCAK", + "UNPAIR", + "LAMBDA", + "CONTRACT", "True", "Right", "PACK", - "IF_CONS", - "KECCAK", - "chest", - "UNIT", + "HASH_KEY", + "VOTING_POWER", + "ticket", + "TRANSFER_TOKENS", "EMPTY_SET", - "NEQ", - "LAMBDA", - "mutez", - "TICKET", - "LOOP", + "MUL", + "IF_NONE", + "string", + "SHA3", + "LEFT", "Left", - "contract", - "LSR", + "OPEN_CHEST", + "LOOP", "EMPTY_BIG_MAP", - "sapling_state", - "JOIN_TICKETS", - "LEVEL", - "UNPAIR", - "SPLIT_TICKET", - "PUSH", - "big_map", - "GT", - "chain_id", - "constant", - "NOW", - "IF_NONE", + "address", + "READ_TICKET", + "LE", + "OR", + "TICKET", "PAIR", - "GET_AND_UPDATE", - "UPDATE", + "list", + "GET", + "sapling_transaction", + "chest_key", + "NONE", + "IF_CONS", + "GE", + "NOW", + "SET_DELEGATE", + "ADDRESS", "ISNAT", - "RENAME", - "OPEN_CHEST", + "SPLIT_TICKET", "EDIV", "EQ", - "ADDRESS", - "bool", + "ITER", + "constant", + "JOIN_TICKETS", "EXEC", - "GET", - "NEG", - "SLICE", + "GBL_CTR_INC", + "MEM", + "SELF", "DUP", "CONS", + "STEPS_TO_QUOTA", "APPLY", - "SUB_MUTEZ", "code" ] }, @@ -1891,54 +1893,132 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false - } - ] - }, - "alpha.rollup_address": { - "title": "A smart contract rollup address", - "description": "A smart contract rollup is identified by a base58 address starting with scr1", - "$ref": "#/definitions/unistring" - }, - "alpha.scripted.contracts": { - "type": "object", - "properties": { - "code": { - "oneOf": [ - { - "title": "Int", - "type": "object", - "properties": { - "int": { - "$ref": "#/definitions/bignum" - } - }, - "required": [ - "int" - ], - "additionalProperties": false + }, + { + "title": "Increment_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "increment_global_counter" + ] }, - { - "title": "String", - "type": "object", - "properties": { - "string": { - "$ref": "#/definitions/unistring" - } - }, - "required": [ - "string" - ], - "additionalProperties": false + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" }, - { - "title": "Bytes", - "type": "object", - "properties": { - "bytes": { - "type": "string", - "pattern": "^([a-zA-Z0-9][a-zA-Z0-9])*$" - } - }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "value": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "value", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, + { + "title": "Get_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "get_global_counter" + ] + }, + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "dummy": {} + }, + "required": [ + "dummy", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + } + ] + }, + "alpha.rollup_address": { + "title": "A smart contract rollup address", + "description": "A smart contract rollup is identified by a base58 address starting with scr1", + "$ref": "#/definitions/unistring" + }, + "alpha.scripted.contracts": { + "type": "object", + "properties": { + "code": { + "oneOf": [ + { + "title": "Int", + "type": "object", + "properties": { + "int": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "int" + ], + "additionalProperties": false + }, + { + "title": "String", + "type": "object", + "properties": { + "string": { + "$ref": "#/definitions/unistring" + } + }, + "required": [ + "string" + ], + "additionalProperties": false + }, + { + "title": "Bytes", + "type": "object", + "properties": { + "bytes": { + "type": "string", + "pattern": "^([a-zA-Z0-9][a-zA-Z0-9])*$" + } + }, "required": [ "bytes" ], @@ -2305,6 +2385,26 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ] } }, + { + "description": { + "title": "Z.t", + "description": "A variable-length sequence of bytes encoding a Zarith integer. Each byte has a running unary size bit: the most significant bit of each byte indicates whether this is the last byte in the sequence (0) or whether the sequence continues (1). The second most significant bit of the first byte is reserved for the sign (0 for positive, 1 for negative). Size and sign bits ignored, the data is the binary representation of the absolute value of the number in little-endian order." + }, + "encoding": { + "fields": [ + { + "name": "Z.t", + "layout": { + "kind": "Bytes" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + } + ] + } + }, { "description": { "title": "alpha.scripted.contracts" @@ -4422,7 +4522,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "Set_deposits_limit" }, { - "tag": 150, + "tag": 113, "fields": [ { "name": "Tag", @@ -4491,12 +4591,23 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "Dynamic" }, "kind": "named" + }, + { + "name": "value", + "layout": { + "name": "Z.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" } ], - "name": "Tx_rollup_origination" + "name": "Increment_global_counter" }, { - "tag": 151, + "tag": 114, "fields": [ { "name": "Tag", @@ -4565,38 +4676,86 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "Dynamic" }, "kind": "named" + } + ], + "name": "Get_global_counter" + }, + { + "tag": 150, + "fields": [ + { + "name": "Tag", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" }, { - "name": "rollup", + "name": "source", "layout": { - "kind": "Bytes" + "name": "public_key_hash", + "kind": "Ref" }, "data_kind": { - "size": 20, + "size": 21, "kind": "Float" }, "kind": "named" }, { - "kind": "dyn", - "num_fields": 1, - "size": "Uint30" + "name": "fee", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" }, { - "name": "content", + "name": "counter", "layout": { - "kind": "String" + "name": "N.t", + "kind": "Ref" }, "data_kind": { - "kind": "Variable" + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "gas_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "storage_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" }, "kind": "named" } ], - "name": "Tx_rollup_submit_batch" + "name": "Tx_rollup_origination" }, { - "tag": 200, + "tag": 151, "fields": [ { "name": "Tag", @@ -4667,13 +4826,12 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" }, { - "name": "kind", + "name": "rollup", "layout": { - "name": "X_2", - "kind": "Ref" + "kind": "Bytes" }, "data_kind": { - "size": 2, + "size": 20, "kind": "Float" }, "kind": "named" @@ -4684,7 +4842,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "size": "Uint30" }, { - "name": "boot_sector", + "name": "content", "layout": { "kind": "String" }, @@ -4694,10 +4852,10 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" } ], - "name": "Sc_rollup_originate" + "name": "Tx_rollup_submit_batch" }, { - "tag": 201, + "tag": 200, "fields": [ { "name": "Tag", @@ -4768,18 +4926,14 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" }, { - "kind": "dyn", - "name": "alpha.rollup_address", - "num_fields": 1, - "size": "Uint30" - }, - { - "name": "rollup", + "name": "kind", "layout": { - "kind": "String" + "name": "X_2", + "kind": "Ref" }, "data_kind": { - "kind": "Variable" + "size": 2, + "kind": "Float" }, "kind": "named" }, @@ -4789,13 +4943,9 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "size": "Uint30" }, { - "name": "message", + "name": "boot_sector", "layout": { - "layout": { - "name": "X_1", - "kind": "Ref" - }, - "kind": "Seq" + "kind": "String" }, "data_kind": { "kind": "Variable" @@ -4803,19 +4953,128 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" } ], - "name": "Sc_rollup_add_messages" - } - ] - } - }, - { - "description": { - "title": "X_0" - }, - "encoding": { - "fields": [ + "name": "Sc_rollup_originate" + }, { - "name": "hash", + "tag": 201, + "fields": [ + { + "name": "Tag", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "source", + "layout": { + "name": "public_key_hash", + "kind": "Ref" + }, + "data_kind": { + "size": 21, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "fee", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "counter", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "gas_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "storage_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "kind": "dyn", + "name": "alpha.rollup_address", + "num_fields": 1, + "size": "Uint30" + }, + { + "name": "rollup", + "layout": { + "kind": "String" + }, + "data_kind": { + "kind": "Variable" + }, + "kind": "named" + }, + { + "kind": "dyn", + "num_fields": 1, + "size": "Uint30" + }, + { + "name": "message", + "layout": { + "layout": { + "name": "X_1", + "kind": "Ref" + }, + "kind": "Seq" + }, + "data_kind": { + "kind": "Variable" + }, + "kind": "named" + } + ], + "name": "Sc_rollup_add_messages" + } + ] + } + }, + { + "description": { + "title": "X_0" + }, + "encoding": { + "fields": [ + { + "name": "hash", "layout": { "kind": "Bytes" }, @@ -5736,152 +5995,154 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "type": "string", "enum": [ "ABS", - "IF", - "SENDER", - "NEVER", - "False", - "DUG", + "GT", + "SOME", "DIG", - "chest_key", + "False", + "SAPLING_VERIFY_UPDATE", + "SAPLING_EMPTY_STATE", + "bls12_381_fr", "BLAKE2B", - "list", - "bls12_381_g1", + "key_hash", + "chain_id", "Pair", - "INT", - "nat", - "never", + "IF_LEFT", + "map", + "sapling_state", "storage", - "SIZE", + "PUSH", "view", "SHA256", "AND", "VIEW", - "bytes", - "NIL", - "map", - "SUB", - "SAPLING_EMPTY_STATE", + "signature", + "NEG", + "lambda", + "SLICE", + "CAST", "CHECK_SIGNATURE", - "VOTING_POWER", - "operation", - "MAP", - "option", - "bls12_381_fr", + "DUG", + "timestamp", + "LSR", + "big_map", + "bls12_381_g1", "ADD", "IMPLICIT_ACCOUNT", "SHA512", - "int", - "LSL", + "bool", + "LEVEL", + "never", "bls12_381_g2", - "ticket", - "sapling_transaction", + "operation", "COMPARE", - "SWAP", - "STEPS_TO_QUOTA", + "SUB", + "SELF_ADDRESS", "DROP", - "pair", + "option", "BALANCE", "CONCAT", - "MUL", + "chest", + "MAP", "FAILWITH", "Elt", - "lambda", - "OR", + "key", + "NOT", "DIP", - "MEM", - "ITER", - "key_hash", - "XOR", + "LT", + "UPDATE", + "int", + "UNIT", "Some", "parameter", - "address", + "unit", "EMPTY_MAP", "None", - "TRANSFER_TOKENS", - "or", + "SUB_MUTEZ", + "nat", "AMOUNT", - "signature", - "SHA3", - "string", + "pair", + "TOTAL_VOTING_POWER", + "set", "CHAIN_ID", - "HASH_KEY", - "IF_LEFT", + "IF", + "GET_AND_UPDATE", "CREATE_ACCOUNT", - "LT", - "TOTAL_VOTING_POWER", + "LSL", + "NEVER", "UNPACK", - "READ_TICKET", - "SELF_ADDRESS", - "timestamp", - "SET_DELEGATE", - "LE", - "SOURCE", + "PAIRING_CHECK", + "SENDER", + "bytes", + "SWAP", + "INT", + "SIZE", "CREATE_CONTRACT", "Unit", - "SAPLING_VERIFY_UPDATE", - "NONE", - "CONTRACT", - "GE", - "SOME", - "key", - "SELF", - "set", - "CAR", - "NOT", - "unit", - "CDR", + "RENAME", + "NEQ", "LOOP_LEFT", - "PAIRING_CHECK", + "GBL_CTR_GET", "RIGHT", - "LEFT", - "CAST", + "contract", + "SOURCE", + "or", + "CAR", + "NIL", + "mutez", + "CDR", + "XOR", + "KECCAK", + "UNPAIR", + "LAMBDA", + "CONTRACT", "True", "Right", "PACK", - "IF_CONS", - "KECCAK", - "chest", - "UNIT", + "HASH_KEY", + "VOTING_POWER", + "ticket", + "TRANSFER_TOKENS", "EMPTY_SET", - "NEQ", - "LAMBDA", - "mutez", - "TICKET", - "LOOP", + "MUL", + "IF_NONE", + "string", + "SHA3", + "LEFT", "Left", - "contract", - "LSR", + "OPEN_CHEST", + "LOOP", "EMPTY_BIG_MAP", - "sapling_state", - "JOIN_TICKETS", - "LEVEL", - "UNPAIR", - "SPLIT_TICKET", - "PUSH", - "big_map", - "GT", - "chain_id", - "constant", - "NOW", - "IF_NONE", + "address", + "READ_TICKET", + "LE", + "OR", + "TICKET", "PAIR", - "GET_AND_UPDATE", - "UPDATE", + "list", + "GET", + "sapling_transaction", + "chest_key", + "NONE", + "IF_CONS", + "GE", + "NOW", + "SET_DELEGATE", + "ADDRESS", "ISNAT", - "RENAME", - "OPEN_CHEST", + "SPLIT_TICKET", "EDIV", "EQ", - "ADDRESS", - "bool", + "ITER", + "constant", + "JOIN_TICKETS", "EXEC", - "GET", - "NEG", - "SLICE", + "GBL_CTR_INC", + "MEM", + "SELF", "DUP", "CONS", + "STEPS_TO_QUOTA", "APPLY", - "SUB_MUTEZ", "code" ] }, @@ -6771,6 +7032,84 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false + }, + { + "title": "Increment_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "increment_global_counter" + ] + }, + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "value": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "value", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, + { + "title": "Get_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "get_global_counter" + ] + }, + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "dummy": {} + }, + "required": [ + "dummy", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false } ] }, diff --git a/tezt/_regressions/rpc/alpha.proxy.mempool.out b/tezt/_regressions/rpc/alpha.proxy.mempool.out index e23a8d85fd5a..5b7383aa247e 100644 --- a/tezt/_regressions/rpc/alpha.proxy.mempool.out +++ b/tezt/_regressions/rpc/alpha.proxy.mempool.out @@ -872,152 +872,154 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "type": "string", "enum": [ "ABS", - "IF", - "SENDER", - "NEVER", - "False", - "DUG", + "GT", + "SOME", "DIG", - "chest_key", + "False", + "SAPLING_VERIFY_UPDATE", + "SAPLING_EMPTY_STATE", + "bls12_381_fr", "BLAKE2B", - "list", - "bls12_381_g1", + "key_hash", + "chain_id", "Pair", - "INT", - "nat", - "never", + "IF_LEFT", + "map", + "sapling_state", "storage", - "SIZE", + "PUSH", "view", "SHA256", "AND", "VIEW", - "bytes", - "NIL", - "map", - "SUB", - "SAPLING_EMPTY_STATE", + "signature", + "NEG", + "lambda", + "SLICE", + "CAST", "CHECK_SIGNATURE", - "VOTING_POWER", - "operation", - "MAP", - "option", - "bls12_381_fr", + "DUG", + "timestamp", + "LSR", + "big_map", + "bls12_381_g1", "ADD", "IMPLICIT_ACCOUNT", "SHA512", - "int", - "LSL", + "bool", + "LEVEL", + "never", "bls12_381_g2", - "ticket", - "sapling_transaction", + "operation", "COMPARE", - "SWAP", - "STEPS_TO_QUOTA", + "SUB", + "SELF_ADDRESS", "DROP", - "pair", + "option", "BALANCE", "CONCAT", - "MUL", + "chest", + "MAP", "FAILWITH", "Elt", - "lambda", - "OR", + "key", + "NOT", "DIP", - "MEM", - "ITER", - "key_hash", - "XOR", + "LT", + "UPDATE", + "int", + "UNIT", "Some", "parameter", - "address", + "unit", "EMPTY_MAP", "None", - "TRANSFER_TOKENS", - "or", + "SUB_MUTEZ", + "nat", "AMOUNT", - "signature", - "SHA3", - "string", + "pair", + "TOTAL_VOTING_POWER", + "set", "CHAIN_ID", - "HASH_KEY", - "IF_LEFT", + "IF", + "GET_AND_UPDATE", "CREATE_ACCOUNT", - "LT", - "TOTAL_VOTING_POWER", + "LSL", + "NEVER", "UNPACK", - "READ_TICKET", - "SELF_ADDRESS", - "timestamp", - "SET_DELEGATE", - "LE", - "SOURCE", + "PAIRING_CHECK", + "SENDER", + "bytes", + "SWAP", + "INT", + "SIZE", "CREATE_CONTRACT", "Unit", - "SAPLING_VERIFY_UPDATE", - "NONE", - "CONTRACT", - "GE", - "SOME", - "key", - "SELF", - "set", - "CAR", - "NOT", - "unit", - "CDR", + "RENAME", + "NEQ", "LOOP_LEFT", - "PAIRING_CHECK", + "GBL_CTR_GET", "RIGHT", - "LEFT", - "CAST", + "contract", + "SOURCE", + "or", + "CAR", + "NIL", + "mutez", + "CDR", + "XOR", + "KECCAK", + "UNPAIR", + "LAMBDA", + "CONTRACT", "True", "Right", "PACK", - "IF_CONS", - "KECCAK", - "chest", - "UNIT", + "HASH_KEY", + "VOTING_POWER", + "ticket", + "TRANSFER_TOKENS", "EMPTY_SET", - "NEQ", - "LAMBDA", - "mutez", - "TICKET", - "LOOP", + "MUL", + "IF_NONE", + "string", + "SHA3", + "LEFT", "Left", - "contract", - "LSR", + "OPEN_CHEST", + "LOOP", "EMPTY_BIG_MAP", - "sapling_state", - "JOIN_TICKETS", - "LEVEL", - "UNPAIR", - "SPLIT_TICKET", - "PUSH", - "big_map", - "GT", - "chain_id", - "constant", - "NOW", - "IF_NONE", + "address", + "READ_TICKET", + "LE", + "OR", + "TICKET", "PAIR", - "GET_AND_UPDATE", - "UPDATE", + "list", + "GET", + "sapling_transaction", + "chest_key", + "NONE", + "IF_CONS", + "GE", + "NOW", + "SET_DELEGATE", + "ADDRESS", "ISNAT", - "RENAME", - "OPEN_CHEST", + "SPLIT_TICKET", "EDIV", "EQ", - "ADDRESS", - "bool", + "ITER", + "constant", + "JOIN_TICKETS", "EXEC", - "GET", - "NEG", - "SLICE", + "GBL_CTR_INC", + "MEM", + "SELF", "DUP", "CONS", + "STEPS_TO_QUOTA", "APPLY", - "SUB_MUTEZ", "code" ] }, @@ -1907,54 +1909,132 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false - } - ] - }, - "alpha.rollup_address": { - "title": "A smart contract rollup address", - "description": "A smart contract rollup is identified by a base58 address starting with scr1", - "$ref": "#/definitions/unistring" - }, - "alpha.scripted.contracts": { - "type": "object", - "properties": { - "code": { - "oneOf": [ - { - "title": "Int", - "type": "object", - "properties": { - "int": { - "$ref": "#/definitions/bignum" - } - }, - "required": [ - "int" - ], - "additionalProperties": false + }, + { + "title": "Increment_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "increment_global_counter" + ] }, - { - "title": "String", - "type": "object", - "properties": { - "string": { - "$ref": "#/definitions/unistring" - } - }, - "required": [ - "string" - ], - "additionalProperties": false + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" }, - { - "title": "Bytes", - "type": "object", - "properties": { - "bytes": { - "type": "string", - "pattern": "^([a-zA-Z0-9][a-zA-Z0-9])*$" - } - }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "value": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "value", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, + { + "title": "Get_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "get_global_counter" + ] + }, + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "dummy": {} + }, + "required": [ + "dummy", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + } + ] + }, + "alpha.rollup_address": { + "title": "A smart contract rollup address", + "description": "A smart contract rollup is identified by a base58 address starting with scr1", + "$ref": "#/definitions/unistring" + }, + "alpha.scripted.contracts": { + "type": "object", + "properties": { + "code": { + "oneOf": [ + { + "title": "Int", + "type": "object", + "properties": { + "int": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "int" + ], + "additionalProperties": false + }, + { + "title": "String", + "type": "object", + "properties": { + "string": { + "$ref": "#/definitions/unistring" + } + }, + "required": [ + "string" + ], + "additionalProperties": false + }, + { + "title": "Bytes", + "type": "object", + "properties": { + "bytes": { + "type": "string", + "pattern": "^([a-zA-Z0-9][a-zA-Z0-9])*$" + } + }, "required": [ "bytes" ], @@ -2321,6 +2401,26 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ] } }, + { + "description": { + "title": "Z.t", + "description": "A variable-length sequence of bytes encoding a Zarith integer. Each byte has a running unary size bit: the most significant bit of each byte indicates whether this is the last byte in the sequence (0) or whether the sequence continues (1). The second most significant bit of the first byte is reserved for the sign (0 for positive, 1 for negative). Size and sign bits ignored, the data is the binary representation of the absolute value of the number in little-endian order." + }, + "encoding": { + "fields": [ + { + "name": "Z.t", + "layout": { + "kind": "Bytes" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + } + ] + } + }, { "description": { "title": "alpha.scripted.contracts" @@ -4438,7 +4538,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "Set_deposits_limit" }, { - "tag": 150, + "tag": 113, "fields": [ { "name": "Tag", @@ -4507,12 +4607,23 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "Dynamic" }, "kind": "named" + }, + { + "name": "value", + "layout": { + "name": "Z.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" } ], - "name": "Tx_rollup_origination" + "name": "Increment_global_counter" }, { - "tag": 151, + "tag": 114, "fields": [ { "name": "Tag", @@ -4581,38 +4692,86 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "Dynamic" }, "kind": "named" + } + ], + "name": "Get_global_counter" + }, + { + "tag": 150, + "fields": [ + { + "name": "Tag", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" }, { - "name": "rollup", + "name": "source", "layout": { - "kind": "Bytes" + "name": "public_key_hash", + "kind": "Ref" }, "data_kind": { - "size": 20, + "size": 21, "kind": "Float" }, "kind": "named" }, { - "kind": "dyn", - "num_fields": 1, - "size": "Uint30" + "name": "fee", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" }, { - "name": "content", + "name": "counter", "layout": { - "kind": "String" + "name": "N.t", + "kind": "Ref" }, "data_kind": { - "kind": "Variable" + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "gas_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "storage_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" }, "kind": "named" } ], - "name": "Tx_rollup_submit_batch" + "name": "Tx_rollup_origination" }, { - "tag": 200, + "tag": 151, "fields": [ { "name": "Tag", @@ -4683,13 +4842,12 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" }, { - "name": "kind", + "name": "rollup", "layout": { - "name": "X_2", - "kind": "Ref" + "kind": "Bytes" }, "data_kind": { - "size": 2, + "size": 20, "kind": "Float" }, "kind": "named" @@ -4700,7 +4858,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "size": "Uint30" }, { - "name": "boot_sector", + "name": "content", "layout": { "kind": "String" }, @@ -4710,10 +4868,10 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" } ], - "name": "Sc_rollup_originate" + "name": "Tx_rollup_submit_batch" }, { - "tag": 201, + "tag": 200, "fields": [ { "name": "Tag", @@ -4784,18 +4942,14 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" }, { - "kind": "dyn", - "name": "alpha.rollup_address", - "num_fields": 1, - "size": "Uint30" - }, - { - "name": "rollup", + "name": "kind", "layout": { - "kind": "String" + "name": "X_2", + "kind": "Ref" }, "data_kind": { - "kind": "Variable" + "size": 2, + "kind": "Float" }, "kind": "named" }, @@ -4805,13 +4959,9 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "size": "Uint30" }, { - "name": "message", + "name": "boot_sector", "layout": { - "layout": { - "name": "X_1", - "kind": "Ref" - }, - "kind": "Seq" + "kind": "String" }, "data_kind": { "kind": "Variable" @@ -4819,19 +4969,128 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind": "named" } ], - "name": "Sc_rollup_add_messages" - } - ] - } - }, - { - "description": { - "title": "X_0" - }, - "encoding": { - "fields": [ + "name": "Sc_rollup_originate" + }, { - "name": "hash", + "tag": 201, + "fields": [ + { + "name": "Tag", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "source", + "layout": { + "name": "public_key_hash", + "kind": "Ref" + }, + "data_kind": { + "size": 21, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "fee", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "counter", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "gas_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "name": "storage_limit", + "layout": { + "name": "N.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + }, + { + "kind": "dyn", + "name": "alpha.rollup_address", + "num_fields": 1, + "size": "Uint30" + }, + { + "name": "rollup", + "layout": { + "kind": "String" + }, + "data_kind": { + "kind": "Variable" + }, + "kind": "named" + }, + { + "kind": "dyn", + "num_fields": 1, + "size": "Uint30" + }, + { + "name": "message", + "layout": { + "layout": { + "name": "X_1", + "kind": "Ref" + }, + "kind": "Seq" + }, + "data_kind": { + "kind": "Variable" + }, + "kind": "named" + } + ], + "name": "Sc_rollup_add_messages" + } + ] + } + }, + { + "description": { + "title": "X_0" + }, + "encoding": { + "fields": [ + { + "name": "hash", "layout": { "kind": "Bytes" }, @@ -5752,152 +6011,154 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "type": "string", "enum": [ "ABS", - "IF", - "SENDER", - "NEVER", - "False", - "DUG", + "GT", + "SOME", "DIG", - "chest_key", + "False", + "SAPLING_VERIFY_UPDATE", + "SAPLING_EMPTY_STATE", + "bls12_381_fr", "BLAKE2B", - "list", - "bls12_381_g1", + "key_hash", + "chain_id", "Pair", - "INT", - "nat", - "never", + "IF_LEFT", + "map", + "sapling_state", "storage", - "SIZE", + "PUSH", "view", "SHA256", "AND", "VIEW", - "bytes", - "NIL", - "map", - "SUB", - "SAPLING_EMPTY_STATE", + "signature", + "NEG", + "lambda", + "SLICE", + "CAST", "CHECK_SIGNATURE", - "VOTING_POWER", - "operation", - "MAP", - "option", - "bls12_381_fr", + "DUG", + "timestamp", + "LSR", + "big_map", + "bls12_381_g1", "ADD", "IMPLICIT_ACCOUNT", "SHA512", - "int", - "LSL", + "bool", + "LEVEL", + "never", "bls12_381_g2", - "ticket", - "sapling_transaction", + "operation", "COMPARE", - "SWAP", - "STEPS_TO_QUOTA", + "SUB", + "SELF_ADDRESS", "DROP", - "pair", + "option", "BALANCE", "CONCAT", - "MUL", + "chest", + "MAP", "FAILWITH", "Elt", - "lambda", - "OR", + "key", + "NOT", "DIP", - "MEM", - "ITER", - "key_hash", - "XOR", + "LT", + "UPDATE", + "int", + "UNIT", "Some", "parameter", - "address", + "unit", "EMPTY_MAP", "None", - "TRANSFER_TOKENS", - "or", + "SUB_MUTEZ", + "nat", "AMOUNT", - "signature", - "SHA3", - "string", + "pair", + "TOTAL_VOTING_POWER", + "set", "CHAIN_ID", - "HASH_KEY", - "IF_LEFT", + "IF", + "GET_AND_UPDATE", "CREATE_ACCOUNT", - "LT", - "TOTAL_VOTING_POWER", + "LSL", + "NEVER", "UNPACK", - "READ_TICKET", - "SELF_ADDRESS", - "timestamp", - "SET_DELEGATE", - "LE", - "SOURCE", + "PAIRING_CHECK", + "SENDER", + "bytes", + "SWAP", + "INT", + "SIZE", "CREATE_CONTRACT", "Unit", - "SAPLING_VERIFY_UPDATE", - "NONE", - "CONTRACT", - "GE", - "SOME", - "key", - "SELF", - "set", - "CAR", - "NOT", - "unit", - "CDR", + "RENAME", + "NEQ", "LOOP_LEFT", - "PAIRING_CHECK", + "GBL_CTR_GET", "RIGHT", - "LEFT", - "CAST", + "contract", + "SOURCE", + "or", + "CAR", + "NIL", + "mutez", + "CDR", + "XOR", + "KECCAK", + "UNPAIR", + "LAMBDA", + "CONTRACT", "True", "Right", "PACK", - "IF_CONS", - "KECCAK", - "chest", - "UNIT", + "HASH_KEY", + "VOTING_POWER", + "ticket", + "TRANSFER_TOKENS", "EMPTY_SET", - "NEQ", - "LAMBDA", - "mutez", - "TICKET", - "LOOP", + "MUL", + "IF_NONE", + "string", + "SHA3", + "LEFT", "Left", - "contract", - "LSR", + "OPEN_CHEST", + "LOOP", "EMPTY_BIG_MAP", - "sapling_state", - "JOIN_TICKETS", - "LEVEL", - "UNPAIR", - "SPLIT_TICKET", - "PUSH", - "big_map", - "GT", - "chain_id", - "constant", - "NOW", - "IF_NONE", + "address", + "READ_TICKET", + "LE", + "OR", + "TICKET", "PAIR", - "GET_AND_UPDATE", - "UPDATE", + "list", + "GET", + "sapling_transaction", + "chest_key", + "NONE", + "IF_CONS", + "GE", + "NOW", + "SET_DELEGATE", + "ADDRESS", "ISNAT", - "RENAME", - "OPEN_CHEST", + "SPLIT_TICKET", "EDIV", "EQ", - "ADDRESS", - "bool", + "ITER", + "constant", + "JOIN_TICKETS", "EXEC", - "GET", - "NEG", - "SLICE", + "GBL_CTR_INC", + "MEM", + "SELF", "DUP", "CONS", + "STEPS_TO_QUOTA", "APPLY", - "SUB_MUTEZ", "code" ] }, @@ -6787,6 +7048,84 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false + }, + { + "title": "Increment_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "increment_global_counter" + ] + }, + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "value": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "value", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, + { + "title": "Get_global_counter", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "get_global_counter" + ] + }, + "source": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "fee": { + "$ref": "#/definitions/alpha.mutez" + }, + "counter": { + "$ref": "#/definitions/positive_bignum" + }, + "gas_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "storage_limit": { + "$ref": "#/definitions/positive_bignum" + }, + "dummy": {} + }, + "required": [ + "dummy", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false } ] }, -- GitLab