From 2d10e623de768a005afcc41c1646fd14ae31e57a Mon Sep 17 00:00:00 2001 From: mbourgoin Date: Tue, 16 Jul 2024 15:03:38 +0200 Subject: [PATCH 1/4] alpha: Add comments for automatic stabilisation --- src/proto_alpha/lib_protocol/init_storage.ml | 8 ++++---- src/proto_alpha/lib_protocol/raw_context.ml | 14 ++++++++++++-- src/proto_alpha/lib_protocol/raw_context.mli | 5 ++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index abc55eaac64c..cc54f4dd4ae3 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -195,11 +195,8 @@ let prepare_first_block chain_id ctxt ~typecheck_smart_contract let* ctxt = Sc_rollup_inbox_storage.init_inbox ~predecessor ctxt in let* ctxt = Adaptive_issuance_storage.init ctxt in return (ctxt, commitments_balance_updates @ bootstrap_balance_updates) + (* Start of Alpha stitching. Comment used for automatic snapshot *) | Alpha -> - (* TODO (#2704): possibly handle attestations for migration block (in bakers); - if that is done, do not set Storage.Tenderbake.First_level_of_protocol. - /!\ this storage is also use to add the smart rollup - inbox migration message. see `sc_rollup_inbox_storage`. *) let* ctxt = Storage.Tenderbake.First_level_of_protocol.update ctxt level in @@ -208,6 +205,8 @@ let prepare_first_block chain_id ctxt ~typecheck_smart_contract Sc_rollup_refutation_storage.migrate_clean_refutation_games ctxt in return (ctxt, []) + (* End of Alpha stitching. Comment used for automatic snapshot *) + (* Start of alpha predecessor stitching. Comment used for automatic snapshot *) | ParisC_020 (* Please update [next_protocol] and [previous_protocol] in [tezt/lib_tezos/protocol.ml] when you update this value. *) -> @@ -223,6 +222,7 @@ let prepare_first_block chain_id ctxt ~typecheck_smart_contract Sc_rollup_refutation_storage.migrate_clean_refutation_games ctxt in return (ctxt, []) + (* End of alpha predecessor stitching. Comment used for automatic snapshot *) in let* ctxt = List.fold_left_es patch_script ctxt Legacy_script_patches.addresses_to_patch diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 1f163fa64e77..ba82eef10392 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -881,7 +881,10 @@ let prepare ~level ~predecessor_timestamp ~timestamp ~adaptive_issuance_enable }; } -type previous_protocol = Genesis of Parameters_repr.t | Alpha | ParisC_020 +type previous_protocol = + | Genesis of Parameters_repr.t + | Alpha + | (* Alpha predecessor *) ParisC_020 (* Alpha predecessor *) let check_and_update_protocol_version ctxt = let open Lwt_result_syntax in @@ -898,7 +901,8 @@ let check_and_update_protocol_version ctxt = let+ param, ctxt = get_proto_param ctxt in (Genesis param, ctxt) else if Compare.String.(s = "alpha_current") then return (Alpha, ctxt) - else if Compare.String.(s = "paris_020") then return (ParisC_020, ctxt) + else if (* Alpha predecessor *) Compare.String.(s = "paris_020") then + return (ParisC_020, ctxt) (* Alpha predecessor *) else Lwt.return @@ storage_error (Incompatible_protocol_version s) in let*! ctxt = @@ -926,6 +930,7 @@ let[@warning "-32"] get_previous_protocol_constants ctxt = context." | Some constants -> return constants) +(* Start of code to remove at next automatic protocol snapshot *) let update_block_time_related_constants (c : Constants_parametric_repr.t) = let divide_period p = Period_repr.of_seconds_exn @@ -986,6 +991,7 @@ let update_cycle_eras ctxt level ~prev_blocks_per_cycle ~blocks_per_cycle in let*? new_cycle_eras = Level_repr.add_cycle_era new_cycle_era cycle_eras in set_cycle_eras ctxt new_cycle_eras +(* End of code to remove at next automatic protocol snapshot *) (* You should ensure that if the type `Constants_parametric_repr.t` is different from `Constants_parametric_previous_repr.t` or the value of these @@ -1017,6 +1023,7 @@ let prepare_first_block ~level ~timestamp _chain_id ctxt = let* ctxt = set_cycle_eras ctxt cycle_eras in let*! result = add_constants ctxt param.constants in return (result, None) + (* Start of Alpha stitching. Comment used for automatic snapshot *) | Alpha -> let module Previous = Constants_parametric_repr in let* c = get_constants ctxt in @@ -1300,6 +1307,8 @@ let prepare_first_block ~level ~timestamp _chain_id ctxt = it should be removed in beta when stabilising *) let*! c = get_previous_protocol_constants ctxt in return (ctxt, Some c) + (* End of Alpha stitching. Comment used for automatic snapshot *) + (* Start of alpha predecessor stitching. Comment used for automatic snapshot *) | ParisC_020 -> let*! c = get_previous_protocol_constants ctxt in @@ -1519,6 +1528,7 @@ let prepare_first_block ~level ~timestamp _chain_id ctxt = in let*! ctxt = add_constants ctxt constants in return (ctxt, Some c) + (* End of alpha predecessor stitching. Comment used for automatic snapshot *) in let+ ctxt = prepare diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index c3ccfeb337e3..af33f199b310 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -93,7 +93,10 @@ val prepare : Context.t -> t tzresult Lwt.t -type previous_protocol = Genesis of Parameters_repr.t | Alpha | ParisC_020 +type previous_protocol = + | Genesis of Parameters_repr.t + | Alpha + | (* Alpha predecessor *) ParisC_020 (* Alpha predecessor *) val prepare_first_block : level:int32 -> -- GitLab From ef59f0fcab89c0eb1e3fe9a134c0df659aab2896 Mon Sep 17 00:00:00 2001 From: mbourgoin Date: Tue, 16 Jul 2024 15:04:16 +0200 Subject: [PATCH 2/4] tezt/protocols: prepare for auto stabilisation --- tezt/lib_tezos/protocol.ml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tezt/lib_tezos/protocol.ml b/tezt/lib_tezos/protocol.ml index f8b1a22b24af..1cbb99b427ce 100644 --- a/tezt/lib_tezos/protocol.ml +++ b/tezt/lib_tezos/protocol.ml @@ -57,6 +57,7 @@ let tag protocol = String.lowercase_ascii (name protocol) let hash = function | Alpha -> "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK" | ParisC -> "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi" +(* DO NOT REMOVE, AUTOMATICALLY ADD STABILISED PROTOCOL HASH HERE *) let genesis_hash = "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im" @@ -321,7 +322,16 @@ let iter_on_supported_protocols ~title ~protocols ?(supports = Any_protocol) f = let add_to_test_parameters ?(additional_tags = fun _ -> []) protocol title tags uses = let uses = match uses with None -> [] | Some uses -> uses protocol in - ( name protocol ^ ": " ^ title, + (* To help automatic generation of regression files during stabilisation we ensure + protocol_name is always of at least size of "alpha" by adding '-' trailing + chars to it if needed *) + let protocol_name = + name protocol + ^ String.make + (max 0 (String.length (name Alpha) - String.length (name protocol))) + '-' + in + ( protocol_name ^ ": " ^ title, (tag protocol :: tags) @ additional_tags protocol, uses ) -- GitLab From 3c96743be5bbd087fa90d98fddfce4a38332eb02 Mon Sep 17 00:00:00 2001 From: mbourgoin Date: Thu, 4 Jul 2024 09:40:13 +0200 Subject: [PATCH 3/4] manifest: rename Alpha into Dev - to handle both proto_alpha and protocols in stabilization --- manifest/main.ml | 4 +-- manifest/product_client_libs.ml | 2 +- manifest/product_octez.ml | 55 ++++++++++++++++----------------- manifest/product_octez.mli | 2 +- scripts/link_protocol.sh | 2 +- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index cccbf3a0dbed..d67806a132c0 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -161,7 +161,7 @@ let () = let () = let write_protocol fmt protocol = match Protocol.number protocol with - | Alpha | V _ -> Format.fprintf fmt "%s\n" (Protocol.name_dash protocol) + | Dev | V _ -> Format.fprintf fmt "%s\n" (Protocol.name_dash protocol) | Other -> () in write "script-inputs/active_protocol_versions" @@ fun fmt -> @@ -171,7 +171,7 @@ let () = let () = let write_protocol fmt protocol = match Protocol.number protocol with - | Alpha | V _ -> Format.fprintf fmt "%s\n" (Protocol.short_hash protocol) + | Dev | V _ -> Format.fprintf fmt "%s\n" (Protocol.short_hash protocol) | Other -> () in write "script-inputs/active_protocol_versions_without_number" @@ fun fmt -> diff --git a/manifest/product_client_libs.ml b/manifest/product_client_libs.ml index 510d50258b73..eb972b1d4e42 100644 --- a/manifest/product_client_libs.ml +++ b/manifest/product_client_libs.ml @@ -89,7 +89,7 @@ let _octez_codec_kaitai = (fun protocol -> let link = match Protocol.number protocol with - | Alpha -> true + | Dev -> true | V number -> number >= 005 | Other -> false in diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index 0551a82aa444..a9cc04a3f257 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -4869,7 +4869,7 @@ let _octez_scoru_wasm_fast_tests = (* PROTOCOL PACKAGES *) module Protocol : sig - type number = Alpha | V of int | Other + type number = Dev | V of int | Other type status = Active | Frozen | Overridden | Not_mainnet @@ -4941,13 +4941,13 @@ module Protocol : sig val all_optionally : (t -> target option) list -> target list end = struct - type number = Alpha | V of int | Other + type number = Dev | V of int | Other module Name : sig type t - (** [alpha] is a protocol name with protocol number [Alpha] *) - val alpha : t + (** [dev] is a named protocol name with protocol number [Dev] *) + val dev : string -> t (** [v name num] constuct a protocol name with protocol number [V num] *) val v : string -> int -> t @@ -4987,7 +4987,7 @@ end = struct name) ; let make_full_name sep name = match number with - | Alpha | Other -> name + | Dev | Other -> name | V number -> sf "%03d%c%s" number sep name in let name_dash = make_full_name '-' name in @@ -4998,7 +4998,7 @@ end = struct let v name number = make name (V number) - let alpha = make "alpha" Alpha + let dev name = make name Dev let other name = make name Other @@ -5130,10 +5130,10 @@ end = struct let test_helpers_exn p = mandatory "test_helpers" p p.test_helpers - (* N as in "protocol number in the Alpha family". *) + (* N as in "protocol number in the Dev family". *) module N = struct (* This function is asymmetrical on purpose: we don't want to compare - numbers with [Alpha] because such comparisons would break when snapshotting. + numbers with [Dev] because such comparisons would break when snapshotting. So the left-hand side is the number of the protocol being built, but the right-hand side is an integer. @@ -5145,7 +5145,7 @@ end = struct meaning the opposite? *) let compare_asymmetric a b = match a with - | Alpha -> 1 + | Dev -> 1 | V a -> Int.compare a b | Other -> invalid_arg "cannot use N.compare_asymmetric on Other protocols" @@ -5605,10 +5605,10 @@ end = struct in let disable_warnings = match number with - (* [Other] and [Alpha] protocols can be edited and should be + (* [Other] and [Dev] protocols can be edited and should be fixed whenever a warning that we care about triggers. We only want to disable a limited set of warnings *) - | Other | Alpha -> [] + | Other | Dev -> [] (* [V _] protocols can't be edited to accomodate warnings, we need to disable warnings instead. *) | V _ as number -> if N.(number >= 014) then [] @@ -5677,7 +5677,7 @@ include Tezos_protocol_environment.V%d.Make(Name)() sf "Tezos/Protocol: %s economic-protocol definition" name_underscore - | Alpha | V _ -> "Tezos/Protocol: economic-protocol definition") + | Dev | V _ -> "Tezos/Protocol: economic-protocol definition") ~modules:["Protocol"; sf "Tezos_protocol_%s" name_underscore] ~flags:(Flags.standard ~nopervasives:true ~disable_warnings ()) ~deps: @@ -5800,7 +5800,7 @@ let hash = Protocol.hash "Tezos/Protocol: %s (economic-protocol definition \ parameterized by its environment implementation)" name_underscore - | Alpha | V _ -> + | Dev | V _ -> "Tezos/Protocol: economic-protocol definition parameterized by \ its environment implementation") ~modules:["Functor"] @@ -5850,7 +5850,7 @@ let hash = Protocol.hash "Tezos/Protocol: %s (economic-protocol definition, embedded \ in `octez-node`)" name_underscore - | Alpha | V _ -> + | Dev | V _ -> "Tezos/Protocol: economic-protocol definition, embedded in \ `octez-node`") ~modules:["Registerer"] @@ -5862,7 +5862,7 @@ let hash = Protocol.hash (* Contrary to client libs and protocol plugin registerers, embedded protocols are useful even when the protocol was overridden. *) Released - | V _, Not_mainnet | (Alpha | Other), _ -> + | V _, Not_mainnet | (Dev | Other), _ -> (* Ideally we would not release the opam packages but this would require removing the dependencies when releasing, both from .opam files and dune files. *) @@ -5980,7 +5980,7 @@ let hash = Protocol.hash match (number, status) with | V _, (Active | Frozen) -> Released | V _, (Overridden | Not_mainnet) -> Unreleased - | Alpha, _ -> Experimental + | Dev, _ -> Experimental | Other, _ -> Unreleased in let optional_library_release_status = @@ -5989,7 +5989,7 @@ let hash = Protocol.hash (* Put explicit dependency in meta-package octez.opam to force the optional dependency to be installed. *) Released - | V _, (Overridden | Not_mainnet) | (Alpha | Other), _ -> + | V _, (Overridden | Not_mainnet) | (Dev | Other), _ -> (* Ideally we would not release the opam packages but this would require removing the dependencies when releasing, both from .opam files and dune files. *) @@ -7007,7 +7007,7 @@ let hash = Protocol.hash let _020_PsParisC = active (Name.v "PsParisC" 020) - let alpha = active Name.alpha + let alpha = active (Name.dev "alpha") let all = List.rev !all_rev @@ -7584,7 +7584,7 @@ let _octez_node = that results in inconsistent hashes. Once this bug is fixed, this exception can be removed. *) false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> (* Other protocols are optional. *) true in @@ -7650,8 +7650,7 @@ let _octez_client = let is_optional = match (Protocol.status protocol, Protocol.number protocol) with | Active, V _ -> false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> - true + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> true in let targets = List.filter_map @@ -7745,7 +7744,7 @@ let _octez_codec = (fun protocol -> let link = match Protocol.number protocol with - | Alpha -> true + | Dev -> true | V number -> number >= 005 | Other -> false in @@ -7972,7 +7971,7 @@ let _octez_dal_node = that results in inconsistent hashes. Once this bug is fixed, this exception can be removed. *) false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> (* Other protocols are optional. *) true in @@ -8036,7 +8035,7 @@ let _octez_dac_node = that results in inconsistent hashes. Once this bug is fixed, this exception can be removed. *) false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> (* Other protocols are optional. *) true in @@ -8089,7 +8088,7 @@ let _octez_dac_client = that results in inconsistent hashes. Once this bug is fixed, this exception can be removed. *) false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> (* Other protocols are optional. *) true in @@ -8126,8 +8125,7 @@ let _octez_smart_rollup_node = let is_optional = match (Protocol.status protocol, Protocol.number protocol) with | Active, V _ -> false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> - true + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> true in let targets = List.filter_map Fun.id [Protocol.octez_sc_rollup_node protocol] @@ -8164,8 +8162,7 @@ let _octez_smart_rollup_node_lib_tests = let is_optional = match (Protocol.status protocol, Protocol.number protocol) with | Active, V _ -> false - | (Frozen | Overridden | Not_mainnet), _ | Active, (Alpha | Other) -> - true + | (Frozen | Overridden | Not_mainnet), _ | Active, (Dev | Other) -> true in let targets = List.filter_map Fun.id [Protocol.octez_sc_rollup_node protocol] diff --git a/manifest/product_octez.mli b/manifest/product_octez.mli index 5140658bc8f3..0e02bdf3e263 100644 --- a/manifest/product_octez.mli +++ b/manifest/product_octez.mli @@ -84,7 +84,7 @@ val tezt_wrapper : Manifest.target module Protocol : sig type t - type number = Alpha | V of int | Other + type number = Dev | V of int | Other (** Status of the protocol on Mainnet. diff --git a/scripts/link_protocol.sh b/scripts/link_protocol.sh index f19778463e05..24c6ca394e22 100755 --- a/scripts/link_protocol.sh +++ b/scripts/link_protocol.sh @@ -25,7 +25,7 @@ if [ -z "${new_hash}" ]; then exit 1 fi -sed "/let alpha = active Name.alpha/i \ let _${new_version}_${new_hash} = active (Name.v \"${new_hash}\" ${new_version})\n" -i manifest/product_octez.ml +sed "/let alpha = active (Name.dev \"alpha\")/i \ let _${new_version}_${new_hash} = active (Name.v \"${new_hash}\" ${new_version})\n" -i manifest/product_octez.ml # Generate everything from the manifest. echo "Updating manifest: generate dune and opam files..." -- GitLab From 25bfe1943ccd822c4ebbfa60d04a8404c476aac6 Mon Sep 17 00:00:00 2001 From: mbourgoin Date: Tue, 16 Jul 2024 17:40:30 +0200 Subject: [PATCH 4/4] .gitignore: ignore .old files used temporarily during automatic snapshotting --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e6bd913f1944..74356d86b8fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ - ## /!\ /!\ Update .dockerignore accordingly /!\ /!\ .DS_Store __pycache__ *.pyc +# temporary files created during snapshotting +*.old + **/_build /_build_rust /_opam -- GitLab