From f0b457a4b0a2f9eafe067e0c11ef27bba7cda717 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 28 Nov 2024 11:10:18 +0100 Subject: [PATCH 1/5] Proto: upgrade all_bakers_attest feature flag We need the activation level instead --- src/proto_alpha/lib_parameters/default_parameters.ml | 2 +- src/proto_alpha/lib_protocol/alpha_context.mli | 4 ++-- .../lib_protocol/constants_parametric_repr.ml | 12 +++++++----- .../lib_protocol/constants_parametric_repr.mli | 2 +- src/proto_alpha/lib_protocol/constants_storage.ml | 4 ++-- src/proto_alpha/lib_protocol/constants_storage.mli | 3 ++- src/proto_alpha/lib_protocol/raw_context.ml | 6 +++--- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 369848b78fd0..36b00fcdb03f 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -334,7 +334,7 @@ let constants_mainnet : Constants.Parametric.t = (* TODO: https://gitlab.com/tezos/tezos/-/issues/7553 Enable once we built performance confidance *) allow_tz4_delegate_enable = false; - all_bakers_attest_enable = false; + all_bakers_attest_activation_level = None; } let constants_sandbox = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index df2f28456d6a..dfa1ce5c0235 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -951,7 +951,7 @@ module Constants : sig direct_ticket_spending_enable : bool; aggregate_attestation : bool; allow_tz4_delegate_enable : bool; - all_bakers_attest_enable : bool; + all_bakers_attest_activation_level : Raw_level_repr.t option; } val encoding : t Data_encoding.t @@ -1091,7 +1091,7 @@ module Constants : sig val allow_tz4_delegate_enable : context -> bool - val all_bakers_attest_enable : context -> bool + val all_bakers_attest_activation_level : context -> Raw_level_repr.t option (** All constants: fixed and parametric *) type t = private {fixed : fixed; parametric : Parametric.t} diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index e105ec83b31a..333156716ddd 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -293,7 +293,7 @@ type t = { direct_ticket_spending_enable : bool; aggregate_attestation : bool; allow_tz4_delegate_enable : bool; - all_bakers_attest_enable : bool; + all_bakers_attest_activation_level : Raw_level_repr.t option; } let sc_rollup_encoding = @@ -604,7 +604,7 @@ let encoding = ( c.direct_ticket_spending_enable, c.aggregate_attestation, c.allow_tz4_delegate_enable, - c.all_bakers_attest_enable ) ) ) ) ) ) ) ) )) + c.all_bakers_attest_activation_level ) ) ) ) ) ) ) ) )) (fun ( ( ( consensus_rights_delay, blocks_preservation_cycles, delegate_parameters_activation_delay, @@ -649,7 +649,7 @@ let encoding = ( direct_ticket_spending_enable, aggregate_attestation, allow_tz4_delegate_enable, - all_bakers_attest_enable ) ) ) ) ) ) ) ) ) -> + all_bakers_attest_activation_level ) ) ) ) ) ) ) ) ) -> { consensus_rights_delay; blocks_preservation_cycles; @@ -696,7 +696,7 @@ let encoding = direct_ticket_spending_enable; aggregate_attestation; allow_tz4_delegate_enable; - all_bakers_attest_enable; + all_bakers_attest_activation_level; }) (merge_objs (merge_objs @@ -764,7 +764,9 @@ let encoding = (req "direct_ticket_spending_enable" bool) (req "aggregate_attestation" bool) (req "allow_tz4_delegate_enable" bool) - (req "all_bakers_attest_enable" bool)))))))))) + (opt + "all_bakers_attest_activation_level" + Raw_level_repr.encoding)))))))))) let update_sc_rollup_parameter ratio_i32 c = (* Constants remain small enough to fit in [int32] after update (as a diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index 60a1a50fbd15..4b0f95c8a5cc 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -230,7 +230,7 @@ type t = { (* attestation aggregation feature flag *) aggregate_attestation : bool; allow_tz4_delegate_enable : bool; - all_bakers_attest_enable : bool; + all_bakers_attest_activation_level : Raw_level_repr.t option; } 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 d765b1c2f2f5..15355ea275fd 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -299,5 +299,5 @@ let aggregate_attestation c = (Raw_context.constants c).aggregate_attestation let allow_tz4_delegate_enable c = (Raw_context.constants c).allow_tz4_delegate_enable -let all_bakers_attest_enable c = - (Raw_context.constants c).all_bakers_attest_enable +let all_bakers_attest_activation_level c = + (Raw_context.constants c).all_bakers_attest_activation_level diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 2de3bbe76632..be085fc30256 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -185,4 +185,5 @@ val slashable_deposits_period : Raw_context.t -> int (* attestation aggregation feature flag *) val aggregate_attestation : Raw_context.t -> bool -val all_bakers_attest_enable : Raw_context.t -> bool +val all_bakers_attest_activation_level : + Raw_context.t -> Raw_level_repr.t option diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index f42782d048f8..3d622aa2ef4a 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -1234,7 +1234,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = direct_ticket_spending_enable; aggregate_attestation; allow_tz4_delegate_enable; - all_bakers_attest_enable; + all_bakers_attest_activation_level; } : Previous.t) = c @@ -1286,7 +1286,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = direct_ticket_spending_enable; aggregate_attestation; allow_tz4_delegate_enable; - all_bakers_attest_enable; + all_bakers_attest_activation_level; } in let*! ctxt = add_constants ctxt constants in @@ -1578,7 +1578,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = direct_ticket_spending_enable; aggregate_attestation = false; allow_tz4_delegate_enable = false; - all_bakers_attest_enable = false; + all_bakers_attest_activation_level = None; } in let new_constants : Constants_parametric_repr.t option = -- GitLab From 0a2cb0c7856be492d5d5ab8e7f272a0dd957ff78 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 28 Nov 2024 11:20:08 +0100 Subject: [PATCH 2/5] Proto: add check_all_bakers_attest_at_level Abstract the level to use it like a feature flag --- src/proto_alpha/lib_protocol/delegate_sampler.ml | 5 +++++ src/proto_alpha/lib_protocol/delegate_sampler.mli | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.ml b/src/proto_alpha/lib_protocol/delegate_sampler.ml index c0cfac951e70..9b7da835fedd 100644 --- a/src/proto_alpha/lib_protocol/delegate_sampler.ml +++ b/src/proto_alpha/lib_protocol/delegate_sampler.ml @@ -141,6 +141,11 @@ module Random = struct return (c, pk) end +let check_all_bakers_attest_at_level ctxt level = + match Constants_storage.all_bakers_attest_activation_level ctxt with + | None -> false + | Some act_level -> Raw_level_repr.(level.Level_repr.level >= act_level) + let slot_owner c level slot = Random.owner c level (Slot_repr.to_int slot) let baking_rights_owner c (level : Level_repr.t) ~round = diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.mli b/src/proto_alpha/lib_protocol/delegate_sampler.mli index 218e63864f1e..e69a05b55769 100644 --- a/src/proto_alpha/lib_protocol/delegate_sampler.mli +++ b/src/proto_alpha/lib_protocol/delegate_sampler.mli @@ -78,6 +78,10 @@ val attesting_rights_count : Level_repr.t -> (Raw_context.t * int Signature.Public_key_hash.Map.t) tzresult Lwt.t +(** [check_all_bakers_attest_at_level ctxt level] checks that at the given + level, all bakers were allowed (and expected) to attest. *) +val check_all_bakers_attest_at_level : Raw_context.t -> Level_repr.t -> bool + module For_RPC : sig (** The baking power for a given delegate computed from its current stake. *) -- GitLab From f589dc11021b1779a7d1ddbb72c455f144958130 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 28 Nov 2024 11:26:02 +0100 Subject: [PATCH 3/5] Kaitai: update --- client-libs/kaitai-struct-files/files/alpha__constants.ksy | 5 ++++- .../files/alpha__constants__parametric.ksy | 5 ++++- client-libs/kaitai-struct-files/files/alpha__parameters.ksy | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client-libs/kaitai-struct-files/files/alpha__constants.ksy b/client-libs/kaitai-struct-files/files/alpha__constants.ksy index 57b37cddac91..d01762e187f9 100644 --- a/client-libs/kaitai-struct-files/files/alpha__constants.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__constants.ksy @@ -382,6 +382,9 @@ seq: - id: allow_tz4_delegate_enable type: u1 enum: bool -- id: all_bakers_attest_enable +- id: all_bakers_attest_activation_level_tag type: u1 enum: bool +- id: all_bakers_attest_activation_level + type: s4be + if: (all_bakers_attest_activation_level_tag == bool::true) diff --git a/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy b/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy index af2c8cac106f..784c6834f8ad 100644 --- a/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy @@ -354,6 +354,9 @@ seq: - id: allow_tz4_delegate_enable type: u1 enum: bool -- id: all_bakers_attest_enable +- id: all_bakers_attest_activation_level_tag type: u1 enum: bool +- id: all_bakers_attest_activation_level + type: s4be + if: (all_bakers_attest_activation_level_tag == bool::true) diff --git a/client-libs/kaitai-struct-files/files/alpha__parameters.ksy b/client-libs/kaitai-struct-files/files/alpha__parameters.ksy index 5b4ef02703a7..ea27edb246c9 100644 --- a/client-libs/kaitai-struct-files/files/alpha__parameters.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__parameters.ksy @@ -632,6 +632,9 @@ seq: - id: allow_tz4_delegate_enable type: u1 enum: bool -- id: all_bakers_attest_enable +- id: all_bakers_attest_activation_level_tag type: u1 enum: bool +- id: all_bakers_attest_activation_level + type: s4be + if: (all_bakers_attest_activation_level_tag == bool::true) -- GitLab From f3b5580fe1354ff04a1ed2244996a1fd3804516d Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 28 Nov 2024 11:35:14 +0100 Subject: [PATCH 4/5] Proto/test: update regressions --- ...lpha- (mode client) RPC regression tests- misc_protocol.out | 2 +- ...Alpha- (mode light) RPC regression tests- misc_protocol.out | 2 +- ...Alpha- (mode proxy) RPC regression tests- misc_protocol.out | 2 +- .../expected/weeklynet.ml/Alpha- weeklynet regression test.out | 2 +- tezt/tests/weeklynet_configs/alpha.json | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out index 4b8e30747e46..afabe372d346 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out @@ -81,7 +81,7 @@ "adaptive_issuance_activation_vote_enable": true, "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, - "allow_tz4_delegate_enable": true, "all_bakers_attest_enable": false } + "allow_tz4_delegate_enable": true } ./octez-client rpc get /chains/main/blocks/head/helpers/baking_rights [ { "level": 2, "delegate": "[PUBLIC_KEY_HASH]", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out index 604258e8de4d..de4cade34093 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out @@ -81,7 +81,7 @@ "adaptive_issuance_activation_vote_enable": true, "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, - "allow_tz4_delegate_enable": true, "all_bakers_attest_enable": false } + "allow_tz4_delegate_enable": true } ./octez-client --mode light rpc get /chains/main/blocks/head/helpers/baking_rights [ { "level": 2, "delegate": "[PUBLIC_KEY_HASH]", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out index 3254159df6e9..617f26d72c71 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out @@ -81,7 +81,7 @@ "adaptive_issuance_activation_vote_enable": true, "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, - "allow_tz4_delegate_enable": true, "all_bakers_attest_enable": false } + "allow_tz4_delegate_enable": true } ./octez-client --mode proxy rpc get /chains/main/blocks/head/helpers/baking_rights [ { "level": 2, "delegate": "[PUBLIC_KEY_HASH]", diff --git a/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out b/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out index a4289984e283..31033a4c506e 100644 --- a/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out +++ b/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out @@ -71,4 +71,4 @@ "adaptive_issuance_activation_vote_enable": true, "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, - "allow_tz4_delegate_enable": false, "all_bakers_attest_enable": false } + "allow_tz4_delegate_enable": false } diff --git a/tezt/tests/weeklynet_configs/alpha.json b/tezt/tests/weeklynet_configs/alpha.json index 84264f34cf49..6c23cb4d9bce 100644 --- a/tezt/tests/weeklynet_configs/alpha.json +++ b/tezt/tests/weeklynet_configs/alpha.json @@ -154,6 +154,5 @@ "adaptive_issuance_force_activation": false, "direct_ticket_spending_enable": false, "aggregate_attestation": false, - "allow_tz4_delegate_enable": false, - "all_bakers_attest_enable": false + "allow_tz4_delegate_enable": false } -- GitLab From 99695e183e776381e025fa29648b031b18d9cee8 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 28 Nov 2024 11:36:10 +0100 Subject: [PATCH 5/5] Proto/doc: update changelog --- docs/protocols/alpha.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 0a5dc83b8f46..c673a4b3ff39 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -81,7 +81,7 @@ Minor Changes - Added a feature flag which would allow tz4 (BLS) addresses as delegate and or as consensus keys. (MR :gl:`!15311`) -- Added a feature flag for allowing all bakers to attest. (MR :gl:`!15584`) +- Added a feature flag for allowing all bakers to attest. (MR :gl:`!15584`, :gl:`!15764`) Internal -------- -- GitLab