From f9dac1f83168f07538a61c31472bb6d58954ce5a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 09:32:08 +0200 Subject: [PATCH 01/13] alpha: rename endorsement in raw_context --- src/proto_alpha/lib_protocol/alpha_context.ml | 4 +- src/proto_alpha/lib_protocol/apply.ml | 10 +-- src/proto_alpha/lib_protocol/main.ml | 6 +- src/proto_alpha/lib_protocol/raw_context.ml | 88 +++++++++---------- src/proto_alpha/lib_protocol/raw_context.mli | 42 ++++----- src/proto_alpha/lib_protocol/validate.ml | 4 +- 6 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index c957640ea0ef..b63316da24fa 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -566,12 +566,12 @@ module Consensus = struct let load_endorsement_branch ctxt = Storage.Tenderbake.Attestation_branch.find ctxt >>=? function | Some endorsement_branch -> - Raw_context.Consensus.set_endorsement_branch ctxt endorsement_branch + Raw_context.Consensus.set_attestation_branch ctxt endorsement_branch |> return | None -> return ctxt let store_endorsement_branch ctxt branch = - let ctxt = set_endorsement_branch ctxt branch in + let ctxt = set_attestation_branch ctxt branch in Storage.Tenderbake.Attestation_branch.add ctxt branch end diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index dc62bde0045d..5c90bfb2f50e 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -2070,10 +2070,10 @@ let record_endorsement ctxt (mode : mode) (content : consensus_content) : match mode with | Application _ | Full_construction _ -> let*? consensus_key, power = - find_in_slot_map content (Consensus.allowed_endorsements ctxt) + find_in_slot_map content (Consensus.allowed_attestations ctxt) in let*? ctxt = - Consensus.record_endorsement ctxt ~initial_slot:content.slot ~power + Consensus.record_attestation ctxt ~initial_slot:content.slot ~power in return (ctxt, mk_endorsement_result consensus_key power) | Partial_construction _ -> @@ -2501,14 +2501,14 @@ let are_endorsements_required ctxt ~level = let record_endorsing_participation ctxt = let open Lwt_result_syntax in let*? validators = - match Consensus.allowed_endorsements ctxt with + match Consensus.allowed_attestations ctxt with | Some x -> ok x | None -> error (Consensus.Slot_map_not_found {loc = __LOC__}) in Slot.Map.fold_es (fun initial_slot ((consensus_pk : Consensus_key.pk), power) ctxt -> let participation = - if Slot.Set.mem initial_slot (Consensus.endorsements_seen ctxt) then + if Slot.Set.mem initial_slot (Consensus.attestations_seen ctxt) then Delegate.Participated else Delegate.Didn't_participate in @@ -2699,7 +2699,7 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash ~(payload_producer : Consensus_key.t) = let open Lwt_result_syntax in let level = Level.current ctxt in - let attestation_power = Consensus.current_endorsement_power ctxt in + let attestation_power = Consensus.current_attestation_power ctxt in let* required_endorsements = are_endorsements_required ctxt ~level:level.level in diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 918ba6539849..60800a86647d 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -131,7 +131,7 @@ type mode = let init_consensus_rights_for_block ctxt mode ~predecessor_level = let open Lwt_result_syntax in let open Alpha_context in - let* ctxt, endorsements_map = + let* ctxt, attestations_map = Baking.endorsing_rights_by_first_slot ctxt predecessor_level in let*? can_contain_preattestations = @@ -158,7 +158,7 @@ let init_consensus_rights_for_block ctxt mode ~predecessor_level = let ctxt = Consensus.initialize_consensus_operation ctxt - ~allowed_endorsements:(Some endorsements_map) + ~allowed_attestations:(Some attestations_map) ~allowed_preattestations in return ctxt @@ -180,7 +180,7 @@ let init_consensus_rights_for_mempool ctxt ~predecessor_level = let ctxt = Consensus.initialize_consensus_operation ctxt - ~allowed_endorsements:None + ~allowed_attestations:None ~allowed_preattestations:None in (* However, we want to ensure that the cycle rights are loaded in diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index f3acf3ce588d..9bcff090c5f3 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -85,10 +85,10 @@ module Raw_consensus = struct this delegate. *) type t = { - current_endorsement_power : int; - (** Number of endorsement slots recorded for the current block. *) - allowed_endorsements : (consensus_pk * int) Slot_repr.Map.t option; - (** Endorsements rights for the current block. Only an endorsement + current_attestation_power : int; + (** Number of attestation slots recorded for the current block. *) + allowed_attestations : (consensus_pk * int) Slot_repr.Map.t option; + (** Attestations rights for the current block. Only an attestation for the lowest slot in the block can be recorded. The map associates to each initial slot the [pkh] associated to this slot with its power. This is [None] only in mempool mode. *) @@ -100,11 +100,11 @@ module Raw_consensus = struct application mode when there is no locked round (so the block cannot contain any preattestations). *) forbidden_delegates : Signature.Public_key_hash.Set.t; - (** Delegates that are not allowed to bake or endorse blocks; i.e., + (** Delegates that are not allowed to bake or attest blocks; i.e., delegates which have zero frozen deposit due to a previous slashing. *) - endorsements_seen : Slot_repr.Set.t; - (** Record the endorsements already seen. Only initial slots are indexed. *) + attestations_seen : Slot_repr.Set.t; + (** Record the attestations already seen. Only initial slots are indexed. *) preattestations_seen : Slot_repr.Set.t; (** Record the preattestations already seen. Only initial slots are indexed. *) @@ -113,30 +113,30 @@ module Raw_consensus = struct preattestations_quorum_round : Round_repr.t option; (** in block construction mode, record the round of preattestations included in a block. *) - endorsement_branch : (Block_hash.t * Block_payload_hash.t) option; + attestation_branch : (Block_hash.t * Block_payload_hash.t) option; } (** Invariant: - - [slot \in endorsements_seen => Int_map.mem slot allowed_endorsements] + - [slot \in attestations_seen => Int_map.mem slot allowed_attestations] - [slot \in preattestations_seen => Int_map.mem slot allowed_preattestations] - - [ |endorsements_seen| > 0 => |included endorsements| > 0] + - [ |attestations_seen| > 0 => |included attestations| > 0] *) let empty : t = { - current_endorsement_power = 0; - allowed_endorsements = Some Slot_repr.Map.empty; + current_attestation_power = 0; + allowed_attestations = Some Slot_repr.Map.empty; allowed_preattestations = Some Slot_repr.Map.empty; forbidden_delegates = Signature.Public_key_hash.Set.empty; - endorsements_seen = Slot_repr.Set.empty; + attestations_seen = Slot_repr.Set.empty; preattestations_seen = Slot_repr.Set.empty; locked_round_evidence = None; preattestations_quorum_round = None; - endorsement_branch = None; + attestation_branch = None; } type error += Double_inclusion_of_consensus_operation @@ -154,15 +154,15 @@ module Raw_consensus = struct | Double_inclusion_of_consensus_operation -> Some () | _ -> None) (fun () -> Double_inclusion_of_consensus_operation) - let record_endorsement t ~initial_slot ~power = + let record_attestation t ~initial_slot ~power = error_when - (Slot_repr.Set.mem initial_slot t.endorsements_seen) + (Slot_repr.Set.mem initial_slot t.attestations_seen) Double_inclusion_of_consensus_operation >|? fun () -> { t with - current_endorsement_power = t.current_endorsement_power + power; - endorsements_seen = Slot_repr.Set.add initial_slot t.endorsements_seen; + current_attestation_power = t.current_attestation_power + power; + attestations_seen = Slot_repr.Set.add initial_slot t.attestations_seen; } let record_preattestation ~initial_slot ~power round t = @@ -206,16 +206,16 @@ module Raw_consensus = struct t | None -> {t with preattestations_quorum_round = Some round} - let initialize_with_endorsements_and_preattestations ~allowed_endorsements + let initialize_with_attestations_and_preattestations ~allowed_attestations ~allowed_preattestations t = - {t with allowed_endorsements; allowed_preattestations} + {t with allowed_attestations; allowed_preattestations} let locked_round_evidence t = t.locked_round_evidence - let endorsement_branch t = t.endorsement_branch + let attestation_branch t = t.attestation_branch - let set_endorsement_branch t endorsement_branch = - {t with endorsement_branch = Some endorsement_branch} + let set_attestation_branch t attestation_branch = + {t with attestation_branch = Some attestation_branch} end type dal_committee = { @@ -1418,7 +1418,7 @@ module type CONSENSUS = sig type consensus_pk - val allowed_endorsements : t -> (consensus_pk * int) slot_map option + val allowed_attestations : t -> (consensus_pk * int) slot_map option val allowed_preattestations : t -> (consensus_pk * int) slot_map option @@ -1426,15 +1426,15 @@ module type CONSENSUS = sig type error += Slot_map_not_found of {loc : string} - val current_endorsement_power : t -> int + val current_attestation_power : t -> int val initialize_consensus_operation : t -> - allowed_endorsements:(consensus_pk * int) slot_map option -> + allowed_attestations:(consensus_pk * int) slot_map option -> allowed_preattestations:(consensus_pk * int) slot_map option -> t - val record_endorsement : t -> initial_slot:slot -> power:int -> t tzresult + val record_attestation : t -> initial_slot:slot -> power:int -> t tzresult val record_preattestation : t -> initial_slot:slot -> power:int -> round -> t tzresult @@ -1443,7 +1443,7 @@ module type CONSENSUS = sig val set_forbidden_delegates : t -> Signature.Public_key_hash.Set.t -> t - val endorsements_seen : t -> slot_set + val attestations_seen : t -> slot_set val get_preattestations_quorum_round : t -> round option @@ -1451,9 +1451,9 @@ module type CONSENSUS = sig val locked_round_evidence : t -> (round * int) option - val set_endorsement_branch : t -> Block_hash.t * Block_payload_hash.t -> t + val set_attestation_branch : t -> Block_hash.t * Block_payload_hash.t -> t - val endorsement_branch : t -> (Block_hash.t * Block_payload_hash.t) option + val attestation_branch : t -> (Block_hash.t * Block_payload_hash.t) option end module Consensus : @@ -1471,8 +1471,8 @@ module Consensus : f ctxt.back.consensus >|? fun consensus -> {ctxt with back = {ctxt.back with consensus}} - let[@inline] allowed_endorsements ctxt = - ctxt.back.consensus.allowed_endorsements + let[@inline] allowed_attestations ctxt = + ctxt.back.consensus.allowed_attestations let[@inline] allowed_preattestations ctxt = ctxt.back.consensus.allowed_preattestations @@ -1483,8 +1483,8 @@ module Consensus : let[@inline] set_forbidden_delegates ctxt delegates = update_consensus_with ctxt (Raw_consensus.set_forbidden_delegates delegates) - let[@inline] current_endorsement_power ctxt = - ctxt.back.consensus.current_endorsement_power + let[@inline] current_attestation_power ctxt = + ctxt.back.consensus.current_attestation_power let[@inline] get_preattestations_quorum_round ctxt = ctxt.back.consensus.preattestations_quorum_round @@ -1492,12 +1492,12 @@ module Consensus : let[@inline] locked_round_evidence ctxt = Raw_consensus.locked_round_evidence ctxt.back.consensus - let[@inline] initialize_consensus_operation ctxt ~allowed_endorsements + let[@inline] initialize_consensus_operation ctxt ~allowed_attestations ~allowed_preattestations = update_consensus_with ctxt - (Raw_consensus.initialize_with_endorsements_and_preattestations - ~allowed_endorsements + (Raw_consensus.initialize_with_attestations_and_preattestations + ~allowed_attestations ~allowed_preattestations) let[@inline] record_preattestation ctxt ~initial_slot ~power round = @@ -1505,27 +1505,27 @@ module Consensus : ctxt (Raw_consensus.record_preattestation ~initial_slot ~power round) - let[@inline] record_endorsement ctxt ~initial_slot ~power = + let[@inline] record_attestation ctxt ~initial_slot ~power = update_consensus_with_tzresult ctxt - (Raw_consensus.record_endorsement ~initial_slot ~power) + (Raw_consensus.record_attestation ~initial_slot ~power) let[@inline] forbid_delegate ctxt delegate = update_consensus_with ctxt (Raw_consensus.forbid_delegate delegate) - let[@inline] endorsements_seen ctxt = ctxt.back.consensus.endorsements_seen + let[@inline] attestations_seen ctxt = ctxt.back.consensus.attestations_seen let[@inline] set_preattestations_quorum_round ctxt round = update_consensus_with ctxt (Raw_consensus.set_preattestations_quorum_round round) - let[@inline] endorsement_branch ctxt = - Raw_consensus.endorsement_branch ctxt.back.consensus + let[@inline] attestation_branch ctxt = + Raw_consensus.attestation_branch ctxt.back.consensus - let[@inline] set_endorsement_branch ctxt branch = + let[@inline] set_attestation_branch ctxt branch = update_consensus_with ctxt (fun ctxt -> - Raw_consensus.set_endorsement_branch ctxt branch) + Raw_consensus.set_attestation_branch ctxt branch) type error += Slot_map_not_found of {loc : string} diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 9dffd3b57ccc..a0bd4770c9e0 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -321,44 +321,44 @@ module type CONSENSUS = sig type consensus_pk - (** Returns a map where each endorser's pkh is associated to the - list of its endorsing slots (in decreasing order) for a given + (** Returns a map where each attester's pkh is associated to the + list of its attesting slots (in decreasing order) for a given level. *) - val allowed_endorsements : t -> (consensus_pk * int) slot_map option + val allowed_attestations : t -> (consensus_pk * int) slot_map option - (** Returns a map where each endorser's pkh is associated to the - list of its endorsing slots (in decreasing order) for a given + (** Returns a map where each attester's pkh is associated to the + list of its attesting slots (in decreasing order) for a given level. *) val allowed_preattestations : t -> (consensus_pk * int) slot_map option (** Returns the set of delegates that are not allowed to bake or - endorse blocks; i.e., delegates which have zero frozen deposit + attest blocks; i.e., delegates which have zero frozen deposit due to a previous slashing. *) val forbidden_delegates : t -> Signature.Public_key_hash.Set.t (** Missing pre-computed map by first slot. This error should not happen. *) type error += Slot_map_not_found of {loc : string} - (** [endorsement power ctx] returns the endorsement power of the + (** [attestation power ctx] returns the attestation power of the current block. *) - val current_endorsement_power : t -> int + val current_attestation_power : t -> int - (** Initializes the map of allowed endorsements and preattestations, - this function must be called only once and before applying - any consensus operation. *) + (** Initializes the map of allowed attestations and preattestations, this + function must be called only once and before applying any consensus + operation. *) val initialize_consensus_operation : t -> - allowed_endorsements:(consensus_pk * int) slot_map option -> + allowed_attestations:(consensus_pk * int) slot_map option -> allowed_preattestations:(consensus_pk * int) slot_map option -> t - (** [record_endorsement ctx ~initial_slot ~power] records an - endorsement for the current block. + (** [record_attestation ctx ~initial_slot ~power] records an + attestation for the current block. - The endorsement should be valid in the sense that - [Int_map.find_opt initial_slot allowed_endorsement ctx = Some + The attestation should be valid in the sense that + [Int_map.find_opt initial_slot allowed_attestation ctx = Some (pkh, power)]. *) - val record_endorsement : t -> initial_slot:slot -> power:int -> t tzresult + val record_attestation : t -> initial_slot:slot -> power:int -> t tzresult (** [record_preattestation ctx ~initial_slot ~power round payload_hash power] records a preattestation for a proposal at @@ -372,14 +372,14 @@ module type CONSENSUS = sig (** [forbid_delegate ctx delegate] adds [delegate] to the set of forbidden delegates, which prevents this delegate from baking or - endorsing. *) + attesting. *) val forbid_delegate : t -> Signature.Public_key_hash.t -> t (** [set_forbidden_delegate ctx delegates] sets [delegates] as the current forbidden delegates. *) val set_forbidden_delegates : t -> Signature.Public_key_hash.Set.t -> t - val endorsements_seen : t -> slot_set + val attestations_seen : t -> slot_set (** [get_preattestations_quorum_round ctx] returns [None] if no preattestation are included in the current block. Otherwise, @@ -398,9 +398,9 @@ module type CONSENSUS = sig preattestations as well as their power. *) val locked_round_evidence : t -> (round * int) option - val set_endorsement_branch : t -> Block_hash.t * Block_payload_hash.t -> t + val set_attestation_branch : t -> Block_hash.t * Block_payload_hash.t -> t - val endorsement_branch : t -> (Block_hash.t * Block_payload_hash.t) option + val attestation_branch : t -> (Block_hash.t * Block_payload_hash.t) option end module Consensus : diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index 20c3d321be25..c9c366d1938b 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -38,7 +38,7 @@ let init_consensus_info ctxt (predecessor_level, predecessor_round) = predecessor_level; predecessor_round; preattestation_slot_map = Consensus.allowed_preattestations ctxt; - endorsement_slot_map = Consensus.allowed_endorsements ctxt; + endorsement_slot_map = Consensus.allowed_attestations ctxt; } (** Map used to detect consensus operation conflicts. Each delegate @@ -693,7 +693,7 @@ module Consensus = struct {level; round; block_payload_hash = bph; slot} = let open Lwt_result_syntax in let*? expected_payload_hash = - match Consensus.endorsement_branch vi.ctxt with + match Consensus.attestation_branch vi.ctxt with | Some ((_branch : Block_hash.t), payload_hash) -> ok payload_hash | None -> (* [Consensus.endorsement_branch] only returns [None] when the -- GitLab From fefa710900a2a981c801bfed126604de9c43d0c6 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 09:52:51 +0200 Subject: [PATCH 02/13] alpha: rename endorsing in constants --- docs/protocols/alpha.rst | 7 ++++--- src/proto_alpha/lib_protocol/constants_parametric_repr.ml | 2 +- ...- (mode client) RPC regression tests- misc_protocol.out | 2 +- ...a- (mode light) RPC regression tests- misc_protocol.out | 2 +- ...a- (mode proxy) RPC regression tests- misc_protocol.out | 2 +- ...erver_data_dir) RPC regression tests- misc_protocol.out | 2 +- ...oxy_server_rpc) RPC regression tests- misc_protocol.out | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 23cbf54ae870..cd04221c7882 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -98,9 +98,10 @@ Breaking Changes - Operation ``Set_deposits_limit`` removed. (MR :gl:`!8831`) -- Protocol parameter ``ratio_of_frozen_deposits_slashed_per_double_endorsement`` is - converted from the ratio ``1/5`` into the percentage ``50%`` and renamed to - ``percentage_of_frozen_deposits_slashed_per_double_endorsement``. (MR :gl:`!8753`) +- Protocol parameter ``ratio_of_frozen_deposits_slashed_per_double_endorsement`` + is converted from the ratio ``1/5`` into the percentage ``50%`` and renamed to + ``percentage_of_frozen_deposits_slashed_per_double_attestation``. (MRs + :gl:`!8753`, :gl:`!9440`) - Protocol parameter ``double_baking_punishment`` is converted from a fixed value of ``640tz`` into the percentage ``11%`` and renamed to diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index ca7f5215398c..77e2a3b36291 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -606,7 +606,7 @@ let encoding = "percentage_of_frozen_deposits_slashed_per_double_baking" uint8) (req - "percentage_of_frozen_deposits_slashed_per_double_endorsement" + "percentage_of_frozen_deposits_slashed_per_double_attestation" uint8) (opt "testnet_dictator" Signature.Public_key_hash.encoding) (opt "initial_seed" State_hash.encoding)) 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 99dd326e8b4d..aae24f2f3a14 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 @@ -31,7 +31,7 @@ "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, "max_slashing_period": 2, "limit_of_delegation_over_baking": 19, "percentage_of_frozen_deposits_slashed_per_double_baking": 10, - "percentage_of_frozen_deposits_slashed_per_double_endorsement": 50, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 50, "cache_script_size": 100000000, "cache_stake_distribution_cycles": 8, "cache_sampler_state_cycles": 8, "dal_parametric": 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 2f0ab0e5d4fc..ea81170aa61f 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 @@ -31,7 +31,7 @@ "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, "max_slashing_period": 2, "limit_of_delegation_over_baking": 19, "percentage_of_frozen_deposits_slashed_per_double_baking": 10, - "percentage_of_frozen_deposits_slashed_per_double_endorsement": 50, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 50, "cache_script_size": 100000000, "cache_stake_distribution_cycles": 8, "cache_sampler_state_cycles": 8, "dal_parametric": 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 936809993542..bc49b62a12cd 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 @@ -31,7 +31,7 @@ "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, "max_slashing_period": 2, "limit_of_delegation_over_baking": 19, "percentage_of_frozen_deposits_slashed_per_double_baking": 10, - "percentage_of_frozen_deposits_slashed_per_double_endorsement": 50, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 50, "cache_script_size": 100000000, "cache_stake_distribution_cycles": 8, "cache_sampler_state_cycles": 8, "dal_parametric": diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out index 5caf83815b5c..e1a295c01167 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out @@ -31,7 +31,7 @@ "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, "max_slashing_period": 2, "limit_of_delegation_over_baking": 19, "percentage_of_frozen_deposits_slashed_per_double_baking": 10, - "percentage_of_frozen_deposits_slashed_per_double_endorsement": 50, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 50, "cache_script_size": 100000000, "cache_stake_distribution_cycles": 8, "cache_sampler_state_cycles": 8, "dal_parametric": diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out index 5caf83815b5c..e1a295c01167 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out @@ -31,7 +31,7 @@ "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, "max_slashing_period": 2, "limit_of_delegation_over_baking": 19, "percentage_of_frozen_deposits_slashed_per_double_baking": 10, - "percentage_of_frozen_deposits_slashed_per_double_endorsement": 50, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 50, "cache_script_size": 100000000, "cache_stake_distribution_cycles": 8, "cache_sampler_state_cycles": 8, "dal_parametric": -- GitLab From 7c996b3c1bc9d6a8a9696f7c2c74a0c6d8de1564 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 09:59:51 +0200 Subject: [PATCH 03/13] alpha: rename endorsing in delegate_missed_attestation_storage --- src/proto_alpha/lib_protocol/TEZOS_PROTOCOL | 2 +- src/proto_alpha/lib_protocol/alpha_context.ml | 2 +- .../lib_protocol/alpha_context.mli | 8 ++-- src/proto_alpha/lib_protocol/apply.ml | 4 +- .../lib_protocol/delegate_cycles.ml | 4 +- ...> delegate_missed_attestations_storage.ml} | 40 +++++++++---------- ... delegate_missed_attestations_storage.mli} | 22 +++++----- .../lib_protocol/delegate_services.ml | 8 ++-- src/proto_alpha/lib_protocol/dune | 14 +++---- .../consensus/test_participation.ml | 2 +- 10 files changed, 53 insertions(+), 53 deletions(-) rename src/proto_alpha/lib_protocol/{delegate_missed_endorsements_storage.ml => delegate_missed_attestations_storage.ml} (90%) rename src/proto_alpha/lib_protocol/{delegate_missed_endorsements_storage.mli => delegate_missed_attestations_storage.mli} (88%) diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index e7c5106560a7..5cf3bd3306f7 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -151,7 +151,7 @@ "Delegate_storage", "Delegate_sampler", "Delegate_rewards", - "Delegate_missed_endorsements_storage", + "Delegate_missed_attestations_storage", "Delegate_slashed_deposits_storage", "Delegate_cycles", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index b63316da24fa..ebffd383df83 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -485,7 +485,7 @@ module Consensus_key = Delegate_consensus_key module Delegate = struct include Delegate_storage - include Delegate_missed_endorsements_storage + include Delegate_missed_attestations_storage include Delegate_slashed_deposits_storage include Delegate_cycles diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 2f59ee6e28ad..8e4717198e89 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2097,7 +2097,7 @@ module Consensus_key : sig end (** This module re-exports definitions from {!Deposits_repr}, {!Delegate_storage}, - {!Delegate_consensus_key}, {!Delegate_missed_endorsements_storage}, + {!Delegate_consensus_key}, {!Delegate_missed_attestations_storage}, {!Delegate_slashed_deposits_storage}, {!Delegate_cycles}, {!Delegate_rewards}. *) module Delegate : sig @@ -2124,7 +2124,7 @@ module Delegate : sig missed_slots : int; missed_levels : int; remaining_allowed_missed_slots : int; - expected_endorsing_rewards : Tez.t; + expected_attesting_rewards : Tez.t; } val participation_info : @@ -2170,11 +2170,11 @@ module Delegate : sig reward_bonus:Tez.t option -> (context * Receipt.balance_updates) tzresult Lwt.t - val record_endorsing_participation : + val record_attesting_participation : context -> delegate:public_key_hash -> participation:level_participation -> - endorsing_power:int -> + attesting_power:int -> context tzresult Lwt.t type deposits = {initial_amount : Tez.t; current_amount : Tez.t} diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 5c90bfb2f50e..983944078263 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -2512,11 +2512,11 @@ let record_endorsing_participation ctxt = Delegate.Participated else Delegate.Didn't_participate in - Delegate.record_endorsing_participation + Delegate.record_attesting_participation ctxt ~delegate:consensus_pk.delegate ~participation - ~endorsing_power:power) + ~attesting_power:power) validators ctxt diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index 604b6de47445..07fadc6722d6 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -119,7 +119,7 @@ let distribute_endorsing_rewards ctxt last_cycle unrevealed_nonces = Stake_storage.get_selected_distribution ctxt last_cycle >>=? fun delegates -> List.fold_left_es (fun (ctxt, balance_updates) (delegate, active_stake) -> - Delegate_missed_endorsements_storage + Delegate_missed_attestations_storage .check_and_reset_delegate_participation ctxt delegate @@ -131,7 +131,7 @@ let distribute_endorsing_rewards ctxt last_cycle unrevealed_nonces = Stake_context.staking_weight ctxt active_stake in let expected_slots = - Delegate_missed_endorsements_storage + Delegate_missed_attestations_storage .expected_slots_for_given_active_stake ctxt ~total_active_stake_weight diff --git a/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml b/src/proto_alpha/lib_protocol/delegate_missed_attestations_storage.ml similarity index 90% rename from src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml rename to src/proto_alpha/lib_protocol/delegate_missed_attestations_storage.ml index f52df13743e0..c0d36827a05e 100644 --- a/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_missed_attestations_storage.ml @@ -33,29 +33,29 @@ let expected_slots_for_given_active_stake ctxt ~total_active_stake_weight let consensus_committee_size = Constants_storage.consensus_committee_size ctxt in - let number_of_endorsements_per_cycle = + let number_of_attestations_per_cycle = blocks_per_cycle * consensus_committee_size in Z.to_int (Z.div (Z.mul (Z.of_int64 active_stake_weight) - (Z.of_int number_of_endorsements_per_cycle)) + (Z.of_int number_of_attestations_per_cycle)) (Z.of_int64 total_active_stake_weight)) type level_participation = Participated | Didn't_participate (* Note that the participation for the last block of a cycle is recorded in the next cycle. *) -let record_endorsing_participation ctxt ~delegate ~participation - ~endorsing_power = +let record_attesting_participation ctxt ~delegate ~participation + ~attesting_power = match participation with | Participated -> Stake_storage.set_active ctxt delegate | Didn't_participate -> ( let contract = Contract_repr.Implicit delegate in Storage.Contract.Missed_attestations.find ctxt contract >>=? function | Some {remaining_slots; missed_levels} -> - let remaining_slots = remaining_slots - endorsing_power in + let remaining_slots = remaining_slots - attesting_power in Storage.Contract.Missed_attestations.update ctxt contract @@ -69,7 +69,7 @@ let record_endorsing_participation ctxt ~delegate ~participation with | None -> (* This happens when the block is the first one in a - cycle, and therefore the endorsements are for the last + cycle, and therefore the attestations are for the last block of the previous cycle, and when the delegate does not have an active stake at the current cycle; in this case its participation is simply ignored. *) @@ -95,7 +95,7 @@ let record_endorsing_participation ctxt ~delegate ~participation in let minimal_activity = expected_slots * numerator / denominator in let maximal_inactivity = expected_slots - minimal_activity in - let remaining_slots = maximal_inactivity - endorsing_power in + let remaining_slots = maximal_inactivity - attesting_power in Storage.Contract.Missed_attestations.init ctxt contract @@ -142,9 +142,9 @@ let check_and_reset_delegate_participation ctxt delegate = Storage.Contract.Missed_attestations.find ctxt contract >>=? fun missed -> match missed with | None -> return (ctxt, true) - | Some missed_endorsements -> + | Some missed_attestations -> Storage.Contract.Missed_attestations.remove ctxt contract >>= fun ctxt -> - return (ctxt, Compare.Int.(missed_endorsements.remaining_slots >= 0)) + return (ctxt, Compare.Int.(missed_attestations.remaining_slots >= 0)) type participation_info = { expected_cycle_activity : int; @@ -152,7 +152,7 @@ type participation_info = { missed_slots : int; missed_levels : int; remaining_allowed_missed_slots : int; - expected_endorsing_rewards : Tez_repr.t; + expected_attesting_rewards : Tez_repr.t; } (* Inefficient, only for RPC *) @@ -175,7 +175,7 @@ let participation_info ctxt delegate = missed_slots = 0; missed_levels = 0; remaining_allowed_missed_slots = 0; - expected_endorsing_rewards = Tez_repr.zero; + expected_attesting_rewards = Tez_repr.zero; } | Some active_stake -> Stake_storage.get_total_active_stake ctxt level.cycle @@ -195,7 +195,7 @@ let participation_info ctxt delegate = let Ratio_repr.{numerator; denominator} = Constants_storage.minimal_participation_ratio ctxt in - let endorsing_reward_per_slot = + let attesting_reward_per_slot = Delegate_rewards.attesting_reward_per_slot ctxt in let minimal_cycle_activity = @@ -204,24 +204,24 @@ let participation_info ctxt delegate = let maximal_cycle_inactivity = expected_cycle_activity - minimal_cycle_activity in - let expected_endorsing_rewards = - Tez_repr.mul_exn endorsing_reward_per_slot expected_cycle_activity + let expected_attesting_rewards = + Tez_repr.mul_exn attesting_reward_per_slot expected_cycle_activity in let contract = Contract_repr.Implicit delegate in Storage.Contract.Missed_attestations.find ctxt contract - >>=? fun missed_endorsements -> + >>=? fun missed_attestations -> let missed_slots, missed_levels, remaining_allowed_missed_slots = - match missed_endorsements with + match missed_attestations with | None -> (0, 0, maximal_cycle_inactivity) | Some {remaining_slots; missed_levels} -> ( maximal_cycle_inactivity - remaining_slots, missed_levels, Compare.Int.max 0 remaining_slots ) in - let expected_endorsing_rewards = - match missed_endorsements with + let expected_attesting_rewards = + match missed_attestations with | Some r when Compare.Int.(r.remaining_slots < 0) -> Tez_repr.zero - | _ -> expected_endorsing_rewards + | _ -> expected_attesting_rewards in return { @@ -230,5 +230,5 @@ let participation_info ctxt delegate = missed_slots; missed_levels; remaining_allowed_missed_slots; - expected_endorsing_rewards; + expected_attesting_rewards; } diff --git a/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.mli b/src/proto_alpha/lib_protocol/delegate_missed_attestations_storage.mli similarity index 88% rename from src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.mli rename to src/proto_alpha/lib_protocol/delegate_missed_attestations_storage.mli index a5469c79e325..d0c6ce21216b 100644 --- a/src/proto_alpha/lib_protocol/delegate_missed_endorsements_storage.mli +++ b/src/proto_alpha/lib_protocol/delegate_missed_attestations_storage.mli @@ -28,7 +28,7 @@ (** This modules deals with delegates' participation in consensus. This module is responsible for maintaining the - {!Storage.Contract.Missed_endorsements} table. *) + {!Storage.Contract.Missed_attestations} table. *) val expected_slots_for_given_active_stake : Raw_context.t -> @@ -39,11 +39,11 @@ val expected_slots_for_given_active_stake : type level_participation = Participated | Didn't_participate (** Record the participation of a delegate as a validator. *) -val record_endorsing_participation : +val record_attesting_participation : Raw_context.t -> delegate:Signature.Public_key_hash.t -> participation:level_participation -> - endorsing_power:int -> + attesting_power:int -> Raw_context.t tzresult Lwt.t (** Sets the payload and block producer as active. Pays the baking @@ -70,19 +70,19 @@ val check_and_reset_delegate_participation : - "dynamic" information that may change during the cycle *) type participation_info = { expected_cycle_activity : int; - (** The total expected slots to be endorsed in the cycle. (static) *) + (** The total expected slots to be attested in the cycle. (static) *) minimal_cycle_activity : int; - (** The minimal endorsing slots in the cycle to get endorsing - rewards. (static) *) + (** The minimal attesting slots in the cycle to get attesting rewards. + (static) *) missed_slots : int; - (** The number of missed endorsing slots in the cycle. (dynamic) *) + (** The number of missed attesting slots in the cycle. (dynamic) *) missed_levels : int; - (** The number of missed endorsing levels in the cycle. (dynamic) *) + (** The number of missed attesting levels in the cycle. (dynamic) *) remaining_allowed_missed_slots : int; - (** Remaining amount of endorsing slots that can be missed in the + (** Remaining amount of attesting slots that can be missed in the cycle before forfeiting the rewards. (dynamic) *) - expected_endorsing_rewards : Tez_repr.t; - (** Endorsing rewards that will be distributed at the end of the + expected_attesting_rewards : Tez_repr.t; + (** Attesting rewards that will be distributed at the end of the cycle if activity at that point will be greater than the minimal required. If the activity is already known to be below the required minimum, then the rewards are zero. (dynamic) *) diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index dff9e530f8f5..a3715a22a345 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -200,27 +200,27 @@ let participation_info_encoding = missed_slots; missed_levels; remaining_allowed_missed_slots; - expected_endorsing_rewards; + expected_attesting_rewards; } -> ( expected_cycle_activity, minimal_cycle_activity, missed_slots, missed_levels, remaining_allowed_missed_slots, - expected_endorsing_rewards )) + expected_attesting_rewards )) (fun ( expected_cycle_activity, minimal_cycle_activity, missed_slots, missed_levels, remaining_allowed_missed_slots, - expected_endorsing_rewards ) -> + expected_attesting_rewards ) -> { expected_cycle_activity; minimal_cycle_activity; missed_slots; missed_levels; remaining_allowed_missed_slots; - expected_endorsing_rewards; + expected_attesting_rewards; }) (obj6 (req "expected_cycle_activity" int31) diff --git a/src/proto_alpha/lib_protocol/dune b/src/proto_alpha/lib_protocol/dune index 7c4ac32bd134..4fef201d0ffb 100644 --- a/src/proto_alpha/lib_protocol/dune +++ b/src/proto_alpha/lib_protocol/dune @@ -169,7 +169,7 @@ Delegate_storage Delegate_sampler Delegate_rewards - Delegate_missed_endorsements_storage + Delegate_missed_attestations_storage Delegate_slashed_deposits_storage Delegate_cycles Vote_storage @@ -439,8 +439,8 @@ delegate_storage.ml delegate_storage.mli delegate_sampler.ml delegate_sampler.mli delegate_rewards.ml delegate_rewards.mli - delegate_missed_endorsements_storage.ml - delegate_missed_endorsements_storage.mli + delegate_missed_attestations_storage.ml + delegate_missed_attestations_storage.mli delegate_slashed_deposits_storage.ml delegate_slashed_deposits_storage.mli delegate_cycles.ml delegate_cycles.mli vote_storage.ml vote_storage.mli @@ -711,8 +711,8 @@ delegate_storage.ml delegate_storage.mli delegate_sampler.ml delegate_sampler.mli delegate_rewards.ml delegate_rewards.mli - delegate_missed_endorsements_storage.ml - delegate_missed_endorsements_storage.mli + delegate_missed_attestations_storage.ml + delegate_missed_attestations_storage.mli delegate_slashed_deposits_storage.ml delegate_slashed_deposits_storage.mli delegate_cycles.ml delegate_cycles.mli vote_storage.ml vote_storage.mli @@ -967,8 +967,8 @@ delegate_storage.ml delegate_storage.mli delegate_sampler.ml delegate_sampler.mli delegate_rewards.ml delegate_rewards.mli - delegate_missed_endorsements_storage.ml - delegate_missed_endorsements_storage.mli + delegate_missed_attestations_storage.ml + delegate_missed_attestations_storage.mli delegate_slashed_deposits_storage.ml delegate_slashed_deposits_storage.mli delegate_cycles.ml delegate_cycles.mli vote_storage.ml vote_storage.mli diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml index ccb4a7ef600f..755c8ff830dc 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml @@ -178,7 +178,7 @@ let test_participation_rpc () = in Assert.equal_tez ~loc:__LOC__ - info.expected_endorsing_rewards + info.expected_attesting_rewards endorsing_rewards >>=? fun () -> bake_and_endorse_once (b_pred, b_crt) del1 del1 >>=? fun b -> -- GitLab From a20d04bb9ce2f96cb33036a14513624f11f6512c Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:22:35 +0200 Subject: [PATCH 04/13] alpha: rename endorsing in delegate_cycles --- src/proto_alpha/lib_protocol/delegate_cycles.ml | 8 ++++---- src/proto_alpha/lib_protocol/delegate_cycles.mli | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index 07fadc6722d6..781bdbfd4c12 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -100,8 +100,8 @@ let update_initial_frozen_deposits ctxt ~new_cycle = let delegate_has_revealed_nonces delegate unrevelead_nonces_set = not (Signature.Public_key_hash.Set.mem delegate unrevelead_nonces_set) -let distribute_endorsing_rewards ctxt last_cycle unrevealed_nonces = - let endorsing_reward_per_slot = +let distribute_attesting_rewards ctxt last_cycle unrevealed_nonces = + let attesting_reward_per_slot = Delegate_rewards.attesting_reward_per_slot ctxt in let unrevealed_nonces_set = @@ -137,7 +137,7 @@ let distribute_endorsing_rewards ctxt last_cycle unrevealed_nonces = ~total_active_stake_weight ~active_stake_weight in - let rewards = Tez_repr.mul_exn endorsing_reward_per_slot expected_slots in + let rewards = Tez_repr.mul_exn attesting_reward_per_slot expected_slots in if sufficient_participation && has_revealed_nonces then (* Sufficient participation: we pay the rewards *) Delegate_staking_parameters.pay_rewards @@ -173,7 +173,7 @@ let cycle_end ctxt last_cycle = ctxt ~new_cycle >>= fun ctxt -> - distribute_endorsing_rewards ctxt last_cycle unrevealed_nonces + distribute_attesting_rewards ctxt last_cycle unrevealed_nonces >>=? fun (ctxt, balance_updates) -> update_initial_frozen_deposits ctxt ~new_cycle >>=? fun ctxt -> Stake_storage.clear_at_cycle_end ctxt ~new_cycle >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.mli b/src/proto_alpha/lib_protocol/delegate_cycles.mli index 82e96bae71f0..a28d60bcdd0a 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.mli +++ b/src/proto_alpha/lib_protocol/delegate_cycles.mli @@ -28,7 +28,7 @@ (** Per-cycle management of delegates. *) (** Trigger the context maintenance at the end of cycle 'n', i.e.: - unfreeze the endorsing rewards, potentially deactivate delegates. + unfreeze the attesting rewards, potentially deactivate delegates. Return the corresponding balances updates and the list of deactivated delegates. *) val cycle_end : -- GitLab From 367ffc0144a917a808c72fc26e7109ec8360ea4a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:24:36 +0200 Subject: [PATCH 05/13] alpha: rename endorsing in adaptive_inflation_services --- .../lib_protocol/adaptive_inflation_services.ml | 16 ++++++++-------- .../lib_protocol/adaptive_inflation_services.mli | 2 +- ... RPC regression tests- adaptive_inflation.out | 6 +++--- ... RPC regression tests- adaptive_inflation.out | 6 +++--- ... RPC regression tests- adaptive_inflation.out | 6 +++--- ... RPC regression tests- adaptive_inflation.out | 6 +++--- ... RPC regression tests- adaptive_inflation.out | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml b/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml index 1c24b7817a63..65f1abb79f92 100644 --- a/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml +++ b/src/proto_alpha/lib_protocol/adaptive_inflation_services.ml @@ -29,7 +29,7 @@ type expected_rewards = { cycle : Cycle.t; baking_reward_fixed_portion : Tez.t; baking_reward_bonus_per_slot : Tez.t; - endorsing_reward_per_slot : Tez.t; + attesting_reward_per_slot : Tez.t; liquidity_baking_subsidy : Tez.t; seed_nonce_revelation_tip : Tez.t; vdf_revelation_tip : Tez.t; @@ -42,7 +42,7 @@ let expected_rewards_encoding : expected_rewards Data_encoding.t = cycle; baking_reward_fixed_portion; baking_reward_bonus_per_slot; - endorsing_reward_per_slot; + attesting_reward_per_slot; liquidity_baking_subsidy; seed_nonce_revelation_tip; vdf_revelation_tip; @@ -50,14 +50,14 @@ let expected_rewards_encoding : expected_rewards Data_encoding.t = ( cycle, baking_reward_fixed_portion, baking_reward_bonus_per_slot, - endorsing_reward_per_slot, + attesting_reward_per_slot, liquidity_baking_subsidy, seed_nonce_revelation_tip, vdf_revelation_tip )) (fun ( cycle, baking_reward_fixed_portion, baking_reward_bonus_per_slot, - endorsing_reward_per_slot, + attesting_reward_per_slot, liquidity_baking_subsidy, seed_nonce_revelation_tip, vdf_revelation_tip ) -> @@ -65,7 +65,7 @@ let expected_rewards_encoding : expected_rewards Data_encoding.t = cycle; baking_reward_fixed_portion; baking_reward_bonus_per_slot; - endorsing_reward_per_slot; + attesting_reward_per_slot; liquidity_baking_subsidy; seed_nonce_revelation_tip; vdf_revelation_tip; @@ -74,7 +74,7 @@ let expected_rewards_encoding : expected_rewards Data_encoding.t = (req "cycle" Cycle.encoding) (req "baking_reward_fixed_portion" Tez.encoding) (req "baking_reward_bonus_per_slot" Tez.encoding) - (req "endorsing_reward_per_slot" Tez.encoding) + (req "attesting_reward_per_slot" Tez.encoding) (req "liquidity_baking_subsidy" Tez.encoding) (req "seed_nonce_revelation_tip" Tez.encoding) (req "vdf_revelation_tip" Tez.encoding)) @@ -198,7 +198,7 @@ let collect_expected_rewards ~ctxt = cycle; baking_reward_fixed_portion = baking_reward_fixed_portion ctxt; baking_reward_bonus_per_slot = baking_reward_bonus_per_slot ctxt; - endorsing_reward_per_slot = attesting_reward_per_slot ctxt; + attesting_reward_per_slot = attesting_reward_per_slot ctxt; liquidity_baking_subsidy = liquidity_baking_subsidy ctxt; seed_nonce_revelation_tip = seed_nonce_revelation_tip ctxt; vdf_revelation_tip = vdf_revelation_tip ctxt; @@ -222,7 +222,7 @@ let collect_expected_rewards ~ctxt = ~coeff csts ~reward_kind:Baking_reward_bonus_per_slot; - endorsing_reward_per_slot = + attesting_reward_per_slot = reward_from_constants ~coeff csts diff --git a/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli b/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli index 81b8b5a488ff..0665287aa695 100644 --- a/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli +++ b/src/proto_alpha/lib_protocol/adaptive_inflation_services.mli @@ -29,7 +29,7 @@ type expected_rewards = { cycle : Cycle.t; baking_reward_fixed_portion : Tez.t; baking_reward_bonus_per_slot : Tez.t; - endorsing_reward_per_slot : Tez.t; + attesting_reward_per_slot : Tez.t; liquidity_baking_subsidy : Tez.t; seed_nonce_revelation_tip : Tez.t; vdf_revelation_tip : Tez.t; diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_inflation.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_inflation.out index 1f68954d4382..a7790fdf837c 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_inflation.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- adaptive_inflation.out @@ -20,13 +20,13 @@ null ./octez-client rpc get /chains/main/blocks/head/context/inflation/expected_rewards [ { "cycle": 0, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 1, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 2, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" } ] diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_inflation.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_inflation.out index a3279233000d..d960ba302c77 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_inflation.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- adaptive_inflation.out @@ -20,13 +20,13 @@ null ./octez-client --mode light rpc get /chains/main/blocks/head/context/inflation/expected_rewards [ { "cycle": 0, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 1, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 2, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" } ] diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_inflation.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_inflation.out index 45af921f7855..2b30104d1013 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_inflation.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- adaptive_inflation.out @@ -20,13 +20,13 @@ null ./octez-client --mode proxy rpc get /chains/main/blocks/head/context/inflation/expected_rewards [ { "cycle": 0, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 1, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 2, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" } ] diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- adaptive_inflation.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- adaptive_inflation.out index e5194d2671de..f159044d73c7 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- adaptive_inflation.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- adaptive_inflation.out @@ -20,13 +20,13 @@ null ./octez-client rpc get /chains/main/blocks/head/context/inflation/expected_rewards [ { "cycle": 0, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 1, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 2, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" } ] diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- adaptive_inflation.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- adaptive_inflation.out index e5194d2671de..f159044d73c7 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- adaptive_inflation.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- adaptive_inflation.out @@ -20,13 +20,13 @@ null ./octez-client rpc get /chains/main/blocks/head/context/inflation/expected_rewards [ { "cycle": 0, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 1, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" }, { "cycle": 2, "baking_reward_fixed_portion": "333333", "baking_reward_bonus_per_slot": "1302", - "endorsing_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", + "attesting_reward_per_slot": "2604", "liquidity_baking_subsidy": "83333", "seed_nonce_revelation_tip": "260", "vdf_revelation_tip": "260" } ] -- GitLab From 960f35195545b784069217f5c8b4a581a9986de7 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:28:55 +0200 Subject: [PATCH 06/13] alpha: rename endorsement in consensus --- src/proto_alpha/lib_protocol/alpha_context.ml | 10 +++++----- src/proto_alpha/lib_protocol/alpha_context.mli | 6 +++--- src/proto_alpha/lib_protocol/apply.ml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index ebffd383df83..3b3ec4b0f0a9 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -563,14 +563,14 @@ module Migration = Migration_repr module Consensus = struct include Raw_context.Consensus - let load_endorsement_branch ctxt = + let load_attestation_branch ctxt = Storage.Tenderbake.Attestation_branch.find ctxt >>=? function - | Some endorsement_branch -> - Raw_context.Consensus.set_attestation_branch ctxt endorsement_branch + | Some attestation_branch -> + Raw_context.Consensus.set_attestation_branch ctxt attestation_branch |> return | None -> return ctxt - let store_endorsement_branch ctxt branch = + let store_attestation_branch ctxt branch = let ctxt = set_attestation_branch ctxt branch in Storage.Tenderbake.Attestation_branch.add ctxt branch end @@ -580,7 +580,7 @@ let prepare_first_block = Init_storage.prepare_first_block let prepare ctxt ~level ~predecessor_timestamp ~timestamp = Init_storage.prepare ctxt ~level ~predecessor_timestamp ~timestamp >>=? fun (ctxt, balance_updates, origination_results) -> - Consensus.load_endorsement_branch ctxt >>=? fun ctxt -> + Consensus.load_attestation_branch ctxt >>=? fun ctxt -> Delegate.load_forbidden_delegates ctxt >>=? fun ctxt -> Adaptive_inflation_storage.load_reward_coeff ctxt >>=? fun ctxt -> return (ctxt, balance_updates, origination_results) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 8e4717198e89..a1fd9e34827c 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -4856,10 +4856,10 @@ module Consensus : sig and type round := Round.t and type consensus_pk := Consensus_key.pk - (** [store_endorsement_branch context branch] sets the "endorsement branch" - (see {!Storage.Tenderbake.Endorsement_branch} to [branch] in both the disk + (** [store_attestation_branch context branch] sets the "attestation branch" + (see {!Storage.Tenderbake.Attestation_branch} to [branch] in both the disk storage and RAM. *) - val store_endorsement_branch : + val store_attestation_branch : context -> Block_hash.t * Block_payload_hash.t -> context Lwt.t end diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 983944078263..58e3bad96b62 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -2717,7 +2717,7 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash (* We mark the current payload hash as the predecessor one => this will only be accessed by the successor block now. *) let*! ctxt = - Consensus.store_endorsement_branch + Consensus.store_attestation_branch ctxt (predecessor_hash, block_payload_hash) in -- GitLab From 8a7432f0b9be831bea5c5d7d83f07acf2136a767 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:32:26 +0200 Subject: [PATCH 07/13] alpha: rename endorsing in baking --- src/proto_alpha/lib_plugin/RPC.ml | 4 ++-- src/proto_alpha/lib_protocol/baking.ml | 4 ++-- src/proto_alpha/lib_protocol/baking.mli | 12 ++++++------ src/proto_alpha/lib_protocol/main.ml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index e24ffb58a191..be3f9990380c 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -3444,7 +3444,7 @@ module Attestation_rights = struct end let attestation_rights_at_level ctxt level = - Baking.endorsing_rights_by_first_slot ctxt level >>=? fun (ctxt, rights) -> + Baking.attesting_rights_by_first_slot ctxt level >>=? fun (ctxt, rights) -> Round.get ctxt >>=? fun current_round -> let current_level = Level.current ctxt in let current_timestamp = Timestamp.current ctxt in @@ -3581,7 +3581,7 @@ module Validators = struct end let add_endorsing_slots_at_level (ctxt, acc) level = - Baking.endorsing_rights ctxt level >|=? fun (ctxt, rights) -> + Baking.attesting_rights ctxt level >|=? fun (ctxt, rights) -> ( ctxt, Signature.Public_key_hash.Map.fold (fun _pkh {Baking.delegate; consensus_key; slots} acc -> diff --git a/src/proto_alpha/lib_protocol/baking.ml b/src/proto_alpha/lib_protocol/baking.ml index 8c23f43773cb..424afe308482 100644 --- a/src/proto_alpha/lib_protocol/baking.ml +++ b/src/proto_alpha/lib_protocol/baking.ml @@ -78,7 +78,7 @@ type ordered_slots = { (* Slots returned by this function are assumed by consumers to be in increasing order, hence the use of [Slot.Range.rev_fold_es]. *) -let endorsing_rights (ctxt : t) level = +let attesting_rights (ctxt : t) level = let consensus_committee_size = Constants.consensus_committee_size ctxt in Slot.Range.create ~min:0 ~count:consensus_committee_size >>?= fun slots -> Slot.Range.rev_fold_es @@ -103,7 +103,7 @@ let endorsing_rights (ctxt : t) level = (ctxt, Signature.Public_key_hash.Map.empty) slots -let endorsing_rights_by_first_slot ctxt level = +let attesting_rights_by_first_slot ctxt level = Slot.Range.create ~min:0 ~count:(Constants.consensus_committee_size ctxt) >>?= fun slots -> Slot.Range.fold_es diff --git a/src/proto_alpha/lib_protocol/baking.mli b/src/proto_alpha/lib_protocol/baking.mli index 5fc4c451f586..d99e7b9dab7b 100644 --- a/src/proto_alpha/lib_protocol/baking.mli +++ b/src/proto_alpha/lib_protocol/baking.mli @@ -39,23 +39,23 @@ type ordered_slots = private { slots : Slot.t list; } -(** For a given level computes who has the right to include an endorsement in +(** For a given level computes who has the right to include an attestation in the next block. - @return map from delegates with such rights to their endorsing slots, in + @return map from delegates with such rights to their attesting slots, in increasing order. This function is only used by the 'validators' RPC. *) -val endorsing_rights : +val attesting_rights : context -> Level.t -> (context * ordered_slots Signature.Public_key_hash.Map.t) tzresult Lwt.t -(** Computes endorsing rights for a given level. +(** Computes attesting rights for a given level. @return map from allocated first slots to their owner's public key, public key - hash, and endorsing power. *) -val endorsing_rights_by_first_slot : + hash, and attesting power. *) +val attesting_rights_by_first_slot : context -> Level.t -> (context * (Consensus_key.pk * int) Slot.Map.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 60800a86647d..897c91e792b8 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -132,7 +132,7 @@ let init_consensus_rights_for_block ctxt mode ~predecessor_level = let open Lwt_result_syntax in let open Alpha_context in let* ctxt, attestations_map = - Baking.endorsing_rights_by_first_slot ctxt predecessor_level + Baking.attesting_rights_by_first_slot ctxt predecessor_level in let*? can_contain_preattestations = match mode with @@ -150,7 +150,7 @@ let init_consensus_rights_for_block ctxt mode ~predecessor_level = let* ctxt, allowed_preattestations = if can_contain_preattestations then let* ctxt, preattestations_map = - Baking.endorsing_rights_by_first_slot ctxt (Level.current ctxt) + Baking.attesting_rights_by_first_slot ctxt (Level.current ctxt) in return (ctxt, Some preattestations_map) else return (ctxt, None) -- GitLab From 275cdd71d8a57dbbe126b45d2f8f102b0cca87ad Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:37:43 +0200 Subject: [PATCH 08/13] alpha: rename endorsing in delegate_services --- docs/protocols/alpha.rst | 2 ++ src/proto_alpha/lib_protocol/delegate_services.ml | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index cd04221c7882..06ad5a3ec9b3 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -155,6 +155,8 @@ RPC Changes based on its current stake (MR :gl:`!9350`) - Two new variants of the ``voting_power`` RPC (which returns the + ``expected_endorsing_rewards`` field from ``/participation`` RPC has been + renamed in ``expected_attesting_rewards``. Operation receipts ------------------ diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index a3715a22a345..aedec5c53a80 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -228,7 +228,7 @@ let participation_info_encoding = (req "missed_slots" int31) (req "missed_levels" int31) (req "remaining_allowed_missed_slots" int31) - (req "expected_endorsing_rewards" Tez.encoding)) + (req "expected_attesting_rewards" Tez.encoding)) type deposit_per_cycle = {cycle : Cycle.t; deposit : Tez.t} @@ -432,15 +432,15 @@ module S = struct indicates, in the field 'expected_cycle_activity', the number of \ slots the delegate is expected to have in the cycle based on its \ active stake. The field 'minimal_cycle_activity' indicates the \ - minimal endorsing slots in the cycle required to get endorsing \ + minimal attesting slots in the cycle required to get attesting \ rewards. It is computed based on 'expected_cycle_activity. The fields \ 'missed_slots' and 'missed_levels' indicate the number of missed \ - endorsing slots and missed levels (for endorsing) in the cycle so \ - far. 'missed_slots' indicates the number of missed endorsing slots in \ + attesting slots and missed levels (for attesting) in the cycle so \ + far. 'missed_slots' indicates the number of missed attesting slots in \ the cycle so far. The field 'remaining_allowed_missed_slots' \ - indicates the remaining amount of endorsing slots that can be missed \ + indicates the remaining amount of attesting slots that can be missed \ in the cycle before forfeiting the rewards. Finally, \ - 'expected_endorsing_rewards' indicates the endorsing rewards that \ + 'expected_attesting_rewards' indicates the attesting rewards that \ will be distributed at the end of the cycle if activity at that point \ will be greater than the minimal required; if the activity is already \ known to be below the required minimum, then the rewards are zero." -- GitLab From 96a6273b4259a008723af64d166897f35e72fa18 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:50:33 +0200 Subject: [PATCH 09/13] alpha: rename endorsement in validate --- docs/protocols/alpha.rst | 5 + src/proto_alpha/lib_protocol/validate.ml | 130 +++++++++++----------- src/proto_alpha/lib_protocol/validate.mli | 12 +- 3 files changed, 76 insertions(+), 71 deletions(-) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 06ad5a3ec9b3..6157d8715d1e 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -127,6 +127,11 @@ Breaking Changes - Field ``missed_endorsements`` from contract storage has been renamed into ``missed_attestations``. (MR :gl:`!9486`) +- Fields ``preendorsements_seen``, ``endorsements_seen`` and + ``double_endorsing_evidences_seen`` from the mempool's ``operation_state`` + encoding has been renamed ``preattestations_seen``, ``attestation_seen`` and + ``double_attesting_evidences_seen``. (MR :gl:`!9440`) + RPC Changes ----------- diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index c9c366d1938b..a089ab389a24 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -30,7 +30,7 @@ type consensus_info = { predecessor_level : Raw_level.t; predecessor_round : Round.t; preattestation_slot_map : (Consensus_key.pk * int) Slot.Map.t option; - endorsement_slot_map : (Consensus_key.pk * int) Slot.Map.t option; + attestation_slot_map : (Consensus_key.pk * int) Slot.Map.t option; } let init_consensus_info ctxt (predecessor_level, predecessor_round) = @@ -38,15 +38,15 @@ let init_consensus_info ctxt (predecessor_level, predecessor_round) = predecessor_level; predecessor_round; preattestation_slot_map = Consensus.allowed_preattestations ctxt; - endorsement_slot_map = Consensus.allowed_attestations ctxt; + attestation_slot_map = Consensus.allowed_attestations ctxt; } (** Map used to detect consensus operation conflicts. Each delegate - may (pre)endorse at most once for each level and round, so two - endorsements (resp. two preattestations) conflict when they have + may (pre)attest at most once for each level and round, so two + attestations (resp. two preattestations) conflict when they have the same slot, level, and round. - Note that when validating a block, all endorsements (resp. all + Note that when validating a block, all attestations (resp. all preattestations) must have the same level and round anyway, so only the slot is relevant. Taking the level and round into account is useful in mempool mode, because we want to be able to accept and @@ -63,7 +63,7 @@ end) type consensus_state = { preattestations_seen : Operation_hash.t Consensus_conflict_map.t; - endorsements_seen : Operation_hash.t Consensus_conflict_map.t; + attestations_seen : Operation_hash.t Consensus_conflict_map.t; dal_attestation_seen : Operation_hash.t Signature.Public_key_hash.Map.t; } @@ -83,13 +83,13 @@ let consensus_state_encoding = let open Data_encoding in def "consensus_state" @@ conv - (fun {preattestations_seen; endorsements_seen; dal_attestation_seen} -> - (preattestations_seen, endorsements_seen, dal_attestation_seen)) - (fun (preattestations_seen, endorsements_seen, dal_attestation_seen) -> - {preattestations_seen; endorsements_seen; dal_attestation_seen}) + (fun {preattestations_seen; attestations_seen; dal_attestation_seen} -> + (preattestations_seen, attestations_seen, dal_attestation_seen)) + (fun (preattestations_seen, attestations_seen, dal_attestation_seen) -> + {preattestations_seen; attestations_seen; dal_attestation_seen}) (obj3 - (req "preendorsements_seen" consensus_conflict_map_encoding) - (req "endorsements_seen" consensus_conflict_map_encoding) + (req "preattestations_seen" consensus_conflict_map_encoding) + (req "attestations_seen" consensus_conflict_map_encoding) (req "dal_attestation_seen" (Signature.Public_key_hash.Map.encoding Operation_hash.encoding))) @@ -97,7 +97,7 @@ let consensus_state_encoding = let empty_consensus_state = { preattestations_seen = Consensus_conflict_map.empty; - endorsements_seen = Consensus_conflict_map.empty; + attestations_seen = Consensus_conflict_map.empty; dal_attestation_seen = Signature.Public_key_hash.Map.empty; } @@ -229,7 +229,7 @@ let anonymous_state_encoding = "double_baking_evidences_seen" (Double_baking_evidence_map.encoding Operation_hash.encoding)) (req - "double_endorsing_evidences_seen" + "double_attesting_evidences_seen" (Double_attesting_evidence_map.encoding Operation_hash.encoding)) (req "seed_nonce_levels_seen" @@ -372,7 +372,7 @@ type block_state = { recorded_operations_rev : Operation_hash.t list; last_op_validation_pass : int option; locked_round_evidence : (Round.t * int) option; - endorsement_power : int; + attestation_power : int; } type validation_state = { @@ -418,13 +418,13 @@ let init_block_state vi = recorded_operations_rev = []; last_op_validation_pass = None; locked_round_evidence = None; - endorsement_power = 0; + attestation_power = 0; } let get_initial_ctxt {info; _} = info.ctxt (** Validation of consensus operations (validation pass [0]): - preattestation, endorsement, and dal_attestation. *) + preattestation, attestation, and dal_attestation. *) module Consensus = struct open Validate_errors.Consensus @@ -520,7 +520,7 @@ module Consensus = struct let*? () = check_level kind vi.current_level.level level in (* We cannot check the exact round here in construction mode, because there is no preexisting fitness to provide the locked_round. We do - however check that all preendorments have the same round in + however check that all preattestations have the same round in [check_construction_preattestation_round_consistency] further below. *) let*? () = check_payload_hash kind expected_payload_hash bph in let*? consensus_key, voting_power = @@ -531,7 +531,7 @@ module Consensus = struct in return (consensus_key, voting_power) - (** Preattestation/endorsement checks for Mempool mode. + (** Preattestation/attestation checks for Mempool mode. We want this mode to be very permissive, to allow the mempool to accept and propagate consensus operations even if they point to a @@ -552,8 +552,8 @@ module Consensus = struct three allowed levels. Checking the slot normalization is therefore the responsability of the baker when it selects the consensus operations to include in a new block. Moreover, - multiple endorsements pointing to the same block with different - slots can be punished by a double-(pre)endorsement operation. + multiple attestations pointing to the same block with different + slots can be punished by a double-(pre)attestation operation. Return the slot owner's consensus key and a fake voting power (the latter won't be used anyway in Mempool mode). *) @@ -685,21 +685,21 @@ module Consensus = struct in {vs with consensus_state = {vs.consensus_state with preattestations_seen}} - (** Endorsement checks for all modes that involve a block: + (** Attestation checks for all modes that involve a block: Application, Partial_validation, and Construction. Return the slot owner's consensus key and voting power. *) - let check_block_endorsement vi consensus_info + let check_block_attestation vi consensus_info {level; round; block_payload_hash = bph; slot} = let open Lwt_result_syntax in let*? expected_payload_hash = match Consensus.attestation_branch vi.ctxt with | Some ((_branch : Block_hash.t), payload_hash) -> ok payload_hash | None -> - (* [Consensus.endorsement_branch] only returns [None] when the + (* [Consensus.attestation_branch] only returns [None] when the predecessor is the block that activates the first protocol of the Tenderbake family; this block should not be - endorsed. This can only happen in tests and test + attested. This can only happen in tests and test networks. *) error Unexpected_attestation_in_block in @@ -708,14 +708,14 @@ module Consensus = struct let*? () = check_round kind consensus_info.predecessor_round round in let*? () = check_payload_hash kind expected_payload_hash bph in let*? consensus_key, voting_power = - get_delegate_details consensus_info.endorsement_slot_map kind slot + get_delegate_details consensus_info.attestation_slot_map kind slot in let* () = check_frozen_deposits_are_positive vi.ctxt consensus_key.delegate in return (consensus_key, voting_power) - let check_endorsement vi ~check_signature + let check_attestation vi ~check_signature (operation : Kind.attestation operation) = let open Lwt_result_syntax in let*? consensus_info = @@ -729,7 +729,7 @@ module Consensus = struct let* consensus_key, voting_power = match vi.mode with | Application _ | Partial_validation _ | Construction _ -> - check_block_endorsement vi consensus_info consensus_content + check_block_attestation vi consensus_info consensus_content | Mempool -> check_mempool_consensus vi @@ -747,7 +747,7 @@ module Consensus = struct in return voting_power - let check_endorsement_conflict vs oph (operation : Kind.attestation operation) + let check_attestation_conflict vs oph (operation : Kind.attestation operation) = let (Single (Attestation {slot; level; round; _})) = operation.protocol_data.contents @@ -755,53 +755,53 @@ module Consensus = struct match Consensus_conflict_map.find_opt (slot, level, round) - vs.consensus_state.endorsements_seen + vs.consensus_state.attestations_seen with | None -> ok_unit | Some existing -> Error (Operation_conflict {existing; new_operation = oph}) - let wrap_endorsement_conflict = function + let wrap_attestation_conflict = function | Ok () -> ok_unit | Error conflict -> error Validate_errors.Consensus.( Conflicting_consensus_operation {kind = Attestation; conflict}) - let add_endorsement vs oph (op : Kind.attestation operation) = + let add_attestation vs oph (op : Kind.attestation operation) = let (Single (Attestation {slot; level; round; _})) = op.protocol_data.contents in - let endorsements_seen = + let attestations_seen = Consensus_conflict_map.add (slot, level, round) oph - vs.consensus_state.endorsements_seen + vs.consensus_state.attestations_seen in - {vs with consensus_state = {vs.consensus_state with endorsements_seen}} + {vs with consensus_state = {vs.consensus_state with attestations_seen}} - let may_update_endorsement_power vi block_state voting_power = + let may_update_attestation_power vi block_state voting_power = match vi.mode with | Mempool -> (* The block_state is not relevant. *) block_state | Application _ | Partial_validation _ | Construction _ -> { block_state with - endorsement_power = block_state.endorsement_power + voting_power; + attestation_power = block_state.attestation_power + voting_power; } (* Hypothesis: this function will only be called in mempool mode *) - let remove_endorsement vs (operation : Kind.attestation operation) = - (* We do not remove the endorsement power because it is not + let remove_attestation vs (operation : Kind.attestation operation) = + (* We do not remove the attestation power because it is not relevant for the mempool mode. *) let (Single (Attestation {slot; level; round; _})) = operation.protocol_data.contents in - let endorsements_seen = + let attestations_seen = Consensus_conflict_map.remove (slot, level, round) - vs.consensus_state.endorsements_seen + vs.consensus_state.attestations_seen in - {vs with consensus_state = {vs.consensus_state with endorsements_seen}} + {vs with consensus_state = {vs.consensus_state with attestations_seen}} let check_dal_attestation vi (operation : Kind.dal_attestation operation) = (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3115 @@ -810,8 +810,8 @@ module Consensus = struct checked. Consequently, it is really important to ensure this operation cannot be included into a block when the feature flag is not set. This is done in order to avoid modifying the - endorsement encoding. However, once the DAL is ready, this - operation should be merged with an endorsement or at least + attestation encoding. However, once the DAL is ready, this + operation should be merged with an attestation or at least refined. *) let open Lwt_result_syntax in let (Single (Dal_attestation op)) = operation.protocol_data.contents in @@ -923,16 +923,16 @@ module Consensus = struct let operation_state = add_preattestation operation_state oph operation in return {info; operation_state; block_state} - let validate_endorsement ~check_signature info operation_state block_state oph + let validate_attestation ~check_signature info operation_state block_state oph operation = let open Lwt_result_syntax in - let* power = check_endorsement info ~check_signature operation in + let* power = check_attestation info ~check_signature operation in let*? () = - check_endorsement_conflict operation_state oph operation - |> wrap_endorsement_conflict + check_attestation_conflict operation_state oph operation + |> wrap_attestation_conflict in - let block_state = may_update_endorsement_power info block_state power in - let operation_state = add_endorsement operation_state oph operation in + let block_state = may_update_attestation_power info block_state power in + let operation_state = add_attestation operation_state oph operation in return {info; operation_state; block_state} end @@ -1350,7 +1350,7 @@ module Anonymous = struct let ordered_hashes = Operation_hash.(op1_hash < op2_hash) in let is_denunciation_consistent = same_levels && same_rounds - (* For the double (pre)endorsements to be punishable, they + (* For the double (pre)attestations to be punishable, they must point to the same block (same level and round), but also have at least a difference that is the delegate's fault: different payloads, different branches, or @@ -2454,7 +2454,7 @@ let check_operation ?(check_signature = true) info (type kind) return_unit | Single (Attestation _) -> let* (_voting_power : int) = - Consensus.check_endorsement info ~check_signature operation + Consensus.check_attestation info ~check_signature operation in return_unit | Single (Dal_attestation _) -> Consensus.check_dal_attestation info operation @@ -2509,7 +2509,7 @@ let check_operation_conflict (type kind) operation_conflict_state oph oph operation | Single (Attestation _) -> - Consensus.check_endorsement_conflict + Consensus.check_attestation_conflict operation_conflict_state oph operation @@ -2572,7 +2572,7 @@ let add_valid_operation operation_conflict_state oph (type kind) | Single (Preattestation _) -> Consensus.add_preattestation operation_conflict_state oph operation | Single (Attestation _) -> - Consensus.add_endorsement operation_conflict_state oph operation + Consensus.add_attestation operation_conflict_state oph operation | Single (Dal_attestation _) -> Consensus.add_dal_attestation operation_conflict_state oph operation | Single (Proposals _) -> @@ -2617,7 +2617,7 @@ let remove_operation operation_conflict_state (type kind) | Single (Preattestation _) -> Consensus.remove_preattestation operation_conflict_state operation | Single (Attestation _) -> - Consensus.remove_endorsement operation_conflict_state operation + Consensus.remove_attestation operation_conflict_state operation | Single (Dal_attestation _) -> Consensus.remove_dal_attestation operation_conflict_state operation | Single (Proposals _) -> @@ -2709,7 +2709,7 @@ let validate_operation ?(check_signature = true) oph operation | Single (Attestation _) -> - Consensus.validate_endorsement + Consensus.validate_attestation ~check_signature info operation_state @@ -2848,12 +2848,12 @@ let validate_operation ?(check_signature = true) open Validate_errors.Block -let check_endorsement_power vi bs = +let check_attestation_power vi bs = let open Lwt_result_syntax in - let* are_endorsements_required = + let* are_attestations_required = (* The migration block (whose level is [first_level_of_protocol]) - is always considered final, and is not endorsed. Therefore, the - block at the next level does not need to contain endorsements. + is always considered final, and is not attested. Therefore, the + block at the next level does not need to contain attestations. (Note that the migration block itself is validated by the previous protocol, so the returned value for it does not matter.) *) let* first_level_of_protocol = First_level_of_protocol.get vi.ctxt in @@ -2862,9 +2862,9 @@ let check_endorsement_power vi bs = in return Compare.Int32.(level_position_in_protocol > 1l) in - if are_endorsements_required then + if are_attestations_required then let required = Constants.consensus_threshold vi.ctxt in - let provided = bs.endorsement_power in + let provided = bs.attestation_power in fail_unless Compare.Int.(provided >= required) (Not_enough_attestations {required; provided}) @@ -2933,7 +2933,7 @@ let finalize_block {info; block_state; _} = let open Lwt_result_syntax in match info.mode with | Application {round; locked_round; predecessor_hash; header_contents} -> - let* () = check_endorsement_power info block_state in + let* () = check_attestation_power info block_state in let*? () = check_fitness_locked_round block_state locked_round in let*? () = check_preattestation_round_and_power info block_state round in let*? () = @@ -2941,12 +2941,12 @@ let finalize_block {info; block_state; _} = in return_unit | Partial_validation {round; locked_round; _} -> - let* () = check_endorsement_power info block_state in + let* () = check_attestation_power info block_state in let*? () = check_fitness_locked_round block_state locked_round in let*? () = check_preattestation_round_and_power info block_state round in return_unit | Construction {round; predecessor_hash; header_contents} -> - let* () = check_endorsement_power info block_state in + let* () = check_attestation_power info block_state in let*? () = check_preattestation_round_and_power info block_state round in let*? () = match block_state.locked_round_evidence with diff --git a/src/proto_alpha/lib_protocol/validate.mli b/src/proto_alpha/lib_protocol/validate.mli index c06eb6ad203f..1afd0828ca0c 100644 --- a/src/proto_alpha/lib_protocol/validate.mli +++ b/src/proto_alpha/lib_protocol/validate.mli @@ -84,7 +84,7 @@ [validate_operation], but not used at all by [finalize_block]. - [block_state] registers global block metrics such as total gas - used or endorsement power. It is filled in by [validate_operation], + used or attestation power. It is filled in by [validate_operation], which also uses it, e.g. to immediately return an error if the block gas limit is exceeded. It is also essential to several checks in [finalize_block]. @@ -102,7 +102,7 @@ [validation_state] for the validation of operations outside of the process of validation of a block. It is intended for mempools (see {!Mempool_validation}) and for some RPCs. The global block - properties such as total block gas and endorsement power are not + properties such as total block gas and attestation power are not checked. Calling [finalize_block] on such a [validation_state] does not make much sense and simply returns unit. @@ -131,8 +131,8 @@ property is that a baker may select any subset of validated operations to bake into a new block, which is then guaranteed to be applicable (provided that it verifies some additional global - properties such as including enough (pre)endorsing power; the baker - is responsible for ensuring this). + properties such as including enough (pre)attesting power; the + baker is responsible for ensuring this). For a manager operation, validity is mainly solvability, ie. the operation must be well-formed and we must be able to take its @@ -243,7 +243,7 @@ val begin_partial_construction : (** Similar to [begin_partial_construction] but do not require predecessor information that is essential to the validation of - preattestation and endorsement operations. As a consequence, the + preattestation and attestation operations. As a consequence, the validation of these operations will always fail. This function is used by the plugin RPC [run_operation], which @@ -281,7 +281,7 @@ val validate_operation : This function should only be used after {!validate_operation} has been called on every operation in the block. It checks the consistency of the block_header with the information computed while - validating the block's operations (Endorsement power, payload hash, + validating the block's operations (Attestation power, payload hash, etc.) Checks vary depending on the mode (ie. which of the [begin_...] functions above was used to initialize the [validation_state]). *) -- GitLab From b37cd4200a9e0d92975e52e6a8449f3f4558bb6d Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:54:23 +0200 Subject: [PATCH 10/13] alpha: rename endorsement in apply --- src/proto_alpha/lib_protocol/apply.ml | 46 +++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 58e3bad96b62..c7708af8fec2 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -2053,10 +2053,10 @@ let record_preattestation ctxt (mode : mode) (content : consensus_content) : in return (ctxt, mk_preattestation_result consensus_key 0 (* Fake power. *)) -let record_endorsement ctxt (mode : mode) (content : consensus_content) : +let record_attestation ctxt (mode : mode) (content : consensus_content) : (context * Kind.attestation contents_result_list) tzresult Lwt.t = let open Lwt_result_syntax in - let mk_endorsement_result ({delegate; consensus_pkh; _} : Consensus_key.pk) + let mk_attestation_result ({delegate; consensus_pkh; _} : Consensus_key.pk) consensus_power = Single_result (Attestation_result @@ -2075,20 +2075,20 @@ let record_endorsement ctxt (mode : mode) (content : consensus_content) : let*? ctxt = Consensus.record_attestation ctxt ~initial_slot:content.slot ~power in - return (ctxt, mk_endorsement_result consensus_key power) + return (ctxt, mk_attestation_result consensus_key power) | Partial_construction _ -> - (* In mempool mode, endorsements are allowed for various levels - and rounds. We do not record endorsements because we could get - false-positive conflicts for endorsements with the same slot - but different levels/rounds. We could record just endorsements + (* In mempool mode, attestations are allowed for various levels + and rounds. We do not record attestations because we could get + false-positive conflicts for attestations with the same slot + but different levels/rounds. We could record just attestations for the predecessor's level and round (the most usual - endorsements), but we don't need to, because there is no block + attestations), but we don't need to, because there is no block to finalize anyway in this mode. *) let* ctxt, consensus_key = let level = Level.from_raw ctxt content.level in Stake_distribution.slot_owner ctxt level content.slot in - return (ctxt, mk_endorsement_result consensus_key 0 (* Fake power. *)) + return (ctxt, mk_attestation_result consensus_key 0 (* Fake power. *)) let apply_manager_contents_list ctxt ~payload_producer chain_id ~gas_cost_for_sig_check fees_updated_contents_list = @@ -2187,7 +2187,7 @@ let apply_contents_list (type kind) ctxt chain_id (mode : mode) | Single (Preattestation consensus_content) -> record_preattestation ctxt mode consensus_content | Single (Attestation consensus_content) -> - record_endorsement ctxt mode consensus_content + record_attestation ctxt mode consensus_content | Single (Dal_attestation op) -> (* DAL/FIXME https://gitlab.com/tezos/tezos/-/issues/3115 @@ -2196,8 +2196,8 @@ let apply_contents_list (type kind) ctxt chain_id (mode : mode) signature. Consequently, it is really important to ensure this operation cannot be included into a block when the feature flag is not set. This is done in order to avoid modifying the - endorsement encoding. However, once the DAL will be ready, this - operation should be merged with an endorsement or at least + attestation encoding. However, once the DAL will be ready, this + operation should be merged with an attestation or at least refined. *) Dal_apply.apply_attestation ctxt op >>?= fun ctxt -> return @@ -2490,15 +2490,15 @@ let apply_liquidity_baking_subsidy ctxt ~per_block_vote = let ctxt = Gas.set_unlimited backtracking_ctxt in Ok (ctxt, [])) -let are_endorsements_required ctxt ~level = +let are_attestations_required ctxt ~level = First_level_of_protocol.get ctxt >|=? fun first_level -> (* NB: the first level is the level of the migration block. There - are no endorsements for this block. Therefore the block at the - next level cannot contain endorsements. *) + are no attestations for this block. Therefore the block at the + next level cannot contain attestations. *) let level_position_in_protocol = Raw_level.diff level first_level in Compare.Int32.(level_position_in_protocol > 1l) -let record_endorsing_participation ctxt = +let record_attesting_participation ctxt = let open Lwt_result_syntax in let*? validators = match Consensus.allowed_attestations ctxt with @@ -2599,7 +2599,7 @@ let begin_full_construction ctxt chain_id ~migration_balance_updates ~predecessor_round ~timestamp in - (* The endorsement/preattestation validation rules for construction are the + (* The attestation/preattestation validation rules for construction are the same as for application. *) let current_level = Level.current ctxt in let* ctxt, _slot, block_producer = @@ -2700,8 +2700,8 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash let open Lwt_result_syntax in let level = Level.current ctxt in let attestation_power = Consensus.current_attestation_power ctxt in - let* required_endorsements = - are_endorsements_required ctxt ~level:level.level + let* required_attestations = + are_attestations_required ctxt ~level:level.level in let block_payload_hash = Block_payload.hash @@ -2710,7 +2710,7 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash (non_consensus_operations ctxt) in (* from this point nothing should fail *) - (* We mark the endorsement branch as the grand parent branch when + (* We mark the attestation branch as the grand parent branch when accessible. This will not be present before the first two blocks of tenderbake. *) let level = Level.current ctxt in @@ -2730,8 +2730,8 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash Nonce.record_hash ctxt {nonce_hash; delegate = block_producer.delegate} in let* ctxt, reward_bonus = - if required_endorsements then - let* ctxt = record_endorsing_participation ctxt in + if required_attestations then + let* ctxt = record_attesting_participation ctxt in let*? rewards_bonus = Baking.bonus_baking_reward ctxt ~attestation_power in @@ -2892,7 +2892,7 @@ let finalize_block (application_state : application_state) shell_header_opt = (* Fake finalization to return a correct type, because there is no block to finalize in mempool mode. If this changes in the future, beware that consensus operations are not recorded by - {!record_preattestation} and {!record_endorsement} in this mode. *) + {!record_preattestation} and {!record_attestation} in this mode. *) let* voting_period_info = Voting_period.get_rpc_current_info ctxt in let level_info = Level.current ctxt in let result = finalize ctxt predecessor_fitness in -- GitLab From 55ca48ed249c28a06864957c65332f636a2d813b Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 10:57:50 +0200 Subject: [PATCH 11/13] alpha: rename endorsement in dal files --- src/proto_alpha/lib_protocol/dal_attestation_repr.ml | 4 ++-- src/proto_alpha/lib_protocol/dal_attestation_repr.mli | 4 ++-- src/proto_alpha/lib_protocol/dal_slot_repr.ml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/proto_alpha/lib_protocol/dal_attestation_repr.ml b/src/proto_alpha/lib_protocol/dal_attestation_repr.ml index 0eee79e381d5..57ec4ebb8028 100644 --- a/src/proto_alpha/lib_protocol/dal_attestation_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_attestation_repr.ml @@ -46,8 +46,8 @@ type t = Bitset.t type operation = { attestor : Signature.Public_key_hash.t; (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/4165 - Compute the endorser from the attested slots in [slot_attestation] below, - or provide a field `min_endorser_slot : int / int32` *) + Compute the attester from the attested slots in [slot_attestation] below, + or provide a field `min_attester_slot : int / int32` *) attestation : t; level : Raw_level_repr.t; } diff --git a/src/proto_alpha/lib_protocol/dal_attestation_repr.mli b/src/proto_alpha/lib_protocol/dal_attestation_repr.mli index 17139107101e..7a62135f6b72 100644 --- a/src/proto_alpha/lib_protocol/dal_attestation_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_attestation_repr.mli @@ -31,7 +31,7 @@ slots at every level (see {!Dal_slot_repr}). Slots are not posted directly onto L1 blocks. Stakeholders, called attestors in this context, can commit on the availability of the data (via - endorsements or attestation operations, see + attestation operations, see https://gitlab.com/tezos/tezos/-/issues/3115). The slot is uniformly split into shards. Each attestor commits, @@ -39,7 +39,7 @@ to. This module encapsulates the representation of this commitment - that aims to be provided with endorsement operations. To avoid + that aims to be provided with attestation operations. To avoid overloading the network, this representation should be compact. *) type t = private Bitset.t diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.ml b/src/proto_alpha/lib_protocol/dal_slot_repr.ml index 210757f072f5..0441bc72ccd9 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.ml @@ -426,7 +426,7 @@ module History = struct A Dal proof is an algebraic datatype with two cases, where we basically prove that a Dal page is confirmed on L1 or not. Being 'not confirmed' here includes the case where the slot's header is not published and the - case where the slot's header is published, but the endorsers didn't + case where the slot's header is published, but the attesters didn't confirm the availability of its data. To produce a proof representation for a page (see function {!produce_proof_repr} -- GitLab From 2df1a23c42a5cf4c0fad35d25c5250e1ad57a556 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 7 Jul 2023 11:02:09 +0200 Subject: [PATCH 12/13] alpha: rename remaining endorsement in comments --- src/proto_alpha/lib_protocol/delegate_storage.mli | 4 ++-- src/proto_alpha/lib_protocol/init_storage.ml | 2 +- src/proto_alpha/lib_protocol/main.ml | 8 ++++---- src/proto_alpha/lib_protocol/mempool_validation.mli | 2 +- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 2 +- src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli | 2 +- src/proto_alpha/lib_protocol/seed_storage.mli | 2 +- src/proto_alpha/lib_protocol/storage.mli | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_storage.mli b/src/proto_alpha/lib_protocol/delegate_storage.mli index a9248eaad9e6..43821be34c16 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.mli +++ b/src/proto_alpha/lib_protocol/delegate_storage.mli @@ -116,14 +116,14 @@ val staking_balance : Raw_context.t -> Signature.Public_key_hash.t -> Tez_repr.t tzresult Lwt.t (** [is_forbidden_delegate ctxt delegate] returns [true] if the given - [delegate] is forbidden to bake or endorse. This means that its + [delegate] is forbidden to bake or attest. This means that its current frozen deposit is equal to zero. Returns [false] otherwise. *) val is_forbidden_delegate : Raw_context.t -> Signature.Public_key_hash.t -> bool (** [forbid_delegate ctxt delegate] adds [delegate] to the set of forbidden delegates and stores the updated set, which prevents this - delegate from baking or endorsing. *) + delegate from baking or attesting. *) val forbid_delegate : Raw_context.t -> Signature.Public_key_hash.t -> Raw_context.t Lwt.t diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 157283fc0fc4..3572233131b9 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -235,7 +235,7 @@ let prepare_first_block chain_id ctxt ~typecheck_smart_contract | 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); + (* 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`. *) diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 897c91e792b8..692c8b114e67 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -86,7 +86,7 @@ let validation_passes = let open Alpha_context.Constants in Updater. [ - (* 2048 endorsements *) + (* 2048 attestations *) {max_size = 2048 * 2048; max_op = Some 2048}; (* 32k of voting operations *) {max_size = 32 * 1024; max_op = None}; @@ -126,7 +126,7 @@ type mode = about the validation/application of a block: application, partial validation, and full construction. - In these modes, endorsements must point to the predecessor's level + In these modes, attestations must point to the predecessor's level and preattestations, if any, to the block's level. *) let init_consensus_rights_for_block ctxt mode ~predecessor_level = let open Lwt_result_syntax in @@ -167,7 +167,7 @@ let init_consensus_rights_for_block ctxt mode ~predecessor_level = construction mode). In the mempool, there are three allowed levels for both - endorsements and preattestations: [predecessor_level - 1] (aka the + attestations and preattestations: [predecessor_level - 1] (aka the grandparent's level), [predecessor_level] (that is, the level of the mempool's head), and [predecessor_level + 1] (aka the current level in ctxt). *) @@ -176,7 +176,7 @@ let init_consensus_rights_for_mempool ctxt ~predecessor_level = let open Alpha_context in (* We don't want to compute the tables by first slot for all three possible levels because it is time-consuming. So we don't compute - any [allowed_endorsements] or [allowed_preattestations] tables. *) + any [allowed_attestations] or [allowed_preattestations] tables. *) let ctxt = Consensus.initialize_consensus_operation ctxt diff --git a/src/proto_alpha/lib_protocol/mempool_validation.mli b/src/proto_alpha/lib_protocol/mempool_validation.mli index 8f205601a453..6b9c8183d612 100644 --- a/src/proto_alpha/lib_protocol/mempool_validation.mli +++ b/src/proto_alpha/lib_protocol/mempool_validation.mli @@ -42,7 +42,7 @@ responsability to ensure that the set of selected operations does not exceed gas/size operations quota. - The baker must also include the required preattestations and - endorsements. + attestations. - The merging of two mempools also maintains the aforementioned properties. diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index bc777364d618..43a22c9bcc0f 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -1225,7 +1225,7 @@ module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : let* dal_params = Dal_parameters.get in let inbox_level = Raw_level_repr.to_int32 inbox_level in (* the [published_level]'s pages to request is [inbox_level - - endorsement_lag - 1]. *) + attestation_lag - 1]. *) let lvl = Int32.sub (Int32.sub inbox_level dal_params.attestation_lag) 1l in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli index bfd29b5c6ace..b73bafaec0d6 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli @@ -222,7 +222,7 @@ module type PVM_with_context_and_state = sig a slot's {!val: Dal_slot_repr.commitment}. *) val dal_parameters : Dal_slot_repr.parameters - (** The lag between the time an endorsement is published on L1 + (** The lag between the time an attestation is published on L1 (its published_level) and the level it should be confirmed. *) val dal_attestation_lag : int end diff --git a/src/proto_alpha/lib_protocol/seed_storage.mli b/src/proto_alpha/lib_protocol/seed_storage.mli index 93c8520aee94..05bfce77d2ac 100644 --- a/src/proto_alpha/lib_protocol/seed_storage.mli +++ b/src/proto_alpha/lib_protocol/seed_storage.mli @@ -81,7 +81,7 @@ val for_cycle : Raw_context.t -> Cycle_repr.t -> Seed_repr.seed tzresult Lwt.t val compute_randao : Raw_context.t -> Raw_context.t tzresult Lwt.t (** Must be run at the end of the cycle, resets the VDF state and returns - unrevealed nonces to know which party has to forfeit its endorsing + unrevealed nonces to know which party has to forfeit its attesting rewards for that cycle. *) val cycle_end : Raw_context.t -> diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 46498b657651..53206dba7f43 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -809,7 +809,7 @@ module Tenderbake : sig and type t := Raw_context.t (** [Forbidden_delegates] stores the set of delegates that are not - allowed to bake or endorse blocks. *) + allowed to bake or attest blocks. *) module Forbidden_delegates : Single_data_storage with type value = Signature.Public_key_hash.Set.t -- GitLab From 9b1d90230d9de42a666962218374bd30c54ddb3f Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 19 Jul 2023 10:53:50 +0200 Subject: [PATCH 13/13] alpha: fix a typo in storage encoding --- src/proto_alpha/lib_protocol/storage.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 5d2d5440a296..0f28c7eeab67 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1098,7 +1098,7 @@ module Slashed_level = struct (for_double_attesting, for_double_baking)) (fun (for_double_attesting, for_double_baking) -> {for_double_attesting; for_double_baking}) - (obj2 (req "for_double_attestating" bool) (req "for_double_baking" bool)) + (obj2 (req "for_double_attesting" bool) (req "for_double_baking" bool)) end module Cycle = struct -- GitLab