diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 11e8eb18027b96411f14563731369c7362f2e363..66a3f9ab52810ab92b22e98b35ad10d978bfbc54 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -330,6 +330,8 @@ let estimated_gas_single (type kind) | Applied (Tx_rollup_dispatch_tickets_result {consumed_gas; _}) -> Ok consumed_gas | Applied (Transfer_ticket_result {consumed_gas; _}) -> Ok consumed_gas + | Applied (Dal_publish_slot_header_result {consumed_gas; _}) -> + Ok consumed_gas | Applied (Sc_rollup_originate_result {consumed_gas; _}) -> Ok consumed_gas | Applied (Sc_rollup_add_messages_result {consumed_gas; _}) -> Ok consumed_gas @@ -392,6 +394,7 @@ let estimated_storage_single (type kind) ~tx_rollup_origination_size Ok paid_storage_size_diff | Applied (Transfer_ticket_result {paid_storage_size_diff; _}) -> Ok paid_storage_size_diff + | Applied (Dal_publish_slot_header_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 @@ -463,6 +466,7 @@ let originated_contracts_single (type kind) | Applied (Tx_rollup_rejection_result _) -> Ok [] | Applied (Tx_rollup_dispatch_tickets_result _) -> Ok [] | Applied (Transfer_ticket_result _) -> Ok [] + | Applied (Dal_publish_slot_header_result _) -> Ok [] | Applied (Sc_rollup_originate_result _) -> Ok [] | Applied (Sc_rollup_add_messages_result _) -> Ok [] | Applied (Sc_rollup_cement_result _) -> Ok [] diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 646a1db0cb794a93c67265f8b6a2c70e067ad72f..3b65fa98047c0f472c79452e0c29eafc8accf4de 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -86,6 +86,7 @@ module Protocol_constants_overrides = struct tx_rollup_max_ticket_payload_size : int option; tx_rollup_rejection_max_proof_size : int option; tx_rollup_sunset_level : int32 option; + dal : Constants.Parametric.dal option; sc_rollup_enable : bool option; sc_rollup_origination_size : int option; sc_rollup_challenge_window_in_blocks : int option; @@ -160,16 +161,18 @@ module Protocol_constants_overrides = struct c.tx_rollup_max_ticket_payload_size, c.tx_rollup_rejection_max_proof_size, c.tx_rollup_sunset_level ) ), - ( c.sc_rollup_enable, - c.sc_rollup_origination_size, - c.sc_rollup_challenge_window_in_blocks, - c.sc_rollup_max_available_messages, - c.sc_rollup_stake_amount_in_mutez, - c.sc_rollup_commitment_period_in_blocks, - c.sc_rollup_commitment_storage_size_in_bytes, - c.sc_rollup_max_lookahead_in_blocks, - c.sc_rollup_max_active_outbox_levels, - c.sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) )) + ( c.dal, + ( c.sc_rollup_enable, + c.sc_rollup_origination_size, + c.sc_rollup_challenge_window_in_blocks, + c.sc_rollup_max_available_messages, + c.sc_rollup_stake_amount_in_mutez, + c.sc_rollup_commitment_period_in_blocks, + c.sc_rollup_commitment_storage_size_in_bytes, + c.sc_rollup_max_lookahead_in_blocks, + c.sc_rollup_max_active_outbox_levels, + c.sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) ) + )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -223,16 +226,18 @@ module Protocol_constants_overrides = struct tx_rollup_max_ticket_payload_size, tx_rollup_rejection_max_proof_size, tx_rollup_sunset_level ) ), - ( sc_rollup_enable, - sc_rollup_origination_size, - sc_rollup_challenge_window_in_blocks, - sc_rollup_max_available_messages, - sc_rollup_stake_amount_in_mutez, - sc_rollup_commitment_period_in_blocks, - sc_rollup_commitment_storage_size_in_bytes, - sc_rollup_max_lookahead_in_blocks, - sc_rollup_max_active_outbox_levels, - sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) ) -> + ( dal, + ( sc_rollup_enable, + sc_rollup_origination_size, + sc_rollup_challenge_window_in_blocks, + sc_rollup_max_available_messages, + sc_rollup_stake_amount_in_mutez, + sc_rollup_commitment_period_in_blocks, + sc_rollup_commitment_storage_size_in_bytes, + sc_rollup_max_lookahead_in_blocks, + sc_rollup_max_active_outbox_levels, + sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) + ) ) -> { preserved_cycles; blocks_per_cycle; @@ -284,6 +289,7 @@ module Protocol_constants_overrides = struct tx_rollup_max_ticket_payload_size; tx_rollup_rejection_max_proof_size; tx_rollup_sunset_level; + dal; sc_rollup_enable; sc_rollup_origination_size; sc_rollup_challenge_window_in_blocks; @@ -369,19 +375,28 @@ module Protocol_constants_overrides = struct (opt "tx_rollup_max_ticket_payload_size" int31) (opt "tx_rollup_rejection_max_proof_size" int31) (opt "tx_rollup_sunset_level" int32))) - (obj10 - (opt "sc_rollup_enable" bool) - (opt "sc_rollup_origination_size" int31) - (opt "sc_rollup_challenge_window_in_blocks" int31) - (opt "sc_rollup_max_available_messages" int31) - (opt "sc_rollup_stake_amount_in_mutez" int31) - (opt "sc_rollup_commitment_period_in_blocks" int31) - (opt - "sc_rollup_commitment_storage_size_in_bytes" - int31) - (opt "sc_rollup_max_lookahead_in_blocks" int32) - (opt "sc_rollup_max_active_outbox_levels" int32) - (opt "sc_rollup_max_outbox_messages_per_level" int31)))))))) + (merge_objs + (obj1 + (opt + "dal_parametric" + Constants.Parametric.dal_encoding)) + (obj10 + (opt "sc_rollup_enable" bool) + (opt "sc_rollup_origination_size" int31) + (opt "sc_rollup_challenge_window_in_blocks" int31) + (opt "sc_rollup_max_available_messages" int31) + (opt "sc_rollup_stake_amount_in_mutez" int31) + (opt + "sc_rollup_commitment_period_in_blocks" + int31) + (opt + "sc_rollup_commitment_storage_size_in_bytes" + int31) + (opt "sc_rollup_max_lookahead_in_blocks" int32) + (opt "sc_rollup_max_active_outbox_levels" int32) + (opt + "sc_rollup_max_outbox_messages_per_level" + int31))))))))) let default_value (cctxt : Tezos_client_base.Client_context.full) : t tzresult Lwt.t = @@ -468,6 +483,7 @@ module Protocol_constants_overrides = struct tx_rollup_rejection_max_proof_size = Some parametric.tx_rollup_rejection_max_proof_size; tx_rollup_sunset_level = Some parametric.tx_rollup_sunset_level; + dal = Some parametric.dal; sc_rollup_enable = Some parametric.sc_rollup_enable; sc_rollup_origination_size = Some parametric.sc_rollup_origination_size; sc_rollup_challenge_window_in_blocks = @@ -546,6 +562,7 @@ module Protocol_constants_overrides = struct tx_rollup_max_ticket_payload_size = None; tx_rollup_rejection_max_proof_size = None; tx_rollup_sunset_level = None; + dal = None; sc_rollup_enable = None; sc_rollup_origination_size = None; sc_rollup_challenge_window_in_blocks = None; @@ -1030,6 +1047,7 @@ module Protocol_constants_overrides = struct Option.value ~default:c.tx_rollup_sunset_level o.tx_rollup_sunset_level; + dal = Option.value ~default:c.dal o.dal; sc_rollup_enable = Option.value ~default:c.sc_rollup_enable o.sc_rollup_enable; sc_rollup_origination_size = diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index ad2d57872ff3a293d8a582afd121c93e6d954ab1..7e41f3d1bbd625564f1d7ace9b0e3374ce15f49a 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -269,6 +269,8 @@ let pp_manager_operation_content (type kind) source pp_result ppf source | Transfer_ticket _ -> Format.fprintf ppf "Transfer tickets:@,From: %a" Contract.pp source + | Dal_publish_slot_header {slot} -> + Format.fprintf ppf "@[<v 2>Publish slot %a@]" Dal.Slot.pp slot | Sc_rollup_originate {kind; boot_sector; parameters_ty} -> let (module R : Sc_rollups.PVM.S) = Sc_rollups.of_kind kind in let parameters_ty = @@ -680,6 +682,10 @@ let pp_manager_operation_contents_and_result ppf Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas ; pp_balance_updates_opt ppf balance_updates in + let pp_dal_publish_slot_header_result + (Dal_publish_slot_header_result {consumed_gas}) = + Format.fprintf ppf "@,Consumed gas: %a" Gas.Arith.pp consumed_gas + in let pp_sc_rollup_originate_result (Sc_rollup_originate_result {address; consumed_gas; size; balance_updates}) = @@ -902,6 +908,17 @@ let pp_manager_operation_contents_and_result ppf "@[<v 0>This transfer ticket operation was BACKTRACKED, its expected \ effects (as follow) were NOT applied.@]" ; pp_transfer_ticket_result op + | Applied (Dal_publish_slot_header_result _ as op) -> + Format.fprintf + ppf + "This operation publishing a slot header was successfully applied" ; + pp_dal_publish_slot_header_result op + | Backtracked ((Dal_publish_slot_header_result _ as op), _errs) -> + Format.fprintf + ppf + "@[<v 0>This operation publishing a slot header was BACKTRACKED, its \ + expected effects (as follow) were NOT applied.@]" ; + pp_dal_publish_slot_header_result op | Applied (Sc_rollup_originate_result _ as op) -> Format.fprintf ppf @@ -1099,6 +1116,13 @@ let rec pp_contents_and_result_list : Signature.Public_key_hash.pp delegate endorsement_power + | Single_and_result + (Dal_slot_availability _, Dal_slot_availability_result {delegate}) -> + Format.fprintf + ppf + "@[<v 2>Slot availability:@,Delegate: %a@]" + Signature.Public_key_hash.pp + delegate | Single_and_result ( Double_endorsement_evidence {op1; op2}, Double_endorsement_evidence_result bus ) -> diff --git a/src/proto_alpha/lib_injector/l1_operation.ml b/src/proto_alpha/lib_injector/l1_operation.ml index b0aef6cc21422cdabccee672c4a12261db8e348c..ca94bfaed2b84300d3178dac7a0ed32c839bd5f8 100644 --- a/src/proto_alpha/lib_injector/l1_operation.ml +++ b/src/proto_alpha/lib_injector/l1_operation.ml @@ -59,6 +59,7 @@ module Manager_operation = struct make tx_rollup_rejection_case; make tx_rollup_dispatch_tickets_case; make transfer_ticket_case; + make dal_publish_slot_header_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; @@ -89,6 +90,7 @@ module Manager_operation = struct | Tx_rollup_rejection _ -> tx_rollup_rejection_case | Tx_rollup_dispatch_tickets _ -> tx_rollup_dispatch_tickets_case | Transfer_ticket _ -> transfer_ticket_case + | Dal_publish_slot_header _ -> dal_publish_slot_header_case | Sc_rollup_originate _ -> sc_rollup_originate_case | Sc_rollup_add_messages _ -> sc_rollup_add_messages_case | Sc_rollup_cement _ -> sc_rollup_cement_case diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 9ae091ee04f76f3ba89e16b770775e04002d740c..a4bd4ec2fe0186ba3518c5e03588d9a7481944e2 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -48,6 +48,17 @@ let sc_rollup_max_active_outbox_levels = pay for at origination time. *) let sc_rollup_max_outbox_messages_per_level = 100 +(* DAL/FIXME: Think harder about those values. *) +let default_dal = + Constants.Parametric. + { + feature_enable = false; + number_of_slots = 256; + number_of_shards = 2048; + endorsement_lag = 2; + availability_threshold = 50; + } + let constants_mainnet = let consensus_committee_size = 7000 in let block_time = 30 in @@ -166,6 +177,7 @@ let constants_mainnet = about one year after the activation of protocol J. See https://tzstats.com/cycle/618 *) tx_rollup_sunset_level = 3_473_409l; + dal = default_dal; sc_rollup_enable = false; (* The following value is chosen to prevent spam. *) sc_rollup_origination_size = 6_314; diff --git a/src/proto_alpha/lib_plugin/plugin.ml b/src/proto_alpha/lib_plugin/plugin.ml index a4e87f1dd557e66bbae04eb48f81556ee6eb9301..e31973a6380d871e0a276daf4d615a0050319857 100644 --- a/src/proto_alpha/lib_plugin/plugin.ml +++ b/src/proto_alpha/lib_plugin/plugin.ml @@ -1003,6 +1003,7 @@ module Mempool = struct Lwt.return (`Branch_refused [Environment.wrap_tzerror Consensus_operation_in_far_future]) + | Single (Dal_slot_availability _) | Single (Seed_nonce_revelation _) | Single (Double_preendorsement_evidence _) | Single (Double_endorsement_evidence _) @@ -1282,6 +1283,7 @@ module Mempool = struct match contents with | Single_result (Preendorsement_result _) | Single_result (Endorsement_result _) + | Single_result (Dal_slot_availability_result _) | Single_result (Seed_nonce_revelation_result _) | Single_result (Double_preendorsement_evidence_result _) | Single_result (Double_endorsement_evidence_result _) diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index 0a8af4e50aaf17a70963d9f433ba365a5aa5e041..98f876a532260a37950d0b271f664f8196ecac29 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -67,6 +67,10 @@ "Tx_rollup_commitment_repr", "Tx_rollup_errors_repr", "Tx_rollup_state_repr", + + "Dal_slot_repr", + "Dal_endorsement_repr", + "Bond_id_repr", "Vote_repr", "Liquidity_baking_repr", @@ -140,6 +144,8 @@ "Sc_rollup_refutation_storage", "Sc_rollup_storage", + "Dal_slot_storage", + "Alpha_context", "Script_string", "Script_int", @@ -194,6 +200,8 @@ "Sc_rollup_arith", "Sc_rollups", + "Dal_apply", + "Baking", "Amendment", "Apply", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index a8171c397beb50802e8474285286da5a928c09cf..3873a278dc7dc4bb669259811f0b23cf0d9422e6 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -73,6 +73,19 @@ module Sc_rollup = struct include Sc_rollup_storage end +module Dal = struct + module Endorsement = struct + include Dal_endorsement_repr + include Raw_context.Dal + end + + module Slot = struct + include Dal_slot_repr + include Dal_slot_storage + include Raw_context.Dal + end +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 cf2daf43c3acb15922aeb4cbf03c0f59c2c57df3..1875b2ef4cc25c915ca2d647e8a82aae4edfc34f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -721,6 +721,16 @@ module Constants : sig (** Constants parameterized by context *) module Parametric : sig + type dal = { + feature_enable : bool; + number_of_slots : int; + number_of_shards : int; + endorsement_lag : int; + availability_threshold : int; + } + + val dal_encoding : dal Data_encoding.t + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -773,6 +783,7 @@ module Constants : sig tx_rollup_max_withdrawals_per_batch : int; tx_rollup_rejection_max_proof_size : int; tx_rollup_sunset_level : int32; + dal : dal; sc_rollup_enable : bool; sc_rollup_origination_size : int; sc_rollup_challenge_window_in_blocks : int; @@ -2736,6 +2747,45 @@ module Destination : sig type error += Invalid_destination_b58check of string end +module Dal : sig + module Endorsement : sig + type t + + val encoding : t Data_encoding.t + + val empty : t + + val occupied_size_in_bits : t -> int + + val expected_size_in_bits : max_index:int -> int + + val shards : context -> endorser:Signature.Public_key_hash.t -> int list + + val record_available_shards : context -> t -> int list -> context + end + + module Slot : sig + type header + + type t = private {level : Raw_level.t; index : int; header : header} + + val encoding : t Data_encoding.t + + val pp : Format.formatter -> t -> unit + + val current_slot_fees : context -> t -> Tez.t option + + val update_slot_fees : context -> t -> Tez.t -> context * bool + + val find : context -> Raw_level.t -> t list option tzresult Lwt.t + + val finalize_current_slots : context -> context Lwt.t + + val finalize_pending_slots : + context -> (context * Endorsement.t) tzresult Lwt.t + end +end + module Block_payload : sig val hash : predecessor:Block_hash.t -> @@ -2859,6 +2909,8 @@ module Kind : sig type endorsement = endorsement_consensus_kind consensus + type dal_slot_availability = Dal_slot_availability_kind + type seed_nonce_revelation = Seed_nonce_revelation_kind type 'a double_consensus_operation_evidence = @@ -2910,6 +2962,8 @@ module Kind : sig type transfer_ticket = Transfer_ticket_kind + type dal_publish_slot_header = Dal_publish_slot_header_kind + type sc_rollup_originate = Sc_rollup_originate_kind type sc_rollup_add_messages = Sc_rollup_add_messages_kind @@ -2943,6 +2997,7 @@ module Kind : sig | Tx_rollup_dispatch_tickets_manager_kind : tx_rollup_dispatch_tickets manager | Transfer_ticket_manager_kind : transfer_ticket manager + | Dal_publish_slot_header_manager_kind : dal_publish_slot_header manager | 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 @@ -2998,6 +3053,9 @@ and _ contents_list = and _ contents = | Preendorsement : consensus_content -> Kind.preendorsement contents | Endorsement : consensus_content -> Kind.endorsement contents + | Dal_slot_availability : + Signature.Public_key_hash.t * Dal.Endorsement.t + -> Kind.dal_slot_availability contents | Seed_nonce_revelation : { level : Raw_level.t; nonce : Nonce.t; @@ -3122,6 +3180,10 @@ and _ manager_operation = entrypoint : Entrypoint.t; } -> Kind.transfer_ticket manager_operation + | Dal_publish_slot_header : { + slot : Dal.Slot.t; + } + -> Kind.dal_publish_slot_header manager_operation | Sc_rollup_originate : { kind : Sc_rollup.Kind.t; boot_sector : string; @@ -3198,6 +3260,7 @@ module Operation : sig type consensus_watermark = | Endorsement of Chain_id.t | Preendorsement of Chain_id.t + | Dal_slot_availability of Chain_id.t val to_watermark : consensus_watermark -> Signature.watermark @@ -3261,6 +3324,8 @@ module Operation : sig val endorsement_case : Kind.endorsement case + val dal_slot_availability_case : Kind.dal_slot_availability case + val seed_nonce_revelation_case : Kind.seed_nonce_revelation case val double_preendorsement_evidence_case : @@ -3310,6 +3375,9 @@ module Operation : sig val transfer_ticket_case : Kind.transfer_ticket Kind.manager case + val dal_publish_slot_header_case : + Kind.dal_publish_slot_header Kind.manager case + val register_global_constant_case : Kind.register_global_constant Kind.manager case @@ -3375,6 +3443,8 @@ module Operation : sig val transfer_ticket_case : Kind.transfer_ticket case + val dal_publish_slot_header_case : Kind.dal_publish_slot_header case + val sc_rollup_originate_case : Kind.sc_rollup_originate case val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages case diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 183dfb0524c7758d709017d450d7476d0aaf973d..d83197a7372c0ddfd2ca09909203fb3066241906 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1221,13 +1221,14 @@ let apply_external_manager_operation_content : source:public_key_hash -> chain_id:Chain_id.t -> gas_consumed_in_precheck:Gas.cost option -> + fee:Tez.t -> kind manager_operation -> (context * kind successful_manager_operation_result * Script_typed_ir.packed_internal_operation list) tzresult Lwt.t = - fun ctxt mode ~source ~chain_id ~gas_consumed_in_precheck operation -> + fun ctxt mode ~source ~chain_id ~gas_consumed_in_precheck ~fee operation -> let source_contract = Contract.Implicit source in prepare_apply_manager_operation_content ~ctxt @@ -1735,6 +1736,11 @@ let apply_external_manager_operation_content : } in return (ctxt, result, []) + | Dal_publish_slot_header {slot} -> + Dal_apply.apply_publish_slot_header ctxt slot fee >>?= fun ctxt -> + let consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt in + let result = Dal_publish_slot_header_result {consumed_gas} in + return (ctxt, result, []) | Sc_rollup_originate {kind; boot_sector; parameters_ty} -> Sc_rollup_operations.originate ctxt ~kind ~boot_sector ~parameters_ty >>=? fun ({address; size}, ctxt) -> @@ -2012,7 +2018,10 @@ let precheck_manager_contents (type kind) ctxt (op : kind Kind.manager contents) | Sc_rollup_originate _ | Sc_rollup_add_messages _ | Sc_rollup_cement _ | Sc_rollup_publish _ | Sc_rollup_refute _ | Sc_rollup_timeout _ | Sc_rollup_atomic_batch _ -> - assert_sc_rollup_feature_enabled ctxt >|=? fun () -> ctxt) + assert_sc_rollup_feature_enabled ctxt >|=? fun () -> ctxt + | Dal_publish_slot_header {slot} -> + Dal_apply.validate_publish_slot_header ctxt slot >>?= fun () -> + return ctxt) >>=? fun ctxt -> Contract.increment_counter ctxt source >>=? fun ctxt -> Token.transfer ctxt (`Contract source_contract) `Block_fees fee @@ -2167,6 +2176,7 @@ let burn_manager_storage_fees : ( ctxt, storage_limit, Tx_rollup_dispatch_tickets_result {payload with balance_updates} ) + | Dal_publish_slot_header_result _ -> return (ctxt, storage_limit, smopr) | Sc_rollup_originate_result payload -> Fees.burn_sc_rollup_origination_fees ctxt @@ -2272,6 +2282,7 @@ let burn_internal_storage_fees : ( ctxt, storage_limit, Tx_rollup_dispatch_tickets_result {payload with balance_updates} ) + | Dal_publish_slot_header_result _ -> return (ctxt, storage_limit, smopr) | Sc_rollup_originate_result ({size; _} as payload) -> Fees.burn_sc_rollup_origination_fees ctxt ~storage_limit ~payer size >>=? fun (ctxt, storage_limit, balance_updates) -> @@ -2304,6 +2315,7 @@ let apply_manager_contents (type kind) ctxt mode chain_id operation; gas_limit; storage_limit; + fee; _; }) = op @@ -2317,6 +2329,7 @@ let apply_manager_contents (type kind) ctxt mode chain_id ~source ~gas_consumed_in_precheck ~chain_id + ~fee operation >>= function | Ok (ctxt, operation_results, internal_operations) -> ( @@ -2655,6 +2668,7 @@ let record_operation (type kind) ctxt (operation : kind operation) : context = match operation.protocol_data.contents with | Single (Preendorsement _) -> ctxt | Single (Endorsement _) -> ctxt + | Single (Dal_slot_availability _) -> ctxt | Single ( Failing_noop _ | Proposals _ | Ballot _ | Seed_nonce_revelation _ | Double_endorsement_evidence _ | Double_preendorsement_evidence _ @@ -3128,6 +3142,23 @@ let apply_contents_list (type kind) ctxt chain_id (apply_mode : apply_mode) mode delegate; endorsement_power = voting_power; }) )) + | Single (Dal_slot_availability (endorser, slot_availability)) -> + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3115 + + This is a temporary operation. We do no check for the + moment. In particular, this means we do not check the + signature. Consequently, it is really important to ensure this + operation cannot be included into a block when the feature flag + is not set. This is done in order to avoid modifying the + endorsement encoding. However, once the DAL will be ready, this + operation should be merged with an endorsement or at least + refined. *) + Dal_apply.validate_data_availability ctxt slot_availability >>?= fun () -> + Dal_apply.apply_data_availability ctxt slot_availability ~endorser + >>=? fun ctxt -> + return + ( ctxt, + Single_result (Dal_slot_availability_result {delegate = endorser}) ) | Single (Seed_nonce_revelation {level; nonce}) -> let level = Level.from_raw ctxt level in Nonce.reveal ctxt level nonce >>=? fun ctxt -> @@ -3694,6 +3725,7 @@ let finalize_application ctxt (mode : finalize_application_mode) protocol_data may_start_new_cycle ctxt >>=? fun (ctxt, cycle_end_balance_updates, deactivated) -> Amendment.may_start_new_voting_period ctxt >>=? fun ctxt -> + Dal_apply.dal_finalisation ctxt >>=? fun (ctxt, dal_slot_availability) -> let balance_updates = migration_balance_updates @ baking_receipts @ cycle_end_balance_updates in @@ -3716,6 +3748,7 @@ let finalize_application ctxt (mode : finalize_application_mode) protocol_data balance_updates; liquidity_baking_toggle_ema; implicit_operations_results; + dal_slot_availability; } in (ctxt, fitness, receipt) diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index 0eeb36942f7d5b7ea3b903485dcaa73e80105199..01a3b1816e70054a298aa85e709451873c77c344 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -213,6 +213,10 @@ type _ successful_manager_operation_result = paid_storage_size_diff : Z.t; } -> Kind.transfer_ticket successful_manager_operation_result + | Dal_publish_slot_header_result : { + consumed_gas : Gas.Arith.fp; + } + -> Kind.dal_publish_slot_header successful_manager_operation_result | Sc_rollup_originate_result : { balance_updates : Receipt.balance_updates; address : Sc_rollup.Address.t; @@ -891,6 +895,26 @@ module Manager_result = struct paid_storage_size_diff; }) + let[@coq_axiom_with_reason "gadt"] dal_publish_slot_header_case = + make + ~op_case: + Operation.Encoding.Manager_operations.dal_publish_slot_header_case + ~encoding: + (obj2 + (dft "consumed_gas" Gas.Arith.n_integral_encoding Gas.Arith.zero) + (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero)) + ~select:(function + | Successful_manager_result (Dal_publish_slot_header_result _ as op) -> + Some op + | _ -> None) + ~proj:(function + | Dal_publish_slot_header_result {consumed_gas} -> + (Gas.Arith.ceil consumed_gas, consumed_gas)) + ~kind:Kind.Dal_publish_slot_header_manager_kind + ~inj:(fun (consumed_gas, consumed_milligas) -> + assert (Gas.Arith.(equal (ceil consumed_milligas) consumed_gas)) ; + Dal_publish_slot_header_result {consumed_gas = consumed_milligas}) + let[@coq_axiom_with_reason "gadt"] sc_rollup_originate_case = make ~op_case:Operation.Encoding.Manager_operations.sc_rollup_originate_case @@ -1446,6 +1470,10 @@ type 'kind contents_result = endorsement_power : int; } -> Kind.endorsement contents_result + | Dal_slot_availability_result : { + delegate : Signature.Public_key_hash.t; + } + -> Kind.dal_slot_availability contents_result | Seed_nonce_revelation_result : Receipt.balance_updates -> Kind.seed_nonce_revelation contents_result @@ -1534,6 +1562,10 @@ let equal_manager_kind : | Kind.Transfer_ticket_manager_kind, Kind.Transfer_ticket_manager_kind -> Some Eq | Kind.Transfer_ticket_manager_kind, _ -> None + | ( Kind.Dal_publish_slot_header_manager_kind, + Kind.Dal_publish_slot_header_manager_kind ) -> + Some Eq + | Kind.Dal_publish_slot_header_manager_kind, _ -> None | Kind.Sc_rollup_originate_manager_kind, Kind.Sc_rollup_originate_manager_kind -> Some Eq @@ -1635,6 +1667,24 @@ module Encoding = struct Endorsement_result {balance_updates; delegate; endorsement_power}); } + let[@coq_axiom_with_reason "gadt"] dal_slot_availability_case = + Case + { + op_case = Operation.Encoding.dal_slot_availability_case; + encoding = obj1 (req "delegate" Signature.Public_key_hash.encoding); + select = + (function + | Contents_result (Dal_slot_availability_result _ as op) -> Some op + | _ -> None); + mselect = + (function + | Contents_and_result ((Dal_slot_availability _ as op), res) -> + Some (op, res) + | _ -> None); + proj = (function Dal_slot_availability_result {delegate} -> delegate); + inj = (fun delegate -> Dal_slot_availability_result {delegate}); + } + let[@coq_axiom_with_reason "gadt"] seed_nonce_revelation_case = Case { @@ -1820,6 +1870,7 @@ module Encoding = struct {op with operation_result = Failed (kind, errs)})) | Contents_result (Preendorsement_result _) -> None | Contents_result (Endorsement_result _) -> None + | Contents_result (Dal_slot_availability_result _) -> None | Contents_result Ballot_result -> None | Contents_result (Seed_nonce_revelation_result _) -> None | Contents_result (Double_endorsement_evidence_result _) -> None @@ -2011,6 +2062,18 @@ module Encoding = struct Some (op, res) | _ -> None) + let[@coq_axiom_with_reason "gadt"] dal_publish_slot_header_case = + make_manager_case + Operation.Encoding.dal_publish_slot_header_case + Manager_result.dal_publish_slot_header_case + (function + | Contents_and_result + ( (Manager_operation {operation = Dal_publish_slot_header _; _} as + op), + res ) -> + Some (op, res) + | _ -> None) + let[@coq_axiom_with_reason "gadt"] sc_rollup_originate_case = make_manager_case Operation.Encoding.sc_rollup_originate_case @@ -2111,6 +2174,7 @@ let contents_result_encoding = make seed_nonce_revelation_case; make endorsement_case; make preendorsement_case; + make dal_slot_availability_case; make double_preendorsement_evidence_case; make double_endorsement_evidence_case; make double_baking_evidence_case; @@ -2132,6 +2196,7 @@ let contents_result_encoding = make tx_rollup_rejection_case; make tx_rollup_dispatch_tickets_case; make transfer_ticket_case; + make dal_publish_slot_header_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; @@ -2305,6 +2370,8 @@ let kind_equal : | Endorsement _, _ -> None | Preendorsement _, Preendorsement_result _ -> Some Eq | Preendorsement _, _ -> None + | Dal_slot_availability _, Dal_slot_availability_result _ -> Some Eq + | Dal_slot_availability _, _ -> None | Seed_nonce_revelation _, Seed_nonce_revelation_result _ -> Some Eq | Seed_nonce_revelation _, _ -> None | Double_preendorsement_evidence _, Double_preendorsement_evidence_result _ -> @@ -2719,6 +2786,23 @@ let kind_equal : } ) -> Some Eq | Manager_operation {operation = Transfer_ticket _; _}, _ -> None + | ( Manager_operation {operation = Dal_publish_slot_header _; _}, + Manager_operation_result + { + operation_result = + Failed (Alpha_context.Kind.Dal_publish_slot_header_manager_kind, _); + _; + } ) -> + Some Eq + | ( Manager_operation {operation = Dal_publish_slot_header _; _}, + Manager_operation_result + { + operation_result = + Skipped Alpha_context.Kind.Dal_publish_slot_header_manager_kind; + _; + } ) -> + Some Eq + | Manager_operation {operation = Dal_publish_slot_header _; _}, _ -> None | ( Manager_operation {operation = Sc_rollup_originate _; _}, Manager_operation_result {operation_result = Applied (Sc_rollup_originate_result _); _} ) -> @@ -3011,6 +3095,7 @@ type block_metadata = { balance_updates : Receipt.balance_updates; liquidity_baking_toggle_ema : Liquidity_baking.Toggle_EMA.t; implicit_operations_results : packed_successful_manager_operation_result list; + dal_slot_availability : Dal.Endorsement.t option; } let block_metadata_encoding = @@ -3028,6 +3113,7 @@ let block_metadata_encoding = balance_updates; liquidity_baking_toggle_ema; implicit_operations_results; + dal_slot_availability; } -> ( ( proposer, baker, @@ -3039,7 +3125,7 @@ let block_metadata_encoding = balance_updates, liquidity_baking_toggle_ema, implicit_operations_results ), - consumed_gas )) + (consumed_gas, dal_slot_availability) )) (fun ( ( proposer, baker, level_info, @@ -3050,7 +3136,7 @@ let block_metadata_encoding = balance_updates, liquidity_baking_toggle_ema, implicit_operations_results ), - _consumed_millgas ) -> + (_consumed_millgas, dal_slot_availability) ) -> { proposer; baker; @@ -3062,6 +3148,7 @@ let block_metadata_encoding = balance_updates; liquidity_baking_toggle_ema; implicit_operations_results; + dal_slot_availability; }) (merge_objs (obj10 @@ -3079,7 +3166,14 @@ let block_metadata_encoding = (req "implicit_operations_results" (list successful_manager_operation_result_encoding))) - (obj1 (req "consumed_milligas" Gas.Arith.n_fp_encoding))) + (obj2 + (req "consumed_milligas" Gas.Arith.n_fp_encoding) + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3119 + + This varopt is here while the DAL is behind a feature + flag. This should be replaced by a required field once + the feature flag will be activated. *) + (varopt "dal_slot_availability" Dal.Endorsement.encoding))) type precheck_result = { consumed_gas : Gas.Arith.fp; diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index 69822f79d6dd2c99e4e02f73e6f98139edd1204e..508d90b0a5102745204e2a6cc90582318c1f95c5 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -99,6 +99,10 @@ and 'kind contents_result = endorsement_power : int; } -> Kind.endorsement contents_result + | Dal_slot_availability_result : { + delegate : Signature.Public_key_hash.t; + } + -> Kind.dal_slot_availability contents_result | Seed_nonce_revelation_result : Receipt.balance_updates -> Kind.seed_nonce_revelation contents_result @@ -256,6 +260,10 @@ and _ successful_manager_operation_result = paid_storage_size_diff : Z.t; } -> Kind.transfer_ticket successful_manager_operation_result + | Dal_publish_slot_header_result : { + consumed_gas : Gas.Arith.fp; + } + -> Kind.dal_publish_slot_header successful_manager_operation_result | Sc_rollup_originate_result : { balance_updates : Receipt.balance_updates; address : Sc_rollup.Address.t; @@ -372,6 +380,7 @@ type block_metadata = { balance_updates : Receipt.balance_updates; liquidity_baking_toggle_ema : Liquidity_baking.Toggle_EMA.t; implicit_operations_results : packed_successful_manager_operation_result list; + dal_slot_availability : Dal.Endorsement.t option; } val block_metadata_encoding : block_metadata Data_encoding.encoding diff --git a/src/proto_alpha/lib_protocol/bitset.ml b/src/proto_alpha/lib_protocol/bitset.ml index ab0bfd4d264aa0c71301d5ccafc53a2141056639..a49c4264ac05e2f7c6f24d5e95ebef680f7cd140 100644 --- a/src/proto_alpha/lib_protocol/bitset.ml +++ b/src/proto_alpha/lib_protocol/bitset.ml @@ -49,3 +49,5 @@ let () = (obj1 (req "position" int31)) (function Invalid_position i -> Some i | _ -> None) (fun i -> Invalid_position i) + +let occupied_size_in_bits = Z.numbits diff --git a/src/proto_alpha/lib_protocol/bitset.mli b/src/proto_alpha/lib_protocol/bitset.mli index 0d8038eb61903879b796d03bd9a0f073d63ff0c5..c7bf12064147e29f5bfa456ddae1cad1616c3910 100644 --- a/src/proto_alpha/lib_protocol/bitset.mli +++ b/src/proto_alpha/lib_protocol/bitset.mli @@ -43,3 +43,7 @@ val mem : t -> int -> bool tzresult This functions returns [Invalid_input i] if [i] is negative. *) val add : t -> int -> t tzresult + +(** [occupied_size_in_bits bitset] returns the current number of bits + occupied by the [bitset]. *) +val occupied_size_in_bits : t -> int diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index 4742a32eb54546971892a7b6f4268ba14d9c5263..791c6905d5e92443bc722ff4381dff59a97b1a02 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -25,6 +25,48 @@ (* *) (*****************************************************************************) +type dal = { + feature_enable : bool; + number_of_slots : int; + number_of_shards : int; + endorsement_lag : int; + availability_threshold : int; +} + +let dal_encoding = + let open Data_encoding in + conv + (fun { + feature_enable; + number_of_slots; + number_of_shards; + endorsement_lag; + availability_threshold; + } -> + ( feature_enable, + number_of_slots, + number_of_shards, + endorsement_lag, + availability_threshold )) + (fun ( feature_enable, + number_of_slots, + number_of_shards, + endorsement_lag, + availability_threshold ) -> + { + feature_enable; + number_of_slots; + number_of_shards; + endorsement_lag; + availability_threshold; + }) + (obj5 + (req "feature_enable" Data_encoding.bool) + (req "number_of_slots" Data_encoding.int16) + (req "number_of_shards" Data_encoding.int16) + (req "endorsement_lag" Data_encoding.int16) + (req "availability_threshold" Data_encoding.int16)) + (* The encoded representation of this type is stored in the context as bytes. Changing the encoding, or the value of these constants from the previous protocol may break the context migration, or (even @@ -87,6 +129,7 @@ type t = { tx_rollup_max_withdrawals_per_batch : int; tx_rollup_rejection_max_proof_size : int; tx_rollup_sunset_level : int32; + dal : dal; sc_rollup_enable : bool; sc_rollup_origination_size : int; sc_rollup_challenge_window_in_blocks : int; @@ -154,16 +197,17 @@ let encoding = c.tx_rollup_max_ticket_payload_size, c.tx_rollup_rejection_max_proof_size, c.tx_rollup_sunset_level ) ), - ( c.sc_rollup_enable, - c.sc_rollup_origination_size, - c.sc_rollup_challenge_window_in_blocks, - c.sc_rollup_max_available_messages, - c.sc_rollup_stake_amount_in_mutez, - c.sc_rollup_commitment_period_in_blocks, - c.sc_rollup_commitment_storage_size_in_bytes, - c.sc_rollup_max_lookahead_in_blocks, - c.sc_rollup_max_active_outbox_levels, - c.sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) )) + ( c.dal, + ( c.sc_rollup_enable, + c.sc_rollup_origination_size, + c.sc_rollup_challenge_window_in_blocks, + c.sc_rollup_max_available_messages, + c.sc_rollup_stake_amount_in_mutez, + c.sc_rollup_commitment_period_in_blocks, + c.sc_rollup_commitment_storage_size_in_bytes, + c.sc_rollup_max_lookahead_in_blocks, + c.sc_rollup_max_active_outbox_levels, + c.sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -215,16 +259,18 @@ let encoding = tx_rollup_max_ticket_payload_size, tx_rollup_rejection_max_proof_size, tx_rollup_sunset_level ) ), - ( sc_rollup_enable, - sc_rollup_origination_size, - sc_rollup_challenge_window_in_blocks, - sc_rollup_max_available_messages, - sc_rollup_stake_amount_in_mutez, - sc_rollup_commitment_period_in_blocks, - sc_rollup_commitment_storage_size_in_bytes, - sc_rollup_max_lookahead_in_blocks, - sc_rollup_max_active_outbox_levels, - sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) ) -> + ( dal, + ( sc_rollup_enable, + sc_rollup_origination_size, + sc_rollup_challenge_window_in_blocks, + sc_rollup_max_available_messages, + sc_rollup_stake_amount_in_mutez, + sc_rollup_commitment_period_in_blocks, + sc_rollup_commitment_storage_size_in_bytes, + sc_rollup_max_lookahead_in_blocks, + sc_rollup_max_active_outbox_levels, + sc_rollup_max_outbox_messages_per_level ) ) ) ) ) ) ) + ) -> { preserved_cycles; blocks_per_cycle; @@ -277,6 +323,7 @@ let encoding = tx_rollup_max_ticket_payload_size; tx_rollup_rejection_max_proof_size; tx_rollup_sunset_level; + dal; sc_rollup_enable; sc_rollup_origination_size; sc_rollup_challenge_window_in_blocks; @@ -359,16 +406,20 @@ let encoding = (req "tx_rollup_max_ticket_payload_size" int31) (req "tx_rollup_rejection_max_proof_size" int31) (req "tx_rollup_sunset_level" int32))) - (obj10 - (req "sc_rollup_enable" bool) - (req "sc_rollup_origination_size" int31) - (req "sc_rollup_challenge_window_in_blocks" int31) - (req "sc_rollup_max_available_messages" int31) - (req "sc_rollup_stake_amount_in_mutez" int31) - (req "sc_rollup_commitment_period_in_blocks" int31) - (req - "sc_rollup_commitment_storage_size_in_bytes" - int31) - (req "sc_rollup_max_lookahead_in_blocks" int32) - (req "sc_rollup_max_active_outbox_levels" int32) - (req "sc_rollup_max_outbox_messages_per_level" int31)))))))) + (merge_objs + (obj1 (req "dal_parametric" dal_encoding)) + (obj10 + (req "sc_rollup_enable" bool) + (req "sc_rollup_origination_size" int31) + (req "sc_rollup_challenge_window_in_blocks" int31) + (req "sc_rollup_max_available_messages" int31) + (req "sc_rollup_stake_amount_in_mutez" int31) + (req "sc_rollup_commitment_period_in_blocks" int31) + (req + "sc_rollup_commitment_storage_size_in_bytes" + int31) + (req "sc_rollup_max_lookahead_in_blocks" int32) + (req "sc_rollup_max_active_outbox_levels" int32) + (req + "sc_rollup_max_outbox_messages_per_level" + int31))))))))) diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index ee6722acc7c1fcb652510f59c89d2d935353d8a5..3f362bfdd07dea855979a2b2053877faf9f0937b 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -25,6 +25,16 @@ (* *) (*****************************************************************************) +type dal = { + feature_enable : bool; + number_of_slots : int; + number_of_shards : int; + endorsement_lag : int; + availability_threshold : int; +} + +val dal_encoding : dal Data_encoding.t + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -116,6 +126,7 @@ type t = { require proofs larger than this should be no-ops. *) tx_rollup_rejection_max_proof_size : int; tx_rollup_sunset_level : int32; + dal : dal; sc_rollup_enable : bool; sc_rollup_origination_size : int; sc_rollup_challenge_window_in_blocks : int; diff --git a/src/proto_alpha/lib_protocol/dal_apply.ml b/src/proto_alpha/lib_protocol/dal_apply.ml new file mode 100644 index 0000000000000000000000000000000000000000..4d88a9db8126004772b04b44b3724e057a20c91f --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_apply.ml @@ -0,0 +1,161 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(* Every function of this file should check the feature flag. *) + +open Alpha_context + +type error += Dal_feature_disabled + +let () = + let description = + "Data-availability layer will be enabled in a future proposal." + in + register_error_kind + `Permanent + ~id:"operation.dal_disabled" + ~title:"DAL is disabled" + ~description + ~pp:(fun ppf () -> Format.fprintf ppf "%s" description) + Data_encoding.unit + (function Dal_feature_disabled -> Some () | _ -> None) + (fun () -> Dal_feature_disabled) + +let assert_dal_feature_enabled ctxt = + let open Constants in + let Parametric.{dal = {feature_enable; _}; _} = parametric ctxt in + error_unless Compare.Bool.(feature_enable = true) Dal_feature_disabled + +let only_if_dal_feature_enabled ctxt ~default f = + let open Constants in + let Parametric.{dal = {feature_enable; _}; _} = parametric ctxt in + if feature_enable then f ctxt else default ctxt + +type error += Dal_endorsement_unexpected_size of {expected : int; got : int} + +let () = + let open Data_encoding in + let description = + "The endorsement for data availability has a different size" + in + register_error_kind + `Permanent + ~id:"dal_endorsement_unexpected_size" + ~title:"DAL endorsement unexpected size" + ~description + ~pp:(fun ppf (expected, got) -> + Format.fprintf ppf "%s: Expected %d. Got %d." description expected got) + (obj2 (req "expected_size" int31) (req "got" int31)) + (function + | Dal_endorsement_unexpected_size {expected; got} -> Some (expected, got) + | _ -> None) + (fun (expected, got) -> Dal_endorsement_unexpected_size {expected; got}) + +let validate_data_availability ctxt data_availability = + assert_dal_feature_enabled ctxt >>? fun () -> + let open Constants in + let Parametric.{dal = {number_of_slots; _}; _} = parametric ctxt in + let expected_size = + Dal.Endorsement.expected_size_in_bits ~max_index:(number_of_slots - 1) + in + let size = Dal.Endorsement.occupied_size_in_bits data_availability in + error_unless + Compare.Int.(size = expected_size) + (Dal_endorsement_unexpected_size {expected = expected_size; got = size}) + +let apply_data_availability ctxt data_availability ~endorser = + assert_dal_feature_enabled ctxt >>?= fun () -> + let shards = Dal.Endorsement.shards ctxt ~endorser in + Dal.Endorsement.record_available_shards ctxt data_availability shards + |> return + +type error += + | Dal_publish_slot_header_invalid_index of {given : int; maximum : int} + +let () = + let open Data_encoding in + let description = "Bad index for slot header" in + register_error_kind + `Permanent + ~id:"dal_publish_slot_header_invalid_index" + ~title:"DAL slot header invalid index" + ~description + ~pp:(fun ppf (given, maximum) -> + Format.fprintf ppf "%s: Given %d. Maximum %d." description given maximum) + (obj2 (req "given" int31) (req "got" int31)) + (function + | Dal_publish_slot_header_invalid_index {given; maximum} -> + Some (given, maximum) + | _ -> None) + (fun (given, maximum) -> + Dal_publish_slot_header_invalid_index {given; maximum}) + +let validate_publish_slot_header ctxt Dal.Slot.{index; _} = + assert_dal_feature_enabled ctxt >>? fun () -> + let open Constants in + let Parametric.{dal = {number_of_slots; _}; _} = parametric ctxt in + error_unless + Compare.Int.(0 <= index && index < number_of_slots) + (Dal_publish_slot_header_invalid_index + {given = index; maximum = number_of_slots - 1}) + +type error += + | Dal_publish_slot_header_candidate_with_low_fees of {proposed_fees : Tez.t} + +(* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3114 + + Better error message *) +let () = + let open Data_encoding in + let description = "Slot header with too low fees" in + register_error_kind + `Permanent + ~id:"dal_publish_slot_header_with_low_fees" + ~title:"DAL slot header with low fees" + ~description + ~pp:(fun ppf proposed -> + Format.fprintf ppf "%s: Proposed fees %a." description Tez.pp proposed) + (obj1 (req "proposed" Tez.encoding)) + (function + | Dal_publish_slot_header_candidate_with_low_fees {proposed_fees} -> + Some proposed_fees + | _ -> None) + (fun proposed_fees -> + Dal_publish_slot_header_candidate_with_low_fees {proposed_fees}) + +let apply_publish_slot_header ctxt slot proposed_fees = + assert_dal_feature_enabled ctxt >>? fun () -> + let ctxt, updated = Dal.Slot.update_slot_fees ctxt slot proposed_fees in + if updated then ok ctxt + else error (Dal_publish_slot_header_candidate_with_low_fees {proposed_fees}) + +let dal_finalisation ctxt = + only_if_dal_feature_enabled + ctxt + ~default:(fun ctxt -> return (ctxt, None)) + (fun ctxt -> + Dal.Slot.finalize_current_slots ctxt >>= fun ctxt -> + Dal.Slot.finalize_pending_slots ctxt >|=? fun (ctxt, slot_availability) -> + (ctxt, Some slot_availability)) diff --git a/src/proto_alpha/lib_protocol/dal_apply.mli b/src/proto_alpha/lib_protocol/dal_apply.mli new file mode 100644 index 0000000000000000000000000000000000000000..22f6324b5004ab384151bf4e04c19dd4a32027ed --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_apply.mli @@ -0,0 +1,63 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** This modules handles all the validation/application/finalisation + of any operation related to the DAL. *) + +open Alpha_context + +(** [validate_data_availability ctxt endorsement] ensures the + [endorsement] is valid and cannot prevent an operation containing + [endorsement] to be refused on top of [ctxt]. If an [Error _] is + returned, the [endorsement] is not valid. *) +val validate_data_availability : t -> Dal.Endorsement.t -> unit tzresult + +(** [apply_data_availability ctxt endorsement ~endorser] applies + [endorsement] into the [ctxt] assuming [endorser] issued those + endorsements. *) +val apply_data_availability : + t -> + Dal.Endorsement.t -> + endorser:Signature.Public_key_hash.t -> + t tzresult Lwt.t + +(** [validate_publish_slot_header ctxt slot] ensures that [slot] is + valid and cannot prevent an operation containing [slot] to be + refused on top of [ctxt]. If an [Error _] is returned, the [slot] + is not valid. *) +val validate_publish_slot_header : t -> Dal.Slot.t -> unit tzresult + +(** [apply_publish_slot_header ctxt slot fees] applies the publication + of [slot] on top of [ctxt] assuming the operation that issued + contains [fees] tez. *) +val apply_publish_slot_header : t -> Dal.Slot.t -> Tez.t -> t tzresult + +(** [dal_finalisation ctxt] should be executed at block finalisation + time. A set of slots available at level [ctxt.current_level - lag] + is returned encapsulated into the endorsement data-structure. + + [lag] is a parametric constant specific to the data-availability + layer. *) +val dal_finalisation : t -> (t * Dal.Endorsement.t option) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/dal_endorsement_repr.ml b/src/proto_alpha/lib_protocol/dal_endorsement_repr.ml new file mode 100644 index 0000000000000000000000000000000000000000..86855111bcab24a9f8d1c7ba2ca383c0fe84b11d --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_endorsement_repr.ml @@ -0,0 +1,130 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3103 + + This may be a bit heavy in practice. We could also assume that in + practice, this bitfield will contain many bits to one. Hence, we + could consider a better encoding which is smaller in the optimistic + case. For example: + + 1. When all the slots are endorsed, the encoding can be represented + in one bit. + + 2. Otherwise, we can pack slots by [8]. Have a header of [slots/8] + which is [1] if all the slots in this set are [1], [0] + otherwise. For all pack with a bit set to [0], we give the explicit + representation. Hence, if there are [256] slots, and [2] are not + endorsed, this representation will be of size [32] bits + [16] bits + = [48] bits which is better than [256] bits. *) +type t = Bitset.t + +type available_slots = t + +let encoding = Bitset.encoding + +let empty = Bitset.empty + +let is_available t index = + match Bitset.mem t index with + | Ok b -> b + | Error _ -> + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3104 + + Should we do something here? *) + false + +let commit t index = + match Bitset.add t index with + | Ok t -> t + | Error _ -> + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3104 + + Should we do something here? *) + t + +let occupied_size_in_bits = Bitset.occupied_size_in_bits + +let expected_size_in_bits ~max_index = + (* We compute an encoding of the data-availability endorsements + which is a (tight) upper bound of what we expect. *) + let open Bitset in + match add empty max_index with + | Error _ -> (* Happens if max_index < 1 *) 0 + | Ok t -> occupied_size_in_bits t + +module Accountability = struct + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3109 + + Think hard about this data structure and whether it needs to be + optimized. + *) + type t = Bitset.t list + + type shard = int + + let init ~length = + let l = + List.init + ~when_negative_length: + "Dal_endorsement_repr.Accountability.init: length cannot be negative" + length + (fun _ -> Bitset.empty) + in + match l with Error msg -> invalid_arg msg | Ok l -> l + + let record_slot_shard_availability bitset shards = + List.fold_left + (fun bitset shard -> + Bitset.add bitset shard |> Result.value ~default:bitset) + bitset + shards + + let record_shards_availability shard_bitset_per_slot slots shards = + List.mapi + (fun slot bitset -> + match Bitset.mem slots slot with + | Error _ -> + (* slot index is above the length provided at initialisation *) + bitset + | Ok slot_available -> + if slot_available then record_slot_shard_availability bitset shards + else bitset) + shard_bitset_per_slot + + let is_slot_available shard_bitset_per_slot ~threshold index = + match List.nth shard_bitset_per_slot index with + | None -> false + | Some bitset -> + let acc = ref 0 in + let max = Bitset.occupied_size_in_bits bitset in + List.iter + (fun x -> + match Bitset.mem bitset x with + | Error _ | Ok false -> () + | Ok true -> incr acc) + Misc.(0 --> max) ; + Compare.Int.(!acc >= threshold) +end diff --git a/src/proto_alpha/lib_protocol/dal_endorsement_repr.mli b/src/proto_alpha/lib_protocol/dal_endorsement_repr.mli new file mode 100644 index 0000000000000000000000000000000000000000..828f185993892e86158f86b071510db9466f73d1 --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_endorsement_repr.mli @@ -0,0 +1,109 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Slot endorsement representation for the data-availability layer. + + {1 Overview} + + For the data-availability layer, the layer 1 provides a list of + slots at every level (see {!dal_slot_repr}). Slots are not posted + directly onto L1 blocks. Stakeholders (via endorsements) can commit + on the availability of the data. + + The slot is uniformly split into shards. Each endorser commits for + every slot at every level on the availability of all shards they + are assigned to. + + This module encapsulates the representation of this commitment + that aims to be provided with endorsement operations. To avoid + overloading the network, this representation should be compact. *) + +type t + +type available_slots = t + +val encoding : t Data_encoding.t + +(** [empty] returns an empty [slot_endorsement] which commits that + every slot are unavailable. *) +val empty : t + +(** [is_available slot_endorsement ~index] returns [true] if the + [slot_endorsement] commits that the slot at [index] is + available. *) +val is_available : t -> Dal_slot_repr.index -> bool + +(** [commit slot_endorsement index] commits into [slot_endorsement] + that the [index] is available. *) +val commit : t -> Dal_slot_repr.index -> t + +(** [occupied_size_in_bits slot_endorsement] returns the size in bits of an endorsement. *) +val occupied_size_in_bits : t -> int + +(** [expected_size_in_bits ~max_index] returns the expected size (in + bits) of an endorsement considering the maximum index for a slot is + [max_index]. *) +val expected_size_in_bits : max_index:Dal_slot_repr.index -> int + +(** This module is used to record the various data-availability + endorsements. + + For each endorser, a list of shards is associated. For each slots + declared available (see {!type:t}) we record that those shards were + available. + + This information will be used at the end of block finalisation to + have the protocol declaring whether the slot is available. *) +module Accountability : sig + (** The data-structure used to record the shards-slots availability. *) + type t + + (** DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3145 + + Consider using the [Bounded] module. In particular, change the + semantics of [is_slot_available] accordingly. *) + + (** A shard aims to be a positive number. *) + type shard = int + + (** [init ~length] initialises a new accountability data-structures + with at most [length] slots and where for every slot, no shard is + available. *) + val init : length:int -> t + + (** [record_shards_availability t slots shards] records that for all + slots declared available in [slots], shard indices in [shards] + are available. It is the responsibility of the caller to ensure + the shard indices are positive numbers. A negative shard index is + ignored. *) + val record_shards_availability : t -> available_slots -> shard list -> t + + (** [is_slot_available t ~threshold slot] returns [true] if the + number of shards recorded in [t] for the [slot] is above the + [threshold]. Returns [false] otherwise or if the [index] is out + of the interval [0;length] where [length] is the value provided + to the [init] function. *) + val is_slot_available : t -> threshold:int -> Dal_slot_repr.index -> bool +end diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.ml b/src/proto_alpha/lib_protocol/dal_slot_repr.ml new file mode 100644 index 0000000000000000000000000000000000000000..44539286a8a9796d44fb876633fe85638c199926 --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.ml @@ -0,0 +1,118 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +module Header = struct + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3101 + + Datatype is mocked for the moment while the cryptography is not + provided by the environment. *) + type t = int + + let encoding = Data_encoding.int31 + + let pp = Format.pp_print_int +end + +type index = int + +type header = Header.t + +type t = {level : Raw_level_repr.t; index : index; header : header} + +type slot = t + +let make ~level ~index ~header = + if Compare.Int.(index < 0) then + invalid_arg "dal_slot_repr.make: index should be a non-negative number" ; + {level; index; header} + +let encoding = + let open Data_encoding in + conv + (fun {level; index; header} -> (level, index, header)) + (fun (level, index, header) -> {level; index; header}) + (obj3 + (req "level" Raw_level_repr.encoding) + (req "index" Data_encoding.uint8) + (req "header" Header.encoding)) + +let pp fmt {level; index; header} = + Format.fprintf + fmt + "level: %a index: %a header: %a" + Raw_level_repr.pp + level + Format.pp_print_int + index + Header.pp + header + +module Slot_market = struct + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3108 + + Think harder about this data structure and whether it can be + optimized. *) + + type t = (slot * Tez_repr.t) option list + + let init ~length = + let l = + List.init + ~when_negative_length: + "Dal_slot_repr.Slot_market.init: length cannot be negative" + length + (fun _ -> None) + in + match l with Error msg -> invalid_arg msg | Ok l -> l + + let current_fees candidates index = + match List.nth candidates index with + | None | Some None -> None + | Some (Some ((_ : slot), tez)) -> Some tez + + let update candidates slot fees = + let has_changed = ref false in + let may_replace_candidate current_candidate = + match current_candidate with + | Some ((_slot : slot), current_fees) when Tez_repr.(current_fees >= fees) + -> + current_candidate + | _ -> Some (slot, fees) + in + let candidates = + List.mapi + (fun i candidate -> + if Compare.Int.(i = slot.index) then may_replace_candidate candidate + else candidate) + candidates + in + (candidates, !has_changed) + + let candidates candidates = + List.filter_map + (fun candidate -> + Option.map (fun (slot, (_fee : Tez_repr.t)) -> slot) candidate) + candidates +end diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.mli b/src/proto_alpha/lib_protocol/dal_slot_repr.mli new file mode 100644 index 0000000000000000000000000000000000000000..231e2d44bcb71a8a810f3af161be531c26983c60 --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.mli @@ -0,0 +1,109 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Slot header representation for the data-availability layer. + + {1 Overview} + + For the data-availability layer, the L1 provides a list of slots + at every level. A slot is a blob of data that can be interpreted by + the users of the data-availability layer (such as SCORU). + + The purpose of the data-availability layer is to increase the + bandwidth of the layer 1 thanks to the distribution of "slots". A + slot is never posted directly onto the layer 1 blocks but on the + data-availability layer. The producer of a slot sill has to post a + slot header onto the layer 1. A slot header is an abstract datatype + certifying that the corresponding slot has some maximum size + (provided by the layer 1). In other words, the whole data contained + into the slot cannot exceed some fixed size. This is to avoid + attacks where a slot header would be posted onto the layer 1 block, + declared available by the protocol, but actually the slot size + would be too large to be refuted a posteriori. + + The slot header can also be used to prove that a blob of data is a + portion of the initial slot. *) + +module Header : sig + type t + + val encoding : t Data_encoding.t +end + +type header = Header.t + +(** A non-negative number which encodes the position of a slot from + the list of slots provided by the L1. We expect this index to be + below [256] (see {!val:encoding}). *) +type index = int + +(** DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3145 + +Consider using the `Bounded` module. *) +type t = private {level : Raw_level_repr.t; index : index; header : header} + +type slot = t + +(** [make ~level ~index ~header] builds a slot. + + @raise Invalid_arg if [index] is a non-positive number *) +val make : level:Raw_level_repr.t -> index:index -> header:header -> t + +(** The encoding ensures the slot index is always a non-negative + number below strictly below 256. *) +val encoding : t Data_encoding.t + +val pp : Format.formatter -> t -> unit + +(** Only one slot header is accepted per slot index. If two slots + headers are included into a block, we use the fee market to know + which slot header will be chosen. + + This is encapsulated in the following module. +*) +module Slot_market : sig + (** Represent the fee market for a list of slots. *) + type t + + (** [init ~length] encodes a list of [length] slots without candidates. *) + val init : length:int -> t + + (** [current_fees t index] returns [Some fees] if the best candidate + recorded for slot at index [index] was posted with fees + [fees]. [None] is returned iff no candidate were recorded or if + the index is negative. It is the responsability of the caller to + ensure [index] is below some reasonable upper bound. *) + val current_fees : t -> index -> Tez_repr.t option + + (** [update t index fees] updates the candidate associated to index + [index]. Returns [Some (_, true)] if the candidate was better + than the current one. Returns [Some (_, false)] otherwise. It is + a no-op if the [index] is not in the interval [0;length] where is + the value provided to the [init] function. *) + val update : t -> slot -> Tez_repr.t -> t * bool + + (** [candidates t] returns a list of slot candidates. *) + val candidates : t -> slot list +end diff --git a/src/proto_alpha/lib_protocol/dal_slot_storage.ml b/src/proto_alpha/lib_protocol/dal_slot_storage.ml new file mode 100644 index 0000000000000000000000000000000000000000..5736bfa01ea5a0924e85cc64bfeff3bc11b4e96d --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_slot_storage.ml @@ -0,0 +1,56 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +let find ctxt level = Storage.Dal.Slot_headers.find ctxt level + +let finalize_current_slots ctxt = + let current_level = Raw_context.current_level ctxt in + let slots = Raw_context.Dal.candidates ctxt in + Storage.Dal.Slot_headers.add ctxt current_level.level slots + +let compute_available_slots ctxt slots = + let fold_available_slots available_slots slot = + if Raw_context.Dal.is_slot_available ctxt slot.Dal_slot_repr.index then + Dal_endorsement_repr.commit available_slots slot.Dal_slot_repr.index + else available_slots + in + List.fold_left fold_available_slots Dal_endorsement_repr.empty slots + +let finalize_pending_slots ctxt = + let current_level = Raw_context.current_level ctxt in + let Constants_parametric_repr.{dal; _} = Raw_context.constants ctxt in + match Raw_level_repr.(sub current_level.level dal.endorsement_lag) with + | None -> return (ctxt, Dal_endorsement_repr.empty) + | Some level_endorsed -> ( + Storage.Dal.Slot_headers.find ctxt level_endorsed >>=? function + | None -> return (ctxt, Dal_endorsement_repr.empty) + | Some slots -> + let available_slots = compute_available_slots ctxt slots in + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3112 + + At this point, available slots can be integrated into + SCORU inboxes *) + Storage.Dal.Slot_headers.remove ctxt level_endorsed >>= fun ctxt -> + return (ctxt, available_slots)) diff --git a/src/proto_alpha/lib_protocol/dal_slot_storage.mli b/src/proto_alpha/lib_protocol/dal_slot_storage.mli new file mode 100644 index 0000000000000000000000000000000000000000..fd38008a4e3b79cba3558216e5434a1bae578e2b --- /dev/null +++ b/src/proto_alpha/lib_protocol/dal_slot_storage.mli @@ -0,0 +1,65 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Storage management of slots for the data-availability layer. + + {1 Overview} + + This module is an interface for the slot storage for the layer 1. + + Depending on the current level of the context and the [lag] (a + constant given by the context), the status of the slot may differ: + + - For every level in the interval [current_level; current_level + + lag -1] the slot is [Pending]. This means a slot header was + proposed but was not declared available yet. + + - For every level above [current_level + lag], the slot may be + [confirmed]. For any slot confirmed by the protocol (i.e. indices + returned by [finalize_pending_slots]), subscribers of the DAL + should take into account the corresponding slots. + + - For every level below [current_level - lag], there should not be + any slot in the storage. *) + +(** [find ctxt level] returns [Some slots] where [slots] are pending + slots at level [level]. [None] is returned if no [slot] was + registered at this level. The function fails if the reading into + the context fails. *) +val find : + Raw_context.t -> + Raw_level_repr.t -> + Dal_slot_repr.t list option tzresult Lwt.t + +(** [finalize_current_slots ctxt] finalizes the current slots posted + on this block and marks them as pending into the context. *) +val finalize_current_slots : Raw_context.t -> Raw_context.t Lwt.t + +(** [finalize_pending_slots ctxt] finalizes pending slots which are + old enough (i.e. registered at level [current_level - lag]). All + slots marked as available are returned. All the pending slots at + [current_level - lag] level are removed from the context. *) +val finalize_pending_slots : + Raw_context.t -> (Raw_context.t * Dal_endorsement_repr.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/dune b/src/proto_alpha/lib_protocol/dune index 73761c300e8d123fe76ffe14f3e3337e7506eece..56e0f7e62a60d7958b7a8dbc0116f3742a4e6157 100644 --- a/src/proto_alpha/lib_protocol/dune +++ b/src/proto_alpha/lib_protocol/dune @@ -98,6 +98,8 @@ Tx_rollup_commitment_repr Tx_rollup_errors_repr Tx_rollup_state_repr + Dal_slot_repr + Dal_endorsement_repr Bond_id_repr Vote_repr Liquidity_baking_repr @@ -163,6 +165,7 @@ Sc_rollup_stake_storage Sc_rollup_refutation_storage Sc_rollup_storage + Dal_slot_storage Alpha_context Script_string Script_int @@ -211,6 +214,7 @@ Sc_rollup_PVM_sem Sc_rollup_arith Sc_rollups + Dal_apply Baking Amendment Apply @@ -311,6 +315,8 @@ tx_rollup_commitment_repr.ml tx_rollup_commitment_repr.mli tx_rollup_errors_repr.ml tx_rollup_state_repr.ml tx_rollup_state_repr.mli + dal_slot_repr.ml dal_slot_repr.mli + dal_endorsement_repr.ml dal_endorsement_repr.mli bond_id_repr.ml bond_id_repr.mli vote_repr.ml vote_repr.mli liquidity_baking_repr.ml liquidity_baking_repr.mli @@ -376,6 +382,7 @@ sc_rollup_stake_storage.ml sc_rollup_stake_storage.mli sc_rollup_refutation_storage.ml sc_rollup_refutation_storage.mli sc_rollup_storage.ml sc_rollup_storage.mli + dal_slot_storage.ml dal_slot_storage.mli alpha_context.ml alpha_context.mli script_string.ml script_string.mli script_int.ml script_int.mli @@ -424,6 +431,7 @@ sc_rollup_PVM_sem.ml sc_rollup_arith.ml sc_rollup_arith.mli sc_rollups.ml sc_rollups.mli + dal_apply.ml dal_apply.mli baking.ml baking.mli amendment.ml amendment.mli apply.ml apply.mli @@ -510,6 +518,8 @@ tx_rollup_commitment_repr.ml tx_rollup_commitment_repr.mli tx_rollup_errors_repr.ml tx_rollup_state_repr.ml tx_rollup_state_repr.mli + dal_slot_repr.ml dal_slot_repr.mli + dal_endorsement_repr.ml dal_endorsement_repr.mli bond_id_repr.ml bond_id_repr.mli vote_repr.ml vote_repr.mli liquidity_baking_repr.ml liquidity_baking_repr.mli @@ -575,6 +585,7 @@ sc_rollup_stake_storage.ml sc_rollup_stake_storage.mli sc_rollup_refutation_storage.ml sc_rollup_refutation_storage.mli sc_rollup_storage.ml sc_rollup_storage.mli + dal_slot_storage.ml dal_slot_storage.mli alpha_context.ml alpha_context.mli script_string.ml script_string.mli script_int.ml script_int.mli @@ -623,6 +634,7 @@ sc_rollup_PVM_sem.ml sc_rollup_arith.ml sc_rollup_arith.mli sc_rollups.ml sc_rollups.mli + dal_apply.ml dal_apply.mli baking.ml baking.mli amendment.ml amendment.mli apply.ml apply.mli @@ -729,6 +741,8 @@ tx_rollup_commitment_repr.ml tx_rollup_commitment_repr.mli tx_rollup_errors_repr.ml tx_rollup_state_repr.ml tx_rollup_state_repr.mli + dal_slot_repr.ml dal_slot_repr.mli + dal_endorsement_repr.ml dal_endorsement_repr.mli bond_id_repr.ml bond_id_repr.mli vote_repr.ml vote_repr.mli liquidity_baking_repr.ml liquidity_baking_repr.mli @@ -794,6 +808,7 @@ sc_rollup_stake_storage.ml sc_rollup_stake_storage.mli sc_rollup_refutation_storage.ml sc_rollup_refutation_storage.mli sc_rollup_storage.ml sc_rollup_storage.mli + dal_slot_storage.ml dal_slot_storage.mli alpha_context.ml alpha_context.mli script_string.ml script_string.mli script_int.ml script_int.mli @@ -842,6 +857,7 @@ sc_rollup_PVM_sem.ml sc_rollup_arith.ml sc_rollup_arith.mli sc_rollups.ml sc_rollups.mli + dal_apply.ml dal_apply.mli baking.ml baking.mli amendment.ml amendment.mli apply.ml apply.mli @@ -944,6 +960,8 @@ tx_rollup_commitment_repr.ml tx_rollup_commitment_repr.mli tx_rollup_errors_repr.ml tx_rollup_state_repr.ml tx_rollup_state_repr.mli + dal_slot_repr.ml dal_slot_repr.mli + dal_endorsement_repr.ml dal_endorsement_repr.mli bond_id_repr.ml bond_id_repr.mli vote_repr.ml vote_repr.mli liquidity_baking_repr.ml liquidity_baking_repr.mli @@ -1009,6 +1027,7 @@ sc_rollup_stake_storage.ml sc_rollup_stake_storage.mli sc_rollup_refutation_storage.ml sc_rollup_refutation_storage.mli sc_rollup_storage.ml sc_rollup_storage.mli + dal_slot_storage.ml dal_slot_storage.mli alpha_context.ml alpha_context.mli script_string.ml script_string.mli script_int.ml script_int.mli @@ -1057,6 +1076,7 @@ sc_rollup_PVM_sem.ml sc_rollup_arith.ml sc_rollup_arith.mli sc_rollups.ml sc_rollups.mli + dal_apply.ml dal_apply.mli baking.ml baking.mli amendment.ml amendment.mli apply.ml apply.mli diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 3a1dfce1293978acc75542ebff3c5b971593cf5d..022ebeb62a766567f09a136f444309da9796365d 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -583,6 +583,7 @@ let finalize_block balance_updates = migration_balance_updates; liquidity_baking_toggle_ema; implicit_operations_results; + dal_slot_availability = None; } ) | Partial_application {fitness; block_producer; _} -> (* For partial application we do not completely check the block validity. @@ -622,6 +623,7 @@ let finalize_block balance_updates = migration_balance_updates; liquidity_baking_toggle_ema; implicit_operations_results; + dal_slot_availability = None; } ) | Application { @@ -690,6 +692,9 @@ let relative_position_within_block op1 op2 = | Single (Endorsement _), Single (Endorsement _) -> 0 | Single (Endorsement _), _ -> -1 | _, Single (Endorsement _) -> 1 + | Single (Dal_slot_availability _), Single (Dal_slot_availability _) -> 0 + | Single (Dal_slot_availability _), _ -> -1 + | _, Single (Dal_slot_availability _) -> 1 | Single (Seed_nonce_revelation _), Single (Seed_nonce_revelation _) -> 0 | _, Single (Seed_nonce_revelation _) -> 1 | Single (Seed_nonce_revelation _), _ -> -1 diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index a45d1e4a03ad248eee9e830a38b314f87b0aa0ec..8ac1f74020bc5ca0945473e086069bdd7b2a53b9 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -39,6 +39,8 @@ module Kind = struct type endorsement = endorsement_consensus_kind consensus + type dal_slot_availability = Dal_slot_availability_kind + type seed_nonce_revelation = Seed_nonce_revelation_kind type 'a double_consensus_operation_evidence = @@ -90,6 +92,8 @@ module Kind = struct type transfer_ticket = Transfer_ticket_kind + type dal_publish_slot_header = Dal_publish_slot_header_kind + type sc_rollup_originate = Sc_rollup_originate_kind type sc_rollup_add_messages = Sc_rollup_add_messages_kind @@ -123,6 +127,7 @@ module Kind = struct | Tx_rollup_dispatch_tickets_manager_kind : tx_rollup_dispatch_tickets manager | Transfer_ticket_manager_kind : transfer_ticket manager + | Dal_publish_slot_header_manager_kind : dal_publish_slot_header manager | 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 @@ -184,12 +189,15 @@ let pp_consensus_content ppf content = type consensus_watermark = | Endorsement of Chain_id.t | Preendorsement of Chain_id.t + | Dal_slot_availability of Chain_id.t let bytes_of_consensus_watermark = function | Preendorsement chain_id -> Bytes.cat (Bytes.of_string "\x12") (Chain_id.to_bytes chain_id) | Endorsement chain_id -> Bytes.cat (Bytes.of_string "\x13") (Chain_id.to_bytes chain_id) + | Dal_slot_availability chain_id -> + Bytes.cat (Bytes.of_string "\x14") (Chain_id.to_bytes chain_id) let to_watermark w = Signature.Custom (bytes_of_consensus_watermark w) @@ -205,6 +213,10 @@ let of_watermark = function Option.map (fun chain_id -> Preendorsement chain_id) (Chain_id.of_bytes_opt (Bytes.sub b 1 (Bytes.length b - 1))) + | '\x14' -> + Option.map + (fun chain_id -> Dal_slot_availability chain_id) + (Chain_id.of_bytes_opt (Bytes.sub b 1 (Bytes.length b - 1))) | _ -> None else None | _ -> None @@ -238,6 +250,9 @@ and _ contents_list = and _ contents = | Preendorsement : consensus_content -> Kind.preendorsement contents | Endorsement : consensus_content -> Kind.endorsement contents + | Dal_slot_availability : + Signature.Public_key_hash.t * Dal_endorsement_repr.t + -> Kind.dal_slot_availability contents | Seed_nonce_revelation : { level : Raw_level_repr.t; nonce : Seed_repr.nonce; @@ -362,6 +377,10 @@ and _ manager_operation = entrypoint : Entrypoint_repr.t; } -> Kind.transfer_ticket manager_operation + | Dal_publish_slot_header : { + slot : Dal_slot_repr.t; + } + -> Kind.dal_publish_slot_header manager_operation | Sc_rollup_originate : { kind : Sc_rollup_repr.Kind.t; boot_sector : string; @@ -425,6 +444,7 @@ let manager_kind : type kind. kind manager_operation -> kind Kind.manager = | Tx_rollup_rejection _ -> Kind.Tx_rollup_rejection_manager_kind | Tx_rollup_dispatch_tickets _ -> Kind.Tx_rollup_dispatch_tickets_manager_kind | Transfer_ticket _ -> Kind.Transfer_ticket_manager_kind + | Dal_publish_slot_header _ -> Kind.Dal_publish_slot_header_manager_kind | 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 @@ -521,6 +541,10 @@ let sc_rollup_operation_timeout_tag = sc_rollup_operation_tag_offset + 5 let sc_rollup_operation_atomic_batch_tag = sc_rollup_operation_tag_offset + 6 +let dal_offset = 230 + +let dal_publish_slot_header_tag = dal_offset + 0 + module Encoding = struct open Data_encoding @@ -940,6 +964,19 @@ module Encoding = struct Sc_rollup_originate {kind; boot_sector; parameters_ty}); } + let[@coq_axiom_with_reason "gadt"] dal_publish_slot_header_case = + MCase + { + tag = dal_publish_slot_header_tag; + name = "dal_publish_slot_header"; + encoding = obj1 (req "slot" Dal_slot_repr.encoding); + select = + (function + | Manager (Dal_publish_slot_header _ as op) -> Some op | _ -> None); + proj = (function Dal_publish_slot_header {slot} -> slot); + inj = (fun slot -> Dal_publish_slot_header {slot}); + } + let[@coq_axiom_with_reason "gadt"] sc_rollup_add_messages_case = MCase { @@ -1193,6 +1230,29 @@ module Encoding = struct @@ union [make endorsement_case])) (varopt "signature" Signature.encoding))) + let dal_slot_availability_encoding = + obj2 + (req "endorser" Signature.Public_key_hash.encoding) + (req "endorsement" Dal_endorsement_repr.encoding) + + let dal_slot_availability_case = + Case + { + tag = 22; + name = "dal_slot_availability"; + encoding = dal_slot_availability_encoding; + select = + (function + | Contents (Dal_slot_availability _ as op) -> Some op | _ -> None); + proj = + (fun [@coq_match_with_default] (Dal_slot_availability + (endorser, endorsement)) -> + (endorser, endorsement)); + inj = + (fun (endorser, endorsement) -> + Dal_slot_availability (endorser, endorsement)); + } + let[@coq_axiom_with_reason "gadt"] seed_nonce_revelation_case = Case { @@ -1434,6 +1494,11 @@ module Encoding = struct transfer_ticket_tag Manager_operations.transfer_ticket_case + let dal_publish_slot_header_case = + make_manager_case + dal_publish_slot_header_tag + Manager_operations.dal_publish_slot_header_case + let sc_rollup_originate_case = make_manager_case sc_rollup_operation_origination_tag @@ -1483,6 +1548,7 @@ module Encoding = struct [ make endorsement_case; make preendorsement_case; + make dal_slot_availability_case; make seed_nonce_revelation_case; make double_endorsement_evidence_case; make double_preendorsement_evidence_case; @@ -1506,6 +1572,7 @@ module Encoding = struct make tx_rollup_rejection_case; make tx_rollup_dispatch_tickets_case; make transfer_ticket_case; + make dal_publish_slot_header_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; @@ -1572,6 +1639,7 @@ let acceptable_passes (op : packed_operation) = | Single (Failing_noop _) -> [] | Single (Preendorsement _) -> [0] | Single (Endorsement _) -> [0] + | Single (Dal_slot_availability _) -> [0] | Single (Proposals _) -> [1] | Single (Ballot _) -> [1] | Single (Seed_nonce_revelation _) -> [2] @@ -1650,6 +1718,11 @@ let check_signature (type kind) key chain_id ~watermark:(to_watermark (Endorsement chain_id)) (Contents_list contents) signature + | Single (Dal_slot_availability _) as contents -> + check + ~watermark:(to_watermark (Dal_slot_availability chain_id)) + (Contents_list contents) + signature | Single ( Failing_noop _ | Proposals _ | Ballot _ | Seed_nonce_revelation _ | Double_endorsement_evidence _ | Double_preendorsement_evidence _ @@ -1717,6 +1790,8 @@ let equal_manager_operation_kind : | Tx_rollup_dispatch_tickets _, _ -> None | Transfer_ticket _, Transfer_ticket _ -> Some Eq | Transfer_ticket _, _ -> None + | Dal_publish_slot_header _, Dal_publish_slot_header _ -> Some Eq + | Dal_publish_slot_header _, _ -> None | Sc_rollup_originate _, Sc_rollup_originate _ -> Some Eq | Sc_rollup_originate _, _ -> None | Sc_rollup_add_messages _, Sc_rollup_add_messages _ -> Some Eq @@ -1740,6 +1815,8 @@ let equal_contents_kind : type a b. a contents -> b contents -> (a, b) eq option | Preendorsement _, _ -> None | Endorsement _, Endorsement _ -> Some Eq | Endorsement _, _ -> None + | Dal_slot_availability _, Dal_slot_availability _ -> Some Eq + | Dal_slot_availability _, _ -> None | Seed_nonce_revelation _, Seed_nonce_revelation _ -> Some Eq | Seed_nonce_revelation _, _ -> None | Double_endorsement_evidence _, Double_endorsement_evidence _ -> Some Eq diff --git a/src/proto_alpha/lib_protocol/operation_repr.mli b/src/proto_alpha/lib_protocol/operation_repr.mli index 63a179cf3944cba19b31a3149fb2fe41fea777f9..3fc89ce6e72280a5f1fedfb6612f30a5f76c9eea 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/operation_repr.mli @@ -68,6 +68,8 @@ module Kind : sig type endorsement = endorsement_consensus_kind consensus + type dal_slot_availability = Dal_slot_availability_kind + type seed_nonce_revelation = Seed_nonce_revelation_kind type 'a double_consensus_operation_evidence = @@ -119,6 +121,8 @@ module Kind : sig type transfer_ticket = Transfer_ticket_kind + type dal_publish_slot_header = Dal_publish_slot_header_kind + type sc_rollup_originate = Sc_rollup_originate_kind type sc_rollup_add_messages = Sc_rollup_add_messages_kind @@ -152,6 +156,7 @@ module Kind : sig | Tx_rollup_dispatch_tickets_manager_kind : tx_rollup_dispatch_tickets manager | Transfer_ticket_manager_kind : transfer_ticket manager + | Dal_publish_slot_header_manager_kind : dal_publish_slot_header manager | 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 @@ -186,6 +191,7 @@ val pp_consensus_content : Format.formatter -> consensus_content -> unit type consensus_watermark = | Endorsement of Chain_id.t | Preendorsement of Chain_id.t + | Dal_slot_availability of Chain_id.t val to_watermark : consensus_watermark -> Signature.watermark @@ -235,6 +241,12 @@ and _ contents = (* Endorsement: About consensus, endorsement of a block held by a validator. *) | Endorsement : consensus_content -> Kind.endorsement contents + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3115 + + Temporary operation to avoid modifying endorsement encoding. *) + | Dal_slot_availability : + Signature.Public_key_hash.t * Dal_endorsement_repr.t + -> Kind.dal_slot_availability contents (* Seed_nonce_revelation: Nonces are created by bakers and are combined to create pseudo-random seeds. Bakers are urged to reveal their nonces after a given number of cycles to keep their block rewards @@ -426,6 +438,10 @@ and _ manager_operation = (** The entrypoint of the smart contract address that should receive the tickets. *) } -> Kind.transfer_ticket manager_operation + | Dal_publish_slot_header : { + slot : Dal_slot_repr.t; + } + -> Kind.dal_publish_slot_header manager_operation (* [Sc_rollup_originate] allows an implicit account to originate a new smart contract rollup (initialized with a given boot sector). *) @@ -561,6 +577,8 @@ module Encoding : sig val endorsement_case : Kind.endorsement case + val dal_slot_availability_case : Kind.dal_slot_availability case + val seed_nonce_revelation_case : Kind.seed_nonce_revelation case val double_preendorsement_evidence_case : @@ -613,6 +631,9 @@ module Encoding : sig val transfer_ticket_case : Kind.transfer_ticket Kind.manager case + val dal_publish_slot_header_case : + Kind.dal_publish_slot_header Kind.manager case + val sc_rollup_originate_case : Kind.sc_rollup_originate Kind.manager case val sc_rollup_add_messages_case : @@ -672,6 +693,8 @@ module Encoding : sig val transfer_ticket_case : Kind.transfer_ticket case + val dal_publish_slot_header_case : Kind.dal_publish_slot_header case + val sc_rollup_originate_case : Kind.sc_rollup_originate case val sc_rollup_add_messages_case : Kind.sc_rollup_add_messages case diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index f1341fb2d2d8c3e4b171a42436ac92843ee6ac28..52ed71a62c96aa94123476b66ab42941d8a86dac 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -247,6 +247,21 @@ type back = { tx_rollup_current_messages : Tx_rollup_inbox_repr.Merkle.tree Tx_rollup_repr.Map.t; sc_rollup_current_messages : Context.tree Sc_rollup_address_map_builder.t; + dal_slot_fee_market : Dal_slot_repr.Slot_market.t; + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3105 + + We associate to a slot header some fees. This enable the use + of a fee market for slot publication. However, this is not + resilient from the game theory point of view. Probably we can find + better incentives here. In any case, because we want the following + invariant: + + - For each level and for each slot there is at most one slot + header. + + - We need to provide an incentive to avoid byzantines to post + dummy slot headers. *) + dal_endorsement_slot_accountability : Dal_endorsement_repr.Accountability.t; } (* @@ -817,6 +832,12 @@ let prepare ~level ~predecessor_timestamp ~timestamp ctxt = stake_distribution_for_current_cycle = None; tx_rollup_current_messages = Tx_rollup_repr.Map.empty; sc_rollup_current_messages = Sc_rollup_carbonated_map.empty; + dal_slot_fee_market = + Dal_slot_repr.Slot_market.init + ~length:constants.Constants_parametric_repr.dal.number_of_slots; + dal_endorsement_slot_accountability = + Dal_endorsement_repr.Accountability.init + ~length:constants.Constants_parametric_repr.dal.number_of_slots; }; } @@ -885,6 +906,16 @@ let prepare_first_block ~level ~timestamp ctxt = add_constants ctxt param.constants >|= ok | Jakarta_013 -> get_previous_protocol_constants ctxt >>= fun c -> + let dal = + Constants_parametric_repr. + { + feature_enable = false; + number_of_slots = 256; + number_of_shards = 2048; + endorsement_lag = 2; + availability_threshold = 50; + } + in let constants = Constants_parametric_repr. { @@ -949,6 +980,7 @@ let prepare_first_block ~level ~timestamp ctxt = tx_rollup_rejection_max_proof_size = c.tx_rollup_rejection_max_proof_size; tx_rollup_sunset_level = c.tx_rollup_sunset_level; + dal; sc_rollup_enable = false; sc_rollup_origination_size = c.sc_rollup_origination_size; sc_rollup_challenge_window_in_blocks = 20_160; @@ -1432,3 +1464,55 @@ module Sc_rollup_in_memory_inbox = struct let back = {ctxt.back with sc_rollup_current_messages} in {ctxt with back} end + +module Dal = struct + let record_available_shards ctxt slots shards = + let dal_endorsement_slot_accountability = + Dal_endorsement_repr.Accountability.record_shards_availability + ctxt.back.dal_endorsement_slot_accountability + slots + shards + in + {ctxt with back = {ctxt.back with dal_endorsement_slot_accountability}} + + let current_slot_fees ctxt Dal_slot_repr.{index; _} = + Dal_slot_repr.Slot_market.current_fees ctxt.back.dal_slot_fee_market index + + let update_slot_fees ctxt slot fees = + let dal_slot_fee_market, updated = + Dal_slot_repr.Slot_market.update ctxt.back.dal_slot_fee_market slot fees + in + ({ctxt with back = {ctxt.back with dal_slot_fee_market}}, updated) + + let candidates ctxt = + Dal_slot_repr.Slot_market.candidates ctxt.back.dal_slot_fee_market + + let is_slot_available ctxt = + let threshold = + ctxt.back.constants.Constants_parametric_repr.dal.availability_threshold + in + Dal_endorsement_repr.Accountability.is_slot_available + ctxt.back.dal_endorsement_slot_accountability + ~threshold + + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3110 + + We have to choose for the sampling. Here we use the one used by + the consensus which is hackish and probably not what we want at + the end. However, it should be enough for a prototype. This has a + very bad complexity too. *) + let shards ctxt ~endorser = + let max_shards = ctxt.back.constants.dal.number_of_shards in + Slot_repr.Map.fold_e + (fun slot (_, public_key_hash, _) shards -> + (* Early fail because 2048 < 7000 *) + if Compare.Int.(Slot_repr.to_int slot >= max_shards) then Error shards + else if Signature.Public_key_hash.(public_key_hash = endorser) then + Ok (Slot_repr.to_int slot :: shards) + else Ok shards) + ctxt.back.consensus.allowed_endorsements + [] + |> function + | Ok shards -> shards + | Error shards -> shards +end diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 913ccadb75d13fe97b7c0c7a4ff87200fac09993..3eb58f1c7d3405d629bab78a09c3a73f9c863ac8 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -370,3 +370,37 @@ module Sc_rollup_in_memory_inbox : sig val set_current_messages : t -> Sc_rollup_repr.t -> Context.tree -> t tzresult end + +module Dal : sig + (** [record_available_shards ctxt slots shards] records that the + list of shards [shards] were declared available. The function + assumes that a shard belongs to the interval [0; number_of_shards + - 1]. Otherwise, for each shard outside this interval, it is a + no-op. *) + val record_available_shards : t -> Dal_endorsement_repr.t -> int list -> t + + (** [current_slot_fees ctxt slot fees] computes the current fees + associated to the slot [slot]. *) + val current_slot_fees : t -> Dal_slot_repr.t -> Tez_repr.t option + + (** [update_slot_fees ctxt slot fees] returns a new context where + the new candidate [(slot,fees)] have been taken into + account. Returns [(ctxt,updated)] where [updated=true] if the + candidate if better (fee-wise) than the current + candidate. [update=false] otherwise. *) + val update_slot_fees : t -> Dal_slot_repr.t -> Tez_repr.t -> t * bool + + (** [candidates ctxt] returns the current list of slot for which + there is at least one candidate. *) + val candidates : t -> Dal_slot_repr.t list + + (** [is_slot_available ctxt slot_index] returns [true] if the + [slot_index] is declared available by the protocol. [false] + otherwise. If the [index] is out of the interval + [0;number_of_slots - 1], returns [false]. *) + val is_slot_available : t -> Dal_slot_repr.index -> bool + + (** [shards ctxt ~endorser] returns the shard assignment for the + [endorser] for the current level. *) + val shards : t -> endorser:Signature.Public_key_hash.t -> int list +end diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index be2aaff2d0e54d871580a9025eac374665fcfdbb..1995ec76a46d191a77326794b74fce438f8bc530 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1719,3 +1719,34 @@ module Sc_rollup = struct end) (Bitset_and_level) end + +module Dal = struct + module Raw_context = + Make_subcontext (Registered) (Raw_context) + (struct + let name = ["dal"] + end) + + module Level_context = + Make_indexed_subcontext + (Make_subcontext (Registered) (Raw_context) + (struct + let name = ["level"] + end)) + (Make_index (Raw_level_repr.Index)) + + (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3113 + + This is only for prototyping. Probably something smarter would be + to index each header directly. *) + module Slot_headers = + Level_context.Make_map + (struct + let name = ["slots"] + end) + (struct + type t = Dal_slot_repr.t list + + let encoding = Data_encoding.(list Dal_slot_repr.encoding) + end) +end diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 667740f8fe60d24841ab31a06375c058c0c69be6..6e834d08137a24cd91f3ee4937a0ae4a18df1636 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -824,3 +824,11 @@ module Sc_rollup : sig and type key = int32 and type value = Raw_level_repr.t * Bitset.t end + +module Dal : sig + module Slot_headers : + Non_iterable_indexed_data_storage + with type t = Raw_context.t + and type key = Raw_level_repr.t + and type value = Dal_slot_repr.slot list +end diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 21b2a26c38b070d0ce7d5f3675e2808926811fb2..6a5e67db9d204c8beeb7c34355a7cb78e1dbc982 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -749,10 +749,10 @@ let bake_n_with_all_balance_updates ?(baking_mode = Application) ?policy | Tx_rollup_remove_commitment_result _ | Tx_rollup_rejection_result _ | Transfer_ticket_result _ | Tx_rollup_dispatch_tickets_result _ - | Sc_rollup_originate_result _ | Sc_rollup_add_messages_result _ - | Sc_rollup_cement_result _ | Sc_rollup_publish_result _ - | Sc_rollup_refute_result _ | Sc_rollup_timeout_result _ - | Sc_rollup_atomic_batch_result _ -> + | Dal_publish_slot_header_result _ | Sc_rollup_originate_result _ + | Sc_rollup_add_messages_result _ | Sc_rollup_cement_result _ + | Sc_rollup_publish_result _ | Sc_rollup_refute_result _ + | Sc_rollup_timeout_result _ | Sc_rollup_atomic_batch_result _ -> balance_updates_rev | Transaction_result (Transaction_to_contract_result {balance_updates; _}) @@ -792,6 +792,7 @@ let bake_n_with_origination_results ?(baking_mode = Application) ?policy n b = | Successful_manager_result (Tx_rollup_rejection_result _) | Successful_manager_result (Tx_rollup_dispatch_tickets_result _) | Successful_manager_result (Transfer_ticket_result _) + | Successful_manager_result (Dal_publish_slot_header_result _) | Successful_manager_result (Sc_rollup_originate_result _) | Successful_manager_result (Sc_rollup_add_messages_result _) | Successful_manager_result (Sc_rollup_cement_result _) diff --git a/tests_python/tests_alpha/test_mockup.py b/tests_python/tests_alpha/test_mockup.py index 246b27c5fdda42e467d0ee928fb7c4956270984b..cde8276531652af30a797c143902de36c359506a 100644 --- a/tests_python/tests_alpha/test_mockup.py +++ b/tests_python/tests_alpha/test_mockup.py @@ -670,6 +670,13 @@ def _test_create_mockup_init_show_roundtrip( "tx_rollup_max_ticket_payload_size": 10_240, "tx_rollup_rejection_max_proof_size": 30_000, "tx_rollup_sunset_level": 3_473_409, + "dal_parametric": { + "feature_enable": True, + "number_of_slots": 64, + "number_of_shards": 1024, + "endorsement_lag": 1, + "availability_threshold": 25, + }, "sc_rollup_enable": False, "sc_rollup_origination_size": 6_314, "sc_rollup_challenge_window_in_blocks": 20_160, diff --git a/tezt/lib_tezos/operation.ml b/tezt/lib_tezos/operation.ml index ec91610bcd61958618adcbb63021f72b3e1ff793..8176c094b5e8c7ba10b747e86940b5f654cbe242 100644 --- a/tezt/lib_tezos/operation.ml +++ b/tezt/lib_tezos/operation.ml @@ -54,6 +54,7 @@ type manager_op_kind = destination : string; entrypoint : string; } + | Dal_publish_slot_header of {level : int; index : int; header : int} (* This is the manager operations' content type *) type manager_operation_content = { @@ -66,6 +67,12 @@ type manager_operation_content = { storage_limit : int; } +type consensus_op_kind = + | Dal_slot_availability of { + endorser : string; (* public_key hash *) + endorsement : bool Array.t; (* Bit vector *) + } + let micheline_to_json convert client = function | `Json json -> return json | `Michelson data -> convert data client @@ -142,11 +149,32 @@ let mk_transfer_ticket ~source ?counter ?(fee = 1_000_000) mk_manager_op ~source ?counter ~fee ~gas_limit ~storage_limit client @@ Transfer_ticket {contents; ty; ticketer; amount; destination; entrypoint} +let mk_publish_slot_header ~source ?counter ?(fee = 1_000_000) + ?(gas_limit = 1_000_000) ?(storage_limit = 0) ~index ~level ~header client = + mk_manager_op ~source ?counter ~fee ~gas_limit ~storage_limit client + @@ Dal_publish_slot_header {index; level; header} + let mk_origination ~source ?counter ?(fee = 1_000_000) ?(gas_limit = 100_000) ?(storage_limit = 10_000) ~code ~init_storage ?(init_balance = 0) client = mk_manager_op ~source ?counter ~fee ~gas_limit ~storage_limit client @@ Origination {code; storage = init_storage; balance = init_balance} +let consensus_op_to_json_string = function + | Dal_slot_availability {endorser; endorsement} -> + let string_of_bool_vector endorsement = + let aux (acc, n) b = + let bit = if b then 1 else 0 in + (acc lor (bit lsl n), n + 1) + in + Array.fold_left aux (0, 0) endorsement |> fst |> string_of_int + in + `O + [ + ("kind", Ezjsonm.string "dal_slot_availability"); + ("endorser", Ezjsonm.string endorser); + ("endorsement", Ezjsonm.string (string_of_bool_vector endorsement)); + ] + (* encodes the given manager operation as a JSON string *) let manager_op_content_to_json_string {op_kind; fee; gas_limit; storage_limit; source; counter} client = @@ -155,7 +183,7 @@ let manager_op_content_to_json_string ?(public_key = `Null) ?(delegate = `Null) ?(balance = `Null) ?(script = `Null) ?(ticket_contents = `Null) ?(ticket_ty = `Null) ?(ticket_ticketer = `Null) ?(ticket_amount = `Null) ?(entrypoint = `Null) - kind = + ?(slot = `Null) kind = let filter = List.filter (fun (_k, v) -> v <> `Null) in return @@ `O @@ -185,6 +213,7 @@ let manager_op_content_to_json_string ("ticket_ticketer", ticket_ticketer); ("ticket_amount", ticket_amount); ("entrypoint", entrypoint); + ("slot", slot); ]) in match op_kind with @@ -222,18 +251,31 @@ let manager_op_content_to_json_string ~ticket_ticketer:(Ezjsonm.string ticketer) ~entrypoint:(Ezjsonm.string entrypoint) "transfer_ticket" + | Dal_publish_slot_header {index; level; header} -> + let index = `Float (float_of_int index) in + let level = `Float (float_of_int level) in + let header = `Float (float_of_int header) in + let slot = `O [("index", index); ("level", level); ("header", header)] in + mk_jsonm ~slot "dal_publish_slot_header" (* construct a JSON operations with contents and branch *) -let manager_op_to_json_string ~branch operations_json = +let op_to_json_string ~branch operations_json = `O [("branch", Ezjsonm.string branch); ("contents", operations_json)] (* Forging, signing and injection operations *) +let forge_manager_batch ~batch client = + Lwt_list.map_p (fun op -> manager_op_content_to_json_string op client) batch + +let forge_consensus_op ~op = consensus_op_to_json_string op + let forge_operation ?protocol ~branch ~batch client = let* json_batch = - Lwt_list.map_p (fun op -> manager_op_content_to_json_string op client) batch + match batch with + | `Manager batch -> forge_manager_batch ~batch client + | `Consensus op -> [forge_consensus_op ~op] |> Lwt.return in - let op_json = manager_op_to_json_string ~branch (`A json_batch) in + let op_json = op_to_json_string ~branch (`A json_batch) in let* hex = match protocol with | None -> RPC.post_forge_operations ~data:op_json client >|= JSON.as_string @@ -321,7 +363,7 @@ let inject_origination ?protocol ?async ?force ?wait_for_injection ?branch ?async ?force ?wait_for_injection - ~batch:[op] + ~batch:(`Manager [op]) ?branch ~signer client @@ -344,7 +386,7 @@ let inject_public_key_revelation ?protocol ?async ?force ?wait_for_injection ?force ?wait_for_injection ?branch - ~batch:[op] + ~batch:(`Manager [op]) ~signer client @@ -367,7 +409,7 @@ let inject_delegation ?protocol ?async ?force ?wait_for_injection ?branch ?force ?wait_for_injection ?branch - ~batch:[op] + ~batch:(`Manager [op]) ~signer client @@ -391,7 +433,7 @@ let inject_transfer ?protocol ?async ?force ?wait_for_injection ?branch ~source ?force ?wait_for_injection ?branch - ~batch:[op] + ~batch:(`Manager [op]) ~signer client @@ -419,7 +461,48 @@ let inject_transfer_ticket ?protocol ?async ?force ?wait_for_injection ?branch ?force ?wait_for_injection ?branch - ~batch:[op] + ~batch:(`Manager [op]) + ~signer + client + +let inject_publish_slot_header ?protocol ?async ?force ?wait_for_injection + ?branch ~source ?(signer = source) ?counter ?fee ?gas_limit ?storage_limit + ~index ~level ~header client = + let* op = + mk_publish_slot_header + ~source + ?counter + ?fee + ?gas_limit + ?storage_limit + ~index + ~level + ~header + client + in + forge_and_inject_operation + ?protocol + ?async + ?force + ?wait_for_injection + ?branch + ~batch:(`Manager [op]) + ~signer + client + +let inject_slot_availability ?protocol ?async ?force ?wait_for_injection ?branch + ~signer ~endorsement client = + let op = + Dal_slot_availability + {endorser = signer.Account.public_key_hash; endorsement} + in + forge_and_inject_operation + ?protocol + ?async + ?force + ?wait_for_injection + ?branch + ~batch:(`Consensus op) ~signer client @@ -445,7 +528,7 @@ let inject_contract_call ?protocol ?async ?force ?wait_for_injection ?branch ?force ?wait_for_injection ?branch - ~batch:[op] + ~batch:(`Manager [op]) ~signer client diff --git a/tezt/lib_tezos/operation.mli b/tezt/lib_tezos/operation.mli index dc87ae86a540573523e470f55a8dfcc1823f731a..6adcdc2b3558e7f63b4e6a6007feecb360f0d100 100644 --- a/tezt/lib_tezos/operation.mli +++ b/tezt/lib_tezos/operation.mli @@ -31,6 +31,12 @@ smart constructors below *) type manager_operation_content +type consensus_op_kind = + | Dal_slot_availability of { + endorser : string; (* public_key hash *) + endorsement : bool Array.t; (* Bit vector *) + } + (** Michelson scripts and data in different representations. Used when originating or calling contracts. @@ -149,6 +155,26 @@ val mk_origination : Client.t -> manager_operation_content Lwt.t +(** [mk_publish_slot_header] allows to construct a manager operation publishing a + slot header. + + - Default [counter] is the successor of the counter of [source]. + - Default [init_balance] is [0] tez. + - Default [fee] is [1_000_000] mutez. + - Default [gas_limit] is [100_000] gas. + - Default [storage_limit] is [10_000]. *) +val mk_publish_slot_header : + source:Account.key -> + ?counter:int -> + ?fee:int -> + ?gas_limit:int -> + ?storage_limit:int -> + index:int -> + level:int -> + header:int -> + Client.t -> + manager_operation_content Lwt.t + (** {2 Helper functions to build manager operations} *) (** Returns the current counter of the given implicit account *) @@ -182,9 +208,11 @@ val sign_manager_op_hex : signer:Account.key -> Hex.t -> Hex.t val forge_operation : ?protocol:Protocol.t -> branch:string -> - batch:manager_operation_content list -> + batch: + [< `Consensus of consensus_op_kind + | `Manager of manager_operation_content list ] -> Client.t -> - Hex.t Lwt.t + [> `Hex of string] Lwt.t (** Inject a forged operation with its signature. @@ -238,7 +266,9 @@ val forge_and_inject_operation : ?async:bool -> ?force:bool -> ?wait_for_injection:Node.t -> - batch:manager_operation_content list -> + batch: + [ `Manager of manager_operation_content list + | `Consensus of consensus_op_kind ] -> signer:Account.key -> Client.t -> [`OpHash of string] Lwt.t @@ -248,7 +278,9 @@ val runnable_forge_and_inject_operation : ?branch:string -> ?async:bool -> ?force:bool -> - batch:manager_operation_content list -> + batch: + [ `Manager of manager_operation_content list + | `Consensus of consensus_op_kind ] -> signer:Account.key -> Client.t -> JSON.t Runnable.process Lwt.t @@ -417,3 +449,32 @@ val inject_transfer_ticket : entrypoint:string -> Client.t -> [`OpHash of string] Lwt.t + +val inject_publish_slot_header : + ?protocol:Protocol.t -> + ?async:bool -> + ?force:bool -> + ?wait_for_injection:Node.t -> + ?branch:string -> + source:Account.key -> + ?signer:Account.key -> + ?counter:int -> + ?fee:int -> + ?gas_limit:int -> + ?storage_limit:int -> + index:int -> + level:int -> + header:int -> + Client.t -> + [`OpHash of string] Lwt.t + +val inject_slot_availability : + ?protocol:Protocol.t -> + ?async:bool -> + ?force:bool -> + ?wait_for_injection:Node.t -> + ?branch:string -> + signer:Account.key -> + endorsement:bool array -> + Client.t -> + [> `OpHash of string] Lwt.t diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml new file mode 100644 index 0000000000000000000000000000000000000000..8e9f157a39cfc2dc048727150227a8f92d301d23 --- /dev/null +++ b/tezt/tests/dal.ml @@ -0,0 +1,105 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(* Testing + ------- + Component: Data-availability layer + Invocation: dune exec tezt/tests/main.exe -- --file dal.ml + Subject: Integration tests related to the data-availability layer +*) + +let test_feature_flag = + (* This test ensures the feature flag works: + + - 1. It checks the feature flag is not enabled by default + + - 2. It checks the new operations added by the feature flag + cannot be propagated by checking their classification in the + mempool. *) + let open Tezt_tezos in + Protocol.register_test ~__FILE__ ~title:"dal feature flag" ~tags:["dal"] + @@ fun protocol -> + let* node, client = Client.init_with_protocol `Client ~protocol () in + let* protocol_parameters = RPC_legacy.get_constants client in + let feature_flag = + JSON.( + protocol_parameters |-> "dal_parametric" |-> "feature_enable" |> as_bool) + in + let number_of_slots = + JSON.( + protocol_parameters |-> "dal_parametric" |-> "number_of_slots" |> as_int) + in + Check.( + (feature_flag = false) + bool + ~error_msg:"Feature flag for the DAL should be disabled") ; + let* (`OpHash oph1) = + Operation.( + forge_and_inject_operation + ~force:true + ~batch: + (`Consensus + (Dal_slot_availability + { + endorser = Constant.bootstrap1.public_key_hash; + endorsement = Array.make number_of_slots false; + })) + ~signer:Constant.bootstrap1 + client) + in + let* slot_header_operation = + Operation.mk_publish_slot_header + ~source:Constant.bootstrap1 + ~index:0 + ~level:1 + ~header:0 + client + in + let* (`OpHash oph2) = + Operation.( + forge_and_inject_operation + ~force:true + ~batch:(`Manager [slot_header_operation]) + ~signer:Constant.bootstrap1 + client) + in + let* mempool = Mempool.get_mempool client in + let expected_mempool = Mempool.{empty with refused = [oph1; oph2]} in + Check.( + (mempool = expected_mempool) + Mempool.classified_typ + ~error_msg:"Expected mempool: %R. Got: %L. (Order does not matter)") ; + let* () = Client.bake_for_and_wait client in + let* block_metadata = RPC.(call node @@ get_block_metadata ()) in + let slot_availability = + JSON.(block_metadata |-> "dal_slot_availability" |> is_null) + in + Check.( + (slot_availability = true) + bool + ~error_msg:"Did not expect to find \"dal_slot_availibility\"") ; + unit + +let register ~protocols = test_feature_flag protocols diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out index eb9b22d5ac0e539c067585e1c87780815d0e9708..c83e3a59b2fce320658ec408003b198cf445796f 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out @@ -1187,6 +1187,30 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_slot_availability", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_slot_availability" + ] + }, + "endorser": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "endorsement": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "endorsement", + "endorser", + "kind" + ], + "additionalProperties": false + }, { "title": "Seed_nonce_revelation", "type": "object", @@ -2980,6 +3004,69 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_publish_slot_header", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_publish_slot_header" + ] + }, + "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" + }, + "slot": { + "type": "object", + "properties": { + "level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "index": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "header": { + "type": "integer", + "minimum": -1073741824, + "maximum": 1073741823 + } + }, + "required": [ + "header", + "index", + "level" + ], + "additionalProperties": false + } + }, + "required": [ + "slot", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, { "title": "Sc_rollup_originate", "type": "object", @@ -4497,6 +4584,47 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "name": "Endorsement" }, + { + "tag": 22, + "fields": [ + { + "name": "Tag", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "endorser", + "layout": { + "name": "public_key_hash", + "kind": "Ref" + }, + "data_kind": { + "size": 21, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "endorsement", + "layout": { + "name": "Z.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + } + ], + "name": "Dal_slot_availability" + }, { "tag": 107, "fields": [ @@ -4683,7 +4811,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "parameters", "layout": { - "name": "X_143", + "name": "X_144", "kind": "Ref" }, "data_kind": { @@ -5348,7 +5476,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "commitment", "layout": { - "name": "X_141", + "name": "X_142", "kind": "Ref" }, "data_kind": { @@ -5711,7 +5839,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "message", "layout": { - "name": "X_14", + "name": "X_15", "kind": "Ref" }, "data_kind": { @@ -5780,7 +5908,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "previous_message_result", "layout": { - "name": "X_15", + "name": "X_16", "kind": "Ref" }, "data_kind": { @@ -5810,7 +5938,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "proof", "layout": { - "name": "X_140", + "name": "X_141", "kind": "Ref" }, "data_kind": { @@ -5966,7 +6094,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "tickets_info", "layout": { "layout": { - "name": "X_10", + "name": "X_11", "kind": "Ref" }, "kind": "Seq" @@ -6207,7 +6335,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "kind", "layout": { - "name": "X_9", + "name": "X_10", "kind": "Ref" }, "data_kind": { @@ -6345,7 +6473,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "message", "layout": { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "Seq" @@ -6549,7 +6677,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "commitment", "layout": { - "name": "X_7", + "name": "X_8", "kind": "Ref" }, "data_kind": { @@ -6663,7 +6791,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "refutation", "layout": { - "name": "X_2", + "name": "X_3", "kind": "Ref" }, "data_kind": { @@ -6764,7 +6892,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "stakers", "layout": { - "name": "X_1", + "name": "X_2", "kind": "Ref" }, "data_kind": { @@ -6931,6 +7059,92 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ], "name": "Sc_rollup_atomic_batch" + }, + { + "tag": 230, + "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" + }, + { + "name": "slot", + "layout": { + "name": "X_1", + "kind": "Ref" + }, + "data_kind": { + "size": 9, + "kind": "Float" + }, + "kind": "named" + } + ], + "name": "Dal_publish_slot_header" } ] } @@ -7483,6 +7697,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": "public_key" @@ -7605,7 +7839,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_143" + "title": "X_144" }, "encoding": { "fields": [ @@ -7948,7 +8182,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_141" + "title": "X_142" }, "encoding": { "fields": [ @@ -7985,7 +8219,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "predecessor", "layout": { - "name": "X_142", + "name": "X_143", "kind": "Ref" }, "data_kind": { @@ -8009,7 +8243,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_142" + "title": "X_143" }, "encoding": { "tag_size": "Uint8", @@ -8079,7 +8313,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_140" + "title": "X_141" }, "encoding": { "tag_size": "Uint8", @@ -8135,7 +8369,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8194,7 +8428,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8253,7 +8487,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8312,7 +8546,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8328,7 +8562,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_139" + "title": "X_140" }, "encoding": { "tag_size": "Uint8", @@ -8364,7 +8598,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8404,7 +8638,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8444,7 +8678,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8484,7 +8718,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8524,7 +8758,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8564,7 +8798,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8604,7 +8838,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8644,7 +8878,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8684,7 +8918,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8724,7 +8958,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8764,7 +8998,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8804,7 +9038,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8844,7 +9078,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8884,7 +9118,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8924,7 +9158,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8964,7 +9198,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -9022,7 +9256,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_21", + "name": "X_22", "kind": "Ref" }, "kind": "Seq", @@ -9057,7 +9291,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_21", + "name": "X_22", "kind": "Ref" }, "kind": "Seq", @@ -9097,7 +9331,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_21", + "name": "X_22", "kind": "Ref" }, "kind": "Seq" @@ -9234,7 +9468,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9283,7 +9517,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9332,7 +9566,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9381,7 +9615,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9407,7 +9641,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_138" + "title": "X_139" }, "encoding": { "fields": [] @@ -9415,7 +9649,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_134" + "title": "X_135" }, "encoding": { "fields": [ @@ -9434,7 +9668,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_126" + "title": "X_127" }, "encoding": { "fields": [ @@ -9463,7 +9697,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_122" + "title": "X_123" }, "encoding": { "tag_size": "Uint8", @@ -9535,7 +9769,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_121" + "title": "X_122" }, "encoding": { "fields": [ @@ -9558,7 +9792,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_16" + "title": "X_17" }, "encoding": { "fields": [ @@ -9570,7 +9804,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_139", + "name": "X_140", "kind": "Ref" }, "kind": "Seq" @@ -9585,13 +9819,13 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_21" + "title": "X_22" }, "encoding": { "fields": [ { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9601,7 +9835,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_122", + "name": "X_123", "kind": "Ref" }, "kind": "anon", @@ -9615,7 +9849,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_15" + "title": "X_16" }, "encoding": { "fields": [ @@ -9646,7 +9880,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_14" + "title": "X_15" }, "encoding": { "tag_size": "Uint8", @@ -9705,7 +9939,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "deposit", "layout": { - "name": "X_12", + "name": "X_13", "kind": "Ref" }, "data_kind": { @@ -9721,7 +9955,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_12" + "title": "X_13" }, "encoding": { "fields": [ @@ -9762,7 +9996,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "amount", "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "data_kind": { @@ -9775,7 +10009,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_13" + "title": "X_14" }, "encoding": { "tag_size": "Uint8", @@ -9904,7 +10138,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_10" + "title": "X_11" }, "encoding": { "fields": [ @@ -9953,7 +10187,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "amount", "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "data_kind": { @@ -9978,7 +10212,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_9" + "title": "X_10" }, "encoding": { "tag_size": "Uint16", @@ -10020,7 +10254,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_8" + "title": "X_9" }, "encoding": { "fields": [ @@ -10043,7 +10277,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_7" + "title": "X_8" }, "encoding": { "fields": [ @@ -10110,7 +10344,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_2" + "title": "X_3" }, "encoding": { "fields": [ @@ -10128,7 +10362,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "step", "layout": { - "name": "X_6", + "name": "X_7", "kind": "Ref" }, "data_kind": { @@ -10141,7 +10375,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_6" + "title": "X_7" }, "encoding": { "tag_size": "Uint8", @@ -10172,7 +10406,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_4", + "name": "X_5", "kind": "Ref" }, "kind": "Seq" @@ -10202,7 +10436,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_3", + "name": "X_4", "kind": "Ref" }, "kind": "anon", @@ -10218,13 +10452,13 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_4" + "title": "X_5" }, "encoding": { "fields": [ { "layout": { - "name": "X_5", + "name": "X_6", "kind": "Ref" }, "kind": "anon", @@ -10247,7 +10481,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_5" + "title": "X_6" }, "encoding": { "tag_size": "Uint8", @@ -10317,7 +10551,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_3" + "title": "X_4" }, "encoding": { "tag_size": "Uint8", @@ -10464,7 +10698,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_1" + "title": "X_2" }, "encoding": { "fields": [ @@ -10492,6 +10726,52 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ] } + }, + { + "description": { + "title": "X_1" + }, + "encoding": { + "fields": [ + { + "name": "level", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "index", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "header", + "layout": { + "min": -1073741824, + "max": 1073741823, + "kind": "RangedInt" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + } + ] + } } ] } @@ -11654,6 +11934,30 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_slot_availability", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_slot_availability" + ] + }, + "endorser": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "endorsement": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "endorsement", + "endorser", + "kind" + ], + "additionalProperties": false + }, { "title": "Seed_nonce_revelation", "type": "object", @@ -13447,6 +13751,69 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_publish_slot_header", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_publish_slot_header" + ] + }, + "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" + }, + "slot": { + "type": "object", + "properties": { + "level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "index": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "header": { + "type": "integer", + "minimum": -1073741824, + "maximum": 1073741823 + } + }, + "required": [ + "header", + "index", + "level" + ], + "additionalProperties": false + } + }, + "required": [ + "slot", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, { "title": "Sc_rollup_originate", "type": "object", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- others.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- others.out index 6ff5687b1695516dd83c0a471705a2aacaa23fea..2a40f893342789a9b8634be3b5594340fb8c8d0e 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- others.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- others.out @@ -40,7 +40,11 @@ "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": false, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- others.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- others.out index 21fb19213d2f5b8dd4a082b1dab57f43b7d2a006..9a20480b7cb9e41a81bb0562223dc81d1317e86c 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- others.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- others.out @@ -40,7 +40,11 @@ "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": false, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out index 555bf116e4c33d9877709368e2db22ad53b7b907..bde688be8883467e2cfd10dc0006c687fdae7eb6 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out @@ -1208,6 +1208,30 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_slot_availability", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_slot_availability" + ] + }, + "endorser": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "endorsement": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "endorsement", + "endorser", + "kind" + ], + "additionalProperties": false + }, { "title": "Seed_nonce_revelation", "type": "object", @@ -3001,6 +3025,69 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_publish_slot_header", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_publish_slot_header" + ] + }, + "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" + }, + "slot": { + "type": "object", + "properties": { + "level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "index": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "header": { + "type": "integer", + "minimum": -1073741824, + "maximum": 1073741823 + } + }, + "required": [ + "header", + "index", + "level" + ], + "additionalProperties": false + } + }, + "required": [ + "slot", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, { "title": "Sc_rollup_originate", "type": "object", @@ -4518,6 +4605,47 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "name": "Endorsement" }, + { + "tag": 22, + "fields": [ + { + "name": "Tag", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "endorser", + "layout": { + "name": "public_key_hash", + "kind": "Ref" + }, + "data_kind": { + "size": 21, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "endorsement", + "layout": { + "name": "Z.t", + "kind": "Ref" + }, + "data_kind": { + "kind": "Dynamic" + }, + "kind": "named" + } + ], + "name": "Dal_slot_availability" + }, { "tag": 107, "fields": [ @@ -4704,7 +4832,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "parameters", "layout": { - "name": "X_143", + "name": "X_144", "kind": "Ref" }, "data_kind": { @@ -5369,7 +5497,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "commitment", "layout": { - "name": "X_141", + "name": "X_142", "kind": "Ref" }, "data_kind": { @@ -5732,7 +5860,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "message", "layout": { - "name": "X_14", + "name": "X_15", "kind": "Ref" }, "data_kind": { @@ -5801,7 +5929,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "previous_message_result", "layout": { - "name": "X_15", + "name": "X_16", "kind": "Ref" }, "data_kind": { @@ -5831,7 +5959,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "proof", "layout": { - "name": "X_140", + "name": "X_141", "kind": "Ref" }, "data_kind": { @@ -5987,7 +6115,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "tickets_info", "layout": { "layout": { - "name": "X_10", + "name": "X_11", "kind": "Ref" }, "kind": "Seq" @@ -6228,7 +6356,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "kind", "layout": { - "name": "X_9", + "name": "X_10", "kind": "Ref" }, "data_kind": { @@ -6366,7 +6494,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' "name": "message", "layout": { "layout": { - "name": "X_8", + "name": "X_9", "kind": "Ref" }, "kind": "Seq" @@ -6570,7 +6698,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "commitment", "layout": { - "name": "X_7", + "name": "X_8", "kind": "Ref" }, "data_kind": { @@ -6684,7 +6812,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "refutation", "layout": { - "name": "X_2", + "name": "X_3", "kind": "Ref" }, "data_kind": { @@ -6785,7 +6913,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "stakers", "layout": { - "name": "X_1", + "name": "X_2", "kind": "Ref" }, "data_kind": { @@ -6952,6 +7080,92 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ], "name": "Sc_rollup_atomic_batch" + }, + { + "tag": 230, + "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" + }, + { + "name": "slot", + "layout": { + "name": "X_1", + "kind": "Ref" + }, + "data_kind": { + "size": 9, + "kind": "Float" + }, + "kind": "named" + } + ], + "name": "Dal_publish_slot_header" } ] } @@ -7504,6 +7718,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": "public_key" @@ -7626,7 +7860,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_143" + "title": "X_144" }, "encoding": { "fields": [ @@ -7969,7 +8203,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_141" + "title": "X_142" }, "encoding": { "fields": [ @@ -8006,7 +8240,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "predecessor", "layout": { - "name": "X_142", + "name": "X_143", "kind": "Ref" }, "data_kind": { @@ -8030,7 +8264,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_142" + "title": "X_143" }, "encoding": { "tag_size": "Uint8", @@ -8100,7 +8334,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_140" + "title": "X_141" }, "encoding": { "tag_size": "Uint8", @@ -8156,7 +8390,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8215,7 +8449,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8274,7 +8508,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8333,7 +8567,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_16", + "name": "X_17", "kind": "Ref" }, "kind": "anon", @@ -8349,7 +8583,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_139" + "title": "X_140" }, "encoding": { "tag_size": "Uint8", @@ -8385,7 +8619,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8425,7 +8659,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8465,7 +8699,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8505,7 +8739,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_138", + "name": "X_139", "kind": "Ref" }, "kind": "anon", @@ -8545,7 +8779,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8585,7 +8819,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8625,7 +8859,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8665,7 +8899,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8705,7 +8939,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8745,7 +8979,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8785,7 +9019,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8825,7 +9059,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_134", + "name": "X_135", "kind": "Ref" }, "kind": "anon", @@ -8865,7 +9099,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8905,7 +9139,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8945,7 +9179,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -8985,7 +9219,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_126", + "name": "X_127", "kind": "Ref" }, "kind": "anon", @@ -9043,7 +9277,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_21", + "name": "X_22", "kind": "Ref" }, "kind": "Seq", @@ -9078,7 +9312,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_21", + "name": "X_22", "kind": "Ref" }, "kind": "Seq", @@ -9118,7 +9352,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_21", + "name": "X_22", "kind": "Ref" }, "kind": "Seq" @@ -9255,7 +9489,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9304,7 +9538,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9353,7 +9587,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9402,7 +9636,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9428,7 +9662,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_138" + "title": "X_139" }, "encoding": { "fields": [] @@ -9436,7 +9670,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_134" + "title": "X_135" }, "encoding": { "fields": [ @@ -9455,7 +9689,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_126" + "title": "X_127" }, "encoding": { "fields": [ @@ -9484,7 +9718,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_122" + "title": "X_123" }, "encoding": { "tag_size": "Uint8", @@ -9556,7 +9790,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_121" + "title": "X_122" }, "encoding": { "fields": [ @@ -9579,7 +9813,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_16" + "title": "X_17" }, "encoding": { "fields": [ @@ -9591,7 +9825,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_139", + "name": "X_140", "kind": "Ref" }, "kind": "Seq" @@ -9606,13 +9840,13 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_21" + "title": "X_22" }, "encoding": { "fields": [ { "layout": { - "name": "X_121", + "name": "X_122", "kind": "Ref" }, "kind": "anon", @@ -9622,7 +9856,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_122", + "name": "X_123", "kind": "Ref" }, "kind": "anon", @@ -9636,7 +9870,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_15" + "title": "X_16" }, "encoding": { "fields": [ @@ -9667,7 +9901,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_14" + "title": "X_15" }, "encoding": { "tag_size": "Uint8", @@ -9726,7 +9960,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "deposit", "layout": { - "name": "X_12", + "name": "X_13", "kind": "Ref" }, "data_kind": { @@ -9742,7 +9976,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_12" + "title": "X_13" }, "encoding": { "fields": [ @@ -9783,7 +10017,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "amount", "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "data_kind": { @@ -9796,7 +10030,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_13" + "title": "X_14" }, "encoding": { "tag_size": "Uint8", @@ -9925,7 +10159,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_10" + "title": "X_11" }, "encoding": { "fields": [ @@ -9974,7 +10208,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "amount", "layout": { - "name": "X_13", + "name": "X_14", "kind": "Ref" }, "data_kind": { @@ -9999,7 +10233,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_9" + "title": "X_10" }, "encoding": { "tag_size": "Uint16", @@ -10041,7 +10275,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_8" + "title": "X_9" }, "encoding": { "fields": [ @@ -10064,7 +10298,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_7" + "title": "X_8" }, "encoding": { "fields": [ @@ -10131,7 +10365,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_2" + "title": "X_3" }, "encoding": { "fields": [ @@ -10149,7 +10383,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "name": "step", "layout": { - "name": "X_6", + "name": "X_7", "kind": "Ref" }, "data_kind": { @@ -10162,7 +10396,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_6" + "title": "X_7" }, "encoding": { "tag_size": "Uint8", @@ -10193,7 +10427,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' { "layout": { "layout": { - "name": "X_4", + "name": "X_5", "kind": "Ref" }, "kind": "Seq" @@ -10223,7 +10457,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "layout": { - "name": "X_3", + "name": "X_4", "kind": "Ref" }, "kind": "anon", @@ -10239,13 +10473,13 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_4" + "title": "X_5" }, "encoding": { "fields": [ { "layout": { - "name": "X_5", + "name": "X_6", "kind": "Ref" }, "kind": "anon", @@ -10268,7 +10502,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_5" + "title": "X_6" }, "encoding": { "tag_size": "Uint8", @@ -10338,7 +10572,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_3" + "title": "X_4" }, "encoding": { "tag_size": "Uint8", @@ -10485,7 +10719,7 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' }, { "description": { - "title": "X_1" + "title": "X_2" }, "encoding": { "fields": [ @@ -10513,6 +10747,52 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' } ] } + }, + { + "description": { + "title": "X_1" + }, + "encoding": { + "fields": [ + { + "name": "level", + "layout": { + "size": "Int32", + "kind": "Int" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "index", + "layout": { + "size": "Uint8", + "kind": "Int" + }, + "data_kind": { + "size": 1, + "kind": "Float" + }, + "kind": "named" + }, + { + "name": "header", + "layout": { + "min": -1073741824, + "max": 1073741823, + "kind": "RangedInt" + }, + "data_kind": { + "size": 4, + "kind": "Float" + }, + "kind": "named" + } + ] + } } ] } @@ -11675,6 +11955,30 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_slot_availability", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_slot_availability" + ] + }, + "endorser": { + "$ref": "#/definitions/Signature.Public_key_hash" + }, + "endorsement": { + "$ref": "#/definitions/bignum" + } + }, + "required": [ + "endorsement", + "endorser", + "kind" + ], + "additionalProperties": false + }, { "title": "Seed_nonce_revelation", "type": "object", @@ -13468,6 +13772,69 @@ curl -s 'http://localhost:[PORT]/describe/chains/main/mempool?recurse=yes' ], "additionalProperties": false }, + { + "title": "Dal_publish_slot_header", + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dal_publish_slot_header" + ] + }, + "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" + }, + "slot": { + "type": "object", + "properties": { + "level": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "index": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "header": { + "type": "integer", + "minimum": -1073741824, + "maximum": 1073741823 + } + }, + "required": [ + "header", + "index", + "level" + ], + "additionalProperties": false + } + }, + "required": [ + "slot", + "storage_limit", + "gas_limit", + "counter", + "fee", + "source", + "kind" + ], + "additionalProperties": false + }, { "title": "Sc_rollup_originate", "type": "object", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- others.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- others.out index 3f950b969cb7853a0054f2648ed83f10fa6bd0e7..f9116a5168d500f1141e98bf5242740461503a6b 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- others.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- others.out @@ -40,7 +40,11 @@ "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": false, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- others.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- others.out index b6e2832eccb11cfa777e7d9c877680572758b3c8..c848a82fc7ff99a78befbf84bbe56e03eb1afc0d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- others.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- others.out @@ -40,7 +40,11 @@ "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": false, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- others.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- others.out index b6e2832eccb11cfa777e7d9c877680572758b3c8..c848a82fc7ff99a78befbf84bbe56e03eb1afc0d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- others.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- others.out @@ -40,7 +40,11 @@ "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": false, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out index 3d04b6d035aacac05974a22248c0d6e878f2bf51..4beddf9946e4ee4488bf00be736760c5fada770d 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out @@ -73,7 +73,11 @@ This sequence of operations was run: "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": true, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out index 876ef15d205dafb6de3cfdedad56290e90f22cd9..56e9bba0a8f7b4d0c8e5bea7ed0c2b7768711f8e 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out @@ -73,7 +73,11 @@ This sequence of operations was run: "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": true, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out index aeb5250796d2cb50e128acf6c08f48e2930c6d0a..133738e60b41d7bc19a76c6b95b7048ead732fac 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out @@ -73,7 +73,11 @@ This sequence of operations was run: "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": true, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out index eec76ca2a25709bdc67554c0f5d6d6511e0a67dc..88d73b7fd01a888f73476c787f2fe87a80dc2a87 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out @@ -73,7 +73,11 @@ This sequence of operations was run: "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": true, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out index afb13b82f5e63e8e2a469adf874fef145e2e27ba..b55c5fc3faad69bc5eb8740a4c99c1e13ae7af31 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out @@ -73,7 +73,11 @@ This sequence of operations was run: "tx_rollup_cost_per_byte_ema_factor": 120, "tx_rollup_max_ticket_payload_size": 2048, "tx_rollup_rejection_max_proof_size": 30000, - "tx_rollup_sunset_level": 3473409, "sc_rollup_enable": true, + "tx_rollup_sunset_level": 3473409, + "dal_parametric": + { "feature_enable": false, "number_of_slots": 256, + "number_of_shards": 2048, "endorsement_lag": 2, + "availability_threshold": 50 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_available_messages": 1000000, diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index 16b77d632e1ea047c700d31950a3c2c5cb7afa63..d3fd21067b0e74478dd439be3a3075e23e7c1795 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -71,6 +71,7 @@ let () = Cache_cache.register [Ithaca; Jakarta; Alpha] ; Baking.register ~protocols:[Ithaca; Jakarta; Alpha] ; Prevalidator.register ~protocols:[Ithaca; Jakarta; Alpha] ; + Dal.register ~protocols:[Alpha] ; Monitor_operations.register ~protocols:[Alpha] ; Stresstest_command.register ~protocols:[Alpha] ; (* Adding a new protocol would require adding samples at ./tezt/tests/encoding_samples directory*) diff --git a/tezt/tests/manager_operations.ml b/tezt/tests/manager_operations.ml index 1cbe90315bdc907eb27a7c6f6c6a582db46a3c84..8e3f35a17f7714711846159c36328385e1fd41cf 100644 --- a/tezt/tests/manager_operations.ml +++ b/tezt/tests/manager_operations.ml @@ -874,7 +874,7 @@ module Deserialisation = struct in Operation.forge_and_inject_operation ?protocol - ~batch:[op] + ~batch:(`Manager [op]) ~signer:source client @@ -1011,7 +1011,7 @@ module Gas_limits = struct @@ fun () -> Operation.forge_and_inject_operation ~protocol - ~batch + ~batch:(`Manager batch) ~signer:Constant.bootstrap2 nodes.main.client in @@ -1036,7 +1036,7 @@ module Gas_limits = struct (* Gas limit per op is too high *) Operation.forge_and_inject_operation ~protocol - ~batch + ~batch:(`Manager batch) ~signer:Constant.bootstrap2 nodes.main.client in @@ -1065,7 +1065,7 @@ module Gas_limits = struct Memchecks.with_refused_checks ~__LOC__ nodes @@ fun () -> Operation.forge_and_inject_operation ~protocol - ~batch + ~batch:(`Manager batch) ~signer:Constant.bootstrap2 nodes.main.client in @@ -1086,7 +1086,10 @@ module Reveal = struct let s2 = {key with Account.public_key = pk2} in let* op1 = Operation.mk_reveal ~source:s1 ~counter:(cpt + 1) ~fee client in let* op2 = Operation.mk_reveal ~source:s2 ~counter:(cpt + 2) ~fee client in - Operation.forge_and_inject_operation ~batch:[op1; op2] ~signer:key client + Operation.forge_and_inject_operation + ~batch:(`Manager [op1; op2]) + ~signer:key + client let simple_reveal_bad_pk = Protocol.register_test @@ -1129,7 +1132,7 @@ module Reveal = struct Memchecks.with_absent_checks ~__LOC__ nodes @@ fun () -> Operation.forge_and_inject_operation ~protocol - ~batch:[op] + ~batch:(`Manager [op]) ~signer:key ~patch_unsigned nodes.main.client @@ -1720,7 +1723,7 @@ module Simple_transfers = struct Memchecks.with_refused_checks ~__LOC__ nodes @@ fun () -> Operation.forge_and_inject_operation ~protocol - ~batch:[op1; op2; op3] + ~batch:(`Manager [op1; op2; op3]) ~signer:Constant.bootstrap2 nodes.main.client in @@ -1761,7 +1764,7 @@ module Simple_transfers = struct Memchecks.with_refused_checks ~__LOC__ nodes @@ fun () -> Operation.forge_and_inject_operation ~protocol - ~batch:[op1; op2; op3] + ~batch:(`Manager [op1; op2; op3]) ~signer:Constant.bootstrap2 nodes.main.client in diff --git a/tezt/tests/prevalidator.ml b/tezt/tests/prevalidator.ml index cccd780e17804551bf2ab7602ec834bb33f571ba..f7aebf716a890130366f1d41f1abf630a02e1226 100644 --- a/tezt/tests/prevalidator.ml +++ b/tezt/tests/prevalidator.ml @@ -863,7 +863,7 @@ module Revamped = struct in let* branch = Operation.get_injection_branch client in let* (`Hex op_str_hex as op_hex) = - Operation.forge_operation ~protocol ~branch ~batch:[op2] client + Operation.forge_operation ~protocol ~branch ~batch:(`Manager [op2]) client in let (`Hex signature) = Operation.sign_manager_op_hex ~signer:Constant.bootstrap2 op_hex @@ -949,7 +949,7 @@ module Revamped = struct Operation.forge_and_inject_operation ~protocol ~force:true - ~batch:[op] + ~batch:(`Manager [op]) ~signer:dest (* signer should be source to be correctly signed *) client in @@ -1954,7 +1954,7 @@ module Revamped = struct let* process = let* runnable = Operation.runnable_forge_and_inject_operation - ~batch:[op] + ~batch:(`Manager [op]) ~signer:Constant.bootstrap1 client in @@ -1985,7 +1985,10 @@ module Revamped = struct client in let* (`Hex raw_unsigned_op as unsigned_op) = - Operation.forge_operation ~branch ~batch:[transfer] client + Operation.forge_operation + ~branch + ~batch:(`Manager [transfer]) + client in let (`Hex signature_op) = Operation.sign_manager_op_hex ~signer:account unsigned_op diff --git a/tezt/tests/replace_by_fees.ml b/tezt/tests/replace_by_fees.ml index 37e66e32f71aa0db2263c722165b28e83238bcfa..5e456dfa807fa13270251f1fec06cf3e5ad37b35 100644 --- a/tezt/tests/replace_by_fees.ml +++ b/tezt/tests/replace_by_fees.ml @@ -211,7 +211,7 @@ let replacement_test_helper ~title ~__LOC__ ~op1 ?(size1 = 1) ~op2 ?(size2 = 1) ~async:true ~force:true ~protocol - ~batch + ~batch:(`Manager batch) ~signer client in @@ -222,7 +222,7 @@ let replacement_test_helper ~title ~__LOC__ ~op1 ?(size1 = 1) ~op2 ?(size2 = 1) ~async:true ~force:true ~protocol - ~batch + ~batch:(`Manager batch) ~signer client in @@ -237,7 +237,7 @@ let replacement_test_helper ~title ~__LOC__ ~op1 ?(size1 = 1) ~op2 ?(size2 = 1) ~async:true ~force:true ~protocol - ~batch + ~batch:(`Manager batch) ~signer client in