diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index c429ab748b0754e91261440526571c8e35f1a12a..c0bd99de8f6b78c9959600742f2759d4be05ba06 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -1160,3 +1160,36 @@ let sc_rollup_cement (cctxt : #full) ~chain ~block ?confirmations ?dry_run match Apply_results.pack_contents_list op result with | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> return (oph, op, result) + +let sc_rollup_publish (cctxt : #full) ~chain ~block ?confirmations ?dry_run + ?verbose_signing ?simulation ?fee ?gas_limit ?storage_limit ?counter ~source + ~rollup ~commitment ~src_pk ~src_sk ~fee_parameter () = + let op = + Annotated_manager_operation.Single_manager + (Injection.prepare_manager_operation + ~fee:(Limit.of_option fee) + ~gas_limit:(Limit.of_option gas_limit) + ~storage_limit:(Limit.of_option storage_limit) + (Sc_rollup_publish {rollup; commitment})) + in + Injection.inject_manager_operation + cctxt + ~chain + ~block + ?confirmations + ?dry_run + ?verbose_signing + ?simulation + ?counter + ~source + ~fee:(Limit.of_option fee) + ~storage_limit:(Limit.of_option storage_limit) + ~gas_limit:(Limit.of_option gas_limit) + ~src_pk + ~src_sk + ~fee_parameter + op + >>=? 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) diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index 45e5015d3be2004e5bbb44dc5655c14e45db20bb..e50a18094b97ba6a808fefb34a6a43419588ceee 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -651,3 +651,28 @@ val sc_rollup_cement : * Kind.sc_rollup_cement Kind.manager Apply_results.contents_result) tzresult Lwt.t + +val sc_rollup_publish : + #Protocol_client_context.full -> + chain:Chain_services.chain -> + block:Block_services.block -> + ?confirmations:int -> + ?dry_run:bool -> + ?verbose_signing:bool -> + ?simulation:bool -> + ?fee:Tez.t -> + ?gas_limit:Gas.Arith.integral -> + ?storage_limit:counter -> + ?counter:counter -> + source:public_key_hash -> + rollup:Alpha_context.Sc_rollup.t -> + commitment:Alpha_context.Sc_rollup.Commitment.t -> + src_pk:public_key -> + src_sk:Client_keys.sk_uri -> + fee_parameter:Injection.fee_parameter -> + unit -> + (Operation_hash.t + * Kind.sc_rollup_publish Kind.manager contents + * Kind.sc_rollup_publish Kind.manager Apply_results.contents_result) + tzresult + Lwt.t diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index c1b9d007d84d44ba94498db7cdd7c948304c4b9b..b6a8be045040aed20869927b77be801a25b3f1e1 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -342,6 +342,7 @@ let estimated_gas_single (type kind) | Applied (Sc_rollup_add_messages_result {consumed_gas; _}) -> Ok consumed_gas | Applied (Sc_rollup_cement_result {consumed_gas; _}) -> Ok consumed_gas + | Applied (Sc_rollup_publish_result {consumed_gas; _}) -> Ok consumed_gas | Skipped _ -> assert false | Backtracked (_, None) -> Ok Gas.Arith.zero (* there must be another error for this to happen *) @@ -395,7 +396,14 @@ let estimated_storage_single (type kind) ~tx_rollup_origination_size | Applied (Tx_rollup_withdraw_result _) -> Ok Z.zero | Applied (Sc_rollup_originate_result {size; _}) -> Ok size | Applied (Sc_rollup_add_messages_result _) -> Ok Z.zero + (* The following Sc_rollup operations have zero storage cost because we + consider them to be paid in the stake deposit. + + TODO: https://gitlab.com/tezos/tezos/-/issues/2686 + Document why this is safe. + *) | Applied (Sc_rollup_cement_result _) -> Ok Z.zero + | Applied (Sc_rollup_publish_result _) -> Ok Z.zero | Skipped _ -> assert false | Backtracked (_, None) -> Ok Z.zero (* there must be another error for this to happen *) @@ -456,6 +464,7 @@ let originated_contracts_single (type kind) | Applied (Sc_rollup_originate_result _) -> Ok [] | Applied (Sc_rollup_add_messages_result _) -> Ok [] | Applied (Sc_rollup_cement_result _) -> Ok [] + | Applied (Sc_rollup_publish_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 e815e7589e524a482b1ac10eb4e73b1492780b51..e7b74ff0bbbfd62c28f5ad21090d1dd2f5a06129 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -291,6 +291,17 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Sc_rollup.Address.pp rollup pp_result + result + | Sc_rollup_publish {rollup; commitment} -> + Format.fprintf + ppf + "@[Publish commitment %a in the smart contract rollup at address \ + %a%a@]" + Sc_rollup.Commitment.pp + commitment + Sc_rollup.Address.pp + rollup + pp_result result) ; Format.fprintf ppf "@]" @@ -615,6 +626,15 @@ let pp_manager_operation_contents_and_result ppf let pp_sc_rollup_cement_result (Sc_rollup_cement_result {consumed_gas}) = Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas in + let pp_sc_rollup_publish_result + (Sc_rollup_publish_result {consumed_gas; staked_hash}) = + Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas ; + Format.fprintf + ppf + "@,Hash of commit: %a" + Sc_rollup.Commitment_hash.pp + staked_hash + in let pp_result (type kind) ppf (result : kind manager_operation_result) = Format.fprintf ppf "@," ; match result with @@ -799,6 +819,19 @@ let pp_manager_operation_contents_and_result ppf rollup was BACKTRACKED, its expected effects (as follow) were NOT \ applied.@]" ; pp_sc_rollup_cement_result op + | Applied (Sc_rollup_publish_result _ as op) -> + Format.fprintf + ppf + "This operation publishing a commitment on a smart contract rollup \ + was successfully applied" ; + pp_sc_rollup_publish_result op + | Backtracked ((Sc_rollup_publish_result _ as op), _errs) -> + Format.fprintf + ppf + "@[This operation publishing a commitment on a smart contract \ + rollup was BACKTRACKED, its expected effects (as follow) were NOT \ + applied.@]" ; + pp_sc_rollup_publish_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 9b4802fcb1b05d048fdfa9f145537fe727817268..17b8094fc29b8f0b7a0854f7f1329e476804977f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -218,6 +218,8 @@ module Raw_level : sig val to_int32 : raw_level -> int32 val of_int32 : int32 -> raw_level tzresult + + val of_int32_exn : int32 -> raw_level end module Cycle : sig @@ -2411,7 +2413,7 @@ module Sc_rollup : sig module Commitment : sig type t = { compressed_state : State_hash.t; - inbox_level : Raw_level_repr.t; + inbox_level : Raw_level.t; predecessor : Commitment_hash.t; number_of_messages : Number_of_messages.t; number_of_ticks : Number_of_ticks.t; @@ -2419,6 +2421,8 @@ module Sc_rollup : sig val encoding : t Data_encoding.t + val pp : Format.formatter -> t -> unit + val hash : t -> Commitment_hash.t end @@ -2456,6 +2460,13 @@ module Sc_rollup : sig Commitment.t -> (Commitment_hash.t * context) tzresult Lwt.t + val publish_commitment : + context -> + t -> + Staker.t -> + Commitment.t -> + (Commitment_hash.t * context) tzresult Lwt.t + val cement_commitment : context -> t -> Commitment_hash.t -> context tzresult Lwt.t @@ -2476,6 +2487,10 @@ module Sc_rollup : sig val list : context -> t list tzresult Lwt.t val initial_level : context -> t -> Raw_level_repr.t tzresult Lwt.t + + module Internal_for_tests : sig + val originated_sc_rollup : Origination_nonce.Internal_for_tests.t -> t + end end module Block_payload : sig @@ -2656,6 +2671,8 @@ module Kind : sig type sc_rollup_cement = Sc_rollup_cement_kind + type sc_rollup_publish = Sc_rollup_publish_kind + type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager @@ -2676,6 +2693,7 @@ module Kind : sig | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager | Sc_rollup_cement_manager_kind : sc_rollup_cement manager + | Sc_rollup_publish_manager_kind : sc_rollup_publish manager end type 'a consensus_operation_type = @@ -2859,6 +2877,11 @@ and _ manager_operation = commitment : Sc_rollup.Commitment_hash.t; } -> Kind.sc_rollup_cement manager_operation + | Sc_rollup_publish : { + rollup : Sc_rollup.t; + commitment : Sc_rollup.Commitment.t; + } + -> Kind.sc_rollup_publish manager_operation and counter = Z.t @@ -3015,6 +3038,8 @@ module Operation : sig val sc_rollup_cement_case : Kind.sc_rollup_cement Kind.manager case + val sc_rollup_publish_case : Kind.sc_rollup_publish Kind.manager case + module Manager_operations : sig type 'b case = | MCase : { @@ -3068,6 +3093,8 @@ module Operation : sig val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages case val sc_rollup_cement_case : Kind.sc_rollup_cement case + + val sc_rollup_publish_case : Kind.sc_rollup_publish case end end diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 9a12fa2a225a70f123c919fdb81494b85a3a6d7e..bc579c92282fa7d75531e92c8790d152b5c58a84 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1747,6 +1747,12 @@ let apply_external_manager_operation_content : let consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt in let result = Sc_rollup_cement_result {consumed_gas} in return (ctxt, result, []) + | Sc_rollup_publish {rollup; commitment} -> + Sc_rollup.publish_commitment ctxt rollup source commitment + >>=? fun (staked_hash, ctxt) -> + let consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt in + let result = Sc_rollup_publish_result {staked_hash; consumed_gas} in + return (ctxt, result, []) type success_or_failure = Success of context | Failure @@ -1919,7 +1925,8 @@ let precheck_manager_contents (type kind) ctxt (op : kind Kind.manager contents) (Tx_rollup_errors.Wrong_message_path_depth {provided = path_size; limit = maximum_path_size}) else return ctxt - | Sc_rollup_originate _ | Sc_rollup_add_messages _ | Sc_rollup_cement _ -> + | Sc_rollup_originate _ | Sc_rollup_add_messages _ | Sc_rollup_cement _ + | Sc_rollup_publish _ -> assert_sc_rollup_feature_enabled ctxt >|=? fun () -> ctxt) >>=? fun ctxt -> Contract.increment_counter ctxt source >>=? fun ctxt -> @@ -2048,6 +2055,7 @@ let burn_storage_fees : return (ctxt, storage_limit, result) | Sc_rollup_add_messages_result _ -> return (ctxt, storage_limit, smopr) | Sc_rollup_cement_result _ -> return (ctxt, storage_limit, smopr) + | Sc_rollup_publish_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 623b28c9effcc9a70fbb13aea7959bc59e5aaa4f..1559fbafd44f7b8326d40c7b58dd0d1d658eb0d3 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -202,6 +202,11 @@ type _ successful_manager_operation_result = consumed_gas : Gas.Arith.fp; } -> Kind.sc_rollup_cement successful_manager_operation_result + | Sc_rollup_publish_result : { + consumed_gas : Gas.Arith.fp; + staked_hash : Sc_rollup.Commitment_hash.t; + } + -> Kind.sc_rollup_publish successful_manager_operation_result let migration_origination_result_to_successful_manager_operation_result ({ @@ -839,6 +844,26 @@ module Manager_result = struct ~inj:(fun (consumed_gas, consumed_milligas) -> assert (Gas.Arith.(equal (ceil consumed_milligas) consumed_gas)) ; Sc_rollup_cement_result {consumed_gas = consumed_milligas}) + + let sc_rollup_publish_case = + make + ~op_case:Operation.Encoding.Manager_operations.sc_rollup_publish_case + ~encoding: + (obj3 + (req "consumed_gas" Gas.Arith.n_integral_encoding) + (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) + (req "staked_hash" Sc_rollup.Commitment_hash.encoding)) + ~select:(function + | Successful_manager_result (Sc_rollup_publish_result _ as op) -> + Some op + | _ -> None) + ~proj:(function + | Sc_rollup_publish_result {consumed_gas; staked_hash} -> + (Gas.Arith.ceil consumed_gas, consumed_gas, staked_hash)) + ~kind:Kind.Sc_rollup_publish_manager_kind + ~inj:(fun (consumed_gas, consumed_milligas, staked_hash) -> + assert (Gas.Arith.(equal (ceil consumed_milligas) consumed_gas)) ; + Sc_rollup_publish_result {consumed_gas = consumed_milligas; staked_hash}) end type 'kind iselect = @@ -1154,6 +1179,10 @@ let equal_manager_kind : | (Kind.Sc_rollup_cement_manager_kind, Kind.Sc_rollup_cement_manager_kind) -> Some Eq | (Kind.Sc_rollup_cement_manager_kind, _) -> None + | (Kind.Sc_rollup_publish_manager_kind, Kind.Sc_rollup_publish_manager_kind) + -> + Some Eq + | (Kind.Sc_rollup_publish_manager_kind, _) -> None module Encoding = struct type 'kind case = @@ -1627,6 +1656,17 @@ module Encoding = struct -> Some (op, res) | _ -> None) + + let[@coq_axiom_with_reason "gadt"] sc_rollup_publish_case = + make_manager_case + Operation.Encoding.sc_rollup_publish_case + Manager_result.sc_rollup_publish_case + (function + | Contents_and_result + ((Manager_operation {operation = Sc_rollup_publish _; _} as op), res) + -> + Some (op, res) + | _ -> None) end let contents_result_encoding = @@ -1674,6 +1714,7 @@ let contents_result_encoding = make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; + make sc_rollup_publish_case; ] let contents_and_result_encoding = @@ -1725,6 +1766,7 @@ let contents_and_result_encoding = make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; + make sc_rollup_publish_case; ] type 'kind contents_result_list = @@ -2299,6 +2341,31 @@ let kind_equal : } ) -> Some Eq | (Manager_operation {operation = Sc_rollup_cement _; _}, _) -> None + | ( Manager_operation {operation = Sc_rollup_publish _; _}, + Manager_operation_result + {operation_result = Applied (Sc_rollup_publish_result _); _} ) -> + Some Eq + | ( Manager_operation {operation = Sc_rollup_publish _; _}, + Manager_operation_result + {operation_result = Backtracked (Sc_rollup_publish_result _, _); _} ) -> + Some Eq + | ( Manager_operation {operation = Sc_rollup_publish _; _}, + Manager_operation_result + { + operation_result = + Failed (Alpha_context.Kind.Sc_rollup_publish_manager_kind, _); + _; + } ) -> + Some Eq + | ( Manager_operation {operation = Sc_rollup_publish _; _}, + Manager_operation_result + { + operation_result = + Skipped Alpha_context.Kind.Sc_rollup_publish_manager_kind; + _; + } ) -> + Some Eq + | (Manager_operation {operation = Sc_rollup_publish _; _}, _) -> 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 bd1dff6b3bbc55b691ece64e8510d39f4bcdf02c..15d2aa4f1e0e22c2be4e2e3931f6f5f9474fd931 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -262,6 +262,11 @@ and _ successful_manager_operation_result = consumed_gas : Gas.Arith.fp; } -> Kind.sc_rollup_cement successful_manager_operation_result + | Sc_rollup_publish_result : { + consumed_gas : Gas.Arith.fp; + staked_hash : Sc_rollup.Commitment_hash.t; + } + -> Kind.sc_rollup_publish 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 8051b2b91e4598d76c54dd75d8dbeb0fa99f54b3..e2805c4506e1ce5a665561bd28b4e5d69137250f 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -93,6 +93,8 @@ module Kind = struct type sc_rollup_cement = Sc_rollup_cement_kind + type sc_rollup_publish = Sc_rollup_publish_kind + type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager @@ -113,6 +115,7 @@ module Kind = struct | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager | Sc_rollup_cement_manager_kind : sc_rollup_cement manager + | Sc_rollup_publish_manager_kind : sc_rollup_publish manager end type 'a consensus_operation_type = @@ -356,6 +359,11 @@ and _ manager_operation = commitment : Sc_rollup_repr.Commitment_hash.t; } -> Kind.sc_rollup_cement manager_operation + | Sc_rollup_publish : { + rollup : Sc_rollup_repr.t; + commitment : Sc_rollup_repr.Commitment.t; + } + -> Kind.sc_rollup_publish manager_operation and counter = Z.t @@ -380,6 +388,7 @@ let manager_kind : type kind. kind manager_operation -> kind Kind.manager = | Sc_rollup_originate _ -> Kind.Sc_rollup_originate_manager_kind | Sc_rollup_add_messages _ -> Kind.Sc_rollup_add_messages_manager_kind | Sc_rollup_cement _ -> Kind.Sc_rollup_cement_manager_kind + | Sc_rollup_publish _ -> Kind.Sc_rollup_publish_manager_kind type packed_manager_operation = | Manager : 'kind manager_operation -> packed_manager_operation @@ -458,6 +467,8 @@ let sc_rollup_operation_add_message_tag = sc_rollup_operation_tag_offset + 1 let sc_rollup_operation_cement_tag = sc_rollup_operation_tag_offset + 2 +let sc_rollup_operation_publish_tag = sc_rollup_operation_tag_offset + 3 + module Encoding = struct open Data_encoding @@ -902,6 +913,25 @@ module Encoding = struct inj = (fun (rollup, commitment) -> Sc_rollup_cement {rollup; commitment}); } + + let[@coq_axiom_with_reason "gadt"] sc_rollup_publish_case = + MCase + { + tag = sc_rollup_operation_publish_tag; + name = "sc_rollup_publish"; + encoding = + obj2 + (req "rollup" Sc_rollup_repr.encoding) + (req "commitment" Sc_rollup_repr.Commitment.encoding); + select = + (function + | Manager (Sc_rollup_publish _ as op) -> Some op | _ -> None); + proj = + (function + | Sc_rollup_publish {rollup; commitment} -> (rollup, commitment)); + inj = + (fun (rollup, commitment) -> Sc_rollup_publish {rollup; commitment}); + } end type 'b case = @@ -1252,6 +1282,11 @@ module Encoding = struct sc_rollup_operation_cement_tag Manager_operations.sc_rollup_cement_case + let sc_rollup_publish_case = + make_manager_case + sc_rollup_operation_publish_tag + Manager_operations.sc_rollup_publish_case + let contents_encoding = let make (Case {tag; name; encoding; select; proj; inj}) = case @@ -1291,6 +1326,7 @@ module Encoding = struct make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; + make sc_rollup_publish_case; ] let contents_list_encoding = @@ -1500,6 +1536,8 @@ let equal_manager_operation_kind : | (Sc_rollup_add_messages _, _) -> None | (Sc_rollup_cement _, Sc_rollup_cement _) -> Some Eq | (Sc_rollup_cement _, _) -> None + | (Sc_rollup_publish _, Sc_rollup_publish _) -> Some Eq + | (Sc_rollup_publish _, _) -> None let equal_contents_kind : type a b. a contents -> b contents -> (a, b) eq option = diff --git a/src/proto_alpha/lib_protocol/operation_repr.mli b/src/proto_alpha/lib_protocol/operation_repr.mli index d554dd4666a3edc6d1d2e2f02bd0e9fe99fd043e..5fafe68f10d5a2b9a6a9c27120839567c6a087c5 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/operation_repr.mli @@ -121,6 +121,8 @@ module Kind : sig type sc_rollup_cement = Sc_rollup_cement_kind + type sc_rollup_publish = Sc_rollup_publish_kind + type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager @@ -141,6 +143,7 @@ module Kind : sig | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager | Sc_rollup_cement_manager_kind : sc_rollup_cement manager + | Sc_rollup_publish_manager_kind : sc_rollup_publish manager end type 'a consensus_operation_type = @@ -428,6 +431,11 @@ and _ manager_operation = commitment : Sc_rollup_repr.Commitment_hash.t; } -> Kind.sc_rollup_cement manager_operation + | Sc_rollup_publish : { + rollup : Sc_rollup_repr.t; + commitment : Sc_rollup_repr.Commitment.t; + } + -> Kind.sc_rollup_publish manager_operation (** Counters are used as anti-replay protection mechanism in manager operations: each manager account stores a counter and @@ -564,6 +572,8 @@ module Encoding : sig val sc_rollup_cement_case : Kind.sc_rollup_cement Kind.manager case + val sc_rollup_publish_case : Kind.sc_rollup_publish Kind.manager case + module Manager_operations : sig type 'b case = | MCase : { @@ -616,5 +626,7 @@ module Encoding : sig val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages case val sc_rollup_cement_case : Kind.sc_rollup_cement case + + val sc_rollup_publish_case : Kind.sc_rollup_publish case end end diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index ebebb4eae471aa9b7a5f56f82c8cfde4e772a31d..82174159d3208489412ee4228d1c170a63e19c2f 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml @@ -72,6 +72,14 @@ module Address = struct | Some nonce -> ok @@ hash_bytes [nonce] end +module Internal_for_tests = struct + let originated_sc_rollup nonce = + let data = + Data_encoding.Binary.to_bytes_exn Origination_nonce.encoding nonce + in + Address.hash_bytes [data] +end + (* 32 *) let commitment_hash_prefix = "\017\144\021\100" (* scc1(54) *) @@ -237,6 +245,27 @@ module Commitment = struct number_of_ticks : Number_of_ticks.t; } + let pp fmt + { + compressed_state; + inbox_level; + predecessor; + number_of_messages; + number_of_ticks; + } = + Format.fprintf + fmt + "@[SCORU Commitment:@ compressed_state: %a@ inbox_level: %a@ \ + predecessor: %a@ number_of_messages: %d@ number_of_ticks: %d@]" + State_hash.pp + compressed_state + Raw_level_repr.pp + inbox_level + Commitment_hash.pp + predecessor + (Int32.to_int (Number_of_messages.to_int32 number_of_messages)) + (Int32.to_int (Number_of_ticks.to_int32 number_of_ticks)) + let encoding = let open Data_encoding in conv diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli index f9c49c2b016b98470f74d5f3fed767dab21e8cb4..72807ac004a546844d89cc07e3c2f93e287b6985 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli @@ -52,6 +52,10 @@ module Address : sig val encoded_size : int end +module Internal_for_tests : sig + val originated_sc_rollup : Origination_nonce.t -> Address.t +end + module Commitment_hash : S.HASH module State_hash : S.HASH @@ -102,6 +106,8 @@ module Commitment : sig number_of_ticks : Number_of_ticks.t; } + val pp : Format.formatter -> t -> unit + val encoding : t Data_encoding.t val hash : t -> Commitment_hash.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_storage.ml b/src/proto_alpha/lib_protocol/sc_rollup_storage.ml index cbe5ba601a312ecd581f343af5a7689e534bf5c8..fed21b17ce96b3a1f24324eda2647154a8ae92bb 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_storage.ml @@ -540,6 +540,15 @@ let refine_stake ctxt rollup staker commitment = in go Commitment.(commitment.predecessor) ctxt +let publish_commitment ctxt rollup staker commitment = + let open Lwt_tzresult_syntax in + let* (ctxt, res) = Store.Stakers.find (ctxt, rollup) staker in + match res with + | None -> + let* ctxt = deposit_stake ctxt rollup staker in + refine_stake ctxt rollup staker commitment + | Some _ -> refine_stake ctxt rollup staker commitment + let cement_commitment ctxt rollup new_lcc = let open Lwt_tzresult_syntax in let refutation_deadline_blocks = diff --git a/src/proto_alpha/lib_protocol/sc_rollup_storage.mli b/src/proto_alpha/lib_protocol/sc_rollup_storage.mli index b8d20148ed04ba2a28063cebc371b085c57d6cc4..6cadeaa79e44909ff2368431a59f89fc85748fb1 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_storage.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_storage.mli @@ -260,6 +260,37 @@ val refine_stake : Sc_rollup_repr.Commitment.t -> (Sc_rollup_repr.Commitment_hash.t * Raw_context.t) tzresult Lwt.t +(** This is a wrapper around [deposit_stake] and [refine_stake] that + deposits a stake and then refines it to the specified commitment, + creating that commitment if necessary. Before calling + [deposit_stake] it checks that the staker is not already staked, and + if so will skip that step and go straight to calling [refine_stake]. + + May fail with: + {ul + {li [Sc_rollup_does_not_exist] if [rollup] does not exist} + {li [Sc_rollup_too_far_ahead] if [staker] would be more than + [sc_rollup_max_future_commitments] ahead of the Last Cemented Commitment} + {li [Sc_rollup_bad_inbox_level] if [commitment]'s predecessor is + less than [sc_rollup_commitment_frequency] blocks ahead} + {li [Sc_rollup_staker_backtracked] if [staker] is not staked on an ancestor + of [commitment]} + {li [Sc_rollup_unknown_commitment] if the parent of the given commitment + does not exist} + {li [Sc_rollup_staker_funds_too_low] if [staker] is not previously a staker, and does not have enough funds + to cover the deposit} + } + + Returns the hash of the given commitment. + + This function does not authenticate the staker. *) +val publish_commitment : + Raw_context.t -> + Sc_rollup_repr.t -> + Sc_rollup_repr.Staker.t -> + Sc_rollup_repr.Commitment.t -> + (Sc_rollup_repr.Commitment_hash.t * Raw_context.t) tzresult Lwt.t + (** [last_cemented_commitment context rollup] returns the last cemented commitment of the rollup. diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 9cdf37f75e0b6123eaf3fde1a24f237a43335157..4ff9f3fb58e00864f5e695cb803665622bf1a084 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -708,7 +708,7 @@ let bake_n_with_all_balance_updates ?(baking_mode = Application) ?policy | Tx_rollup_remove_commitment_result _ | Tx_rollup_rejection_result _ | Tx_rollup_withdraw_result _ | Sc_rollup_originate_result _ | Sc_rollup_add_messages_result _ - | Sc_rollup_cement_result _ -> + | Sc_rollup_cement_result _ | Sc_rollup_publish_result _ -> balance_updates_rev | Transaction_result (Transaction_to_contract_result {balance_updates; _}) @@ -749,7 +749,8 @@ let bake_n_with_origination_results ?(baking_mode = Application) ?policy n b = | Successful_manager_result (Tx_rollup_withdraw_result _) | Successful_manager_result (Sc_rollup_originate_result _) | Successful_manager_result (Sc_rollup_add_messages_result _) - | Successful_manager_result (Sc_rollup_cement_result _) -> + | Successful_manager_result (Sc_rollup_cement_result _) + | Successful_manager_result (Sc_rollup_publish_result _) -> origination_results_rev | Successful_manager_result (Origination_result x) -> Origination_result x :: origination_results_rev) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 543e15907f1f1d05cd5c1d27528efcee944ebb41..e79ee3de9e88b4209f2867b9b51ce0d5a19dc5fb 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -183,7 +183,7 @@ let get_seed ctxt = Alpha_services.Seed.get rpc_ctxt ctxt let get_constants ctxt = Alpha_services.Constants.all rpc_ctxt ctxt -let default_test_contants = +let default_test_constants = Tezos_protocol_alpha_parameters.Default_parameters.constants_test let get_baking_reward_fixed_portion ctxt = diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 194116c765b7439039423055bd9e979172418aaf..607f009b41e362e97cc1dbfe71ce7f5d27ab5981 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -75,7 +75,7 @@ val get_constants : t -> Constants.t tzresult Lwt.t (** The default constants used in the test framework. To be used with [init_with_constants]. *) -val default_test_contants : Constants.parametric +val default_test_constants : Constants.parametric val get_baking_reward_fixed_portion : t -> Tez.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 6cbb7bf76da32bda2e08ea8c8540dd7d8e2d9b2c..b16493a940a181dd285fabaae715ebc551e51ea1 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -538,20 +538,6 @@ let tx_rollup_submit_batch ?counter ?fee ?burn_limit ?gas_limit ?storage_limit Context.Contract.manager ctxt source >|=? fun account -> sign account.sk ctxt to_sign_op -let sc_rollup_origination ?counter ?fee ?gas_limit ?storage_limit ctxt - (src : Contract.t) kind boot_sector = - manager_operation - ?counter - ?fee - ?gas_limit - ?storage_limit - ~source:src - ctxt - (Sc_rollup_originate {kind; boot_sector}) - >>=? fun to_sign_op -> - Context.Contract.manager ctxt src >|=? fun account -> - sign account.sk ctxt to_sign_op - let tx_rollup_commit ?counter ?fee ?gas_limit ?storage_limit ctxt (source : Contract.t) (tx_rollup : Tx_rollup.t) (commitment : Tx_rollup_commitment.t) = @@ -666,3 +652,51 @@ let tx_rollup_reject ?counter ?fee ?gas_limit ?storage_limit ctxt >>=? fun to_sign_op -> Context.Contract.manager ctxt source >|=? fun account -> sign account.sk ctxt to_sign_op + +let originated_sc_rollup op = + let packed = Operation.hash_packed op in + let nonce = Origination_nonce.Internal_for_tests.initial packed in + Sc_rollup.Internal_for_tests.originated_sc_rollup nonce + +let sc_rollup_origination ?counter ?fee ?gas_limit ?storage_limit ctxt + (src : Contract.t) kind boot_sector = + manager_operation + ?counter + ?fee + ?gas_limit + ?storage_limit + ~source:src + ctxt + (Sc_rollup_originate {kind; boot_sector}) + >>=? fun to_sign_op -> + Context.Contract.manager ctxt src >|=? fun account -> + let op = sign account.sk ctxt to_sign_op in + originated_sc_rollup op |> fun addr -> (op, addr) + +let sc_rollup_publish ?counter ?fee ?gas_limit ?storage_limit ctxt + (src : Contract.t) rollup commitment = + manager_operation + ?counter + ?fee + ?gas_limit + ?storage_limit + ~source:src + ctxt + (Sc_rollup_publish {rollup; commitment}) + >>=? fun to_sign_op -> + Context.Contract.manager ctxt src >|=? fun account -> + sign account.sk ctxt to_sign_op + +let sc_rollup_cement ?counter ?fee ?gas_limit ?storage_limit ctxt + (src : Contract.t) rollup commitment = + manager_operation + ?counter + ?fee + ?gas_limit + ?storage_limit + ~source:src + ctxt + (Sc_rollup_cement {rollup; commitment}) + >>=? fun to_sign_op -> + Context.Contract.manager ctxt src >|=? fun account -> + sign account.sk ctxt to_sign_op diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index de11856d42e271951ac6b79a2269297c07eeb3d8..087c0e4910c97e3f1f5c9ff215a044274652d3c1 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -237,20 +237,6 @@ val tx_rollup_submit_batch : string -> Operation.packed tzresult Lwt.t -(** [sc_rollup_origination ctxt source kind boot_sector] originates a new - smart contract rollup of some given [kind] booting using [boot_sector]. - The process is the same as in [tx_rollup_origination]. *) -val sc_rollup_origination : - ?counter:counter -> - ?fee:Tez.t -> - ?gas_limit:Gas.Arith.integral -> - ?storage_limit:counter -> - Context.t -> - Contract.t -> - Sc_rollup.Kind.t -> - string -> - packed_operation tzresult Lwt.t - (** [tx_rollup_commit ctxt source tx_rollup commitment] Commits to a tx rollup state. *) val tx_rollup_commit : @@ -357,3 +343,43 @@ val tx_rollup_reject : proof:Tx_rollup_l2_proof.t -> previous_message_result:Tx_rollup_commitment.message_result -> Operation.packed tzresult Lwt.t + +(** [sc_rollup_origination ctxt source kind boot_sector] originates a new + smart contract rollup of some given [kind] booting using [boot_sector]. + The process is the same as in [tx_rollup_origination]. *) +val sc_rollup_origination : + ?counter:counter -> + ?fee:Tez.t -> + ?gas_limit:Gas.Arith.integral -> + ?storage_limit:counter -> + Context.t -> + Contract.t -> + Sc_rollup.Kind.t -> + string -> + (packed_operation * Sc_rollup.t) tzresult Lwt.t + +(** [sc_rollup_publish ctxt source rollup commitment] tries to publish a + commitment to the SCORU. *) +val sc_rollup_publish : + ?counter:Z.t -> + ?fee:Tez.tez -> + ?gas_limit:Gas.Arith.integral -> + ?storage_limit:Z.t -> + Context.t -> + Contract.t -> + Sc_rollup.t -> + Sc_rollup.Commitment.t -> + Operation.packed tzresult Lwt.t + +(** [sc_rollup_cement ctxt source rollup commitment] tries to cement the + specified commitment. *) +val sc_rollup_cement : + ?counter:Z.t -> + ?fee:Tez.tez -> + ?gas_limit:Gas.Arith.integral -> + ?storage_limit:Z.t -> + Context.t -> + Contract.t -> + Sc_rollup.t -> + Sc_rollup.Commitment_hash.t -> + Operation.packed tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index 1e25f86abfd6a52215fc2f25e62a5b9abc0320bb..7e43cd100edaf1b1c3adf673fd77079de81d165c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -34,23 +34,36 @@ open Protocol open Alpha_context +open Lwt_tzresult_syntax exception Sc_rollup_test_error of string let err x = Exn (Sc_rollup_test_error x) +(** [context_init n] initializes a context for testing in which the + [sc_rollup_enable] constant is set to true. It returns the created + context and [n] contracts. *) +let context_init n = + Context.init_with_constants + { + Context.default_test_constants with + sc_rollup_enable = true; + consensus_threshold = 0; + sc_rollup_challenge_window_in_blocks = 10; + } + n + (** [test_disable_feature_flag ()] tries to originate a smart contract - rollup with the feature flag is deactivated and checks that it + rollup when the feature flag is deactivated and checks that it fails. *) let test_disable_feature_flag () = - Context.init 1 >>=? fun (b, contracts) -> + let* (b, contracts) = Context.init 1 in let contract = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 0 in - Incremental.begin_construction b >>=? fun i -> + let* i = Incremental.begin_construction b in let kind = Sc_rollup.Kind.Example_arith in - let boot_sector = "" in - Op.sc_rollup_origination (I i) contract kind boot_sector >>=? fun op -> + let* (op, _) = Op.sc_rollup_origination (I i) contract kind "" in let expect_failure = function | Environment.Ecoproto_error (Apply.Sc_rollup_feature_disabled as e) :: _ -> Assert.test_error_encodings e ; @@ -60,7 +73,8 @@ let test_disable_feature_flag () = "It should not be possible to send a smart contract rollup operation \ when the feature flag is disabled." in - Incremental.add_operation ~expect_failure i op >>= fun _i -> return_unit + let*! _ = Incremental.add_operation ~expect_failure i op in + return_unit (** [test_sc_rollups_all_well_defined] checks that [Sc_rollups.all] contains all the constructors of [Sc_rollup.Kind.t] and that @@ -90,7 +104,167 @@ let test_sc_rollups_all_well_defined () = (err (Printf.sprintf "PVM name `%s' is not a valid kind name" P.name))) Sc_rollups.all in - all_contains_all_constructors () >>=? fun () -> all_names_are_valid () + let* _ = all_contains_all_constructors () in + all_names_are_valid () + +(** Initializes the context and originates a SCORU. *) +let init_and_originate n = + let* (ctxt, contracts) = context_init n in + let contract = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 0 + in + let kind = Sc_rollup.Kind.Example_arith in + let* (operation, rollup) = + Op.sc_rollup_origination (B ctxt) contract kind "" + in + let* b = Block.bake ~operation ctxt in + return (b, contracts, rollup) + +let number_of_messages_exn n = + match Sc_rollup.Number_of_messages.of_int32 n with + | Some x -> x + | None -> Stdlib.failwith "Bad Number_of_messages" + +let number_of_ticks_exn n = + match Sc_rollup.Number_of_ticks.of_int32 n with + | Some x -> x + | None -> Stdlib.failwith "Bad Number_of_ticks" + +let rec bake_until i top = + let level = Incremental.level i in + if level >= top then return i + else + Incremental.finalize_block i >>=? fun b -> + Incremental.begin_construction b >>=? fun i -> bake_until i top + +let dummy_commitment = + Sc_rollup.Commitment. + { + predecessor = Sc_rollup.Commitment_hash.zero; + inbox_level = Raw_level.of_int32_exn 21l; + number_of_messages = number_of_messages_exn 3l; + number_of_ticks = number_of_ticks_exn 3000l; + compressed_state = Sc_rollup.State_hash.zero; + } + +(** [test_publish_and_cement] creates a rollup, publishes a + commitment and then 20 blocks later cements that commitment *) +let test_publish_and_cement () = + let* (ctxt, contracts, rollup) = init_and_originate 2 in + let contract = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 1 + in + let* operation = + Op.sc_rollup_publish (B ctxt) contract rollup dummy_commitment + in + let* i = Incremental.begin_construction ctxt in + let* i = Incremental.add_operation i operation in + let* b = Incremental.finalize_block i in + let* i = Incremental.begin_construction b in + let* i = bake_until i 20l in + let hash = Sc_rollup.Commitment.hash dummy_commitment in + let* cement_op = Op.sc_rollup_cement (I i) contract rollup hash in + let* _ = Incremental.add_operation i cement_op in + return_unit + +(** [test_cement_fails_if_premature] creates a rollup, publishes a + commitment and then tries to cement the commitment immediately + without waiting for the challenge period to elapse. We check that + this fails with the correct error. *) +let test_cement_fails_if_premature () = + let* (ctxt, contracts, rollup) = init_and_originate 2 in + let contract = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 1 + in + let* operation = + Op.sc_rollup_publish (B ctxt) contract rollup dummy_commitment + in + let* i = Incremental.begin_construction ctxt in + let* i = Incremental.add_operation i operation in + let* b = Incremental.finalize_block i in + let* i = Incremental.begin_construction b in + let hash = Sc_rollup.Commitment.hash dummy_commitment in + let* cement_op = Op.sc_rollup_cement (I i) contract rollup hash in + let expect_failure = function + | Environment.Ecoproto_error (Sc_rollup_storage.Sc_rollup_too_recent as e) + :: _ -> + Assert.test_error_encodings e ; + return_unit + | _ -> + failwith "It should not be possible to cement a commitment prematurely." + in + let* _ = Incremental.add_operation ~expect_failure i cement_op in + return_unit + +(** [test_publish_fails_on_backtrack] creates a rollup and then + publishes two different commitments with the same staker. We check + that the second publish fails. *) +let test_publish_fails_on_backtrack () = + let* (ctxt, contracts, rollup) = init_and_originate 2 in + let contract = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 1 + in + let commitment1 = dummy_commitment in + let commitment2 = + {dummy_commitment with number_of_ticks = number_of_ticks_exn 3001l} + in + let* operation1 = Op.sc_rollup_publish (B ctxt) contract rollup commitment1 in + let* i = Incremental.begin_construction ctxt in + let* i = Incremental.add_operation i operation1 in + let* b = Incremental.finalize_block i in + let* operation2 = Op.sc_rollup_publish (B b) contract rollup commitment2 in + let* i = Incremental.begin_construction b in + let expect_failure = function + | Environment.Ecoproto_error + (Sc_rollup_storage.Sc_rollup_staker_backtracked as e) + :: _ -> + Assert.test_error_encodings e ; + return_unit + | _ -> failwith "It should not be possible for a staker to backtrack." + in + let* _ = Incremental.add_operation ~expect_failure i operation2 in + return_unit + +(** [test_cement_fails_on_conflict] creates a rollup and then publishes + two different commitments. It waits 20 blocks and then attempts to + cement one of the commitments; it checks that this fails because the + commitment is contested. *) +let test_cement_fails_on_conflict () = + let* (ctxt, contracts, rollup) = init_and_originate 3 in + let contract1 = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 1 + in + let contract2 = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth contracts 2 + in + let commitment1 = dummy_commitment in + let commitment2 = + {dummy_commitment with number_of_ticks = number_of_ticks_exn 3001l} + in + let* operation1 = + Op.sc_rollup_publish (B ctxt) contract1 rollup commitment1 + in + let* i = Incremental.begin_construction ctxt in + let* i = Incremental.add_operation i operation1 in + let* b = Incremental.finalize_block i in + let* operation2 = Op.sc_rollup_publish (B b) contract2 rollup commitment2 in + let* i = Incremental.begin_construction b in + let* i = Incremental.add_operation i operation2 in + let* b = Incremental.finalize_block i in + let* i = Incremental.begin_construction b in + let* i = bake_until i 20l in + let hash = Sc_rollup.Commitment.hash commitment1 in + let* cement_op = Op.sc_rollup_cement (I i) contract1 rollup hash in + let expect_failure = function + | Environment.Ecoproto_error (Sc_rollup_storage.Sc_rollup_disputed as e) + :: _ -> + Assert.test_error_encodings e ; + return_unit + | _ -> + failwith "It should not be possible to cement a contested commitment." + in + let* _ = Incremental.add_operation ~expect_failure i cement_op in + return_unit let tests = [ @@ -102,4 +276,20 @@ let tests = "check that all rollup kinds are correctly enumerated" `Quick test_sc_rollups_all_well_defined; + Tztest.tztest + "can publish a commit and then cement it" + `Quick + test_publish_and_cement; + Tztest.tztest + "cement will fail if it is too soon" + `Quick + test_cement_fails_if_premature; + Tztest.tztest + "publish will fail if staker is backtracking" + `Quick + test_publish_fails_on_backtrack; + Tztest.tztest + "cement will fail if commitment is contested" + `Quick + test_cement_fails_on_conflict; ] diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml index 0a83e6a3516b46de1eea1dbde377a27c37b73f8a..1374af5193dcfa8e971220652a66b2246dc4b35f 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml @@ -159,7 +159,7 @@ let context_init ?(tx_rollup_max_inboxes_count = 2100) ?(tx_rollup_max_ticket_payload_size = 10_240) n = Context.init_with_constants { - Context.default_test_contants with + Context.default_test_constants with consensus_threshold = 0; tx_rollup_enable = true; tx_rollup_finality_period = 1; diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml index 51a9a1fcc28c519fb0e2d2218a4d6f297ab02c7f..4d13b6ea0bb3ed00e3139a9194e5e4b1634f3c5d 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml @@ -28,7 +28,7 @@ Component: Protocol Sc_rollup_storage Invocation: dune exec src/proto_alpha/lib_protocol/test/unit/main.exe \ -- test "^\[Unit\] Sc_rollup_storage.ml$" - Subject: Tests for the gas monad module + Subject: Tests for the SCORU storage module *) open Protocol @@ -278,6 +278,70 @@ let test_deposit_then_refine_bad_inbox () = (Sc_rollup_storage.refine_stake ctxt rollup staker commitment) "Attempted to commit to a bad inbox level." +let test_publish () = + let* ctxt = new_context () in + lift + @@ let* (rollup, ctxt) = new_sc_rollup ctxt in + let staker = + Sc_rollup_repr.Staker.of_b58check_exn + "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" + in + let commitment = + Sc_rollup_repr.Commitment. + { + predecessor = Sc_rollup_repr.Commitment_hash.zero; + inbox_level = Raw_level_repr.of_int32_exn 21l; + number_of_messages = number_of_messages_exn 5l; + number_of_ticks = number_of_ticks_exn 152231l; + compressed_state = Sc_rollup_repr.State_hash.zero; + } + in + let* (_node, ctxt) = + Sc_rollup_storage.publish_commitment ctxt rollup staker commitment + in + assert_true ctxt + +let test_deposit_then_publish () = + let* ctxt = new_context () in + lift + @@ let* (rollup, ctxt) = new_sc_rollup ctxt in + let staker = + Sc_rollup_repr.Staker.of_b58check_exn + "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" + in + let* ctxt = Sc_rollup_storage.deposit_stake ctxt rollup staker in + let commitment = + Sc_rollup_repr.Commitment. + { + predecessor = Sc_rollup_repr.Commitment_hash.zero; + inbox_level = Raw_level_repr.of_int32_exn 21l; + number_of_messages = number_of_messages_exn 5l; + number_of_ticks = number_of_ticks_exn 152231l; + compressed_state = Sc_rollup_repr.State_hash.zero; + } + in + let* (_node, ctxt) = + Sc_rollup_storage.publish_commitment ctxt rollup staker commitment + in + assert_true ctxt + +let test_publish_missing_rollup () = + let staker = + Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" + in + let commitment = + Sc_rollup_repr.Commitment. + { + predecessor = Sc_rollup_repr.Commitment_hash.zero; + inbox_level = Raw_level_repr.of_int32_exn 21l; + number_of_messages = number_of_messages_exn 3l; + number_of_ticks = number_of_ticks_exn 1232909l; + compressed_state = Sc_rollup_repr.State_hash.zero; + } + in + assert_fails_with_missing_rollup ~loc:__LOC__ (fun ctxt rollup -> + Sc_rollup_storage.publish_commitment ctxt rollup staker commitment) + let test_cement () = let* ctxt = new_context () in let challenge_window = @@ -1433,6 +1497,9 @@ let tests = `Quick test_deposit_then_refine_bad_inbox; Tztest.tztest "stake on existing node" `Quick test_stake_on_existing_node; + Tztest.tztest "publish commitment" `Quick test_publish; + Tztest.tztest "stake then publish" `Quick test_deposit_then_publish; + Tztest.tztest "publish with no rollup" `Quick test_publish_missing_rollup; Tztest.tztest "withdrawal from missing rollup fails" `Quick diff --git a/tezt/_regressions/rpc/alpha.client.mempool.out b/tezt/_regressions/rpc/alpha.client.mempool.out index e79ff9e0920c11f64064bbd5565d3e254514dc3d..749fe44a2ebf744bf37651e46430ffbe2bd93929 100644 --- a/tezt/_regressions/rpc/alpha.client.mempool.out +++ b/tezt/_regressions/rpc/alpha.client.mempool.out @@ -3461,6 +3461,81 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false + }, + { + "title": "Sc_rollup_publish", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "sc_rollup_publish" + ] + }, + "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" + }, + "rollup": { + "$ref": "#/definitions/alpha.rollup_address" + }, + "commitment": { + "type": "object", + "properties": { + "compressed_state": { + "$ref": "#/definitions/state_hash" + }, + "inbox_level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "predecessor": { + "$ref": "#/definitions/commitment_hash" + }, + "number_of_messages": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "number_of_ticks": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + } + }, + "required": [ + "number_of_ticks", + "number_of_messages", + "predecessor", + "inbox_level", + "compressed_state" + ], + "additionalProperties": false + } + }, + "required": [ + "commitment", + "rollup", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false } ] }, @@ -3763,6 +3838,10 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "title": "A script expression ID (Base58Check-encoded)", "$ref": "#/definitions/unistring" }, + "state_hash": { + "title": "The hash of the VM state of a smart contract rollup (Base58Check-encoded)", + "$ref": "#/definitions/unistring" + }, "timestamp.protocol": { "description": "A timestamp as seen by the protocol: second-level precision, epoch based.", "$ref": "#/definitions/unistring" @@ -4620,7 +4699,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "parameters", "layout": { - "name": "X_135", + "name": "X_136", "kind": "Ref" }, "data_kind": { @@ -5285,7 +5364,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "commitment", "layout": { - "name": "X_133", + "name": "X_134", "kind": "Ref" }, "data_kind": { @@ -5648,7 +5727,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "message", "layout": { - "name": "X_6", + "name": "X_7", "kind": "Ref" }, "data_kind": { @@ -5688,7 +5767,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "previous_message_result", "layout": { - "name": "X_7", + "name": "X_8", "kind": "Ref" }, "data_kind": { @@ -5700,7 +5779,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "proof", "layout": { - "name": "X_132", + "name": "X_133", "kind": "Ref" }, "data_kind": { @@ -5916,7 +5995,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "ticket_amount", "layout": { - "name": "X_5", + "name": "X_6", "kind": "Ref" }, "data_kind": { @@ -6028,7 +6107,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "kind", "layout": { - "name": "X_2", + "name": "X_3", "kind": "Ref" }, "data_kind": { @@ -6151,7 +6230,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "message", "layout": { "layout": { - "name": "X_1", + "name": "X_2", "kind": "Ref" }, "kind": "Seq" @@ -6264,6 +6343,108 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ], "name": "Sc_rollup_cement" + }, + { + "tag": 203, + "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" + }, + { + "name": "commitment", + "layout": { + "name": "X_1", + "kind": "Ref" + }, + "data_kind": { + "size": 76, + "kind": "Float" + }, + "kind": "named" + } + ], + "name": "Sc_rollup_publish" } ] } @@ -6938,7 +7119,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_135" + "title": "X_136" }, "encoding": { "fields": [ @@ -7321,7 +7502,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_133" + "title": "X_134" }, "encoding": { "fields": [ @@ -7358,7 +7539,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "predecessor", "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "data_kind": { @@ -7382,7 +7563,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_134" + "title": "X_135" }, "encoding": { "tag_size": "Uint8", @@ -7452,7 +7633,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_132" + "title": "X_133" }, "encoding": { "tag_size": "Uint8", @@ -7508,7 +7689,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7567,7 +7748,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7626,7 +7807,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7685,7 +7866,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7701,7 +7882,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_131" + "title": "X_132" }, "encoding": { "tag_size": "Uint8", @@ -7737,7 +7918,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7777,7 +7958,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7817,7 +7998,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7857,7 +8038,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7897,7 +8078,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -7937,7 +8118,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -7977,7 +8158,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8017,7 +8198,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8057,7 +8238,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8097,7 +8278,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8137,7 +8318,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8177,7 +8358,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8217,7 +8398,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8257,7 +8438,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8297,7 +8478,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8337,7 +8518,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8395,7 +8576,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "kind": "Seq", @@ -8430,7 +8611,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "kind": "Seq", @@ -8470,7 +8651,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "kind": "Seq" @@ -8607,7 +8788,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8656,7 +8837,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8705,7 +8886,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8754,7 +8935,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8780,7 +8961,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_130" + "title": "X_131" }, "encoding": { "fields": [] @@ -8788,7 +8969,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_126" + "title": "X_127" }, "encoding": { "fields": [ @@ -8807,7 +8988,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_118" + "title": "X_119" }, "encoding": { "fields": [ @@ -8836,7 +9017,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_114" + "title": "X_115" }, "encoding": { "tag_size": "Uint8", @@ -8908,7 +9089,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_113" + "title": "X_114" }, "encoding": { "fields": [ @@ -8931,7 +9112,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_8" + "title": "X_9" }, "encoding": { "fields": [ @@ -8943,7 +9124,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_131", + "name": "X_132", "kind": "Ref" }, "kind": "Seq" @@ -8958,13 +9139,13 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_13" + "title": "X_14" }, "encoding": { "fields": [ { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8974,7 +9155,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_114", + "name": "X_115", "kind": "Ref" }, "kind": "anon", @@ -8988,7 +9169,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_7" + "title": "X_8" }, "encoding": { "fields": [ @@ -9019,7 +9200,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_6" + "title": "X_7" }, "encoding": { "tag_size": "Uint8", @@ -9078,7 +9259,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "deposit", "layout": { - "name": "X_4", + "name": "X_5", "kind": "Ref" }, "data_kind": { @@ -9094,7 +9275,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_4" + "title": "X_5" }, "encoding": { "fields": [ @@ -9135,7 +9316,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "amount", "layout": { - "name": "X_5", + "name": "X_6", "kind": "Ref" }, "data_kind": { @@ -9148,7 +9329,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_5" + "title": "X_6" }, "encoding": { "tag_size": "Uint8", @@ -9361,7 +9542,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_2" + "title": "X_3" }, "encoding": { "tag_size": "Uint16", @@ -9403,7 +9584,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_1" + "title": "X_2" }, "encoding": { "fields": [ @@ -9423,6 +9604,73 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ] } + }, + { + "description": { + "title": "X_1" + }, + "encoding": { + "fields": [ + { + "name": "compressed_state", + "layout": { + "kind": "Bytes" + }, + "data_kind": { + "size": 32, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "inbox_level", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "predecessor", + "layout": { + "kind": "Bytes" + }, + "data_kind": { + "size": 32, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "number_of_messages", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "number_of_ticks", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + } + ] + } } ] } @@ -12858,6 +13106,81 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false + }, + { + "title": "Sc_rollup_publish", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "sc_rollup_publish" + ] + }, + "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" + }, + "rollup": { + "$ref": "#/definitions/alpha.rollup_address" + }, + "commitment": { + "type": "object", + "properties": { + "compressed_state": { + "$ref": "#/definitions/state_hash" + }, + "inbox_level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "predecessor": { + "$ref": "#/definitions/commitment_hash" + }, + "number_of_messages": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "number_of_ticks": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + } + }, + "required": [ + "number_of_ticks", + "number_of_messages", + "predecessor", + "inbox_level", + "compressed_state" + ], + "additionalProperties": false + } + }, + "required": [ + "commitment", + "rollup", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false } ] }, @@ -13191,6 +13514,10 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "title": "A script expression ID (Base58Check-encoded)", "$ref": "#/definitions/unistring" }, + "state_hash": { + "title": "The hash of the VM state of a smart contract rollup (Base58Check-encoded)", + "$ref": "#/definitions/unistring" + }, "timestamp.protocol": { "description": "A timestamp as seen by the protocol: second-level precision, epoch based.", "$ref": "#/definitions/unistring" diff --git a/tezt/_regressions/rpc/alpha.proxy.mempool.out b/tezt/_regressions/rpc/alpha.proxy.mempool.out index e76f21f08c4ce8287047beaf2260a6d8ebd4a9df..f3a5a02ef53259904830845cbe3b29ee79d0df96 100644 --- a/tezt/_regressions/rpc/alpha.proxy.mempool.out +++ b/tezt/_regressions/rpc/alpha.proxy.mempool.out @@ -3482,6 +3482,81 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false + }, + { + "title": "Sc_rollup_publish", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "sc_rollup_publish" + ] + }, + "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" + }, + "rollup": { + "$ref": "#/definitions/alpha.rollup_address" + }, + "commitment": { + "type": "object", + "properties": { + "compressed_state": { + "$ref": "#/definitions/state_hash" + }, + "inbox_level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "predecessor": { + "$ref": "#/definitions/commitment_hash" + }, + "number_of_messages": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "number_of_ticks": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + } + }, + "required": [ + "number_of_ticks", + "number_of_messages", + "predecessor", + "inbox_level", + "compressed_state" + ], + "additionalProperties": false + } + }, + "required": [ + "commitment", + "rollup", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false } ] }, @@ -3784,6 +3859,10 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "title": "A script expression ID (Base58Check-encoded)", "$ref": "#/definitions/unistring" }, + "state_hash": { + "title": "The hash of the VM state of a smart contract rollup (Base58Check-encoded)", + "$ref": "#/definitions/unistring" + }, "timestamp.protocol": { "description": "A timestamp as seen by the protocol: second-level precision, epoch based.", "$ref": "#/definitions/unistring" @@ -4641,7 +4720,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "parameters", "layout": { - "name": "X_135", + "name": "X_136", "kind": "Ref" }, "data_kind": { @@ -5306,7 +5385,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "commitment", "layout": { - "name": "X_133", + "name": "X_134", "kind": "Ref" }, "data_kind": { @@ -5669,7 +5748,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "message", "layout": { - "name": "X_6", + "name": "X_7", "kind": "Ref" }, "data_kind": { @@ -5709,7 +5788,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "previous_message_result", "layout": { - "name": "X_7", + "name": "X_8", "kind": "Ref" }, "data_kind": { @@ -5721,7 +5800,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "proof", "layout": { - "name": "X_132", + "name": "X_133", "kind": "Ref" }, "data_kind": { @@ -5937,7 +6016,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "ticket_amount", "layout": { - "name": "X_5", + "name": "X_6", "kind": "Ref" }, "data_kind": { @@ -6049,7 +6128,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "kind", "layout": { - "name": "X_2", + "name": "X_3", "kind": "Ref" }, "data_kind": { @@ -6172,7 +6251,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "message", "layout": { "layout": { - "name": "X_1", + "name": "X_2", "kind": "Ref" }, "kind": "Seq" @@ -6285,6 +6364,108 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ], "name": "Sc_rollup_cement" + }, + { + "tag": 203, + "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" + }, + { + "name": "commitment", + "layout": { + "name": "X_1", + "kind": "Ref" + }, + "data_kind": { + "size": 76, + "kind": "Float" + }, + "kind": "named" + } + ], + "name": "Sc_rollup_publish" } ] } @@ -6959,7 +7140,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_135" + "title": "X_136" }, "encoding": { "fields": [ @@ -7342,7 +7523,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_133" + "title": "X_134" }, "encoding": { "fields": [ @@ -7379,7 +7560,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "predecessor", "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "data_kind": { @@ -7403,7 +7584,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_134" + "title": "X_135" }, "encoding": { "tag_size": "Uint8", @@ -7473,7 +7654,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_132" + "title": "X_133" }, "encoding": { "tag_size": "Uint8", @@ -7529,7 +7710,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7588,7 +7769,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7647,7 +7828,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7706,7 +7887,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "anon", @@ -7722,7 +7903,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_131" + "title": "X_132" }, "encoding": { "tag_size": "Uint8", @@ -7758,7 +7939,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7798,7 +7979,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7838,7 +8019,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7878,7 +8059,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_130", + "name": "X_131", "kind": "Ref" }, "kind": "anon", @@ -7918,7 +8099,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -7958,7 +8139,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -7998,7 +8179,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8038,7 +8219,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8078,7 +8259,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8118,7 +8299,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8158,7 +8339,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8198,7 +8379,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8238,7 +8419,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8278,7 +8459,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8318,7 +8499,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8358,7 +8539,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_118", + "name": "X_119", "kind": "Ref" }, "kind": "anon", @@ -8416,7 +8597,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "kind": "Seq", @@ -8451,7 +8632,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "kind": "Seq", @@ -8491,7 +8672,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "kind": "Seq" @@ -8628,7 +8809,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8677,7 +8858,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8726,7 +8907,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8775,7 +8956,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8801,7 +8982,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_130" + "title": "X_131" }, "encoding": { "fields": [] @@ -8809,7 +8990,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_126" + "title": "X_127" }, "encoding": { "fields": [ @@ -8828,7 +9009,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_118" + "title": "X_119" }, "encoding": { "fields": [ @@ -8857,7 +9038,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_114" + "title": "X_115" }, "encoding": { "tag_size": "Uint8", @@ -8929,7 +9110,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_113" + "title": "X_114" }, "encoding": { "fields": [ @@ -8952,7 +9133,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_8" + "title": "X_9" }, "encoding": { "fields": [ @@ -8964,7 +9145,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_131", + "name": "X_132", "kind": "Ref" }, "kind": "Seq" @@ -8979,13 +9160,13 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_13" + "title": "X_14" }, "encoding": { "fields": [ { "layout": { - "name": "X_113", + "name": "X_114", "kind": "Ref" }, "kind": "anon", @@ -8995,7 +9176,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_114", + "name": "X_115", "kind": "Ref" }, "kind": "anon", @@ -9009,7 +9190,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_7" + "title": "X_8" }, "encoding": { "fields": [ @@ -9040,7 +9221,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_6" + "title": "X_7" }, "encoding": { "tag_size": "Uint8", @@ -9099,7 +9280,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "deposit", "layout": { - "name": "X_4", + "name": "X_5", "kind": "Ref" }, "data_kind": { @@ -9115,7 +9296,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_4" + "title": "X_5" }, "encoding": { "fields": [ @@ -9156,7 +9337,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "amount", "layout": { - "name": "X_5", + "name": "X_6", "kind": "Ref" }, "data_kind": { @@ -9169,7 +9350,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_5" + "title": "X_6" }, "encoding": { "tag_size": "Uint8", @@ -9382,7 +9563,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_2" + "title": "X_3" }, "encoding": { "tag_size": "Uint16", @@ -9424,7 +9605,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_1" + "title": "X_2" }, "encoding": { "fields": [ @@ -9444,6 +9625,73 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ] } + }, + { + "description": { + "title": "X_1" + }, + "encoding": { + "fields": [ + { + "name": "compressed_state", + "layout": { + "kind": "Bytes" + }, + "data_kind": { + "size": 32, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "inbox_level", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "predecessor", + "layout": { + "kind": "Bytes" + }, + "data_kind": { + "size": 32, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "number_of_messages", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "number_of_ticks", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + } + ] + } } ] } @@ -12879,6 +13127,81 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "kind" ], "additionalProperties": false + }, + { + "title": "Sc_rollup_publish", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "sc_rollup_publish" + ] + }, + "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" + }, + "rollup": { + "$ref": "#/definitions/alpha.rollup_address" + }, + "commitment": { + "type": "object", + "properties": { + "compressed_state": { + "$ref": "#/definitions/state_hash" + }, + "inbox_level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "predecessor": { + "$ref": "#/definitions/commitment_hash" + }, + "number_of_messages": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "number_of_ticks": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + } + }, + "required": [ + "number_of_ticks", + "number_of_messages", + "predecessor", + "inbox_level", + "compressed_state" + ], + "additionalProperties": false + } + }, + "required": [ + "commitment", + "rollup", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false } ] }, @@ -13212,6 +13535,10 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "title": "A script expression ID (Base58Check-encoded)", "$ref": "#/definitions/unistring" }, + "state_hash": { + "title": "The hash of the VM state of a smart contract rollup (Base58Check-encoded)", + "$ref": "#/definitions/unistring" + }, "timestamp.protocol": { "description": "A timestamp as seen by the protocol: second-level precision, epoch based.", "$ref": "#/definitions/unistring"