diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 462b29885ef4c1580d13a3a298e73ce3f071e4af..e340830d818887a0a264618bcea2d8f072a835aa 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2304,7 +2304,6 @@ module Tx_rollup_errors : sig [ `Valid_path of Tx_rollup_commitment.Merkle.h * int | `Hash of Tx_rollup_message_result_hash.t ]; } - | Wrong_deposit_parameters | Proof_failed_to_reject | Proof_produced_rejected_state | Proof_invalid_before of { diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 8b5bc41e532a05a251357a7eb1061cdd5e4687a2..23bdab2df0fc12f56357fbf4b9cce813fe5a7f4b 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -963,8 +963,9 @@ let apply_transaction_to_tx_rollup ~ctxt ~parameters_ty ~parameters ~payer returned using the L2 withdrawal mechanism: a failing deposit emits a withdrawal that can be executed by [payer]. *) - Tx_rollup_parameters.get_deposit_parameters parameters_ty parameters - >>?= fun {ex_ticket; l2_destination} -> + let Tx_rollup_parameters.{ex_ticket; l2_destination} = + Tx_rollup_parameters.get_deposit_parameters parameters_ty parameters + in ex_ticket_size ctxt ex_ticket >>=? fun (ctxt, ticket_size) -> let limit = Constants.tx_rollup_max_ticket_payload_size ctxt in fail_when diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.ml b/src/proto_alpha/lib_protocol/script_typed_ir.ml index 9cc3a94ac81b429a89f943f2435f09e0242093df..e0371d154e5fe98d03cb033144792250d7e60f2a 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir.ml @@ -1371,8 +1371,8 @@ and 'kind internal_operation_contents = -> Kind.transaction internal_operation_contents | Transaction_to_tx_rollup : { destination : Tx_rollup.t; - parameters_ty : ('a, _) ty; - parameters : 'a; + parameters_ty : (('a ticket, tx_rollup_l2_address) pair, _) ty; + parameters : ('a ticket, tx_rollup_l2_address) pair; unparsed_parameters : Script.expr; } -> Kind.transaction internal_operation_contents diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.mli b/src/proto_alpha/lib_protocol/script_typed_ir.mli index da95bffff5f176f8a47c1d9cb0c2375874b116eb..2899f5ce523d0c331bcf0fac9b0dcbb4fa3a5921 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.mli +++ b/src/proto_alpha/lib_protocol/script_typed_ir.mli @@ -1512,8 +1512,8 @@ and 'kind internal_operation_contents = -> Kind.transaction internal_operation_contents | Transaction_to_tx_rollup : { destination : Tx_rollup.t; - parameters_ty : ('a, _) ty; - parameters : 'a; + parameters_ty : (('a ticket, tx_rollup_l2_address) pair, _) ty; + parameters : ('a ticket, tx_rollup_l2_address) pair; unparsed_parameters : Script.expr; } -> Kind.transaction internal_operation_contents diff --git a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml index 9bac8dc869f58efa792214fd72962ae47b22c1cd..c3db21d23593a404f1a8875569d2ef5e2977c1af 100644 --- a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml @@ -193,8 +193,9 @@ let tickets_of_operation ctxt ~allow_zero_amount_tickets ~parameters | Transaction_to_tx_rollup {destination; unparsed_parameters = _; parameters_ty; parameters} -> - Tx_rollup_parameters.get_deposit_parameters parameters_ty parameters - >>?= fun {ex_ticket; l2_destination = _} -> + let Tx_rollup_parameters.{ex_ticket; l2_destination = _} = + Tx_rollup_parameters.get_deposit_parameters parameters_ty parameters + in return ( Some { diff --git a/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml b/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml index a79f10792ef97a45a705b1e5eb6c7c17b9458dd7..6e14836718e8ed44c62a70b3d9512d0a992c662a 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml @@ -87,7 +87,6 @@ type error += | `Hash of Tx_rollup_message_result_hash_repr.t ]; } | Ticket_payload_size_limit_exceeded of {payload_size : int; limit : int} - | Wrong_deposit_parameters | Proof_failed_to_reject | Proof_produced_rejected_state | Proof_invalid_before of {agreed : Context_hash.t; provided : Context_hash.t} diff --git a/src/proto_alpha/lib_protocol/tx_rollup_parameters.ml b/src/proto_alpha/lib_protocol/tx_rollup_parameters.ml index 7c93e0a7f75e9ead3844e75f1ac63651e02b17ee..f79d341c7642621a0e12542bf0d6b4ab2b9bebf7 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_parameters.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_parameters.ml @@ -25,18 +25,18 @@ (* *) (*****************************************************************************) +open Script_typed_ir + type deposit_parameters = { ex_ticket : Ticket_scanner.ex_ticket; - l2_destination : Script_typed_ir.tx_rollup_l2_address; + l2_destination : tx_rollup_l2_address; } let get_deposit_parameters : type a comparable. - (a, comparable) Script_typed_ir.ty -> a -> deposit_parameters tzresult = - fun ty contents -> - let open Script_typed_ir in - match (ty, contents) with - | ( Pair_t (Ticket_t (ty, _), Tx_rollup_l2_address_t, _, _), - (ticket, l2_destination) ) -> - ok {ex_ticket = Ticket_scanner.Ex_ticket (ty, ticket); l2_destination} - | _ -> error Alpha_context.Tx_rollup_errors.Wrong_deposit_parameters + ((a ticket, tx_rollup_l2_address) pair, comparable) ty -> + (a ticket, tx_rollup_l2_address) pair -> + deposit_parameters = + fun (Pair_t (Ticket_t (ty, _), Tx_rollup_l2_address_t, _, _)) + (ticket, l2_destination) -> + {ex_ticket = Ticket_scanner.Ex_ticket (ty, ticket); l2_destination} diff --git a/src/proto_alpha/lib_protocol/tx_rollup_parameters.mli b/src/proto_alpha/lib_protocol/tx_rollup_parameters.mli index 8d240a428375885abe114567cd18bb693821da9f..76bd401277010e7d7f4313c2d0eb2a5d7731129f 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_parameters.mli +++ b/src/proto_alpha/lib_protocol/tx_rollup_parameters.mli @@ -28,22 +28,24 @@ (** A module for representing and extracting typed transactional rollup parameters. *) +open Script_typed_ir + (** A type representing deposit parameters for transactional rollups. Deposit parameters consist of a ticket of arbitrary content along with a layer-2 destination address. *) type deposit_parameters = { ex_ticket : Ticket_scanner.ex_ticket; - l2_destination : Script_typed_ir.tx_rollup_l2_address; + l2_destination : tx_rollup_l2_address; } (** [get_deposit_parameters ty value] returns [ex_ticket] and a - [tx_rollup_l2_address] from a michelson typed value. if [ty] is not of a - pair of ticket and [tx_rollup_l2_address] then it fails with - [Tx_rollup_errors.Wrong_deposit_parameters]. + [tx_rollup_l2_address] from a michelson typed value. This function is intended to be used to enforce the type of the transaction to a [tx_rollup%deposit]. It must be used both in [ticket_diffs_of_operations] to account for the ticket deposited and in [apply] to retrieve the ticket when applying the transaction to a tx_rollup. *) val get_deposit_parameters : - ('a, 'comparable) Script_typed_ir.ty -> 'a -> deposit_parameters tzresult + (('a ticket, tx_rollup_l2_address) pair, 'comparable) ty -> + ('a ticket, tx_rollup_l2_address) pair -> + deposit_parameters diff --git a/src/proto_alpha/lib_tx_rollup/daemon.ml b/src/proto_alpha/lib_tx_rollup/daemon.ml index 673e1dd72cd6caed6508568ba60b93c7d21b9484..2c8b32e864f057d733c1c1dcbee12fe0418c3047 100644 --- a/src/proto_alpha/lib_tx_rollup/daemon.ml +++ b/src/proto_alpha/lib_tx_rollup/daemon.ml @@ -53,14 +53,11 @@ let parse_ticketer : Script.node -> Contract.t tzresult = let open Micheline in function | Bytes (_loc, bytes) (* As unparsed with [Optimized]. *) -> - Result.of_option - ~error: - [Environment.wrap_tzerror Tx_rollup_errors.Wrong_deposit_parameters] + Result.of_option ~error:[Wrong_deposit_parameters] @@ Data_encoding.Binary.of_bytes_opt Contract.encoding bytes | String (_loc, str) (* As unparsed with [Readable]. *) -> Environment.wrap_tzresult @@ Contract.of_b58check str - | Int _ | Prim _ | Seq _ -> - error (Environment.wrap_tzerror Tx_rollup_errors.Wrong_deposit_parameters) + | Int _ | Prim _ | Seq _ -> error Wrong_deposit_parameters let parse_tx_rollup_deposit_parameters : Script.expr -> diff --git a/src/proto_alpha/lib_tx_rollup/error.ml b/src/proto_alpha/lib_tx_rollup/error.ml index fec8c73affbae21ae07d41bad1e27e195bd078ab..13277743addf7ee0a6ede59d810875e5dbf7d947 100644 --- a/src/proto_alpha/lib_tx_rollup/error.ml +++ b/src/proto_alpha/lib_tx_rollup/error.ml @@ -561,3 +561,5 @@ let () = Data_encoding.(obj1 (req "operation" Operation_hash.encoding)) (function Tx_rollup_deposit_slashed o -> Some o | _ -> None) (fun o -> Tx_rollup_deposit_slashed o) + +type error += Wrong_deposit_parameters diff --git a/src/proto_alpha/lib_tx_rollup/error.mli b/src/proto_alpha/lib_tx_rollup/error.mli index 097c2a811136e81beb5b928b82259ce98ba69ce2..5c396b5a3671ec1510d545e304ad3eef74365ff6 100644 --- a/src/proto_alpha/lib_tx_rollup/error.mli +++ b/src/proto_alpha/lib_tx_rollup/error.mli @@ -132,3 +132,5 @@ type error += Tx_rollup_deposit_not_allowed (** Error (fatal) when we are slashed *) type error += Tx_rollup_deposit_slashed of Operation_hash.t + +type error += Wrong_deposit_parameters