diff --git a/src/proto_alpha/bin_sc_rollup_node/commitment.ml b/src/proto_alpha/bin_sc_rollup_node/commitment.ml index df12f12decc6371fad9f84c720c48073a4b62c07..f1fdb67ca2bbfe33c2bb403d6d99a5604fdcca02 100644 --- a/src/proto_alpha/bin_sc_rollup_node/commitment.ml +++ b/src/proto_alpha/bin_sc_rollup_node/commitment.ml @@ -71,13 +71,13 @@ let sc_rollup_commitment_period = (* FIXME: https://gitlab.com/tezos/tezos/-/issues/2977 Use effective on-chain protocol parameter. *) Int32.of_int - Default_parameters.constants_mainnet.sc_rollup_commitment_period_in_blocks + Default_parameters.constants_mainnet.sc_rollup.commitment_period_in_blocks let sc_rollup_challenge_window = (* FIXME: https://gitlab.com/tezos/tezos/-/issues/2977 Use effective on-chain protocol parameter. *) Int32.of_int - Default_parameters.constants_mainnet.sc_rollup_challenge_window_in_blocks + Default_parameters.constants_mainnet.sc_rollup.challenge_window_in_blocks let last_commitment_level (module Last_commitment_level : Mutable_level_store) store = diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 66a3f9ab52810ab92b22e98b35ad10d978bfbc54..28465244ae558f60744902a75309e2998b3eb3f0 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -603,7 +603,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) hard_gas_limit_per_block; hard_storage_limit_per_operation; origination_size; - tx_rollup_origination_size; + tx_rollup = {origination_size = tx_rollup_origination_size; _}; cost_per_byte; _; }; diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 5f44dfe90f2c4b2fddb7a597b2ddc71229078bfa..a258a667bdfbcf8b798e29372e9196843182a58e 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -35,6 +35,37 @@ module Protocol_constants_overrides = struct (** Equivalent of [Constants.parametric] with additionally [chain_id] and [timestamp] but each field is wrapped in an [option]. [Some] is an override, [None] means "Use the default value". *) + type tx_rollup = { + enable : bool option; + origination_size : int option; + hard_size_limit_per_inbox : int option; + hard_size_limit_per_message : int option; + max_withdrawals_per_batch : int option; + commitment_bond : Tez.t option; + finality_period : int option; + max_inboxes_count : int option; + withdraw_period : int option; + max_messages_per_inbox : int option; + max_commitments_count : int option; + cost_per_byte_ema_factor : int option; + max_ticket_payload_size : int option; + rejection_max_proof_size : int option; + sunset_level : int32 option; + } + + type sc_rollup = { + enable : bool option; + origination_size : int option; + challenge_window_in_blocks : int option; + max_available_messages : int option; + stake_amount : Tez.t option; + commitment_period_in_blocks : int option; + commitment_storage_size_in_bytes : int option; + max_lookahead_in_blocks : int32 option; + max_active_outbox_levels : int32 option; + max_outbox_messages_per_level : int option; + } + type t = { preserved_cycles : int option; blocks_per_cycle : int32 option; @@ -71,39 +102,136 @@ module Protocol_constants_overrides = struct cache_script_size : int option; cache_stake_distribution_cycles : int option; cache_sampler_state_cycles : int option; - tx_rollup_enable : bool option; - tx_rollup_origination_size : int option; - tx_rollup_hard_size_limit_per_inbox : int option; - tx_rollup_hard_size_limit_per_message : int option; - tx_rollup_max_withdrawals_per_batch : int option; - tx_rollup_commitment_bond : Tez.t option; - tx_rollup_finality_period : int option; - tx_rollup_max_inboxes_count : int option; - tx_rollup_withdraw_period : int option; - tx_rollup_max_messages_per_inbox : int option; - tx_rollup_max_commitments_count : int option; - tx_rollup_cost_per_byte_ema_factor : int option; - tx_rollup_max_ticket_payload_size : int option; - tx_rollup_rejection_max_proof_size : int option; - tx_rollup_sunset_level : int32 option; + tx_rollup : tx_rollup; dal : Constants.Parametric.dal option; - sc_rollup_enable : bool option; - sc_rollup_origination_size : int option; - sc_rollup_challenge_window_in_blocks : int option; - sc_rollup_max_available_messages : int option; - sc_rollup_stake_amount : Tez.t option; - sc_rollup_commitment_period_in_blocks : int option; - sc_rollup_commitment_storage_size_in_bytes : int option; - sc_rollup_max_lookahead_in_blocks : int32 option; - sc_rollup_max_active_outbox_levels : int32 option; - sc_rollup_max_outbox_messages_per_level : int option; + sc_rollup : sc_rollup; (* Additional, "bastard" parameters (they are not protocol constants but partially treated the same way). *) chain_id : Chain_id.t option; timestamp : Time.Protocol.t option; initial_seed : State_hash.t option option; } - (** Shamefully copied from [Constants_repr.parametric_encoding] and adapted ([opt] instead of [req]). *) + (** Shamefully copied from [Constants_parametric_repr.encoding] and adapted ([opt] instead of [req]). *) + let tx_rollup_encoding = + let open Data_encoding in + conv + (fun (c : tx_rollup) -> + ( ( c.enable, + c.origination_size, + c.hard_size_limit_per_inbox, + c.hard_size_limit_per_message, + c.max_withdrawals_per_batch, + c.commitment_bond, + c.finality_period, + c.withdraw_period, + c.max_inboxes_count, + c.max_messages_per_inbox ), + ( c.max_commitments_count, + c.cost_per_byte_ema_factor, + c.max_ticket_payload_size, + c.rejection_max_proof_size, + c.sunset_level ) )) + (fun ( ( tx_rollup_enable, + tx_rollup_origination_size, + tx_rollup_hard_size_limit_per_inbox, + tx_rollup_hard_size_limit_per_message, + tx_rollup_max_withdrawals_per_batch, + tx_rollup_commitment_bond, + tx_rollup_finality_period, + tx_rollup_withdraw_period, + tx_rollup_max_inboxes_count, + tx_rollup_max_messages_per_inbox ), + ( tx_rollup_max_commitments_count, + tx_rollup_cost_per_byte_ema_factor, + tx_rollup_max_ticket_payload_size, + tx_rollup_rejection_max_proof_size, + tx_rollup_sunset_level ) ) -> + { + enable = tx_rollup_enable; + origination_size = tx_rollup_origination_size; + hard_size_limit_per_inbox = tx_rollup_hard_size_limit_per_inbox; + hard_size_limit_per_message = tx_rollup_hard_size_limit_per_message; + max_withdrawals_per_batch = tx_rollup_max_withdrawals_per_batch; + commitment_bond = tx_rollup_commitment_bond; + finality_period = tx_rollup_finality_period; + withdraw_period = tx_rollup_withdraw_period; + max_inboxes_count = tx_rollup_max_inboxes_count; + max_messages_per_inbox = tx_rollup_max_messages_per_inbox; + max_commitments_count = tx_rollup_max_commitments_count; + cost_per_byte_ema_factor = tx_rollup_cost_per_byte_ema_factor; + max_ticket_payload_size = tx_rollup_max_ticket_payload_size; + rejection_max_proof_size = tx_rollup_rejection_max_proof_size; + sunset_level = tx_rollup_sunset_level; + }) + (merge_objs + (obj10 + (opt "tx_rollup_enable" bool) + (opt "tx_rollup_origination_size" int31) + (opt "tx_rollup_hard_size_limit_per_inbox" int31) + (opt "tx_rollup_hard_size_limit_per_message" int31) + (opt "tx_rollup_max_withdrawals_per_batch" int31) + (opt "tx_rollup_commitment_bond" Tez.encoding) + (opt "tx_rollup_finality_period" int31) + (opt "tx_rollup_withdraw_period" int31) + (opt "tx_rollup_max_inboxes_count" int31) + (opt "tx_rollup_max_messages_per_inbox" int31)) + (obj5 + (opt "tx_rollup_max_commitments_count" int31) + (opt "tx_rollup_cost_per_byte_ema_factor" int31) + (opt "tx_rollup_max_ticket_payload_size" int31) + (opt "tx_rollup_rejection_max_proof_size" int31) + (opt "tx_rollup_sunset_level" int32))) + + let sc_rollup_encoding = + let open Data_encoding in + conv + (fun (c : sc_rollup) -> + ( c.enable, + c.origination_size, + c.challenge_window_in_blocks, + c.max_available_messages, + c.stake_amount, + c.commitment_period_in_blocks, + c.commitment_storage_size_in_bytes, + c.max_lookahead_in_blocks, + c.max_active_outbox_levels, + c.max_outbox_messages_per_level )) + (fun ( sc_rollup_enable, + sc_rollup_origination_size, + sc_rollup_challenge_window_in_blocks, + sc_rollup_max_available_messages, + sc_rollup_stake_amount, + 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 ) -> + { + enable = sc_rollup_enable; + origination_size = sc_rollup_origination_size; + challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; + max_available_messages = sc_rollup_max_available_messages; + stake_amount = sc_rollup_stake_amount; + commitment_period_in_blocks = sc_rollup_commitment_period_in_blocks; + commitment_storage_size_in_bytes = + sc_rollup_commitment_storage_size_in_bytes; + max_lookahead_in_blocks = sc_rollup_max_lookahead_in_blocks; + max_active_outbox_levels = sc_rollup_max_active_outbox_levels; + max_outbox_messages_per_level = + sc_rollup_max_outbox_messages_per_level; + }) + (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" Tez.encoding) + (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 encoding = let open Data_encoding in conv @@ -146,33 +274,7 @@ module Protocol_constants_overrides = struct ( ( c.cache_script_size, c.cache_stake_distribution_cycles, c.cache_sampler_state_cycles ), - ( ( ( c.tx_rollup_enable, - c.tx_rollup_origination_size, - c.tx_rollup_hard_size_limit_per_inbox, - c.tx_rollup_hard_size_limit_per_message, - c.tx_rollup_max_withdrawals_per_batch, - c.tx_rollup_commitment_bond, - c.tx_rollup_finality_period, - c.tx_rollup_max_inboxes_count, - c.tx_rollup_withdraw_period, - c.tx_rollup_max_messages_per_inbox ), - ( c.tx_rollup_max_commitments_count, - c.tx_rollup_cost_per_byte_ema_factor, - c.tx_rollup_max_ticket_payload_size, - c.tx_rollup_rejection_max_proof_size, - c.tx_rollup_sunset_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, - 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.tx_rollup, (c.dal, c.sc_rollup)) ) ) ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -211,33 +313,7 @@ module Protocol_constants_overrides = struct ( ( cache_script_size, cache_stake_distribution_cycles, cache_sampler_state_cycles ), - ( ( ( tx_rollup_enable, - tx_rollup_origination_size, - tx_rollup_hard_size_limit_per_inbox, - tx_rollup_hard_size_limit_per_message, - tx_rollup_max_withdrawals_per_batch, - tx_rollup_commitment_bond, - tx_rollup_finality_period, - tx_rollup_max_inboxes_count, - tx_rollup_withdraw_period, - tx_rollup_max_messages_per_inbox ), - ( tx_rollup_max_commitments_count, - tx_rollup_cost_per_byte_ema_factor, - 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, - sc_rollup_max_available_messages, - sc_rollup_stake_amount, - 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 ) ) ) ) ) ) - ) ) -> + (tx_rollup, (dal, sc_rollup)) ) ) ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -266,40 +342,17 @@ module Protocol_constants_overrides = struct delay_increment_per_round; minimal_participation_ratio; max_slashing_period; - frozen_deposits_percentage; consensus_committee_size; consensus_threshold; + frozen_deposits_percentage; double_baking_punishment; ratio_of_frozen_deposits_slashed_per_double_endorsement; cache_script_size; cache_stake_distribution_cycles; cache_sampler_state_cycles; - tx_rollup_enable; - tx_rollup_origination_size; - tx_rollup_hard_size_limit_per_inbox; - tx_rollup_hard_size_limit_per_message; - tx_rollup_max_withdrawals_per_batch; - tx_rollup_commitment_bond; - tx_rollup_finality_period; - tx_rollup_max_inboxes_count; - tx_rollup_withdraw_period; - tx_rollup_max_messages_per_inbox; - tx_rollup_max_commitments_count; - tx_rollup_cost_per_byte_ema_factor; - tx_rollup_max_ticket_payload_size; - tx_rollup_rejection_max_proof_size; - tx_rollup_sunset_level; + tx_rollup; dal; - sc_rollup_enable; - sc_rollup_origination_size; - sc_rollup_challenge_window_in_blocks; - sc_rollup_max_available_messages; - sc_rollup_stake_amount; - 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; + sc_rollup; chain_id; timestamp; initial_seed; @@ -355,48 +408,13 @@ module Protocol_constants_overrides = struct (opt "cache_stake_distribution_cycles" int8) (opt "cache_sampler_state_cycles" int8)) (merge_objs - (merge_objs - (obj10 - (opt "tx_rollup_enable" Data_encoding.bool) - (opt "tx_rollup_origination_size" int31) - (opt "tx_rollup_hard_size_limit_per_inbox" int31) - (opt - "tx_rollup_hard_size_limit_per_message" - int31) - (opt "tx_rollup_max_withdrawals_per_batch" int31) - (opt "tx_rollup_commitment_bond" Tez.encoding) - (opt "tx_rollup_finality_period" int31) - (opt "tx_rollup_max_inboxes_count" int31) - (opt "tx_rollup_withdraw_period" int31) - (opt "tx_rollup_max_messages_per_inbox" int31)) - (obj5 - (opt "tx_rollup_max_commitments_count" int31) - (opt "tx_rollup_cost_per_byte_ema_factor" int31) - (opt "tx_rollup_max_ticket_payload_size" int31) - (opt "tx_rollup_rejection_max_proof_size" int31) - (opt "tx_rollup_sunset_level" int32))) + tx_rollup_encoding (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" Tez.encoding) - (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))))))))) + sc_rollup_encoding))))))) let default_value (cctxt : Tezos_client_base.Client_context.full) : t tzresult Lwt.t = @@ -459,48 +477,53 @@ module Protocol_constants_overrides = struct cache_stake_distribution_cycles = Some parametric.cache_stake_distribution_cycles; cache_sampler_state_cycles = Some parametric.cache_sampler_state_cycles; - tx_rollup_enable = Some parametric.tx_rollup_enable; - tx_rollup_origination_size = Some parametric.tx_rollup_origination_size; - tx_rollup_hard_size_limit_per_inbox = - Some parametric.tx_rollup_hard_size_limit_per_inbox; - tx_rollup_hard_size_limit_per_message = - Some parametric.tx_rollup_hard_size_limit_per_message; - tx_rollup_max_withdrawals_per_batch = - Some parametric.tx_rollup_max_withdrawals_per_batch; - tx_rollup_commitment_bond = Some parametric.tx_rollup_commitment_bond; - tx_rollup_finality_period = Some parametric.tx_rollup_finality_period; - tx_rollup_max_inboxes_count = - Some parametric.tx_rollup_max_inboxes_count; - tx_rollup_withdraw_period = Some parametric.tx_rollup_withdraw_period; - tx_rollup_max_messages_per_inbox = - Some parametric.tx_rollup_max_messages_per_inbox; - tx_rollup_max_commitments_count = - Some parametric.tx_rollup_max_commitments_count; - tx_rollup_cost_per_byte_ema_factor = - Some parametric.tx_rollup_cost_per_byte_ema_factor; - tx_rollup_max_ticket_payload_size = - Some parametric.tx_rollup_max_ticket_payload_size; - tx_rollup_rejection_max_proof_size = - Some parametric.tx_rollup_rejection_max_proof_size; - tx_rollup_sunset_level = Some parametric.tx_rollup_sunset_level; + sc_rollup = + { + enable = Some parametric.sc_rollup.enable; + origination_size = Some parametric.sc_rollup.origination_size; + challenge_window_in_blocks = + Some parametric.sc_rollup.challenge_window_in_blocks; + max_available_messages = + Some parametric.sc_rollup.max_available_messages; + stake_amount = Some parametric.sc_rollup.stake_amount; + commitment_period_in_blocks = + Some parametric.sc_rollup.commitment_period_in_blocks; + commitment_storage_size_in_bytes = + Some parametric.sc_rollup.commitment_storage_size_in_bytes; + max_lookahead_in_blocks = + Some parametric.sc_rollup.max_lookahead_in_blocks; + max_active_outbox_levels = + Some parametric.sc_rollup.max_active_outbox_levels; + max_outbox_messages_per_level = + Some parametric.sc_rollup.max_outbox_messages_per_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 = - Some parametric.sc_rollup_challenge_window_in_blocks; - sc_rollup_max_available_messages = - Some parametric.sc_rollup_max_available_messages; - sc_rollup_stake_amount = Some parametric.sc_rollup_stake_amount; - sc_rollup_commitment_period_in_blocks = - Some parametric.sc_rollup_commitment_period_in_blocks; - sc_rollup_commitment_storage_size_in_bytes = - Some parametric.sc_rollup_commitment_storage_size_in_bytes; - sc_rollup_max_lookahead_in_blocks = - Some parametric.sc_rollup_max_lookahead_in_blocks; - sc_rollup_max_active_outbox_levels = - Some parametric.sc_rollup_max_active_outbox_levels; - sc_rollup_max_outbox_messages_per_level = - Some parametric.sc_rollup_max_outbox_messages_per_level; + tx_rollup = + { + enable = Some parametric.tx_rollup.enable; + origination_size = Some parametric.tx_rollup.origination_size; + hard_size_limit_per_inbox = + Some parametric.tx_rollup.hard_size_limit_per_inbox; + hard_size_limit_per_message = + Some parametric.tx_rollup.hard_size_limit_per_message; + max_withdrawals_per_batch = + Some parametric.tx_rollup.max_withdrawals_per_batch; + commitment_bond = Some parametric.tx_rollup.commitment_bond; + finality_period = Some parametric.tx_rollup.finality_period; + max_inboxes_count = Some parametric.tx_rollup.max_inboxes_count; + withdraw_period = Some parametric.tx_rollup.withdraw_period; + max_messages_per_inbox = + Some parametric.tx_rollup.max_messages_per_inbox; + max_commitments_count = + Some parametric.tx_rollup.max_commitments_count; + cost_per_byte_ema_factor = + Some parametric.tx_rollup.cost_per_byte_ema_factor; + max_ticket_payload_size = + Some parametric.tx_rollup.max_ticket_payload_size; + rejection_max_proof_size = + Some parametric.tx_rollup.rejection_max_proof_size; + sunset_level = Some parametric.tx_rollup.sunset_level; + }; (* Bastard additional parameters. *) chain_id = to_chain_id_opt cpctxt#chain; timestamp = Some header.timestamp; @@ -546,32 +569,38 @@ module Protocol_constants_overrides = struct cache_script_size = None; cache_stake_distribution_cycles = None; cache_sampler_state_cycles = None; - tx_rollup_enable = None; - tx_rollup_origination_size = None; - tx_rollup_hard_size_limit_per_inbox = None; - tx_rollup_hard_size_limit_per_message = None; - tx_rollup_max_withdrawals_per_batch = None; - tx_rollup_commitment_bond = None; - tx_rollup_finality_period = None; - tx_rollup_max_inboxes_count = None; - tx_rollup_withdraw_period = None; - tx_rollup_max_messages_per_inbox = None; - tx_rollup_max_commitments_count = None; - tx_rollup_cost_per_byte_ema_factor = None; - tx_rollup_max_ticket_payload_size = None; - tx_rollup_rejection_max_proof_size = None; - tx_rollup_sunset_level = None; + sc_rollup = + { + enable = None; + origination_size = None; + challenge_window_in_blocks = None; + max_available_messages = None; + stake_amount = None; + commitment_period_in_blocks = None; + commitment_storage_size_in_bytes = None; + max_lookahead_in_blocks = None; + max_active_outbox_levels = None; + max_outbox_messages_per_level = None; + }; dal = None; - sc_rollup_enable = None; - sc_rollup_origination_size = None; - sc_rollup_challenge_window_in_blocks = None; - sc_rollup_max_available_messages = None; - sc_rollup_stake_amount = None; - sc_rollup_commitment_period_in_blocks = None; - sc_rollup_commitment_storage_size_in_bytes = None; - sc_rollup_max_lookahead_in_blocks = None; - sc_rollup_max_active_outbox_levels = None; - sc_rollup_max_outbox_messages_per_level = None; + tx_rollup = + { + enable = None; + origination_size = None; + hard_size_limit_per_inbox = None; + hard_size_limit_per_message = None; + max_withdrawals_per_batch = None; + commitment_bond = None; + finality_period = None; + max_inboxes_count = None; + withdraw_period = None; + max_messages_per_inbox = None; + max_commitments_count = None; + cost_per_byte_ema_factor = None; + max_ticket_payload_size = None; + rejection_max_proof_size = None; + sunset_level = None; + }; chain_id = None; timestamp = None; initial_seed = None; @@ -788,19 +817,19 @@ module Protocol_constants_overrides = struct O { name = "sc_rollup_enable"; - override_value = o.sc_rollup_enable; + override_value = o.sc_rollup.enable; pp = pp_print_bool; }; O { name = "sc_rollup_origination_size"; - override_value = o.sc_rollup_origination_size; + override_value = o.sc_rollup.origination_size; pp = pp_print_int; }; O { name = "sc_rollup_challenge_window_in_blocks"; - override_value = o.sc_rollup_challenge_window_in_blocks; + override_value = o.sc_rollup.challenge_window_in_blocks; pp = pp_print_int; }; O {name = "chain_id"; override_value = o.chain_id; pp = Chain_id.pp}; @@ -813,49 +842,49 @@ module Protocol_constants_overrides = struct O { name = "tx_rollup_enable"; - override_value = o.tx_rollup_enable; + override_value = o.tx_rollup.enable; pp = pp_print_bool; }; O { name = "tx_rollup_origination_size"; - override_value = o.tx_rollup_origination_size; + override_value = o.tx_rollup.origination_size; pp = pp_print_int; }; O { name = "tx_rollup_hard_size_limit_per_inbox"; - override_value = o.tx_rollup_hard_size_limit_per_inbox; + override_value = o.tx_rollup.hard_size_limit_per_inbox; pp = pp_print_int; }; O { name = "tx_rollup_hard_size_limit_per_message"; - override_value = o.tx_rollup_hard_size_limit_per_message; + override_value = o.tx_rollup.hard_size_limit_per_message; pp = pp_print_int; }; O { name = "tx_rollup_commitment_bond"; - override_value = o.tx_rollup_commitment_bond; + override_value = o.tx_rollup.commitment_bond; pp = Tez.pp; }; O { name = "tx_rollup_cost_per_byte_ema_factor"; - override_value = o.tx_rollup_cost_per_byte_ema_factor; + override_value = o.tx_rollup.cost_per_byte_ema_factor; pp = pp_print_int; }; O { name = "tx_rollup_rejection_max_proof_size"; - override_value = o.tx_rollup_rejection_max_proof_size; + override_value = o.tx_rollup.rejection_max_proof_size; pp = pp_print_int; }; O { name = "tx_rollup_sunset_level"; - override_value = o.tx_rollup_sunset_level; + override_value = o.tx_rollup.sunset_level; pp = pp_print_int32; }; ] @@ -988,103 +1017,107 @@ module Protocol_constants_overrides = struct Option.value ~default:c.cache_sampler_state_cycles o.cache_sampler_state_cycles; - tx_rollup_enable = - Option.value ~default:c.tx_rollup_enable o.tx_rollup_enable; - tx_rollup_origination_size = - Option.value - ~default:c.tx_rollup_origination_size - o.tx_rollup_origination_size; - tx_rollup_hard_size_limit_per_inbox = - Option.value - ~default:c.tx_rollup_hard_size_limit_per_inbox - o.tx_rollup_hard_size_limit_per_inbox; - tx_rollup_hard_size_limit_per_message = - Option.value - ~default:c.tx_rollup_hard_size_limit_per_message - o.tx_rollup_hard_size_limit_per_message; - tx_rollup_max_withdrawals_per_batch = - Option.value - ~default:c.tx_rollup_max_withdrawals_per_batch - o.tx_rollup_max_withdrawals_per_batch; - tx_rollup_commitment_bond = - Option.value - ~default:c.tx_rollup_commitment_bond - o.tx_rollup_commitment_bond; - tx_rollup_finality_period = - Option.value - ~default:c.tx_rollup_finality_period - o.tx_rollup_finality_period; - tx_rollup_max_inboxes_count = - Option.value - ~default:c.tx_rollup_max_inboxes_count - o.tx_rollup_max_inboxes_count; - tx_rollup_withdraw_period = - Option.value - ~default:c.tx_rollup_withdraw_period - o.tx_rollup_withdraw_period; - tx_rollup_max_messages_per_inbox = - Option.value - ~default:c.tx_rollup_max_messages_per_inbox - o.tx_rollup_max_messages_per_inbox; - tx_rollup_max_commitments_count = - Option.value - ~default:c.tx_rollup_max_commitments_count - o.tx_rollup_max_commitments_count; - tx_rollup_cost_per_byte_ema_factor = - Option.value - ~default:c.tx_rollup_cost_per_byte_ema_factor - o.tx_rollup_cost_per_byte_ema_factor; - tx_rollup_max_ticket_payload_size = - Option.value - ~default:c.tx_rollup_max_ticket_payload_size - o.tx_rollup_max_ticket_payload_size; - tx_rollup_rejection_max_proof_size = - Option.value - ~default:c.tx_rollup_rejection_max_proof_size - o.tx_rollup_rejection_max_proof_size; - tx_rollup_sunset_level = - Option.value - ~default:c.tx_rollup_sunset_level - o.tx_rollup_sunset_level; + sc_rollup = + { + enable = Option.value ~default:c.sc_rollup.enable o.sc_rollup.enable; + origination_size = + Option.value + ~default:c.sc_rollup.origination_size + o.sc_rollup.origination_size; + challenge_window_in_blocks = + Option.value + ~default:c.sc_rollup.challenge_window_in_blocks + o.sc_rollup.challenge_window_in_blocks; + max_available_messages = + Option.value + ~default:c.sc_rollup.max_available_messages + o.sc_rollup.max_available_messages; + stake_amount = + Option.value + ~default:c.sc_rollup.stake_amount + o.sc_rollup.stake_amount; + commitment_period_in_blocks = + Option.value + ~default:c.sc_rollup.commitment_period_in_blocks + o.sc_rollup.commitment_period_in_blocks; + commitment_storage_size_in_bytes = + Option.value + ~default:c.sc_rollup.commitment_storage_size_in_bytes + o.sc_rollup.commitment_storage_size_in_bytes; + max_lookahead_in_blocks = + Option.value + ~default:c.sc_rollup.max_lookahead_in_blocks + o.sc_rollup.max_lookahead_in_blocks; + max_active_outbox_levels = + Option.value + ~default:c.sc_rollup.max_active_outbox_levels + o.sc_rollup.max_active_outbox_levels; + max_outbox_messages_per_level = + Option.value + ~default:c.sc_rollup.max_outbox_messages_per_level + o.sc_rollup.max_outbox_messages_per_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 = - Option.value - ~default:c.sc_rollup_origination_size - o.sc_rollup_origination_size; - sc_rollup_challenge_window_in_blocks = - Option.value - ~default:c.sc_rollup_challenge_window_in_blocks - o.sc_rollup_challenge_window_in_blocks; - sc_rollup_max_available_messages = - Option.value - ~default:c.sc_rollup_max_available_messages - o.sc_rollup_max_available_messages; - sc_rollup_stake_amount = - Option.value - ~default:c.sc_rollup_stake_amount - o.sc_rollup_stake_amount; - sc_rollup_commitment_period_in_blocks = - Option.value - ~default:c.sc_rollup_commitment_period_in_blocks - o.sc_rollup_commitment_period_in_blocks; - sc_rollup_commitment_storage_size_in_bytes = - Option.value - ~default:c.sc_rollup_commitment_storage_size_in_bytes - o.sc_rollup_commitment_storage_size_in_bytes; - sc_rollup_max_lookahead_in_blocks = - Option.value - ~default:c.sc_rollup_max_lookahead_in_blocks - o.sc_rollup_max_lookahead_in_blocks; - sc_rollup_max_active_outbox_levels = - Option.value - ~default:c.sc_rollup_max_active_outbox_levels - o.sc_rollup_max_active_outbox_levels; - sc_rollup_max_outbox_messages_per_level = - Option.value - ~default:c.sc_rollup_max_outbox_messages_per_level - o.sc_rollup_max_outbox_messages_per_level; + tx_rollup = + { + enable = Option.value ~default:c.tx_rollup.enable o.tx_rollup.enable; + origination_size = + Option.value + ~default:c.tx_rollup.origination_size + o.tx_rollup.origination_size; + hard_size_limit_per_inbox = + Option.value + ~default:c.tx_rollup.hard_size_limit_per_inbox + o.tx_rollup.hard_size_limit_per_inbox; + hard_size_limit_per_message = + Option.value + ~default:c.tx_rollup.hard_size_limit_per_message + o.tx_rollup.hard_size_limit_per_message; + max_withdrawals_per_batch = + Option.value + ~default:c.tx_rollup.max_withdrawals_per_batch + o.tx_rollup.max_withdrawals_per_batch; + commitment_bond = + Option.value + ~default:c.tx_rollup.commitment_bond + o.tx_rollup.commitment_bond; + finality_period = + Option.value + ~default:c.tx_rollup.finality_period + o.tx_rollup.finality_period; + max_inboxes_count = + Option.value + ~default:c.tx_rollup.max_inboxes_count + o.tx_rollup.max_inboxes_count; + withdraw_period = + Option.value + ~default:c.tx_rollup.withdraw_period + o.tx_rollup.withdraw_period; + max_messages_per_inbox = + Option.value + ~default:c.tx_rollup.max_messages_per_inbox + o.tx_rollup.max_messages_per_inbox; + max_commitments_count = + Option.value + ~default:c.tx_rollup.max_commitments_count + o.tx_rollup.max_commitments_count; + cost_per_byte_ema_factor = + Option.value + ~default:c.tx_rollup.cost_per_byte_ema_factor + o.tx_rollup.cost_per_byte_ema_factor; + max_ticket_payload_size = + Option.value + ~default:c.tx_rollup.max_ticket_payload_size + o.tx_rollup.max_ticket_payload_size; + rejection_max_proof_size = + Option.value + ~default:c.tx_rollup.rejection_max_proof_size + o.tx_rollup.rejection_max_proof_size; + sunset_level = + Option.value + ~default:c.tx_rollup.sunset_level + o.tx_rollup.sunset_level; + }; } : Constants.Parametric.t) end diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 44531626217d1ff9de388fd6b74859b15ca73c88..ddbce004124b08b950eeee3ea0de28acf9afa811 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -130,70 +130,76 @@ let constants_mainnet = cache_stake_distribution_cycles = 8; (* One for the sampler state for all cycles stored at any moment (as above). *) cache_sampler_state_cycles = 8; - tx_rollup_enable = true; - (* Based on how storage burn is implemented for - transaction rollups, this means that a rollup operator - can create 100 inboxes (40 bytes per inboxes) before - having to pay storage burn. *) - tx_rollup_origination_size = 4_000; - (* Considering an average size of layer-2 operations of - 20, this gives a TPS per rollup higher than 400, and - the capability to have two rollups at full speed on - mainnet (as long as they do not reach scalability - issues related to proof size). *) - tx_rollup_hard_size_limit_per_inbox = 500_000; - tx_rollup_hard_size_limit_per_message = 5_000; - tx_rollup_commitment_bond = Tez.of_mutez_exn 10_000_000_000L; - tx_rollup_finality_period; - tx_rollup_max_inboxes_count = tx_rollup_finality_period + 100; - (* [60_000] blocks is about two weeks. *) - tx_rollup_withdraw_period = tx_rollup_finality_period; - tx_rollup_max_messages_per_inbox = 1_010; - (* Must be greater than the withdraw period. *) - tx_rollup_max_commitments_count = (2 * tx_rollup_finality_period) + 100; - tx_rollup_cost_per_byte_ema_factor = 120; - (* Tickets are transmitted in batches in the - [Tx_rollup_dispatch_tickets] operation. + tx_rollup = + { + enable = true; + (* Based on how storage burn is implemented for + transaction rollups, this means that a rollup operator + can create 100 inboxes (40 bytes per inbox) before + having to pay storage burn. *) + origination_size = 4_000; + (* Considering an average size of layer-2 operations of + 20, this gives a TPS per rollup higher than 400, and + the capability to have two rollups at full speed on + mainnet (as long as they do not reach scalability + issues related to proof size). *) + hard_size_limit_per_inbox = 500_000; + hard_size_limit_per_message = 5_000; + commitment_bond = Tez.of_mutez_exn 10_000_000_000L; + finality_period = tx_rollup_finality_period; + max_inboxes_count = tx_rollup_finality_period + 100; + (* [60_000] blocks is about two weeks. *) + withdraw_period = tx_rollup_finality_period; + max_messages_per_inbox = 1_010; + (* Must be greater than the withdraw period. *) + max_commitments_count = (2 * tx_rollup_finality_period) + 100; + cost_per_byte_ema_factor = 120; + (* Tickets are transmitted in batches in the + [Tx_rollup_dispatch_tickets] operation. - The semantics is that this operation is used to - concretize the withdraw orders emitted by the layer-2, - one layer-1 operation per messages of an - inbox. Therefore, it is of significant importance that - a valid batch does not produce a list of withdraw - orders which could not fit in a layer-1 operation. + The semantics is that this operation is used to + concretize the withdraw orders emitted by the layer-2, + one layer-1 operation per messages of an + inbox. Therefore, it is of significant importance that + a valid batch does not produce a list of withdraw + orders which could not fit in a layer-1 operation. - With these values, at least 2048 bytes remain available - to store the rest of the operands of - [Tx_rollup_dispatch_tickets] (in practice, even more, - because we overapproximate the size of tickets). So we - are safe. *) - tx_rollup_max_withdrawals_per_batch = 15; - tx_rollup_max_ticket_payload_size = 2_048; - (* Must be smaller than maximum limit of a manager operation - (minus overhead), since we need to limit our proofs to those - that can fit in an operation. *) - tx_rollup_rejection_max_proof_size = 30000; - (* This is the first block of cycle 618, which is expected to be - about one year after the activation of protocol J. - See https://tzstats.com/cycle/618 *) - tx_rollup_sunset_level = 3_473_409l; + With these values, at least 2048 bytes remain available + to store the rest of the operands of + [Tx_rollup_dispatch_tickets] (in practice, even more, + because we overapproximate the size of tickets). So we + are safe. *) + max_withdrawals_per_batch = 15; + max_ticket_payload_size = 2_048; + (* Must be smaller than maximum limit of a manager operation + (minus overhead), since we need to limit our proofs to those + that can fit in an operation. *) + rejection_max_proof_size = 30000; + (* This is the first block of cycle 618, which is expected to be + about one year after the activation of protocol J. + See https://tzstats.com/cycle/618 *) + 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; - sc_rollup_challenge_window_in_blocks; - (* The following value is chosen to limit the length of inbox refutation proofs. *) - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2556 - The follow constants need to be refined. *) - sc_rollup_max_available_messages = 1_000_000; - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 - The following constants need to be refined. *) - sc_rollup_stake_amount = Tez.of_mutez_exn 32_000_000L; - sc_rollup_commitment_period_in_blocks = 30; - sc_rollup_commitment_storage_size_in_bytes = 84; - sc_rollup_max_lookahead_in_blocks = 30_000l; - sc_rollup_max_active_outbox_levels; - sc_rollup_max_outbox_messages_per_level; + sc_rollup = + { + enable = false; + (* The following value is chosen to prevent spam. *) + origination_size = 6_314; + challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; + (* The following value is chosen to limit the length of inbox refutation proofs. *) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2556 + The follow constants need to be refined. *) + max_available_messages = 1_000_000; + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 + The following constants need to be refined. *) + stake_amount = Tez.of_mutez_exn 32_000_000L; + commitment_period_in_blocks = 30; + commitment_storage_size_in_bytes = 84; + max_lookahead_in_blocks = 30_000l; + max_active_outbox_levels = sc_rollup_max_active_outbox_levels; + max_outbox_messages_per_level = sc_rollup_max_outbox_messages_per_level; + }; } let constants_sandbox = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index a63f10edef248a0cc84566f65007352057a8e2bb..f5f9cade4a78862add4719e9c1315800d03531d3 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -731,6 +731,37 @@ module Constants : sig val dal_encoding : dal Data_encoding.t + type tx_rollup = { + enable : bool; + origination_size : int; + hard_size_limit_per_inbox : int; + hard_size_limit_per_message : int; + commitment_bond : Tez.t; + finality_period : int; + withdraw_period : int; + max_inboxes_count : int; + max_messages_per_inbox : int; + max_commitments_count : int; + cost_per_byte_ema_factor : int; + max_ticket_payload_size : int; + max_withdrawals_per_batch : int; + rejection_max_proof_size : int; + sunset_level : int32; + } + + type sc_rollup = { + enable : bool; + origination_size : int; + challenge_window_in_blocks : int; + max_available_messages : int; + stake_amount : Tez.t; + commitment_period_in_blocks : int; + commitment_storage_size_in_bytes : int; + max_lookahead_in_blocks : int32; + max_active_outbox_levels : int32; + max_outbox_messages_per_level : int; + } + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -768,32 +799,9 @@ module Constants : sig cache_script_size : int; cache_stake_distribution_cycles : int; cache_sampler_state_cycles : int; - tx_rollup_enable : bool; - tx_rollup_origination_size : int; - tx_rollup_hard_size_limit_per_inbox : int; - tx_rollup_hard_size_limit_per_message : int; - tx_rollup_commitment_bond : Tez.t; - tx_rollup_finality_period : int; - tx_rollup_withdraw_period : int; - tx_rollup_max_inboxes_count : int; - tx_rollup_max_messages_per_inbox : int; - tx_rollup_max_commitments_count : int; - tx_rollup_cost_per_byte_ema_factor : int; - tx_rollup_max_ticket_payload_size : int; - tx_rollup_max_withdrawals_per_batch : int; - tx_rollup_rejection_max_proof_size : int; - tx_rollup_sunset_level : int32; + tx_rollup : tx_rollup; dal : dal; - sc_rollup_enable : bool; - sc_rollup_origination_size : int; - sc_rollup_challenge_window_in_blocks : int; - sc_rollup_max_available_messages : int; - sc_rollup_stake_amount : Tez.t; - sc_rollup_commitment_period_in_blocks : int; - sc_rollup_commitment_storage_size_in_bytes : int; - sc_rollup_max_lookahead_in_blocks : int32; - sc_rollup_max_active_outbox_levels : int32; - sc_rollup_max_outbox_messages_per_level : int; + sc_rollup : sc_rollup; } val encoding : t Data_encoding.t @@ -813,6 +821,10 @@ module Constants : sig val parametric : context -> Parametric.t + val tx_rollup : context -> Parametric.tx_rollup + + val sc_rollup : context -> Parametric.sc_rollup + val preserved_cycles : context -> int val blocks_per_cycle : context -> int32 diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 19c506c4856dbc554e505f7eb60c91fcc8a4a28e..8eb7143843861a81cc01cf23fbad13a49c54fa0f 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1964,25 +1964,20 @@ let precheck_manager_contents (type kind) ctxt (op : kind Kind.manager contents) | Tx_rollup_dispatch_tickets {tickets_info; message_result_path; _} -> assert_tx_rollup_feature_enabled ctxt >>=? fun () -> let Constants.Parametric. - { - tx_rollup_max_messages_per_inbox; - tx_rollup_max_withdrawals_per_batch; - _; - } = - Constants.parametric ctxt + {max_messages_per_inbox; max_withdrawals_per_batch; _} = + Constants.tx_rollup ctxt in Tx_rollup_errors.check_path_depth `Commitment (Tx_rollup_commitment.Merkle.path_depth message_result_path) - ~count_limit:tx_rollup_max_messages_per_inbox + ~count_limit:max_messages_per_inbox >>?= fun () -> error_when Compare.List_length_with.(tickets_info = 0) Tx_rollup_errors.No_withdrawals_to_dispatch >>?= fun () -> error_when - Compare.List_length_with.( - tickets_info > tx_rollup_max_withdrawals_per_batch) + Compare.List_length_with.(tickets_info > max_withdrawals_per_batch) Tx_rollup_errors.Too_many_withdrawals >>?= fun () -> record_trace Gas_quota_exceeded_init_deserialize @@ -2002,23 +1997,23 @@ let precheck_manager_contents (type kind) ctxt (op : kind Kind.manager contents) | Tx_rollup_rejection {message_path; message_result_path; previous_message_result_path; _} -> assert_tx_rollup_feature_enabled ctxt >>=? fun () -> - let Constants.Parametric.{tx_rollup_max_messages_per_inbox; _} = - Constants.parametric ctxt + let Constants.Parametric.{max_messages_per_inbox; _} = + Constants.tx_rollup ctxt in Tx_rollup_errors.check_path_depth `Inbox (Tx_rollup_inbox.Merkle.path_depth message_path) - ~count_limit:tx_rollup_max_messages_per_inbox + ~count_limit:max_messages_per_inbox >>?= fun () -> Tx_rollup_errors.check_path_depth `Commitment (Tx_rollup_commitment.Merkle.path_depth message_result_path) - ~count_limit:tx_rollup_max_messages_per_inbox + ~count_limit:max_messages_per_inbox >>?= fun () -> Tx_rollup_errors.check_path_depth `Commitment (Tx_rollup_commitment.Merkle.path_depth previous_message_result_path) - ~count_limit:tx_rollup_max_messages_per_inbox + ~count_limit:max_messages_per_inbox >>?= fun () -> return ctxt | Sc_rollup_originate _ | Sc_rollup_add_messages _ | Sc_rollup_cement _ | Sc_rollup_publish _ | Sc_rollup_refute _ | Sc_rollup_timeout _ diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index 96086463d219aebc53b166bd82bc925066249efb..2d8d2770ebdde5de961fb97f9312f9cb2c8c3d94 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -75,6 +75,38 @@ let dal_encoding = If you change this encoding compared to `Constants_parametric_previous_repr.t`, you should ensure that there is a proper migration of the constants during context migration. See: `Raw_context.prepare_first_block` *) + +type tx_rollup = { + enable : bool; + origination_size : int; + hard_size_limit_per_inbox : int; + hard_size_limit_per_message : int; + commitment_bond : Tez_repr.t; + finality_period : int; + withdraw_period : int; + max_inboxes_count : int; + max_messages_per_inbox : int; + max_commitments_count : int; + cost_per_byte_ema_factor : int; + max_ticket_payload_size : int; + max_withdrawals_per_batch : int; + rejection_max_proof_size : int; + sunset_level : int32; +} + +type sc_rollup = { + enable : bool; + origination_size : int; + challenge_window_in_blocks : int; + max_available_messages : int; + stake_amount : Tez_repr.t; + commitment_period_in_blocks : int; + commitment_storage_size_in_bytes : int; + max_lookahead_in_blocks : int32; + max_active_outbox_levels : int32; + max_outbox_messages_per_level : int; +} + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -114,34 +146,130 @@ type t = { cache_script_size : int; cache_stake_distribution_cycles : int; cache_sampler_state_cycles : int; - tx_rollup_enable : bool; - tx_rollup_origination_size : int; - tx_rollup_hard_size_limit_per_inbox : int; - tx_rollup_hard_size_limit_per_message : int; - tx_rollup_commitment_bond : Tez_repr.t; - tx_rollup_finality_period : int; - tx_rollup_withdraw_period : int; - tx_rollup_max_inboxes_count : int; - tx_rollup_max_messages_per_inbox : int; - tx_rollup_max_commitments_count : int; - tx_rollup_cost_per_byte_ema_factor : int; - tx_rollup_max_ticket_payload_size : int; - tx_rollup_max_withdrawals_per_batch : int; - tx_rollup_rejection_max_proof_size : int; - tx_rollup_sunset_level : int32; + tx_rollup : tx_rollup; dal : dal; - sc_rollup_enable : bool; - sc_rollup_origination_size : int; - sc_rollup_challenge_window_in_blocks : int; - sc_rollup_max_available_messages : int; - sc_rollup_stake_amount : Tez_repr.t; - sc_rollup_commitment_period_in_blocks : int; - sc_rollup_commitment_storage_size_in_bytes : int; - sc_rollup_max_lookahead_in_blocks : int32; - sc_rollup_max_active_outbox_levels : int32; - sc_rollup_max_outbox_messages_per_level : int; + sc_rollup : sc_rollup; } +let tx_rollup_encoding = + let open Data_encoding in + conv + (fun (c : tx_rollup) -> + ( ( c.enable, + c.origination_size, + c.hard_size_limit_per_inbox, + c.hard_size_limit_per_message, + c.max_withdrawals_per_batch, + c.commitment_bond, + c.finality_period, + c.withdraw_period, + c.max_inboxes_count, + c.max_messages_per_inbox ), + ( c.max_commitments_count, + c.cost_per_byte_ema_factor, + c.max_ticket_payload_size, + c.rejection_max_proof_size, + c.sunset_level ) )) + (fun ( ( tx_rollup_enable, + tx_rollup_origination_size, + tx_rollup_hard_size_limit_per_inbox, + tx_rollup_hard_size_limit_per_message, + tx_rollup_max_withdrawals_per_batch, + tx_rollup_commitment_bond, + tx_rollup_finality_period, + tx_rollup_withdraw_period, + tx_rollup_max_inboxes_count, + tx_rollup_max_messages_per_inbox ), + ( tx_rollup_max_commitments_count, + tx_rollup_cost_per_byte_ema_factor, + tx_rollup_max_ticket_payload_size, + tx_rollup_rejection_max_proof_size, + tx_rollup_sunset_level ) ) -> + { + enable = tx_rollup_enable; + origination_size = tx_rollup_origination_size; + hard_size_limit_per_inbox = tx_rollup_hard_size_limit_per_inbox; + hard_size_limit_per_message = tx_rollup_hard_size_limit_per_message; + max_withdrawals_per_batch = tx_rollup_max_withdrawals_per_batch; + commitment_bond = tx_rollup_commitment_bond; + finality_period = tx_rollup_finality_period; + withdraw_period = tx_rollup_withdraw_period; + max_inboxes_count = tx_rollup_max_inboxes_count; + max_messages_per_inbox = tx_rollup_max_messages_per_inbox; + max_commitments_count = tx_rollup_max_commitments_count; + cost_per_byte_ema_factor = tx_rollup_cost_per_byte_ema_factor; + max_ticket_payload_size = tx_rollup_max_ticket_payload_size; + rejection_max_proof_size = tx_rollup_rejection_max_proof_size; + sunset_level = tx_rollup_sunset_level; + }) + (merge_objs + (obj10 + (req "tx_rollup_enable" bool) + (req "tx_rollup_origination_size" int31) + (req "tx_rollup_hard_size_limit_per_inbox" int31) + (req "tx_rollup_hard_size_limit_per_message" int31) + (req "tx_rollup_max_withdrawals_per_batch" int31) + (req "tx_rollup_commitment_bond" Tez_repr.encoding) + (req "tx_rollup_finality_period" int31) + (req "tx_rollup_withdraw_period" int31) + (req "tx_rollup_max_inboxes_count" int31) + (req "tx_rollup_max_messages_per_inbox" int31)) + (obj5 + (req "tx_rollup_max_commitments_count" int31) + (req "tx_rollup_cost_per_byte_ema_factor" int31) + (req "tx_rollup_max_ticket_payload_size" int31) + (req "tx_rollup_rejection_max_proof_size" int31) + (req "tx_rollup_sunset_level" int32))) + +let sc_rollup_encoding = + let open Data_encoding in + conv + (fun (c : sc_rollup) -> + ( c.enable, + c.origination_size, + c.challenge_window_in_blocks, + c.max_available_messages, + c.stake_amount, + c.commitment_period_in_blocks, + c.commitment_storage_size_in_bytes, + c.max_lookahead_in_blocks, + c.max_active_outbox_levels, + c.max_outbox_messages_per_level )) + (fun ( sc_rollup_enable, + sc_rollup_origination_size, + sc_rollup_challenge_window_in_blocks, + sc_rollup_max_available_messages, + sc_rollup_stake_amount, + 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 ) -> + { + enable = sc_rollup_enable; + origination_size = sc_rollup_origination_size; + challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; + max_available_messages = sc_rollup_max_available_messages; + stake_amount = sc_rollup_stake_amount; + commitment_period_in_blocks = sc_rollup_commitment_period_in_blocks; + commitment_storage_size_in_bytes = + sc_rollup_commitment_storage_size_in_bytes; + max_lookahead_in_blocks = sc_rollup_max_lookahead_in_blocks; + max_active_outbox_levels = sc_rollup_max_active_outbox_levels; + max_outbox_messages_per_level = sc_rollup_max_outbox_messages_per_level; + }) + (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" Tez_repr.encoding) + (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)) + let encoding = let open Data_encoding in conv @@ -182,32 +310,7 @@ let encoding = ( ( c.cache_script_size, c.cache_stake_distribution_cycles, c.cache_sampler_state_cycles ), - ( ( ( c.tx_rollup_enable, - c.tx_rollup_origination_size, - c.tx_rollup_hard_size_limit_per_inbox, - c.tx_rollup_hard_size_limit_per_message, - c.tx_rollup_max_withdrawals_per_batch, - c.tx_rollup_commitment_bond, - c.tx_rollup_finality_period, - c.tx_rollup_withdraw_period, - c.tx_rollup_max_inboxes_count, - c.tx_rollup_max_messages_per_inbox ), - ( c.tx_rollup_max_commitments_count, - c.tx_rollup_cost_per_byte_ema_factor, - c.tx_rollup_max_ticket_payload_size, - c.tx_rollup_rejection_max_proof_size, - c.tx_rollup_sunset_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, - 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.tx_rollup, (c.dal, c.sc_rollup)) ) ) ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -244,33 +347,7 @@ let encoding = ( ( cache_script_size, cache_stake_distribution_cycles, cache_sampler_state_cycles ), - ( ( ( tx_rollup_enable, - tx_rollup_origination_size, - tx_rollup_hard_size_limit_per_inbox, - tx_rollup_hard_size_limit_per_message, - tx_rollup_max_withdrawals_per_batch, - tx_rollup_commitment_bond, - tx_rollup_finality_period, - tx_rollup_withdraw_period, - tx_rollup_max_inboxes_count, - tx_rollup_max_messages_per_inbox ), - ( tx_rollup_max_commitments_count, - tx_rollup_cost_per_byte_ema_factor, - 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, - sc_rollup_max_available_messages, - sc_rollup_stake_amount, - 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 ) ) ) ) ) ) ) - ) -> + (tx_rollup, (dal, sc_rollup)) ) ) ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -308,32 +385,9 @@ let encoding = cache_script_size; cache_stake_distribution_cycles; cache_sampler_state_cycles; - tx_rollup_enable; - tx_rollup_origination_size; - tx_rollup_hard_size_limit_per_inbox; - tx_rollup_hard_size_limit_per_message; - tx_rollup_max_withdrawals_per_batch; - tx_rollup_commitment_bond; - tx_rollup_finality_period; - tx_rollup_withdraw_period; - tx_rollup_max_inboxes_count; - tx_rollup_max_messages_per_inbox; - tx_rollup_max_commitments_count; - tx_rollup_cost_per_byte_ema_factor; - tx_rollup_max_ticket_payload_size; - tx_rollup_rejection_max_proof_size; - tx_rollup_sunset_level; + tx_rollup; dal; - sc_rollup_enable; - sc_rollup_origination_size; - sc_rollup_challenge_window_in_blocks; - sc_rollup_max_available_messages; - sc_rollup_stake_amount; - 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; + sc_rollup; }) (merge_objs (obj9 @@ -388,38 +442,7 @@ let encoding = (req "cache_stake_distribution_cycles" int8) (req "cache_sampler_state_cycles" int8)) (merge_objs - (merge_objs - (obj10 - (req "tx_rollup_enable" bool) - (req "tx_rollup_origination_size" int31) - (req "tx_rollup_hard_size_limit_per_inbox" int31) - (req "tx_rollup_hard_size_limit_per_message" int31) - (req "tx_rollup_max_withdrawals_per_batch" int31) - (req "tx_rollup_commitment_bond" Tez_repr.encoding) - (req "tx_rollup_finality_period" int31) - (req "tx_rollup_withdraw_period" int31) - (req "tx_rollup_max_inboxes_count" int31) - (req "tx_rollup_max_messages_per_inbox" int31)) - (obj5 - (req "tx_rollup_max_commitments_count" int31) - (req "tx_rollup_cost_per_byte_ema_factor" int31) - (req "tx_rollup_max_ticket_payload_size" int31) - (req "tx_rollup_rejection_max_proof_size" int31) - (req "tx_rollup_sunset_level" int32))) + tx_rollup_encoding (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" Tez_repr.encoding) - (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))))))))) + sc_rollup_encoding))))))) diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index 2af7fc0673ce7beb274f93894192c96b69ebc13c..79ae0c2deb433371ae043ac46f588e7a9477426d 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -35,6 +35,75 @@ type dal = { val dal_encoding : dal Data_encoding.t +type tx_rollup = { + enable : bool; + origination_size : int; + (* the maximum amount of bytes messages can allocate in an inbox *) + hard_size_limit_per_inbox : int; + (* the maximum amount of bytes one batch can allocate in an inbox *) + hard_size_limit_per_message : int; + (* the amount of tez to bond a tx rollup commitment *) + commitment_bond : Tez_repr.t; + (* the number of blocks before a tx rollup block is final *) + finality_period : int; + (* the maximum number of levels that can be left unfinalized + before we stop accepting new inboxes for a tx rollup *) + (* the minimum number of blocks to wait before removing a finalised + commitment from the context. *) + withdraw_period : int; + max_inboxes_count : int; + (* the maximum number of messages in an inbox. This bounds the + size of a commitment. *) + max_messages_per_inbox : int; + (* the maximum number of finalized commitments, to ensure that + remove_commitment is ever called *) + max_commitments_count : int; + (* The number of blocks used to compute the ema factor determining + the cost per byte for new messages in the inbox. *) + cost_per_byte_ema_factor : int; + (* Tickets are transmitted in batches in the + [Tx_rollup_dispatch_tickets] operation. + + The semantics is that this operation is used to + concretize the withdraw orders emitted by the layer-2, + one layer-1 operation per messages of an + inbox. Therefore, it is of significant importance that + a valid batch does not produce a list of withdraw + orders which could not fit in a layer-1 operation. + + With these values, at least 2048 bytes remain available + to store the rest of the operands of + [Tx_rollup_dispatch_tickets] (in practice, even more, + because we overapproximate the size of tickets). So we + are safe. *) + max_ticket_payload_size : int; + max_withdrawals_per_batch : int; + (* The maximum size, in bytes, of a Merkle proof. Operations which would + require proofs larger than this should be no-ops. *) + rejection_max_proof_size : int; + sunset_level : int32; +} + +type sc_rollup = { + enable : bool; + origination_size : int; + challenge_window_in_blocks : int; + max_available_messages : int; + stake_amount : Tez_repr.t; + (* The period with which commitments are made. *) + commitment_period_in_blocks : int; + (* The storage size requirement (in bytes) of a commitment *) + commitment_storage_size_in_bytes : int; + (* The maximum depth of a staker's position - chosen alongside + [commitment_period_in_blocks] to prevent the cost + of a staker's commitments' storage being greater than their deposit. *) + max_lookahead_in_blocks : int32; + (* Maximum number of active outbox levels allowed. An outbox level is active + if it has an associated record of applied messages. *) + max_active_outbox_levels : int32; + max_outbox_messages_per_level : int; +} + type t = { preserved_cycles : int; blocks_per_cycle : int32; @@ -80,70 +149,9 @@ type t = { (* in cycles *) cache_sampler_state_cycles : int; (* in cycles *) - tx_rollup_enable : bool; - tx_rollup_origination_size : int; - (* the maximum amount of bytes messages can allocate in an inbox *) - tx_rollup_hard_size_limit_per_inbox : int; - (* the maximum amount of bytes one batch can allocate in an inbox *) - tx_rollup_hard_size_limit_per_message : int; - (* the amount of tez to bond a tx rollup commitment *) - tx_rollup_commitment_bond : Tez_repr.t; - (* the number of blocks before a tx rollup block is final *) - tx_rollup_finality_period : int; - (* the maximum number of levels that can be left unfinalized - before we stop accepting new inboxes for a tx rollup *) - (* the minimum number of blocks to wait before removing a finalised - commitment from the context. *) - tx_rollup_withdraw_period : int; - tx_rollup_max_inboxes_count : int; - (* the maximum number of messages in an inbox. This bounds the - size of a commitment. *) - tx_rollup_max_messages_per_inbox : int; - (* the maximum number of finalized commitments, to ensure that - remove_commitment is ever called *) - tx_rollup_max_commitments_count : int; - (* The number of blocks used to compute the ema factor determining - the cost per byte for new messages in the inbox. *) - tx_rollup_cost_per_byte_ema_factor : int; - (* Tickets are transmitted in batches in the - [Tx_rollup_dispatch_tickets] operation. - - The semantics is that this operation is used to - concretize the withdraw orders emitted by the layer-2, - one layer-1 operation per messages of an - inbox. Therefore, it is of significant importance that - a valid batch does not produce a list of withdraw - orders which could not fit in a layer-1 operation. - - With these values, at least 2048 bytes remain available - to store the rest of the operands of - [Tx_rollup_dispatch_tickets] (in practice, even more, - because we overapproximate the size of tickets). So we - are safe. *) - tx_rollup_max_ticket_payload_size : int; - tx_rollup_max_withdrawals_per_batch : int; - (* The maximum size, in bytes, of a Merkle proof. Operations which would - require proofs larger than this should be no-ops. *) - tx_rollup_rejection_max_proof_size : int; - tx_rollup_sunset_level : int32; + tx_rollup : tx_rollup; dal : dal; - sc_rollup_enable : bool; - sc_rollup_origination_size : int; - sc_rollup_challenge_window_in_blocks : int; - sc_rollup_max_available_messages : int; - sc_rollup_stake_amount : Tez_repr.t; - (* The period with which commitments are made. *) - sc_rollup_commitment_period_in_blocks : int; - (* The storage size requirement (in bytes) of a commitment *) - sc_rollup_commitment_storage_size_in_bytes : int; - (* The maximum depth of a staker's position - chosen alongside - [sc_rollup_commitment_period_in_blocks] to prevent the cost - of a staker's commitments' storage being greater than their deposit. *) - sc_rollup_max_lookahead_in_blocks : int32; - (* Maximum number of active outbox levels allowed. An outbox level is active - if it has an associated record of applied messages. *) - sc_rollup_max_active_outbox_levels : int32; - sc_rollup_max_outbox_messages_per_level : int; + sc_rollup : sc_rollup; } val encoding : t Data_encoding.encoding diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index 753ac3c3479d58960a9253bed5ba42faf00294e5..96f2802654dae37d492501eaad0026fbcc8bc356 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -114,6 +114,10 @@ let liquidity_baking_toggle_ema_threshold c = let parametric c = Raw_context.constants c +let tx_rollup c = (Raw_context.constants c).tx_rollup + +let sc_rollup c = (Raw_context.constants c).sc_rollup + let minimal_block_delay c = let constants = Raw_context.constants c in constants.minimal_block_delay @@ -147,105 +151,105 @@ let double_baking_punishment c = constants.double_baking_punishment let tx_rollup_enable c = - let constants = Raw_context.constants c in - constants.tx_rollup_enable + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.enable let tx_rollup_sunset_level c = - let constants = Raw_context.constants c in - constants.tx_rollup_sunset_level + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.sunset_level let tx_rollup_origination_size c = - let constants = Raw_context.constants c in - constants.tx_rollup_origination_size + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.origination_size let tx_rollup_hard_size_limit_per_inbox c = - let constants = Raw_context.constants c in - constants.tx_rollup_hard_size_limit_per_inbox + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.hard_size_limit_per_inbox let tx_rollup_hard_size_limit_per_message c = - let constants = Raw_context.constants c in - constants.tx_rollup_hard_size_limit_per_message + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.hard_size_limit_per_message let tx_rollup_max_withdrawals_per_batch c = - let constants = Raw_context.constants c in - constants.tx_rollup_max_withdrawals_per_batch + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.max_withdrawals_per_batch let tx_rollup_commitment_bond c = - let constants = Raw_context.constants c in - constants.tx_rollup_commitment_bond + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.commitment_bond let tx_rollup_finality_period c = - let constants = Raw_context.constants c in - constants.tx_rollup_finality_period + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.finality_period let tx_rollup_withdraw_period c = - let constants = Raw_context.constants c in - constants.tx_rollup_withdraw_period + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.withdraw_period let tx_rollup_max_inboxes_count c = - let constants = Raw_context.constants c in - constants.tx_rollup_max_inboxes_count + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.max_inboxes_count let tx_rollup_max_messages_per_inbox c = - let constants = Raw_context.constants c in - constants.tx_rollup_max_messages_per_inbox + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.max_messages_per_inbox let tx_rollup_max_commitments_count c = - let constants = Raw_context.constants c in - constants.tx_rollup_max_commitments_count + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.max_commitments_count let tx_rollup_cost_per_byte_ema_factor c = - let constants = Raw_context.constants c in - constants.tx_rollup_cost_per_byte_ema_factor + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.cost_per_byte_ema_factor let tx_rollup_max_ticket_payload_size c = - let constants = Raw_context.constants c in - constants.tx_rollup_max_ticket_payload_size + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.max_ticket_payload_size let tx_rollup_rejection_max_proof_size c = - let constants = Raw_context.constants c in - constants.tx_rollup_rejection_max_proof_size + let tx_rollup = Raw_context.tx_rollup c in + tx_rollup.rejection_max_proof_size let ratio_of_frozen_deposits_slashed_per_double_endorsement c = let constants = Raw_context.constants c in constants.ratio_of_frozen_deposits_slashed_per_double_endorsement let sc_rollup_enable c = - let constants = Raw_context.constants c in - constants.sc_rollup_enable + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.enable let sc_rollup_origination_size c = - let constants = Raw_context.constants c in - constants.sc_rollup_origination_size + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.origination_size let sc_rollup_challenge_window_in_blocks c = - let constants = Raw_context.constants c in - constants.sc_rollup_challenge_window_in_blocks + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.challenge_window_in_blocks let sc_rollup_max_available_messages c = - let constants = Raw_context.constants c in - constants.sc_rollup_max_available_messages + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.max_available_messages let sc_rollup_stake_amount c = - let constants = Raw_context.constants c in - constants.sc_rollup_stake_amount + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.stake_amount let sc_rollup_commitment_period_in_blocks c = - let constants = Raw_context.constants c in - constants.sc_rollup_commitment_period_in_blocks + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.commitment_period_in_blocks let sc_rollup_commitment_storage_size_in_bytes c = - let constants = Raw_context.constants c in - constants.sc_rollup_commitment_storage_size_in_bytes + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.commitment_storage_size_in_bytes let sc_rollup_max_lookahead_in_blocks c = - let constants = Raw_context.constants c in - constants.sc_rollup_max_lookahead_in_blocks + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.max_lookahead_in_blocks let sc_rollup_max_active_outbox_levels c = - let constants = Raw_context.constants c in - constants.sc_rollup_max_active_outbox_levels + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.max_active_outbox_levels let sc_rollup_max_outbox_messages_per_level c = - let constants = Raw_context.constants c in - constants.sc_rollup_max_outbox_messages_per_level + let sc_rollup = Raw_context.sc_rollup c in + sc_rollup.max_outbox_messages_per_level diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 9f0a9c5a8ebce0b4f95c1b874aa7c91d539e1f18..9d5371cee5361e99d0f979e8605d513b13362f4a 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -76,6 +76,10 @@ val liquidity_baking_toggle_ema_threshold : Raw_context.t -> int32 val parametric : Raw_context.t -> Constants_parametric_repr.t +val tx_rollup : Raw_context.t -> Constants_parametric_repr.tx_rollup + +val sc_rollup : Raw_context.t -> Constants_parametric_repr.sc_rollup + val consensus_committee_size : Raw_context.t -> int val consensus_threshold : Raw_context.t -> int diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index af2b11748ce8bf36a933384bf56acc0dad520ff6..2454cf0a3a15aec55bdb9e2cf36e5ef0a6d790a1 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -298,6 +298,10 @@ let[@inline] cycle_eras ctxt = ctxt.back.cycle_eras let[@inline] constants ctxt = ctxt.back.constants +let[@inline] tx_rollup ctxt = ctxt.back.constants.tx_rollup + +let[@inline] sc_rollup ctxt = ctxt.back.constants.sc_rollup + let[@inline] recover ctxt = ctxt.back.context let[@inline] fees ctxt = ctxt.back.fees @@ -958,55 +962,57 @@ let prepare_first_block ~level ~timestamp ctxt = cache_script_size = c.cache_script_size; cache_stake_distribution_cycles = c.cache_stake_distribution_cycles; cache_sampler_state_cycles = c.cache_sampler_state_cycles; - tx_rollup_enable = c.tx_rollup_enable; - tx_rollup_origination_size = c.tx_rollup_origination_size; - tx_rollup_hard_size_limit_per_inbox = - c.tx_rollup_hard_size_limit_per_inbox; - tx_rollup_hard_size_limit_per_message = - c.tx_rollup_hard_size_limit_per_message; - tx_rollup_max_withdrawals_per_batch = - c.tx_rollup_max_withdrawals_per_batch; - tx_rollup_max_ticket_payload_size = - c.tx_rollup_max_ticket_payload_size; - tx_rollup_commitment_bond = c.tx_rollup_commitment_bond; - tx_rollup_finality_period = c.tx_rollup_finality_period; - tx_rollup_withdraw_period = c.tx_rollup_withdraw_period; - tx_rollup_max_inboxes_count = c.tx_rollup_max_inboxes_count; - tx_rollup_max_messages_per_inbox = - c.tx_rollup_max_messages_per_inbox; - tx_rollup_max_commitments_count = c.tx_rollup_max_commitments_count; - tx_rollup_cost_per_byte_ema_factor = - c.tx_rollup_cost_per_byte_ema_factor; - tx_rollup_rejection_max_proof_size = - c.tx_rollup_rejection_max_proof_size; - tx_rollup_sunset_level = c.tx_rollup_sunset_level; + tx_rollup = + { + enable = c.tx_rollup_enable; + origination_size = c.tx_rollup_origination_size; + hard_size_limit_per_inbox = + c.tx_rollup_hard_size_limit_per_inbox; + hard_size_limit_per_message = + c.tx_rollup_hard_size_limit_per_message; + max_withdrawals_per_batch = + c.tx_rollup_max_withdrawals_per_batch; + max_ticket_payload_size = c.tx_rollup_max_ticket_payload_size; + commitment_bond = c.tx_rollup_commitment_bond; + finality_period = c.tx_rollup_finality_period; + withdraw_period = c.tx_rollup_withdraw_period; + max_inboxes_count = c.tx_rollup_max_inboxes_count; + max_messages_per_inbox = c.tx_rollup_max_messages_per_inbox; + max_commitments_count = c.tx_rollup_max_commitments_count; + cost_per_byte_ema_factor = c.tx_rollup_cost_per_byte_ema_factor; + rejection_max_proof_size = c.tx_rollup_rejection_max_proof_size; + 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; - (* The following value is chosen to limit the maximal - length of an inbox refutation proof. *) - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2556 - The follow constants need to be refined. *) - sc_rollup_max_available_messages = 1_000_000; - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 - The following constants need to be refined. *) - sc_rollup_stake_amount = Tez_repr.of_mutez_exn 32_000_000L; - sc_rollup_commitment_period_in_blocks = 30; - (* 76 for Commitments entry + 4 for Commitment_stake_count entry - + 4 for Commitment_added entry - + 0 for Staker_count_update entry *) - sc_rollup_commitment_storage_size_in_bytes = 84; - sc_rollup_max_lookahead_in_blocks = 30_000l; - (* Number of active levels kept for executing outbox messages. - WARNING: Changing this value impacts the storage charge for - applying messages from the outbox. It also requires migration for - remapping existing active outbox levels to new indices. *) - sc_rollup_max_active_outbox_levels = 20_160l; - (* Maximum number of outbox messages per level. - WARNING: changing this value impacts the storage cost charged - for applying messages from the outbox. *) - sc_rollup_max_outbox_messages_per_level = 100; + sc_rollup = + { + enable = false; + origination_size = c.sc_rollup_origination_size; + challenge_window_in_blocks = 20_160; + (* The following value is chosen to limit the maximal + length of an inbox refutation proof. *) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2556 + The follow constants need to be refined. *) + max_available_messages = 1_000_000; + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 + The following constants need to be refined. *) + stake_amount = Tez_repr.of_mutez_exn 32_000_000L; + commitment_period_in_blocks = 30; + (* 76 for Commitments entry + 4 for Commitment_stake_count entry + + 4 for Commitment_added entry + + 0 for Staker_count_update entry *) + commitment_storage_size_in_bytes = 84; + max_lookahead_in_blocks = 30_000l; + (* Number of active levels kept for executing outbox messages. + WARNING: Changing this value impacts the storage charge for + applying messages from the outbox. It also requires migration for + remapping existing active outbox levels to new indices. *) + max_active_outbox_levels = 20_160l; + (* Maximum number of outbox messages per level. + WARNING: changing this value impacts the storage cost charged + for applying messages from the outbox. *) + max_outbox_messages_per_level = 100; + }; } in add_constants ctxt constants >>= fun ctxt -> return ctxt) diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 3eb58f1c7d3405d629bab78a09c3a73f9c863ac8..906b187e6930ab1deaec7a56586861f0b2bf9bf2 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -105,6 +105,10 @@ val current_timestamp : t -> Time.t val constants : t -> Constants_parametric_repr.t +val tx_rollup : t -> Constants_parametric_repr.tx_rollup + +val sc_rollup : t -> Constants_parametric_repr.sc_rollup + val patch_constants : t -> (Constants_parametric_repr.t -> Constants_parametric_repr.t) -> t Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 6a5e67db9d204c8beeb7c34355a7cb78e1dbc982..d9eb23de47996f3fd1ff608785eb1555abf92b4b 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -467,20 +467,20 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum Option.value ~default:constants.consensus_threshold consensus_threshold in let tx_rollup_enable = - Option.value ~default:constants.tx_rollup_enable tx_rollup_enable + Option.value ~default:constants.tx_rollup.enable tx_rollup_enable in let tx_rollup_sunset_level = Option.value - ~default:constants.tx_rollup_sunset_level + ~default:constants.tx_rollup.sunset_level tx_rollup_sunset_level in let tx_rollup_origination_size = Option.value - ~default:constants.tx_rollup_origination_size + ~default:constants.tx_rollup.origination_size tx_rollup_origination_size in let sc_rollup_enable = - Option.value ~default:constants.sc_rollup_enable sc_rollup_enable + Option.value ~default:constants.sc_rollup.enable sc_rollup_enable in let constants = { @@ -495,10 +495,14 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum cost_per_byte; liquidity_baking_subsidy; consensus_threshold; - tx_rollup_enable; - tx_rollup_sunset_level; - tx_rollup_origination_size; - sc_rollup_enable; + tx_rollup = + { + constants.tx_rollup with + enable = tx_rollup_enable; + sunset_level = tx_rollup_sunset_level; + origination_size = tx_rollup_origination_size; + }; + sc_rollup = {constants.sc_rollup with enable = sc_rollup_enable}; } in (* Check there is at least one roll *) diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml index 31e534d3e8815d3bd52a3ba301b1cd605ec1b86c..3aee56eb04df4e9e1d8f1c7ab6a839fd8ace0627 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml @@ -72,7 +72,14 @@ let test_context () = let test_context_with_nat_nat_big_map ?(sc_rollup_enable = false) () = Context.init_with_constants1 - {Context.default_test_constants with sc_rollup_enable} + { + Context.default_test_constants with + sc_rollup = + { + Context.default_test_constants.sc_rollup with + enable = sc_rollup_enable; + }; + } >>=? fun (b, source) -> Op.contract_origination (B b) source ~script:Op.dummy_script >>=? fun (operation, originated) -> diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index 9699ecdc73046adafd6de413acdc737d3b1a5974..17e33c1d34d8098b1e1a7255214d0848f387a43c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -70,9 +70,13 @@ let context_init ?(sc_rollup_challenge_window_in_blocks = 10) tup = tup { Context.default_test_constants with - sc_rollup_enable = true; consensus_threshold = 0; - sc_rollup_challenge_window_in_blocks; + sc_rollup = + { + Context.default_test_constants.sc_rollup with + enable = true; + challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; + }; } (** [test_disable_feature_flag ()] tries to originate a smart contract @@ -200,7 +204,7 @@ let test_publish_and_cement () = let* b = Incremental.finalize_block i in let* constants = Context.get_constants (B b) in let* b = - Block.bake_n constants.parametric.sc_rollup_challenge_window_in_blocks b + Block.bake_n constants.parametric.sc_rollup.challenge_window_in_blocks b in let* i = Incremental.begin_construction b in let hash = Sc_rollup.Commitment.hash c in @@ -258,7 +262,7 @@ let test_cement_fails_on_conflict () = let* b = Incremental.finalize_block i in let* constants = Context.get_constants (B b) in let* b = - Block.bake_n constants.parametric.sc_rollup_challenge_window_in_blocks b + Block.bake_n constants.parametric.sc_rollup.challenge_window_in_blocks b in let* i = Incremental.begin_construction b in let hash = Sc_rollup.Commitment.hash commitment1 in @@ -408,7 +412,7 @@ let test_atomic_batch_fails () = let* b = Incremental.finalize_block i in let* constants = Context.get_constants (B b) in let* b = - Block.bake_n constants.parametric.sc_rollup_challenge_window_in_blocks b + Block.bake_n constants.parametric.sc_rollup.challenge_window_in_blocks b in let* i = Incremental.begin_construction b in let hash = Sc_rollup.Commitment.hash c in diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml index bee71cc51eab0bce327e0fff7b6cd0371779d213..0e4c09691ee8789540928425b3ee35ad057f1f67 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml @@ -71,7 +71,10 @@ let check_runtime_error e = function flag is deactivated and check it fails *) let test_disable_feature_flag () = Context.init_with_constants1 - {Context.default_test_constants with tx_rollup_enable = false} + { + Context.default_test_constants with + tx_rollup = {Context.default_test_constants.tx_rollup with enable = false}; + } >>=? fun (b, contract) -> Incremental.begin_construction b >>=? fun i -> Op.tx_rollup_origination (I i) contract >>=? fun (op, _tx_rollup) -> @@ -87,8 +90,12 @@ let test_sunset () = Context.init_with_constants1 { Context.default_test_constants with - tx_rollup_enable = true; - tx_rollup_sunset_level = 0l; + tx_rollup = + { + Context.default_test_constants.tx_rollup with + enable = true; + sunset_level = 0l; + }; } >>=? fun (b, contract) -> Incremental.begin_construction b >>=? fun i -> @@ -206,19 +213,23 @@ let context_init ?(tx_rollup_max_inboxes_count = 2100) { Context.default_test_constants with consensus_threshold = 0; - tx_rollup_enable = true; - tx_rollup_sunset_level = Int32.max_int; - tx_rollup_finality_period; - tx_rollup_withdraw_period = 2; - tx_rollup_max_commitments_count = 3; - tx_rollup_origination_size; - tx_rollup_rejection_max_proof_size; - tx_rollup_max_inboxes_count; - tx_rollup_hard_size_limit_per_message; + tx_rollup = + { + Context.default_test_constants.tx_rollup with + enable = true; + sunset_level = Int32.max_int; + withdraw_period = 2; + max_commitments_count = 3; + finality_period = tx_rollup_finality_period; + origination_size = tx_rollup_origination_size; + rejection_max_proof_size = tx_rollup_rejection_max_proof_size; + max_inboxes_count = tx_rollup_max_inboxes_count; + hard_size_limit_per_message = tx_rollup_hard_size_limit_per_message; + max_ticket_payload_size = tx_rollup_max_ticket_payload_size; + }; endorsing_reward_per_slot = Tez.zero; baking_reward_bonus_per_slot = Tez.zero; baking_reward_fixed_portion = Tez.zero; - tx_rollup_max_ticket_payload_size; cost_per_byte; } @@ -277,7 +288,7 @@ let l2_parameters : Context.t -> Tx_rollup_l2_apply.parameters tzresult Lwt.t = fun ctxt -> Context.get_constants ctxt >>=? fun constants -> let tx_rollup_max_withdrawals_per_batch = - constants.parametric.tx_rollup_max_withdrawals_per_batch + constants.parametric.tx_rollup.max_withdrawals_per_batch in return Tx_rollup_l2_apply.{tx_rollup_max_withdrawals_per_batch} @@ -609,13 +620,16 @@ let test_origination () = Context.init1 ~tx_rollup_enable:true ~tx_rollup_sunset_level:Int32.max_int () >>=? fun (b, contract) -> Context.get_constants (B b) - >>=? fun {parametric = {tx_rollup_origination_size; cost_per_byte; _}; _} -> + >>=? fun { + parametric = {tx_rollup = {origination_size; _}; cost_per_byte; _}; + _; + } -> Context.Contract.balance (B b) contract >>=? fun balance -> Incremental.begin_construction b >>=? fun i -> Op.tx_rollup_origination (I i) contract >>=? fun (op, tx_rollup) -> Incremental.add_operation i op >>=? fun i -> check_tx_rollup_exists (I i) tx_rollup >>=? fun () -> - cost_per_byte *? Int64.of_int tx_rollup_origination_size + cost_per_byte *? Int64.of_int origination_size >>?= fun tx_rollup_origination_burn -> Assert.balance_was_debited ~loc:__LOC__ @@ -889,7 +903,7 @@ let test_batch_too_big () = Context.get_constants (B b) >>=? fun constant -> let contents = String.make - (constant.parametric.tx_rollup_hard_size_limit_per_message + 1) + (constant.parametric.tx_rollup.hard_size_limit_per_message + 1) 'd' in Incremental.begin_construction b >>=? fun i -> @@ -911,7 +925,7 @@ let fill_inbox b tx_rollup contract contents k = let message_size = String.length contents in Context.get_constants (B b) >>=? fun constant -> let tx_rollup_inbox_limit = - constant.parametric.tx_rollup_hard_size_limit_per_inbox + constant.parametric.tx_rollup.hard_size_limit_per_inbox in Context.Contract.counter (B b) contract >>=? fun counter -> Incremental.begin_construction b >>=? fun i -> @@ -941,7 +955,7 @@ let test_inbox_size_too_big () = context_init1 () >>=? fun (b, contract) -> Context.get_constants (B b) >>=? fun constant -> let tx_rollup_batch_limit = - constant.parametric.tx_rollup_hard_size_limit_per_message - 1 + constant.parametric.tx_rollup.hard_size_limit_per_message - 1 in let contents = String.make tx_rollup_batch_limit 'd' in originate b contract >>=? fun (b, tx_rollup) -> @@ -960,7 +974,7 @@ let test_inbox_count_too_big () = context_init1 () >>=? fun (b, contract) -> let _, _, pkh = gen_l2_account () in Context.get_constants (B b) >>=? fun constant -> - let message_count = constant.parametric.tx_rollup_max_messages_per_inbox in + let message_count = constant.parametric.tx_rollup.max_messages_per_inbox in let contents = "some contents" in originate b contract >>=? fun (b, tx_rollup) -> Contract_helpers.originate_contract @@ -1190,7 +1204,7 @@ let test_invalid_deposit_too_big_ticket () = context_init1 () >>=? fun (b, account) -> Context.get_constants (B b) >>=? fun constant -> let tx_rollup_max_ticket_payload_size = - constant.parametric.tx_rollup_max_ticket_payload_size + constant.parametric.tx_rollup.max_ticket_payload_size in originate b account >>=? fun (b, tx_rollup) -> Contract_helpers.originate_contract @@ -1241,7 +1255,7 @@ let test_invalid_deposit_too_big_ticket_type () = context_init1 () >>=? fun (b, account) -> Context.get_constants (B b) >>=? fun constant -> let tx_rollup_max_ticket_payload_size = - constant.parametric.tx_rollup_max_ticket_payload_size + constant.parametric.tx_rollup.max_ticket_payload_size in originate b account >>=? fun (b, tx_rollup) -> Contract_helpers.originate_contract @@ -1298,7 +1312,7 @@ let test_valid_deposit_big_ticket () = context_init1 () >>=? fun (b, account) -> Context.get_constants (B b) >>=? fun constant -> let tx_rollup_max_ticket_payload_size = - constant.parametric.tx_rollup_max_ticket_payload_size + constant.parametric.tx_rollup.max_ticket_payload_size in originate b account >>=? fun (b, tx_rollup) -> Contract_helpers.originate_contract @@ -1444,7 +1458,7 @@ let test_finalization () = let filler = contract in originate b contract >>=? fun (b, tx_rollup) -> Context.get_constants (B b) - >>=? fun {parametric = {tx_rollup_hard_size_limit_per_inbox; _}; _} -> + >>=? fun {parametric = {tx_rollup = {hard_size_limit_per_inbox; _}; _}; _} -> (* Get the initial burn_per_byte. *) Context.Tx_rollup.state (B b) tx_rollup >>=? fun state -> burn_per_byte state >>?= fun cost -> @@ -1452,7 +1466,7 @@ let test_finalization () = (* Fill the inbox. *) Context.get_constants (B b) >>=? fun constant -> let tx_rollup_batch_limit = - constant.parametric.tx_rollup_hard_size_limit_per_message - 1 + constant.parametric.tx_rollup.hard_size_limit_per_message - 1 in let contents = String.make tx_rollup_batch_limit 'd' in (* Repeating fill inbox and finalize block to increase EMA @@ -1464,7 +1478,7 @@ let test_finalization () = let inbox_ema = Alpha_context.Tx_rollup_state.Internal_for_tests.get_inbox_ema state in - if tx_rollup_hard_size_limit_per_inbox * 91 / 100 < inbox_ema then + if hard_size_limit_per_inbox * 91 / 100 < inbox_ema then return (b, n, inbox_size) else increase_ema (n + 1) b tx_rollup f in @@ -1481,7 +1495,7 @@ let test_finalization () = ~elapsed ~factor ~final_size:inbox_size - ~hard_limit:tx_rollup_hard_size_limit_per_inbox + ~hard_limit:hard_size_limit_per_inbox in update_burn_per_byte_n_time (n - 1) state else state @@ -1566,7 +1580,7 @@ let test_commitment_duplication () = Op.tx_rollup_commit (I i) contract1 tx_rollup commitment >>=? fun op -> Incremental.add_operation i op >>=? fun i -> Context.get_constants (I i) >>=? fun constants -> - let cost = constants.parametric.tx_rollup_commitment_bond in + let cost = constants.parametric.tx_rollup.commitment_bond in Assert.balance_was_debited ~loc:__LOC__ (I i) contract1 balance cost >>=? fun () -> (* Successfully fail to submit a duplicate commitment *) @@ -1905,9 +1919,15 @@ let test_full_inbox () = endorsing_reward_per_slot = Tez.zero; baking_reward_bonus_per_slot = Tez.zero; baking_reward_fixed_portion = Tez.zero; - tx_rollup_enable = true; - tx_rollup_sunset_level = Int32.max_int; - tx_rollup_max_inboxes_count = 15; + tx_rollup = + { + Tezos_protocol_alpha_parameters.Default_parameters.constants_test + .tx_rollup + with + enable = true; + sunset_level = Int32.max_int; + max_inboxes_count = 15; + }; } in Context.init_with_constants1 constants >>=? fun (b, contract) -> @@ -1940,7 +1960,7 @@ let test_bond_finalization () = (* Let’s try to remove the bond *) Incremental.begin_construction b >>=? fun i -> Context.get_constants (I i) >>=? fun constants -> - let bond = constants.parametric.tx_rollup_commitment_bond in + let bond = constants.parametric.tx_rollup.commitment_bond in Op.tx_rollup_return_bond (I i) contract1 tx_rollup >>=? fun op -> Incremental.add_operation i @@ -2622,7 +2642,7 @@ module Rejection = struct make_invalid_commitment i level1 Context_hash.zero >>=? fun (i, commitment1) -> Context.get_constants (I i) >>=? fun constants -> - let bond_cost = constants.parametric.tx_rollup_commitment_bond in + let bond_cost = constants.parametric.tx_rollup.commitment_bond in Assert.balance_was_debited ~loc:__LOC__ (I i) contract1 balance bond_cost >>=? fun () -> check_frozen ~loc:__LOC__ i bond_cost >>=? fun () -> @@ -3469,7 +3489,7 @@ module Rejection = struct Op.tx_rollup_submit_batch (I i) account tx_rollup batch_bytes >>=? fun op2 -> let message_count = - constant.parametric.tx_rollup_max_messages_per_inbox - 2 + constant.parametric.tx_rollup.max_messages_per_inbox - 2 in (* Fill the inbox at tx_level 0. Trying to reject a commitment for a full inbox has the benefit of having large message paths. Thus, making the @@ -3768,7 +3788,7 @@ let test_state () = (B b) account2 before_slashing - constants.parametric.tx_rollup_commitment_bond + constants.parametric.tx_rollup.commitment_bond >>=? fun () -> (* Inboxes: [ ] - [ ] - [ ] diff --git a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml index 9e98c26728012028996f9c802dcbed4c89988992..08ed46c5d7867849c21c548d6eb134c714096ab8 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml @@ -67,9 +67,9 @@ let test_max_operations_ttl () = the throughput of the rollup. *) let test_sc_rollup_challenge_window_lt_max_lookahead () = let constants = Default_parameters.constants_mainnet in - let max_lookahead = constants.sc_rollup_max_lookahead_in_blocks in + let max_lookahead = constants.sc_rollup.max_lookahead_in_blocks in let challenge_window = - Int32.of_int constants.sc_rollup_challenge_window_in_blocks + Int32.of_int constants.sc_rollup.challenge_window_in_blocks in Assert.lt_int32 ~loc:__LOC__ challenge_window max_lookahead @@ -86,26 +86,26 @@ let test_sc_rollup_max_commitment_storage_cost_lt_deposit () = Alpha_context.Tez.to_mutez constants.cost_per_byte in let commitment_storage_size = - Int64.of_int constants.sc_rollup_commitment_storage_size_in_bytes + Int64.of_int constants.sc_rollup.commitment_storage_size_in_bytes in let commitment_storage_cost = Int64.mul cost_per_byte_mutez commitment_storage_size in let max_lookahead = - Int64.of_int32 constants.sc_rollup_max_lookahead_in_blocks + Int64.of_int32 constants.sc_rollup.max_lookahead_in_blocks in let commitment_period = - Int64.of_int constants.sc_rollup_commitment_period_in_blocks + Int64.of_int constants.sc_rollup.commitment_period_in_blocks in - let stake_amount_in_mutez = - Alpha_context.Tez.to_mutez constants.sc_rollup_stake_amount + let stake_amount = + Alpha_context.Tez.to_mutez constants.sc_rollup.stake_amount in Assert.leq_int64 ~loc:__LOC__ (Int64.mul commitment_storage_cost (Int64.div max_lookahead commitment_period)) - stake_amount_in_mutez + stake_amount (* Check that [sc_rollup_commitment_storage_size_in_bytes = commitments_entry_size + @@ -152,7 +152,7 @@ let test_sc_rollup_commitment_storage_size () = in Assert.equal_int ~loc:__LOC__ - constants.sc_rollup_commitment_storage_size_in_bytes + constants.sc_rollup.commitment_storage_size_in_bytes (Bytes.length commitment_bytes + Bytes.length level_bytes + Bytes.length commitment_stake_count_bytes) diff --git a/src/proto_alpha/lib_tx_rollup/accuser.ml b/src/proto_alpha/lib_tx_rollup/accuser.ml index 215beb9d01ff86e9104a59da19adf8f7295011a6..e11383d09a6b197f0ddd9b6eb77f57abb48233fe 100644 --- a/src/proto_alpha/lib_tx_rollup/accuser.ml +++ b/src/proto_alpha/lib_tx_rollup/accuser.ml @@ -208,7 +208,7 @@ let build_rejection state ~(reject_commitment : Tx_rollup_commitment.Full.t) Protocol.Tx_rollup_l2_apply. { tx_rollup_max_withdrawals_per_batch = - state.constants.parametric.tx_rollup_max_withdrawals_per_batch; + state.constants.parametric.tx_rollup.max_withdrawals_per_batch; } in let+ proof, _ = diff --git a/src/proto_alpha/lib_tx_rollup/batcher.ml b/src/proto_alpha/lib_tx_rollup/batcher.ml index 617d2fde48f3c26d1af4c364e89965b6c6d97b2e..9b107aeaad45f8931809198800663dfff171cb6c 100644 --- a/src/proto_alpha/lib_tx_rollup/batcher.ml +++ b/src/proto_alpha/lib_tx_rollup/batcher.ml @@ -63,11 +63,11 @@ let inject_batches state batches = criteria: The proof produced by the batch interpretation must be smaller than - [constants.parametric.tx_rollup_rejection_max_proof_size]. Otherwise, the + [constants.parametric.tx_rollup.rejection_max_proof_size]. Otherwise, the associated commitment can be rejected because of the size. The batch exceeds the - [constants.parametric.tx_rollup_hard_size_limit_per_message], the submit + [constants.parametric.tx_rollup.hard_size_limit_per_message], the submit batch operation will fail. *) let is_batch_valid ctxt (constants : Constants.t) batch = let open Lwt_result_syntax in @@ -76,14 +76,14 @@ let is_batch_valid ctxt (constants : Constants.t) batch = 2. The batch is small enough *) let batch_size_ok = let size = Data_encoding.Binary.length Tx_rollup_l2_batch.encoding batch in - size <= constants.parametric.tx_rollup_hard_size_limit_per_message + size <= constants.parametric.tx_rollup.hard_size_limit_per_message in if batch_size_ok then let parameters = Tx_rollup_l2_apply. { tx_rollup_max_withdrawals_per_batch = - constants.parametric.tx_rollup_max_withdrawals_per_batch; + constants.parametric.tx_rollup.max_withdrawals_per_batch; } in let*! res_interp = @@ -91,7 +91,7 @@ let is_batch_valid ctxt (constants : Constants.t) batch = ctxt parameters ~rejection_max_proof_size: - constants.parametric.tx_rollup_rejection_max_proof_size + constants.parametric.tx_rollup.rejection_max_proof_size batch in let b_proof_size = Result.is_ok res_interp in @@ -172,12 +172,12 @@ let on_register state ~apply (tr : L2_transaction.t) = let* () = fail_when (msg_size - >= state.constants.parametric.tx_rollup_hard_size_limit_per_message) + >= state.constants.parametric.tx_rollup.hard_size_limit_per_message) (Error.Transaction_too_large { actual = msg_size; limit = - state.constants.parametric.tx_rollup_hard_size_limit_per_message; + state.constants.parametric.tx_rollup.hard_size_limit_per_message; }) in let context = state.incr_context in @@ -189,7 +189,7 @@ let on_register state ~apply (tr : L2_transaction.t) = Tx_rollup_l2_apply. { tx_rollup_max_withdrawals_per_batch = - state.constants.parametric.tx_rollup_max_withdrawals_per_batch; + state.constants.parametric.tx_rollup.max_withdrawals_per_batch; } in L2_apply.Batch_V1.apply_batch context parameters batch diff --git a/src/proto_alpha/lib_tx_rollup/daemon.ml b/src/proto_alpha/lib_tx_rollup/daemon.ml index 855ea3ae0916073ec927b98904d3fadb4399f03a..547744c32824b0dcde91c92ad8660286e4d37104 100644 --- a/src/proto_alpha/lib_tx_rollup/daemon.ml +++ b/src/proto_alpha/lib_tx_rollup/daemon.ml @@ -317,7 +317,7 @@ let process_messages_and_inboxes (state : State.t) Protocol.Tx_rollup_l2_apply. { tx_rollup_max_withdrawals_per_batch = - state.constants.parametric.tx_rollup_max_withdrawals_per_batch; + state.constants.parametric.tx_rollup.max_withdrawals_per_batch; } in let context = predecessor_context in @@ -326,7 +326,7 @@ let process_messages_and_inboxes (state : State.t) context parameters ~rejection_max_proof_size: - state.constants.parametric.tx_rollup_rejection_max_proof_size + state.constants.parametric.tx_rollup.rejection_max_proof_size messages in let* context =