diff --git a/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.ml index 7f009a5d9a47ff8807d4bc18ba3abf6505ca871b..19fe7aad28a300fc3518b26512b31de5f051be9c 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.ml @@ -28,12 +28,9 @@ type dal = { feature_enable : bool; number_of_slots : int; - number_of_shards : int; - endorsement_lag : int; + attestation_lag : int; availability_threshold : int; - slot_size : int; - redundancy_factor : int; - page_size : int; + cryptobox_parameters : Dal.parameters; } let dal_encoding = @@ -42,48 +39,34 @@ let dal_encoding = (fun { feature_enable; number_of_slots; - number_of_shards; - endorsement_lag; + attestation_lag; availability_threshold; - slot_size; - redundancy_factor; - page_size; + cryptobox_parameters; } -> - ( feature_enable, - number_of_slots, - number_of_shards, - endorsement_lag, - availability_threshold, - slot_size, - redundancy_factor, - page_size )) - (fun ( feature_enable, - number_of_slots, - number_of_shards, - endorsement_lag, - availability_threshold, - slot_size, - redundancy_factor, - page_size ) -> + ( ( feature_enable, + number_of_slots, + attestation_lag, + availability_threshold ), + cryptobox_parameters )) + (fun ( ( feature_enable, + number_of_slots, + attestation_lag, + availability_threshold ), + cryptobox_parameters ) -> { feature_enable; number_of_slots; - number_of_shards; - endorsement_lag; + attestation_lag; availability_threshold; - slot_size; - redundancy_factor; - page_size; + cryptobox_parameters; }) - (obj8 - (req "feature_enable" Data_encoding.bool) - (req "number_of_slots" Data_encoding.int16) - (req "number_of_shards" Data_encoding.int16) - (req "endorsement_lag" Data_encoding.int16) - (req "availability_threshold" Data_encoding.int16) - (req "slot_size" Data_encoding.int31) - (req "redundancy_factor" Data_encoding.uint8) - (req "page_size" Data_encoding.uint16)) + (merge_objs + (obj4 + (req "feature_enable" bool) + (req "number_of_slots" int16) + (req "attestation_lag" int16) + (req "availability_threshold" int16)) + Dal.parameters_encoding) (* The encoded representation of this type is stored in the context as bytes. Changing the encoding, or the value of these constants from @@ -114,9 +97,9 @@ type tx_rollup = { type sc_rollup = { enable : bool; + arith_pvm_enable : bool; origination_size : int; challenge_window_in_blocks : int; - max_number_of_messages_per_commitment_period : int; stake_amount : Tez_repr.t; commitment_period_in_blocks : int; max_lookahead_in_blocks : int32; @@ -125,6 +108,7 @@ type sc_rollup = { number_of_sections_in_dissection : int; timeout_period_in_blocks : int; max_number_of_stored_cemented_commitments : int; + max_number_of_parallel_games : int; } type zk_rollup = { @@ -255,35 +239,36 @@ let sc_rollup_encoding = conv (fun (c : sc_rollup) -> ( ( c.enable, + c.arith_pvm_enable, c.origination_size, c.challenge_window_in_blocks, - c.max_number_of_messages_per_commitment_period, c.stake_amount, c.commitment_period_in_blocks, c.max_lookahead_in_blocks, c.max_active_outbox_levels, - c.max_outbox_messages_per_level, - c.number_of_sections_in_dissection ), - (c.timeout_period_in_blocks, c.max_number_of_stored_cemented_commitments) - )) + c.max_outbox_messages_per_level ), + ( c.number_of_sections_in_dissection, + c.timeout_period_in_blocks, + c.max_number_of_stored_cemented_commitments, + c.max_number_of_parallel_games ) )) (fun ( ( sc_rollup_enable, + sc_rollup_arith_pvm_enable, sc_rollup_origination_size, sc_rollup_challenge_window_in_blocks, - sc_rollup_max_number_of_messages_per_commitment_period, sc_rollup_stake_amount, sc_rollup_commitment_period_in_blocks, sc_rollup_max_lookahead_in_blocks, sc_rollup_max_active_outbox_levels, - sc_rollup_max_outbox_messages_per_level, - sc_rollup_number_of_sections_in_dissection ), - ( sc_rollup_timeout_period_in_blocks, - sc_rollup_max_number_of_cemented_commitments ) ) -> + sc_rollup_max_outbox_messages_per_level ), + ( sc_rollup_number_of_sections_in_dissection, + sc_rollup_timeout_period_in_blocks, + sc_rollup_max_number_of_cemented_commitments, + sc_rollup_max_number_of_parallel_games ) ) -> { enable = sc_rollup_enable; + arith_pvm_enable = sc_rollup_arith_pvm_enable; origination_size = sc_rollup_origination_size; challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; - max_number_of_messages_per_commitment_period = - sc_rollup_max_number_of_messages_per_commitment_period; stake_amount = sc_rollup_stake_amount; commitment_period_in_blocks = sc_rollup_commitment_period_in_blocks; max_lookahead_in_blocks = sc_rollup_max_lookahead_in_blocks; @@ -294,22 +279,24 @@ let sc_rollup_encoding = timeout_period_in_blocks = sc_rollup_timeout_period_in_blocks; max_number_of_stored_cemented_commitments = sc_rollup_max_number_of_cemented_commitments; + max_number_of_parallel_games = sc_rollup_max_number_of_parallel_games; }) (merge_objs - (obj10 - (req "sc_rollup_enable" bool) - (req "sc_rollup_origination_size" int31) - (req "sc_rollup_challenge_window_in_blocks" int31) - (req "sc_rollup_max_number_of_messages_per_commitment_period" int31) - (req "sc_rollup_stake_amount" Tez_repr.encoding) - (req "sc_rollup_commitment_period_in_blocks" 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) - (req "sc_rollup_number_of_sections_in_dissection" uint8)) - (obj2 - (req "sc_rollup_timeout_period_in_blocks" int31) - (req "sc_rollup_max_number_of_cemented_commitments" int31))) + (obj9 + (req "smart_rollup_enable" bool) + (req "smart_rollup_arith_pvm_enable" bool) + (req "smart_rollup_origination_size" int31) + (req "smart_rollup_challenge_window_in_blocks" int31) + (req "smart_rollup_stake_amount" Tez_repr.encoding) + (req "smart_rollup_commitment_period_in_blocks" int31) + (req "smart_rollup_max_lookahead_in_blocks" int32) + (req "smart_rollup_max_active_outbox_levels" int32) + (req "smart_rollup_max_outbox_messages_per_level" int31)) + (obj4 + (req "smart_rollup_number_of_sections_in_dissection" uint8) + (req "smart_rollup_timeout_period_in_blocks" int31) + (req "smart_rollup_max_number_of_cemented_commitments" int31) + (req "smart_rollup_max_number_of_parallel_games" int31))) let zk_rollup_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.mli index db5c1c5ab07ab668b2b8216d23581e6b9b7e40ca..6f3abe5e5c057e06419605bcdcde4f6a462fbabe 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.mli @@ -28,12 +28,9 @@ type dal = { feature_enable : bool; number_of_slots : int; - number_of_shards : int; - endorsement_lag : int; + attestation_lag : int; availability_threshold : int; - slot_size : int; - redundancy_factor : int; - page_size : int; + cryptobox_parameters : Dal.parameters; } val dal_encoding : dal Data_encoding.t @@ -89,9 +86,9 @@ type tx_rollup = { type sc_rollup = { enable : bool; + arith_pvm_enable : bool; origination_size : int; challenge_window_in_blocks : int; - max_number_of_messages_per_commitment_period : int; stake_amount : Tez_repr.t; (* The period with which commitments are made. *) commitment_period_in_blocks : int; @@ -124,6 +121,8 @@ type sc_rollup = { timeout_period_in_blocks : int; (* The maximum number of cemented commitments stored for a sc rollup. *) max_number_of_stored_cemented_commitments : int; + (* The maximum number of parallel games played by a given staker. *) + max_number_of_parallel_games : int; } type zk_rollup = { diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 0cdd0afeac34a4263a6670ab0615111523ad20fb..c2f2f61a0ae4a01f877e3c3f3042815a2653a857 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -160,16 +160,14 @@ let prepare_first_block _chain_id ctxt ~typecheck ~level ~timestamp ~predecessor ( ctxt, commitments_balance_updates @ bootstrap_balance_updates @ deposits_balance_updates ) - | Lima_015 + | Mumbai_016 (* Please update [next_protocol] and [previous_protocol] in [tezt/lib_tezos/protocol.ml] when you update this value. *) -> (* TODO (#2704): possibly handle endorsements for migration block (in bakers); if that is done, do not set Storage.Tenderbake.First_level_of_protocol. *) Raw_level_repr.of_int32 level >>?= fun level -> Storage.Tenderbake.First_level_of_protocol.update ctxt level - >>=? fun ctxt -> - Sc_rollup_inbox_storage.init_inbox ~predecessor ctxt >>= fun ctxt -> - return (ctxt, [])) + >>=? fun ctxt -> return (ctxt, [])) >>=? fun (ctxt, balance_updates) -> List.fold_right_es patch_script Legacy_script_patches.addresses_to_patch ctxt >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 53b43d0c97cbc6f1c16c20fcf895f79db6abb872..dce7673371233aa5a07d5bb76e8bfb5ace32a5b5 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -839,7 +839,7 @@ let prepare ~level ~predecessor_timestamp ~timestamp ctxt = }; } -type previous_protocol = Genesis of Parameters_repr.t | Lima_015 +type previous_protocol = Genesis of Parameters_repr.t | Mumbai_016 let check_and_update_protocol_version ctxt = (Context.find ctxt version_key >>= function @@ -851,7 +851,7 @@ let check_and_update_protocol_version ctxt = failwith "Internal error: previously initialized context." else if Compare.String.(s = "genesis") then get_proto_param ctxt >|=? fun (param, ctxt) -> (Genesis param, ctxt) - else if Compare.String.(s = "lima_015") then return (Lima_015, ctxt) + else if Compare.String.(s = "mumbai_016") then return (Mumbai_016, ctxt) else Lwt.return @@ storage_error (Incompatible_protocol_version s)) >>=? fun (previous_proto, ctxt) -> Context.add ctxt version_key (Bytes.of_string version_value) >|= fun ctxt -> @@ -875,82 +875,6 @@ let[@warning "-32"] get_previous_protocol_constants ctxt = context." | Some constants -> Lwt.return constants) -let update_block_time_related_constants (c : Constants_parametric_repr.t) = - let divide_period p = - Period_repr.of_seconds_exn - Int64.(div (add (Period_repr.to_seconds p) 1L) 2L) - in - let minimal_block_delay = divide_period c.minimal_block_delay in - let delay_increment_per_round = divide_period c.delay_increment_per_round in - let hard_gas_limit_per_block = - let two = Z.(succ one) in - Gas_limit_repr.Arith.( - integral_exn (Z.div (integral_to_z c.hard_gas_limit_per_block) two)) - in - let Constants_repr.Generated. - { - consensus_threshold = _; - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; - liquidity_baking_subsidy; - } = - Constants_repr.Generated.generate - ~consensus_committee_size: - c.Constants_parametric_repr.consensus_committee_size - ~blocks_per_minute: - { - numerator = 60; - denominator = - minimal_block_delay |> Period_repr.to_seconds |> Int64.to_int; - } - in - let double = Int32.mul 2l in - let blocks_per_cycle = double c.blocks_per_cycle in - let blocks_per_commitment = double c.blocks_per_commitment in - let nonce_revelation_threshold = double c.nonce_revelation_threshold in - let blocks_per_stake_snapshot = double c.blocks_per_stake_snapshot in - let max_operations_time_to_live = 2 * c.max_operations_time_to_live in - { - c with - blocks_per_cycle; - blocks_per_commitment; - nonce_revelation_threshold; - blocks_per_stake_snapshot; - max_operations_time_to_live; - minimal_block_delay; - delay_increment_per_round; - hard_gas_limit_per_block; - baking_reward_fixed_portion; - baking_reward_bonus_per_slot; - endorsing_reward_per_slot; - liquidity_baking_subsidy; - } - -let update_cycle_eras ctxt level ~prev_blocks_per_cycle ~blocks_per_cycle - ~blocks_per_commitment = - get_cycle_eras ctxt >>=? fun cycle_eras -> - let current_era = Level_repr.current_era cycle_eras in - let current_cycle = - let level_position = - Int32.sub level (Raw_level_repr.to_int32 current_era.first_level) - in - Cycle_repr.add - current_era.first_cycle - (Int32.to_int (Int32.div level_position prev_blocks_per_cycle)) - in - let new_cycle_era = - Level_repr. - { - first_level = Raw_level_repr.of_int32_exn (Int32.succ level); - first_cycle = Cycle_repr.succ current_cycle; - blocks_per_cycle; - blocks_per_commitment; - } - in - Level_repr.add_cycle_era new_cycle_era cycle_eras >>?= fun new_cycle_eras -> - set_cycle_eras ctxt new_cycle_eras - (* You should ensure that if the type `Constants_parametric_repr.t` is different from `Constants_parametric_previous_repr.t` or the value of these constants is modified, is changed from the previous protocol, then @@ -978,7 +902,7 @@ let prepare_first_block ~level ~timestamp ctxt = Level_repr.create_cycle_eras [cycle_era] >>?= fun cycle_eras -> set_cycle_eras ctxt cycle_eras >>=? fun ctxt -> add_constants ctxt param.constants >|= ok - | Lima_015 -> + | Mumbai_016 -> get_previous_protocol_constants ctxt >>= fun c -> let tx_rollup = Constants_parametric_repr. @@ -1003,10 +927,10 @@ let prepare_first_block ~level ~timestamp ctxt = in let cryptobox_parameters = { - Dal.page_size = 4096; - number_of_shards = 2048; - slot_size = 1 lsl 20; - redundancy_factor = 16; + Dal.page_size = c.dal.cryptobox_parameters.page_size; + number_of_shards = c.dal.cryptobox_parameters.number_of_shards; + slot_size = c.dal.cryptobox_parameters.slot_size; + redundancy_factor = c.dal.cryptobox_parameters.redundancy_factor; } in let dal = @@ -1014,7 +938,7 @@ let prepare_first_block ~level ~timestamp ctxt = { feature_enable = c.dal.feature_enable; number_of_slots = c.dal.number_of_slots; - attestation_lag = c.dal.endorsement_lag; + attestation_lag = c.dal.attestation_lag; attestation_threshold = c.dal.availability_threshold; blocks_per_epoch = 32l; cryptobox_parameters; @@ -1026,19 +950,21 @@ let prepare_first_block ~level ~timestamp ctxt = enable = true; arith_pvm_enable = false; origination_size = c.sc_rollup.origination_size; - challenge_window_in_blocks = 80_640; + challenge_window_in_blocks = c.sc_rollup.challenge_window_in_blocks; stake_amount = c.sc_rollup.stake_amount; - commitment_period_in_blocks = 60; - max_lookahead_in_blocks = 172_800l; - max_active_outbox_levels = 80_640l; + commitment_period_in_blocks = + c.sc_rollup.commitment_period_in_blocks; + max_lookahead_in_blocks = c.sc_rollup.max_lookahead_in_blocks; + max_active_outbox_levels = c.sc_rollup.max_active_outbox_levels; max_outbox_messages_per_level = c.sc_rollup.max_outbox_messages_per_level; number_of_sections_in_dissection = c.sc_rollup.number_of_sections_in_dissection; - timeout_period_in_blocks = 40_320; + timeout_period_in_blocks = c.sc_rollup.timeout_period_in_blocks; max_number_of_stored_cemented_commitments = c.sc_rollup.max_number_of_stored_cemented_commitments; - max_number_of_parallel_games = 32; + max_number_of_parallel_games = + c.sc_rollup.max_number_of_parallel_games; } in let zk_rollup = @@ -1100,20 +1026,6 @@ let prepare_first_block ~level ~timestamp ctxt = zk_rollup; } in - let block_time_is_at_least_15s = - Compare.Int64.(Period_repr.to_seconds c.minimal_block_delay >= 15L) - in - (if block_time_is_at_least_15s then - let new_constants = update_block_time_related_constants constants in - update_cycle_eras - ctxt - level - ~prev_blocks_per_cycle:constants.blocks_per_cycle - ~blocks_per_cycle:new_constants.blocks_per_cycle - ~blocks_per_commitment:new_constants.blocks_per_commitment - >>=? fun ctxt -> return (ctxt, new_constants) - else return (ctxt, constants)) - >>=? fun (ctxt, constants) -> add_constants ctxt constants >>= fun ctxt -> return ctxt) >>=? fun ctxt -> prepare ctxt ~level ~predecessor_timestamp:timestamp ~timestamp diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index a90061197281c3aedd3d7713df4a1610c6df7f61..3c05749133111af6a655706552f85bc7415778be 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -83,7 +83,7 @@ val prepare : Context.t -> t tzresult Lwt.t -type previous_protocol = Genesis of Parameters_repr.t | Lima_015 +type previous_protocol = Genesis of Parameters_repr.t | Mumbai_016 val prepare_first_block : level:int32 -> diff --git a/tests_python/tests_alpha/protocol.py b/tests_python/tests_alpha/protocol.py index 73c350857c68e7dd60ecab72bb0dde2eeb4e8147..02bc3317ab548a8099551287cd4f9ac706dc211c 100644 --- a/tests_python/tests_alpha/protocol.py +++ b/tests_python/tests_alpha/protocol.py @@ -15,9 +15,9 @@ TENDERBAKE_PARAMETERS['consensus_committee_size'] = 67 FOLDER = constants.ALPHA_FOLDER -PREV_HASH = constants.LIMA -PREV_DAEMON = constants.LIMA_DAEMON -PREV_PARAMETERS = constants.LIMA_PARAMETERS +PREV_HASH = constants.MUMBAI +PREV_DAEMON = constants.MUMBAI_DAEMON +PREV_PARAMETERS = constants.MUMBAI_PARAMETERS def activate( diff --git a/tezt/lib_tezos/protocol.ml b/tezt/lib_tezos/protocol.ml index e241eaf243690a3a640fed1ec0625c38653bd70a..ea75eeaaab3cefd290a0f00a075c81b99defe6e1 100644 --- a/tezt/lib_tezos/protocol.ml +++ b/tezt/lib_tezos/protocol.ml @@ -168,12 +168,12 @@ let write_parameter_file : Lwt.return overriden_parameters let next_protocol = function - | Lima -> Some Alpha + | Lima -> Some Mumbai | Mumbai -> Some Alpha | Alpha -> None let previous_protocol = function - | Alpha -> Some Lima + | Alpha -> Some Mumbai | Mumbai -> Some Lima | Lima -> None