From fce5e09b4bb541ba006ba4bd163cba767ff52112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Wed, 19 Apr 2023 17:05:27 +0100 Subject: [PATCH 1/3] Proto: Migrate from Nairobi --- src/proto_alpha/lib_protocol/init_storage.ml | 6 ++---- src/proto_alpha/lib_protocol/raw_context.ml | 6 +++--- src/proto_alpha/lib_protocol/raw_context.mli | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index f4207edb5240..35b22e66a083 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -160,7 +160,7 @@ let prepare_first_block _chain_id ctxt ~typecheck ~level ~timestamp ~predecessor ( ctxt, commitments_balance_updates @ bootstrap_balance_updates @ deposits_balance_updates ) - | Mumbai_016 + | Nairobi_017 (* 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); @@ -169,9 +169,7 @@ let prepare_first_block _chain_id ctxt ~typecheck ~level ~timestamp ~predecessor inbox migration message. see `sc_rollup_inbox_storage`. *) Raw_level_repr.of_int32 level >>?= fun level -> Storage.Tenderbake.First_level_of_protocol.update ctxt level - >>=? fun ctxt -> - Storage.Legacy.Grand_parent_branch.remove ctxt >>= fun ctxt -> - return (ctxt, [])) + >>=? fun ctxt -> return (ctxt, [])) >>=? fun (ctxt, balance_updates) -> List.fold_left_es patch_script ctxt Legacy_script_patches.addresses_to_patch >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index d0ab540d7692..bfd405b5e46f 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -836,7 +836,7 @@ let prepare ~level ~predecessor_timestamp ~timestamp ctxt = }; } -type previous_protocol = Genesis of Parameters_repr.t | Mumbai_016 +type previous_protocol = Genesis of Parameters_repr.t | Nairobi_017 let check_and_update_protocol_version ctxt = (Context.find ctxt version_key >>= function @@ -848,7 +848,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 = "mumbai_016") then return (Mumbai_016, ctxt) + else if Compare.String.(s = "nairobi_017") then return (Nairobi_017, 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 -> @@ -899,7 +899,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 - | Mumbai_016 -> + | Nairobi_017 -> get_previous_protocol_constants ctxt >>= fun c -> let tx_rollup = Constants_parametric_repr. diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index b53538adbaff..01d81c27304e 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -92,7 +92,7 @@ val prepare : Context.t -> t tzresult Lwt.t -type previous_protocol = Genesis of Parameters_repr.t | Mumbai_016 +type previous_protocol = Genesis of Parameters_repr.t | Nairobi_017 val prepare_first_block : level:int32 -> -- GitLab From 810caf46bbb0d4c4fefce87d09bb75d462954620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Wed, 19 Apr 2023 17:07:46 +0100 Subject: [PATCH 2/3] Proto: Update previous constants representation --- .../constants_parametric_previous_repr.ml | 20 +++++++++----- .../constants_parametric_previous_repr.mli | 3 ++- src/proto_alpha/lib_protocol/raw_context.ml | 26 +++++-------------- 3 files changed, 21 insertions(+), 28 deletions(-) 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 19fe7aad28a3..918a77b9190c 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.ml @@ -29,7 +29,8 @@ type dal = { feature_enable : bool; number_of_slots : int; attestation_lag : int; - availability_threshold : int; + attestation_threshold : int; + blocks_per_epoch : int32; cryptobox_parameters : Dal.parameters; } @@ -40,32 +41,37 @@ let dal_encoding = feature_enable; number_of_slots; attestation_lag; - availability_threshold; + attestation_threshold; cryptobox_parameters; + blocks_per_epoch; } -> ( ( feature_enable, number_of_slots, attestation_lag, - availability_threshold ), + attestation_threshold, + blocks_per_epoch ), cryptobox_parameters )) (fun ( ( feature_enable, number_of_slots, attestation_lag, - availability_threshold ), + attestation_threshold, + blocks_per_epoch ), cryptobox_parameters ) -> { feature_enable; number_of_slots; attestation_lag; - availability_threshold; + attestation_threshold; + blocks_per_epoch; cryptobox_parameters; }) (merge_objs - (obj4 + (obj5 (req "feature_enable" bool) (req "number_of_slots" int16) (req "attestation_lag" int16) - (req "availability_threshold" int16)) + (req "attestation_threshold" int16) + (req "blocks_per_epoch" int32)) Dal.parameters_encoding) (* The encoded representation of this type is stored in the context as 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 6f3abe5e5c05..5776add0db65 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_previous_repr.mli @@ -29,7 +29,8 @@ type dal = { feature_enable : bool; number_of_slots : int; attestation_lag : int; - availability_threshold : int; + attestation_threshold : int; + blocks_per_epoch : int32; cryptobox_parameters : Dal.parameters; } diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index bfd405b5e46f..8f20eed7f29a 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -904,7 +904,7 @@ let prepare_first_block ~level ~timestamp ctxt = let tx_rollup = Constants_parametric_repr. { - enable = false; + 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 = @@ -936,16 +936,16 @@ 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.attestation_lag; - attestation_threshold = c.dal.availability_threshold; - blocks_per_epoch = 32l; + attestation_threshold = c.dal.attestation_threshold; + blocks_per_epoch = c.dal.blocks_per_epoch; cryptobox_parameters; } in let sc_rollup = Constants_parametric_repr. { - enable = true; - arith_pvm_enable = false; + enable = c.sc_rollup.enable; + arith_pvm_enable = c.sc_rollup.arith_pvm_enable; origination_size = c.sc_rollup.origination_size; challenge_window_in_blocks = c.sc_rollup.challenge_window_in_blocks; stake_amount = c.sc_rollup.stake_amount; @@ -972,20 +972,6 @@ let prepare_first_block ~level ~timestamp ctxt = min_pending_to_process = c.zk_rollup.min_pending_to_process; } in - let proof_of_work_threshold = - let mainnet_previous_proof_of_work_threshold = - Int64.(sub (shift_left 1L 46) 1L) - in - let new_proof_of_work_threshold = Int64.(sub (shift_left 1L 48) 1L) in - (* Only override constants that match the mainnet's existing - value; otherwise, it might affect testnets that set - different values. *) - if - Compare.Int64.( - c.proof_of_work_threshold = mainnet_previous_proof_of_work_threshold) - then new_proof_of_work_threshold - else c.proof_of_work_threshold - in let constants = Constants_parametric_repr. { @@ -997,7 +983,7 @@ let prepare_first_block ~level ~timestamp ctxt = cycles_per_voting_period = c.cycles_per_voting_period; hard_gas_limit_per_operation = c.hard_gas_limit_per_operation; hard_gas_limit_per_block = c.hard_gas_limit_per_block; - proof_of_work_threshold; + proof_of_work_threshold = c.proof_of_work_threshold; minimal_stake = c.minimal_stake; vdf_difficulty = c.vdf_difficulty; seed_nonce_revelation_tip = c.seed_nonce_revelation_tip; -- GitLab From 3bcba87789de191562340c5ff8322aa7b2567bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Wed, 19 Apr 2023 17:07:58 +0100 Subject: [PATCH 3/3] Test/Tezt: Migrate from Mumbai --- tezt/lib_tezos/protocol.ml | 2 +- tezt/tests/main.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tezt/lib_tezos/protocol.ml b/tezt/lib_tezos/protocol.ml index 24a25d6abc5d..4b684c7586ff 100644 --- a/tezt/lib_tezos/protocol.ml +++ b/tezt/lib_tezos/protocol.ml @@ -178,7 +178,7 @@ let next_protocol = function | Alpha -> None let previous_protocol = function - | Alpha -> Some Mumbai + | Alpha -> Some Nairobi | Nairobi -> Some Mumbai | Mumbai -> None diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index e29d87f0d2be..7cdff9b50e13 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -82,7 +82,7 @@ let register_protocol_migration_tests () = ~from_protocol:migrate_to ~to_protocol:Demo ~loser_protocols:[migrate_from] ; - Sc_rollup.register_migration ~migrate_from:Protocol.Mumbai ~migrate_to + Sc_rollup.register_migration ~migrate_from:Protocol.Nairobi ~migrate_to (* Register tests that use [Protocol.register_test] and for which we rely on [?supports] to decide which protocols the tests should run on. -- GitLab