diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index 2c87a9c76ede30e33b746dec5ad536c79a012cb6..271719ebc5f3fbea6fd0654f931fc113dce14db4 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -139,11 +139,11 @@ type block_to_bake = { type action = | Do_nothing | Inject_block of {block_to_bake : block_to_bake; updated_state : state} - | Inject_preendorsements of { - preendorsements : (consensus_key_and_delegate * consensus_content) list; + | Inject_preattestations of { + preattestations : (consensus_key_and_delegate * consensus_content) list; } - | Inject_endorsements of { - endorsements : (consensus_key_and_delegate * consensus_content) list; + | Inject_attestations of { + attestations : (consensus_key_and_delegate * consensus_content) list; } | Update_to_level of level_update | Synchronize_round of round_update @@ -168,8 +168,8 @@ type t = action let pp_action fmt = function | Do_nothing -> Format.fprintf fmt "do nothing" | Inject_block _ -> Format.fprintf fmt "inject block" - | Inject_preendorsements _ -> Format.fprintf fmt "inject preattestations" - | Inject_endorsements _ -> Format.fprintf fmt "inject attestations" + | Inject_preattestations _ -> Format.fprintf fmt "inject preattestations" + | Inject_attestations _ -> Format.fprintf fmt "inject attestations" | Update_to_level _ -> Format.fprintf fmt "update to level" | Synchronize_round _ -> Format.fprintf fmt "synchronize round" | Watch_proposal -> Format.fprintf fmt "watch proposal" @@ -422,7 +422,7 @@ let inject_block ~state_recorder state block_to_bake ~updated_state = in return updated_state -let inject_preendorsements state ~preendorsements = +let inject_preattestations state ~preattestations = let open Lwt_result_syntax in let cctxt = state.global_state.cctxt in let chain_id = state.global_state.chain_id in @@ -450,7 +450,7 @@ let inject_preendorsements state ~preendorsements = let* may_sign = cctxt#with_lock (fun () -> let* may_sign = - Baking_highwatermarks.may_sign_preendorsement + Baking_highwatermarks.may_sign_preattestation cctxt block_location ~delegate:consensus_key.public_key_hash @@ -460,7 +460,7 @@ let inject_preendorsements state ~preendorsements = match may_sign with | true -> let* () = - Baking_highwatermarks.record_preendorsement + Baking_highwatermarks.record_preattestation cctxt block_location ~delegate:consensus_key.public_key_hash @@ -496,7 +496,7 @@ let inject_preendorsements state ~preendorsements = in let operation : Operation.packed = {shell; protocol_data} in return_some (delegate, operation, level, round)) - preendorsements + preattestations in (* TODO: add a RPC to inject multiple operations *) List.iter_ep @@ -517,7 +517,7 @@ let inject_preendorsements state ~preendorsements = return_unit)) signed_operations -let sign_endorsements state endorsements = +let sign_attestations state attestations = let open Lwt_result_syntax in let cctxt = state.global_state.cctxt in let chain_id = state.global_state.chain_id in @@ -547,7 +547,7 @@ let sign_endorsements state endorsements = let* may_sign = cctxt#with_lock (fun () -> let* may_sign = - Baking_highwatermarks.may_sign_endorsement + Baking_highwatermarks.may_sign_attestation cctxt block_location ~delegate:consensus_key.public_key_hash @@ -557,7 +557,7 @@ let sign_endorsements state endorsements = match may_sign with | true -> let* () = - Baking_highwatermarks.record_endorsement + Baking_highwatermarks.record_attestation cctxt block_location ~delegate:consensus_key.public_key_hash @@ -591,7 +591,7 @@ let sign_endorsements state endorsements = in let operation : Operation.packed = {shell; protocol_data} in return_some (delegate, operation, level, round)) - endorsements + attestations let sign_dal_attestations state attestations = let open Lwt_result_syntax in @@ -636,11 +636,11 @@ let sign_dal_attestations state attestations = (delegate, operation, consensus_content.Dal.Attestation.attestation)) attestations -let inject_endorsements state ~endorsements = +let inject_attestations state ~attestations = let open Lwt_result_syntax in let cctxt = state.global_state.cctxt in let chain_id = state.global_state.chain_id in - let* signed_operations = sign_endorsements state endorsements in + let* signed_operations = sign_attestations state attestations in (* TODO: add a RPC to inject multiple operations *) List.iter_ep (fun (delegate, operation, level, round) -> @@ -792,23 +792,23 @@ let prepare_waiting_for_quorum state = in (consensus_threshold, get_slot_voting_power, candidate) -let start_waiting_for_preendorsement_quorum state = +let start_waiting_for_preattestation_quorum state = let consensus_threshold, get_slot_voting_power, candidate = prepare_waiting_for_quorum state in let operation_worker = state.global_state.operation_worker in - Operation_worker.monitor_preendorsement_quorum + Operation_worker.monitor_preattestation_quorum operation_worker ~consensus_threshold ~get_slot_voting_power candidate -let start_waiting_for_endorsement_quorum state = +let start_waiting_for_attestation_quorum state = let consensus_threshold, get_slot_voting_power, candidate = prepare_waiting_for_quorum state in let operation_worker = state.global_state.operation_worker in - Operation_worker.monitor_endorsement_quorum + Operation_worker.monitor_attestation_quorum operation_worker ~consensus_threshold ~get_slot_voting_power @@ -902,15 +902,15 @@ let rec perform_action ~state_recorder state (action : action) = return state | Inject_block {block_to_bake; updated_state} -> inject_block state ~state_recorder block_to_bake ~updated_state - | Inject_preendorsements {preendorsements} -> - let* () = inject_preendorsements state ~preendorsements in + | Inject_preattestations {preattestations} -> + let* () = inject_preattestations state ~preattestations in perform_action ~state_recorder state Watch_proposal - | Inject_endorsements {endorsements} -> + | Inject_attestations {attestations} -> let* () = state_recorder ~new_state:state in - let* () = inject_endorsements state ~endorsements in - (* We wait for endorsements to trigger the [Quorum_reached] + let* () = inject_attestations state ~attestations in + (* We wait for attestations to trigger the [Quorum_reached] event *) - let*! () = start_waiting_for_endorsement_quorum state in + let*! () = start_waiting_for_attestation_quorum state in (* TODO: https://gitlab.com/tezos/tezos/-/issues/4667 Also inject attestations for the migration block. *) (* TODO: https://gitlab.com/tezos/tezos/-/issues/4671 @@ -924,7 +924,7 @@ let rec perform_action ~state_recorder state (action : action) = let* new_state, new_action = synchronize_round state round_update in perform_action ~state_recorder new_state new_action | Watch_proposal -> - (* We wait for preendorsements to trigger the + (* We wait for preattestations to trigger the [Prequorum_reached] event *) - let*! () = start_waiting_for_preendorsement_quorum state in + let*! () = start_waiting_for_preattestation_quorum state in return state diff --git a/src/proto_alpha/lib_delegate/baking_actions.mli b/src/proto_alpha/lib_delegate/baking_actions.mli index 84669d976d7e764d5460160be5eaa79f2f058b9d..3ecf8433abaf6016636921258d394bc4481cf1fa 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.mli +++ b/src/proto_alpha/lib_delegate/baking_actions.mli @@ -51,11 +51,11 @@ type block_to_bake = { type action = | Do_nothing | Inject_block of {block_to_bake : block_to_bake; updated_state : state} - | Inject_preendorsements of { - preendorsements : (consensus_key_and_delegate * consensus_content) list; + | Inject_preattestations of { + preattestations : (consensus_key_and_delegate * consensus_content) list; } - | Inject_endorsements of { - endorsements : (consensus_key_and_delegate * consensus_content) list; + | Inject_attestations of { + attestations : (consensus_key_and_delegate * consensus_content) list; } | Update_to_level of level_update | Synchronize_round of round_update @@ -90,21 +90,21 @@ val inject_block : updated_state:state -> state tzresult Lwt.t -val inject_preendorsements : +val inject_preattestations : state -> - preendorsements:(consensus_key_and_delegate * consensus_content) list -> + preattestations:(consensus_key_and_delegate * consensus_content) list -> unit tzresult Lwt.t -val sign_endorsements : +val sign_attestations : state -> (consensus_key_and_delegate * consensus_content) list -> (consensus_key_and_delegate * packed_operation * int32 * Round.t) list tzresult Lwt.t -val inject_endorsements : +val inject_attestations : state -> - endorsements:(consensus_key_and_delegate * consensus_content) list -> + attestations:(consensus_key_and_delegate * consensus_content) list -> unit tzresult Lwt.t val sign_dal_attestations : @@ -122,9 +122,9 @@ val get_dal_attestations : val prepare_waiting_for_quorum : state -> int * (slot:Slot.t -> int option) * Operation_worker.candidate -val start_waiting_for_preendorsement_quorum : state -> unit Lwt.t +val start_waiting_for_preattestation_quorum : state -> unit Lwt.t -val start_waiting_for_endorsement_quorum : state -> unit Lwt.t +val start_waiting_for_attestation_quorum : state -> unit Lwt.t val update_to_level : state -> level_update -> (state * t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/baking_commands.ml b/src/proto_alpha/lib_delegate/baking_commands.ml index bf76bd5caeade6f07fad6754270c7e2c3948c39a..65c165fe4df4c0e7f9dfa72354ea7eb33858269f 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.ml +++ b/src/proto_alpha/lib_delegate/baking_commands.ml @@ -410,7 +410,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list (prefixes ["attest"; "for"] @@ sources_param) (fun force pkhs cctxt -> let* delegates = get_delegates cctxt pkhs in - Baking_lib.endorse ~force cctxt delegates); + Baking_lib.attest ~force cctxt delegates); command ~group ~desc: @@ -420,7 +420,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list (prefixes ["endorse"; "for"] @@ sources_param) (fun force pkhs cctxt -> let* delegates = get_delegates cctxt pkhs in - Baking_lib.endorse ~force cctxt delegates); + Baking_lib.attest ~force cctxt delegates); command ~group ~desc:"Forge and inject a preattestation operation." @@ -428,7 +428,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list (prefixes ["preattest"; "for"] @@ sources_param) (fun force pkhs cctxt -> let* delegates = get_delegates cctxt pkhs in - Baking_lib.preendorse ~force cctxt delegates); + Baking_lib.preattest ~force cctxt delegates); command ~group ~desc: @@ -438,7 +438,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list (prefixes ["preendorse"; "for"] @@ sources_param) (fun force pkhs cctxt -> let* delegates = get_delegates cctxt pkhs in - Baking_lib.preendorse ~force cctxt delegates); + Baking_lib.preattest ~force cctxt delegates); command ~group ~desc:"Send a Tenderbake proposal" diff --git a/src/proto_alpha/lib_delegate/baking_highwatermarks.ml b/src/proto_alpha/lib_delegate/baking_highwatermarks.ml index 5ff827b3d6c2d2ae5ca24976e87063b6b10b2584..d4e3201795c8e1c6d6b3a1c5fd3cc36d7a0aec33 100644 --- a/src/proto_alpha/lib_delegate/baking_highwatermarks.ml +++ b/src/proto_alpha/lib_delegate/baking_highwatermarks.ml @@ -117,41 +117,68 @@ let highwatermark_delegate_map_encoding = type highwatermarks = { blocks : highwatermark DelegateMap.t; - preendorsements : highwatermark DelegateMap.t; - endorsements : highwatermark DelegateMap.t; + preattestations : highwatermark DelegateMap.t; + attestations : highwatermark DelegateMap.t; } type t = highwatermarks -let encoding = +let encoding ~use_legacy_attestation_name = let open Data_encoding in conv - (fun {blocks; preendorsements; endorsements} -> - (blocks, preendorsements, endorsements)) - (fun (blocks, preendorsements, endorsements) -> - {blocks; preendorsements; endorsements}) + (fun {blocks; preattestations; attestations} -> + (blocks, preattestations, attestations)) + (fun (blocks, preattestations, attestations) -> + {blocks; preattestations; attestations}) (obj3 (req "blocks" highwatermark_delegate_map_encoding) - (req "preendorsements" highwatermark_delegate_map_encoding) - (req "endorsements" highwatermark_delegate_map_encoding)) + (req + (if use_legacy_attestation_name then "preendorsements" + else "preattestations") + highwatermark_delegate_map_encoding) + (req + (if use_legacy_attestation_name then "endorsements" + else "attestations") + highwatermark_delegate_map_encoding)) + +let load_encoding = + let open Data_encoding in + union + [ + case + ~title:"new" + (Tag 0) + (encoding ~use_legacy_attestation_name:false) + Option.some + Fun.id; + case + ~title:"old" + (Tag 1) + (encoding ~use_legacy_attestation_name:true) + Option.some + Fun.id; + ] let empty = { blocks = DelegateMap.empty; - preendorsements = DelegateMap.empty; - endorsements = DelegateMap.empty; + preattestations = DelegateMap.empty; + attestations = DelegateMap.empty; } (* We do not lock these functions. The caller will be already locked. *) let load (cctxt : #Protocol_client_context.full) location : t tzresult Lwt.t = protect (fun () -> - cctxt#load (Baking_files.filename location) encoding ~default:empty) + cctxt#load (Baking_files.filename location) load_encoding ~default:empty) let save_highwatermarks (cctxt : #Protocol_client_context.full) filename highwatermarks : unit tzresult Lwt.t = protect (fun () -> (* TODO: improve the backend so we don't write partial informations *) - cctxt#write filename highwatermarks encoding) + cctxt#write + filename + highwatermarks + (encoding ~use_legacy_attestation_name:false)) let may_sign highwatermarks ~delegate ~level ~round = match DelegateMap.find delegate highwatermarks with @@ -168,15 +195,15 @@ let may_sign_block cctxt (location : [`Highwatermarks] Baking_files.location) let* all_highwatermarks = load cctxt location in return @@ may_sign all_highwatermarks.blocks ~delegate ~level ~round -let may_sign_preendorsement cctxt location ~delegate ~level ~round = +let may_sign_preattestation cctxt location ~delegate ~level ~round = let open Lwt_result_syntax in let* all_highwatermarks = load cctxt location in - return @@ may_sign all_highwatermarks.preendorsements ~delegate ~level ~round + return @@ may_sign all_highwatermarks.preattestations ~delegate ~level ~round -let may_sign_endorsement cctxt location ~delegate ~level ~round = +let may_sign_attestation cctxt location ~delegate ~level ~round = let open Lwt_result_syntax in let* all_highwatermarks = load cctxt location in - return @@ may_sign all_highwatermarks.endorsements ~delegate ~level ~round + return @@ may_sign all_highwatermarks.attestations ~delegate ~level ~round let record map ~delegate ~new_level ~new_round = DelegateMap.update @@ -203,14 +230,14 @@ let record_block (cctxt : #Protocol_client_context.full) location ~delegate in save_highwatermarks cctxt filename {highwatermarks with blocks = new_blocks} -let record_preendorsement (cctxt : #Protocol_client_context.full) location +let record_preattestation (cctxt : #Protocol_client_context.full) location ~delegate ~level ~round = let open Lwt_result_syntax in let filename = Baking_files.filename location in let* highwatermarks = load cctxt location in - let new_preendorsements = + let new_preattestations = record - highwatermarks.preendorsements + highwatermarks.preattestations ~delegate ~new_level:level ~new_round:round @@ -218,16 +245,16 @@ let record_preendorsement (cctxt : #Protocol_client_context.full) location save_highwatermarks cctxt filename - {highwatermarks with preendorsements = new_preendorsements} + {highwatermarks with preattestations = new_preattestations} -let record_endorsement (cctxt : #Protocol_client_context.full) location +let record_attestation (cctxt : #Protocol_client_context.full) location ~delegate ~level ~round = let open Lwt_result_syntax in let filename = Baking_files.filename location in let* highwatermarks = load cctxt location in - let new_endorsements = + let new_attestations = record - highwatermarks.endorsements + highwatermarks.attestations ~delegate ~new_level:level ~new_round:round @@ -235,4 +262,4 @@ let record_endorsement (cctxt : #Protocol_client_context.full) location save_highwatermarks cctxt filename - {highwatermarks with endorsements = new_endorsements} + {highwatermarks with attestations = new_attestations} diff --git a/src/proto_alpha/lib_delegate/baking_highwatermarks.mli b/src/proto_alpha/lib_delegate/baking_highwatermarks.mli index eca9165cdcca799dcc53a289b7270bb326c10c60..f189a0d972077fdb36cb4c35724444b17ad330d1 100644 --- a/src/proto_alpha/lib_delegate/baking_highwatermarks.mli +++ b/src/proto_alpha/lib_delegate/baking_highwatermarks.mli @@ -35,8 +35,6 @@ type error += Block_previously_attested of highwatermark type t -val encoding : t Data_encoding.t - val load : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> @@ -50,7 +48,7 @@ val may_sign_block : round:Round.t -> bool tzresult Lwt.t -val may_sign_preendorsement : +val may_sign_preattestation : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> delegate:Signature.public_key_hash -> @@ -58,7 +56,7 @@ val may_sign_preendorsement : round:Round.t -> bool tzresult Lwt.t -val may_sign_endorsement : +val may_sign_attestation : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> delegate:Signature.public_key_hash -> @@ -74,7 +72,7 @@ val record_block : round:Round.t -> unit tzresult Lwt.t -val record_preendorsement : +val record_preattestation : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> delegate:Signature.public_key_hash -> @@ -82,7 +80,7 @@ val record_preendorsement : round:Round.t -> unit tzresult Lwt.t -val record_endorsement : +val record_attestation : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> delegate:Signature.public_key_hash -> diff --git a/src/proto_alpha/lib_delegate/baking_lib.ml b/src/proto_alpha/lib_delegate/baking_lib.ml index ea1ab57e8b94edfa967c88f9de2c265afc47e8a0..cbd164e4d1192272b1481f918cd411b4ae44ff44 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.ml +++ b/src/proto_alpha/lib_delegate/baking_lib.ml @@ -55,7 +55,7 @@ let get_current_proposal cctxt ?cache () = module Events = Baking_events.Lib -let preendorse (cctxt : Protocol_client_context.full) ?(force = false) delegates +let preattest (cctxt : Protocol_client_context.full) ?(force = false) delegates = let open State_transitions in let open Lwt_result_syntax in @@ -86,9 +86,9 @@ let preendorse (cctxt : Protocol_client_context.full) ?(force = false) delegates Baking_state.pp_consensus_key_and_delegate) (List.map fst consensus_list) in - Baking_actions.inject_preendorsements state ~preendorsements:consensus_list + Baking_actions.inject_preattestations state ~preattestations:consensus_list -let endorse (cctxt : Protocol_client_context.full) ?(force = false) delegates = +let attest (cctxt : Protocol_client_context.full) ?(force = false) delegates = let open State_transitions in let open Lwt_result_syntax in let cache = Baking_cache.Block_cache.create 10 in @@ -120,7 +120,7 @@ let endorse (cctxt : Protocol_client_context.full) ?(force = false) delegates = let* () = Baking_state.may_record_new_state ~previous_state:state ~new_state:state in - Baking_actions.inject_endorsements state ~endorsements:consensus_list + Baking_actions.inject_attestations state ~attestations:consensus_list let bake_at_next_level state = let open Lwt_result_syntax in @@ -145,7 +145,7 @@ let bake_at_next_level state = return (Baking_state.Timeout (Time_to_bake_next_level {at_round = round})) (* Simulate the end of the current round to bootstrap the automaton - or endorse the block if necessary *) + or attest the block if necessary *) let first_automaton_event state = match state.level_state.elected_block with | None -> Lwt.return (Baking_scheduling.compute_bootstrap_event state) @@ -154,21 +154,21 @@ let first_automaton_event state = level after waiting its date *) bake_at_next_level state -let endorsements_endorsing_power state endorsements = - let get_endorsement_voting_power {slot; _} = +let attestations_attesting_power state attestations = + let get_attestation_voting_power {slot; _} = match Delegate_slots.voting_power state.level_state.delegate_slots ~slot with | None -> 0 (* cannot happen *) - | Some endorsing_power -> endorsing_power + | Some attesting_power -> attesting_power in - List.sort_uniq compare endorsements + List.sort_uniq compare attestations |> List.fold_left - (fun power endorsement -> - power + get_endorsement_voting_power endorsement) + (fun power attestation -> + power + get_attestation_voting_power attestation) 0 -let generic_endorsing_power (filter : packed_operation list -> 'a list) +let generic_attesting_power (filter : packed_operation list -> 'a list) (extract : 'a -> consensus_content) state = let current_mempool = Operation_worker.get_current_operations state.global_state.operation_worker @@ -176,10 +176,10 @@ let generic_endorsing_power (filter : packed_operation list -> 'a list) let latest_proposal = state.level_state.latest_proposal in let block_round = latest_proposal.block.round in let shell_level = latest_proposal.block.shell.level in - let endorsements = + let attestations = filter (Operation_pool.Operation_set.elements current_mempool.consensus) in - let endorsements_in_mempool = + let attestations_in_mempool = List.filter_map (fun v -> let consensus_content = extract v in @@ -189,14 +189,14 @@ let generic_endorsing_power (filter : packed_operation list -> 'a list) Raw_level.to_int32 consensus_content.level = shell_level) then Some consensus_content else None) - endorsements + attestations in - let power = endorsements_endorsing_power state endorsements_in_mempool in - (power, endorsements) + let power = attestations_attesting_power state attestations_in_mempool in + (power, attestations) -let state_endorsing_power = - generic_endorsing_power - Operation_pool.filter_endorsements +let state_attesting_power = + generic_attesting_power + Operation_pool.filter_attestations (fun ({ protocol_data = {contents = Single (Attestation consensus_content); _}; @@ -262,23 +262,23 @@ let propose_at_next_level ~minimal_timestamp state = let* state = State_transitions.step state event >>= do_action in cctxt#message "Proposal injected" >>= fun () -> return state -let endorsement_quorum state = - let power, endorsements = state_endorsing_power state in +let attestation_quorum state = + let power, attestations = state_attesting_power state in if Compare.Int.( power >= state.global_state.constants.parametric.consensus_threshold) - then Some (power, endorsements) + then Some (power, attestations) else None (* Here's the sketch of the algorithm: - Do I have an endorsement quorum for the current block or an elected block? + Do I have an attestation quorum for the current block or an elected block? - Yes :: wait and propose at next level - No :: Is the current proposal at the right round? - Yes :: fail propose - No :: - Is there a preendorsement quorum or does the last proposal contain a prequorum? - - Yes :: repropose block with right payload and preendorsements for current round + Is there a preattestation quorum or does the last proposal contain a prequorum? + - Yes :: repropose block with right payload and preattestations for current round - No :: repropose fresh block for current round *) let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply ?force @@ -302,15 +302,15 @@ let propose (cctxt : Protocol_client_context.full) ?minimal_fees match state.level_state.elected_block with | Some _ -> propose_at_next_level ~minimal_timestamp state | None -> ( - match endorsement_quorum state with - | Some (_voting_power, endorsement_qc) -> + match attestation_quorum state with + | Some (_voting_power, attestation_qc) -> let state = { state with round_state = { state.round_state with - current_phase = Baking_state.Awaiting_endorsements; + current_phase = Baking_state.Awaiting_attestations; }; } in @@ -325,7 +325,7 @@ let propose (cctxt : Protocol_client_context.full) ?minimal_fees let* state = State_transitions.step state - (Baking_state.Quorum_reached (candidate, endorsement_qc)) + (Baking_state.Quorum_reached (candidate, attestation_qc)) >>= do_action (* this will register the elected block *) in @@ -401,20 +401,20 @@ let bake_using_automaton config state heads_stream = return_unit | _ -> cctxt#error "Baking loop unexpectedly ended" -(* endorse the latest proposal and bake with it *) +(* attest the latest proposal and bake with it *) let baking_minimal_timestamp state = let open Lwt_result_syntax in let cctxt = state.global_state.cctxt in let latest_proposal = state.level_state.latest_proposal in - let own_endorsements = + let own_attestations = State_transitions.make_consensus_list state latest_proposal in let current_mempool = Operation_worker.get_current_operations state.global_state.operation_worker in - let endorsements_in_mempool = + let attestations_in_mempool = Operation_pool.( - filter_endorsements (Operation_set.elements current_mempool.consensus)) + filter_attestations (Operation_set.elements current_mempool.consensus)) |> List.filter_map (fun ({ @@ -434,10 +434,10 @@ let baking_minimal_timestamp state = in let total_voting_power = List.fold_left - (fun endorsements own -> snd own :: endorsements) - endorsements_in_mempool - own_endorsements - |> endorsements_endorsing_power state + (fun attestations own -> snd own :: attestations) + attestations_in_mempool + own_attestations + |> attestations_attesting_power state in let consensus_threshold = state.global_state.constants.parametric.consensus_threshold @@ -460,13 +460,13 @@ let baking_minimal_timestamp state = | None -> cctxt#error "No potential baking slot for the given delegates." | Some first_potential_round -> return first_potential_round in - let* signed_endorsements = - Baking_actions.sign_endorsements state own_endorsements + let* signed_attestations = + Baking_actions.sign_attestations state own_attestations in let pool = Operation_pool.add_operations current_mempool - (List.map (fun (_, x, _, _) -> x) signed_endorsements) + (List.map (fun (_, x, _, _) -> x) signed_attestations) in let dal_attestation_level = Int32.succ latest_proposal.block.shell.level in let* own_dal_attestations = diff --git a/src/proto_alpha/lib_delegate/baking_lib.mli b/src/proto_alpha/lib_delegate/baking_lib.mli index 8cfb36ced83d406e13e7de81f21148e236760b07..324ce221908bc502937f83ac695945b1924c1327 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.mli +++ b/src/proto_alpha/lib_delegate/baking_lib.mli @@ -42,13 +42,13 @@ val bake : Baking_state.consensus_key list -> unit tzresult Lwt.t -val preendorse : +val preattest : Protocol_client_context.full -> ?force:bool -> Baking_state.consensus_key list -> unit tzresult Lwt.t -val endorse : +val attest : Protocol_client_context.full -> ?force:bool -> Baking_state.consensus_key list -> diff --git a/src/proto_alpha/lib_delegate/baking_scheduling.ml b/src/proto_alpha/lib_delegate/baking_scheduling.ml index 608522a0a6fff9633ffe5de386f5573c76663cb2..b3fcea6f86217a44b222057fea95149b21a3655a 100644 --- a/src/proto_alpha/lib_delegate/baking_scheduling.ml +++ b/src/proto_alpha/lib_delegate/baking_scheduling.ml @@ -243,14 +243,14 @@ let rec wait_next_event ~timeout loop_state = loop_state.last_future_block_event <- None ; return_some (New_valid_proposal proposal) | `QC_reached - (Some (Operation_worker.Prequorum_reached (candidate, preendorsement_qc))) + (Some (Operation_worker.Prequorum_reached (candidate, preattestation_qc))) -> loop_state.last_get_qc_event <- None ; - return_some (Prequorum_reached (candidate, preendorsement_qc)) + return_some (Prequorum_reached (candidate, preattestation_qc)) | `QC_reached - (Some (Operation_worker.Quorum_reached (candidate, endorsement_qc))) -> + (Some (Operation_worker.Quorum_reached (candidate, attestation_qc))) -> loop_state.last_get_qc_event <- None ; - return_some (Quorum_reached (candidate, endorsement_qc)) + return_some (Quorum_reached (candidate, attestation_qc)) | `Timeout e -> return_some (Timeout e) (** From the current [state], the function returns an optional @@ -259,7 +259,7 @@ let rec wait_next_event ~timeout loop_state = let compute_next_round_time state = let open Baking_state in let proposal = - match state.level_state.endorsable_payload with + match state.level_state.attestable_payload with | None -> state.level_state.latest_proposal | Some {proposal; _} -> proposal in @@ -550,7 +550,7 @@ let compute_next_timeout state : Baking_state.timeout_kind Lwt.t tzresult Lwt.t | Some next_round, None -> ( (* If there is an elected block, then we make the assumption that the bakers at the next level have also received an - endorsement quorum, and we delay a bit injecting at the next + attestation quorum, and we delay a bit injecting at the next round, so that there are not two blocks injected at the same time. *) match state.level_state.elected_block with @@ -580,7 +580,7 @@ let compute_next_timeout state : Baking_state.timeout_kind Lwt.t tzresult Lwt.t (* same observation is in the [(Some next_round, None)] case *) delay_next_round_timeout next_round_info -(* initialises endorsable_payload with the PQC included in the latest block +(* initialises attestable_payload with the PQC included in the latest block if there is one and if it's more recent than the one loaded from disk if any *) let may_initialise_with_latest_proposal_pqc state = @@ -588,9 +588,9 @@ let may_initialise_with_latest_proposal_pqc state = match p.block.prequorum with | None -> return state | Some pqc -> ( - match state.level_state.endorsable_payload with + match state.level_state.attestable_payload with | Some ep when ep.prequorum.round >= pqc.round -> - (*do not change the endorsable_payload loaded from disk if it's + (*do not change the attestable_payload loaded from disk if it's more recent *) return state | Some _ | None -> @@ -600,7 +600,7 @@ let may_initialise_with_latest_proposal_pqc state = level_state = { state.level_state with - endorsable_payload = Some {prequorum = pqc; proposal = p}; + attestable_payload = Some {prequorum = pqc; proposal = p}; }; }) @@ -626,7 +626,7 @@ let create_dal_node_rpc_ctxt endpoint = let create_initial_state cctxt ?(synchronize = true) ~chain config operation_worker ~(current_proposal : Baking_state.proposal) delegates = - (* FIXME? consider saved endorsable value *) + (* FIXME? consider saved attestable value *) let open Protocol in let open Baking_state in Shell_services.Chain.chain_id cctxt ~chain () >>=? fun chain_id -> @@ -677,7 +677,7 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config if Baking_state.is_first_block_in_protocol current_proposal then (* If the last block is a protocol transition, we admit it as a final block *) - Some {proposal = current_proposal; endorsement_qc = []} + Some {proposal = current_proposal; attestation_qc = []} else None in let level_state = @@ -687,7 +687,7 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config is_latest_proposal_applied = true (* this proposal is expected to be the current head *); locked_round = None; - endorsable_payload = None; + attestable_payload = None; elected_block; delegate_slots; next_level_delegate_slots; @@ -708,8 +708,8 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config }) >>?= fun round_state -> let state = {global_state; level_state; round_state} in - (* Try loading locked round and endorsable round from disk *) - Baking_state.may_load_endorsable_data state >>=? fun state -> + (* Try loading locked round and attestable round from disk *) + Baking_state.may_load_attestable_data state >>=? fun state -> may_initialise_with_latest_proposal_pqc state let compute_bootstrap_event state = @@ -720,7 +720,7 @@ let compute_bootstrap_event state = state.level_state.latest_proposal.block.round = state.round_state.current_round) then - (* If so, then trigger the new proposal event to possibly preendorse *) + (* If so, then trigger the new proposal event to possibly preattest *) ok @@ Baking_state.New_head_proposal state.level_state.latest_proposal else (* Otherwise, trigger the end of round to check whether we @@ -775,7 +775,7 @@ let perform_sanity_check cctxt ~chain_id = (prefix_base_dir (Baking_files.filename highwatermarks_location) ^ "s")) >>=? fun _ -> let state_location = Baking_files.resolve_location ~chain_id `State in - Baking_state.load_endorsable_data cctxt state_location + Baking_state.load_attestable_data cctxt state_location |> trace (Cannot_load_local_file (prefix_base_dir (Baking_files.filename state_location))) diff --git a/src/proto_alpha/lib_delegate/baking_state.ml b/src/proto_alpha/lib_delegate/baking_state.ml index 0d25e32bef90422c38a259f2b476ffcbcd2637c4..b9af5963affc36b534df7c55a4ea70b2837ee494 100644 --- a/src/proto_alpha/lib_delegate/baking_state.ml +++ b/src/proto_alpha/lib_delegate/baking_state.ml @@ -97,7 +97,7 @@ type prequorum = { level : int32; round : Round.t; block_payload_hash : Block_payload_hash.t; - preendorsements : Kind.preattestation operation list; + preattestations : Kind.preattestation operation list; } type block_info = { @@ -143,22 +143,22 @@ type global_state = { let prequorum_encoding = let open Data_encoding in conv - (fun {level; round; block_payload_hash; preendorsements} -> - (level, round, block_payload_hash, List.map Operation.pack preendorsements)) - (fun (level, round, block_payload_hash, preendorsements) -> + (fun {level; round; block_payload_hash; preattestations} -> + (level, round, block_payload_hash, List.map Operation.pack preattestations)) + (fun (level, round, block_payload_hash, preattestations) -> { level; round; block_payload_hash; - preendorsements = - List.filter_map Operation_pool.unpack_preendorsement preendorsements; + preattestations = + List.filter_map Operation_pool.unpack_preattestation preattestations; }) (obj4 (req "level" int32) (req "round" Round.encoding) (req "block_payload_hash" Block_payload_hash.encoding) (req - "attestations" + "preattestations" (list (dynamic_size Operation.encoding_with_legacy_attestation_name)))) let block_info_encoding = @@ -200,7 +200,7 @@ let block_info_encoding = payload_round; round; prequorum; - quorum = List.filter_map Operation_pool.unpack_endorsement quorum; + quorum = List.filter_map Operation_pool.unpack_attestation quorum; dal_attestations = List.filter_map Operation_pool.unpack_dal_attestation dal_attestations; payload; @@ -230,7 +230,7 @@ module SlotMap : Map.S with type key = Slot.t = Map.Make (Slot) type delegate_slot = { consensus_key_and_delegate : consensus_key_and_delegate; first_slot : Slot.t; - endorsing_power : int; + attesting_power : int; } module Delegate_slots = struct @@ -243,10 +243,10 @@ module Delegate_slots = struct as the round can be arbitrary. *) all_delegate_voting_power : int SlotMap.t; (* This is a map having as keys the first slot of all delegates, and as - values their endorsing power. + values their attesting power. This map contains just the first slot for a delegate, because it is - only used in [slot_voting_power] which is about (pre)endorsements, - not proposals. Indeed, only (pre)endorsements that use the delegate's + only used in [slot_voting_power] which is about (pre)attestations, + not proposals. Indeed, only (pre)attestations that use the delegate's first slot are valid for inclusion in a block and count toward the (pre)quorum. Note that the baker might receive nominally valid non-first-slot operations from the mempool because this check is @@ -289,9 +289,9 @@ let locked_round_encoding = (req "payload_hash" Block_payload_hash.encoding) (req "round" Round.encoding)) -type endorsable_payload = {proposal : proposal; prequorum : prequorum} +type attestable_payload = {proposal : proposal; prequorum : prequorum} -let endorsable_payload_encoding = +let attestable_payload_encoding = let open Data_encoding in conv (fun {proposal; prequorum} -> (proposal, prequorum)) @@ -302,7 +302,7 @@ let endorsable_payload_encoding = type elected_block = { proposal : proposal; - endorsement_qc : Kind.attestation Operation.t list; + attestation_qc : Kind.attestation Operation.t list; } (* Updated only when we receive a block at a different level. @@ -313,12 +313,12 @@ type level_state = { current_level : int32; latest_proposal : proposal; is_latest_proposal_applied : bool; - (* Last proposal received where we injected an endorsement (thus we - have seen 2f+1 preendorsements) *) + (* Last proposal received where we injected an attestation (thus we + have seen 2f+1 preattestations) *) locked_round : locked_round option; - (* Latest payload where we've seen a proposal reach 2f+1 preendorsements *) - endorsable_payload : endorsable_payload option; - (* Block for which we've seen 2f+1 endorsements and that we may bake onto *) + (* Latest payload where we've seen a proposal reach 2f+1 preattestations *) + attestable_payload : attestable_payload option; + (* Block for which we've seen 2f+1 attestations and that we may bake onto *) elected_block : elected_block option; delegate_slots : delegate_slots; next_level_delegate_slots : delegate_slots; @@ -327,9 +327,9 @@ type level_state = { type phase = | Idle - | Awaiting_preendorsements + | Awaiting_preattestations | Awaiting_application - | Awaiting_endorsements + | Awaiting_attestations let phase_encoding = let open Data_encoding in @@ -346,8 +346,8 @@ let phase_encoding = ~title:"Awaiting_preattestations" (Tag 1) (constant "Awaiting_preattestations") - (function Awaiting_preendorsements -> Some () | _ -> None) - (fun () -> Awaiting_preendorsements); + (function Awaiting_preattestations -> Some () | _ -> None) + (fun () -> Awaiting_preattestations); case ~title:"Awaiting_application" (Tag 2) @@ -358,8 +358,8 @@ let phase_encoding = ~title:"Awaiting_attestationss" (Tag 3) (constant "Awaiting_attestationss") - (function Awaiting_endorsements -> Some () | _ -> None) - (fun () -> Awaiting_endorsements); + (function Awaiting_attestations -> Some () | _ -> None) + (fun () -> Awaiting_attestations); ] type round_state = { @@ -448,7 +448,7 @@ let event_encoding = | _ -> None) (fun ((), candidate, ops) -> Prequorum_reached - (candidate, Operation_pool.filter_preendorsements ops)); + (candidate, Operation_pool.filter_preattestations ops)); case (Tag 3) ~title:"Quorum_reached" @@ -462,7 +462,7 @@ let event_encoding = Some ((), candidate, List.map Operation.pack ops) | _ -> None) (fun ((), candidate, ops) -> - Quorum_reached (candidate, Operation_pool.filter_endorsements ops)); + Quorum_reached (candidate, Operation_pool.filter_attestations ops)); case (Tag 4) ~title:"Timeout" @@ -490,20 +490,20 @@ end type state_data = { level_data : int32; locked_round_data : locked_round option; - endorsable_payload_data : endorsable_payload option; + attestable_payload_data : attestable_payload option; } let state_data_encoding = let open Data_encoding in conv - (fun {level_data; locked_round_data; endorsable_payload_data} -> - (level_data, locked_round_data, endorsable_payload_data)) - (fun (level_data, locked_round_data, endorsable_payload_data) -> - {level_data; locked_round_data; endorsable_payload_data}) + (fun {level_data; locked_round_data; attestable_payload_data} -> + (level_data, locked_round_data, attestable_payload_data)) + (fun (level_data, locked_round_data, attestable_payload_data) -> + {level_data; locked_round_data; attestable_payload_data}) (obj3 (req "level" int32) (req "locked_round" (option locked_round_encoding)) - (req "attestable_payload" (option endorsable_payload_encoding))) + (req "attestable_payload" (option attestable_payload_encoding))) let record_state (state : state) = let cctxt = state.global_state.cctxt in @@ -517,11 +517,11 @@ let record_state (state : state) = cctxt#with_lock @@ fun () -> let level_data = state.level_state.current_level in let locked_round_data = state.level_state.locked_round in - let endorsable_payload_data = state.level_state.endorsable_payload in + let attestable_payload_data = state.level_state.attestable_payload in let bytes = Data_encoding.Binary.to_bytes_exn state_data_encoding - {level_data; locked_round_data; endorsable_payload_data} + {level_data; locked_round_data; attestable_payload_data} in let filename_tmp = filename ^ "_tmp" in Lwt_io.with_file @@ -554,7 +554,7 @@ let may_record_new_state ~previous_state ~new_state = let { current_level = previous_current_level; locked_round = previous_locked_round; - endorsable_payload = previous_endorsable_payload; + attestable_payload = previous_attestable_payload; _; } = previous_state.level_state @@ -562,7 +562,7 @@ let may_record_new_state ~previous_state ~new_state = let { current_level = new_current_level; locked_round = new_locked_round; - endorsable_payload = new_endorsable_payload; + attestable_payload = new_attestable_payload; _; } = new_state.level_state @@ -580,17 +580,17 @@ let may_record_new_state ~previous_state ~new_state = | Some new_locked_round, Some previous_locked_round -> Round.(new_locked_round.round >= previous_locked_round.round) in - let is_new_endorsable_payload_consistent = - match (new_endorsable_payload, previous_endorsable_payload) with + let is_new_attestable_payload_consistent = + match (new_attestable_payload, previous_attestable_payload) with | None, None -> true | Some _, None -> true | None, Some _ -> false - | Some new_endorsable_payload, Some previous_endorsable_payload -> + | Some new_attestable_payload, Some previous_attestable_payload -> Round.( - new_endorsable_payload.proposal.block.round - >= previous_endorsable_payload.proposal.block.round) + new_attestable_payload.proposal.block.round + >= previous_attestable_payload.proposal.block.round) in - is_new_locked_round_consistent && is_new_endorsable_payload_consistent + is_new_locked_round_consistent && is_new_attestable_payload_consistent else true in fail_unless is_new_state_consistent Broken_locked_values_invariant @@ -600,12 +600,12 @@ let may_record_new_state ~previous_state ~new_state = == new_state.level_state.current_level && previous_state.level_state.locked_round == new_state.level_state.locked_round - && previous_state.level_state.endorsable_payload - == new_state.level_state.endorsable_payload + && previous_state.level_state.attestable_payload + == new_state.level_state.attestable_payload in if has_not_changed then return_unit else record_state new_state -let load_endorsable_data cctxt location = +let load_attestable_data cctxt location = protect (fun () -> let filename = Filename.Infix.(cctxt#get_base_dir // Baking_files.filename location) @@ -628,21 +628,21 @@ let load_endorsable_data cctxt location = Events.(emit incompatible_stored_state ()) >>= fun () -> return_none)) -let may_load_endorsable_data state = +let may_load_attestable_data state = let cctxt = state.global_state.cctxt in let chain_id = state.global_state.chain_id in let location = Baking_files.resolve_location ~chain_id `State in protect ~on_error:(fun _ -> return state) @@ fun () -> cctxt#with_lock @@ fun () -> - load_endorsable_data cctxt location >>=? function + load_attestable_data cctxt location >>=? function | None -> return state - | Some {level_data; locked_round_data; endorsable_payload_data} -> + | Some {level_data; locked_round_data; attestable_payload_data} -> if Compare.Int32.(state.level_state.current_level = level_data) then let loaded_level_state = { state.level_state with locked_round = locked_round_data; - endorsable_payload = endorsable_payload_data; + attestable_payload = attestable_payload_data; } in return {state with level_state = loaded_level_state} @@ -671,35 +671,35 @@ module DelegateSet = struct with Found d -> Some d end -let delegate_slots endorsing_rights delegates = +let delegate_slots attesting_rights delegates = let own_delegates = DelegateSet.of_list delegates in let own_delegate_first_slots, own_delegate_slots, all_delegate_voting_power = List.fold_left (fun (own_list, own_map, all_map) slot -> let {Plugin.RPC.Validators.consensus_key; delegate; slots; _} = slot in let first_slot = Stdlib.List.hd slots in - let endorsing_power = List.length slots in - let all_map = SlotMap.add first_slot endorsing_power all_map in + let attesting_power = List.length slots in + let all_map = SlotMap.add first_slot attesting_power all_map in let own_list, own_map = match DelegateSet.find_pkh consensus_key own_delegates with | Some consensus_key -> - let endorsing_slot = + let attesting_slot = { consensus_key_and_delegate = (consensus_key, delegate); first_slot; - endorsing_power; + attesting_power; } in - ( endorsing_slot :: own_list, + ( attesting_slot :: own_list, List.fold_left - (fun own_map slot -> SlotMap.add slot endorsing_slot own_map) + (fun own_map slot -> SlotMap.add slot attesting_slot own_map) own_map slots ) | None -> (own_list, own_map) in (own_list, own_map, all_map)) ([], SlotMap.empty, SlotMap.empty) - endorsing_rights + attesting_rights in Delegate_slots. { @@ -712,8 +712,8 @@ let compute_delegate_slots (cctxt : Protocol_client_context.full) ?(block = `Head 0) ~level ~chain delegates = Environment.wrap_tzresult (Raw_level.of_int32 level) >>?= fun level -> Plugin.RPC.Validators.get cctxt (chain, block) ~levels:[level] - >>=? fun endorsing_rights -> - delegate_slots endorsing_rights delegates |> return + >>=? fun attesting_rights -> + delegate_slots attesting_rights delegates |> return let round_proposer state ~level round = let slots = @@ -761,7 +761,7 @@ let pp_option pp fmt = function | None -> Format.fprintf fmt "none" | Some v -> Format.fprintf fmt "%a" pp v -let pp_prequorum fmt {level; round; block_payload_hash; preendorsements} = +let pp_prequorum fmt {level; round; block_payload_hash; preattestations} = Format.fprintf fmt "level: %ld, round: %a, payload_hash: %a, preattestations: %d" @@ -770,7 +770,7 @@ let pp_prequorum fmt {level; round; block_payload_hash; preendorsements} = round Block_payload_hash.pp_short block_payload_hash - (List.length preendorsements) + (List.length preattestations) let pp_block_info fmt { @@ -816,7 +816,7 @@ let pp_locked_round fmt ({payload_hash; round} : locked_round) = Round.pp round -let pp_endorsable_payload fmt {proposal; prequorum} = +let pp_attestable_payload fmt {proposal; prequorum} = Format.fprintf fmt "proposal: %a, prequorum: %a" @@ -825,38 +825,38 @@ let pp_endorsable_payload fmt {proposal; prequorum} = pp_prequorum prequorum -let pp_elected_block fmt {proposal; endorsement_qc} = +let pp_elected_block fmt {proposal; attestation_qc} = Format.fprintf fmt "@[%a@ nb quorum attestations: %d@]" pp_block_info proposal.block - (List.length endorsement_qc) + (List.length attestation_qc) let pp_delegate_slot fmt - {consensus_key_and_delegate; first_slot; endorsing_power} = + {consensus_key_and_delegate; first_slot; attesting_power} = Format.fprintf fmt - "slots: @[first_slot: %a@],@ delegate: %a,@ attestation_power: %d" + "slots: @[first_slot: %a@],@ delegate: %a,@ attesting_power: %d" Slot.pp first_slot pp_consensus_key_and_delegate consensus_key_and_delegate - endorsing_power + attesting_power let pp_delegate_slots fmt Delegate_slots.{own_delegate_slots; _} = Format.fprintf fmt "@[%a@]" Format.( - pp_print_list ~pp_sep:pp_print_cut (fun fmt (slot, endorsing_slot) -> + pp_print_list ~pp_sep:pp_print_cut (fun fmt (slot, attesting_slot) -> Format.fprintf fmt "slot: %a, %a" Slot.pp slot pp_delegate_slot - endorsing_slot)) + attesting_slot)) (SlotMap.bindings own_delegate_slots) let pp_level_state fmt @@ -865,7 +865,7 @@ let pp_level_state fmt latest_proposal; is_latest_proposal_applied; locked_round; - endorsable_payload; + attestable_payload; elected_block; delegate_slots; next_level_delegate_slots; @@ -883,8 +883,8 @@ let pp_level_state fmt latest_proposal (pp_option pp_locked_round) locked_round - (pp_option pp_endorsable_payload) - endorsable_payload + (pp_option pp_attestable_payload) + attestable_payload (pp_option pp_elected_block) elected_block pp_delegate_slots @@ -896,9 +896,9 @@ let pp_level_state fmt let pp_phase fmt = function | Idle -> Format.fprintf fmt "idle" - | Awaiting_preendorsements -> Format.fprintf fmt "awaiting preattestations" + | Awaiting_preattestations -> Format.fprintf fmt "awaiting preattestations" | Awaiting_application -> Format.fprintf fmt "awaiting application" - | Awaiting_endorsements -> Format.fprintf fmt "awaiting attestations" + | Awaiting_attestations -> Format.fprintf fmt "awaiting attestations" let pp_round_state fmt {current_round; current_phase; delayed_prequorum} = Format.fprintf @@ -940,20 +940,20 @@ let pp_event fmt = function "new head proposal received: %a" pp_block_info proposal.block - | Prequorum_reached (candidate, preendos) -> + | Prequorum_reached (candidate, preattestations) -> Format.fprintf fmt "prequorum reached with %d preattestations for %a at round %a" - (List.length preendos) + (List.length preattestations) Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched - | Quorum_reached (candidate, endos) -> + | Quorum_reached (candidate, attestations) -> Format.fprintf fmt "quorum reached with %d attestations for %a at round %a" - (List.length endos) + (List.length attestations) Block_hash.pp candidate.Operation_worker.hash Round.pp diff --git a/src/proto_alpha/lib_delegate/baking_state.mli b/src/proto_alpha/lib_delegate/baking_state.mli index 0b03b6aa5bbcc15cff11f55fc5f49e4f217f3965..de673ae60042657f1ff9951cc9ec055cef536831 100644 --- a/src/proto_alpha/lib_delegate/baking_state.mli +++ b/src/proto_alpha/lib_delegate/baking_state.mli @@ -51,7 +51,7 @@ type prequorum = { level : int32; round : Round.t; block_payload_hash : Block_payload_hash.t; - preendorsements : Kind.preattestation operation list; + preattestations : Kind.preattestation operation list; } type block_info = { @@ -93,11 +93,11 @@ val round_of_shell_header : Block_header.shell_header -> Round.t tzresult module SlotMap : Map.S with type key = Slot.t (** A delegate slot consists of the delegate's consensus key, its public key - hash, its first slot, and its endorsing power at some level. *) + hash, its first slot, and its attesting power at some level. *) type delegate_slot = { consensus_key_and_delegate : consensus_key_and_delegate; first_slot : Slot.t; - endorsing_power : int; + attesting_power : int; } module Delegate_slots : sig @@ -109,7 +109,7 @@ module Delegate_slots : sig val own_delegates : t -> delegate_slot list (** Returns, among our *own* delegates, the delegate (together with its - first endorsing slot) that owns the given slot, if any (even if the + first attesting slot) that owns the given slot, if any (even if the given slot is not the delegate's first slot). *) val own_slot_owner : t -> slot:Slot.t -> delegate_slot option @@ -130,20 +130,20 @@ val proposal_encoding : proposal Data_encoding.t This block should be baked by the baker of the previous protocol (that's why this same block is also referred to as the last block of the previous protocol). It is always considered final and - therefore is not endorsed.*) + therefore is not attested.*) val is_first_block_in_protocol : proposal -> bool type locked_round = {payload_hash : Block_payload_hash.t; round : Round.t} val locked_round_encoding : locked_round Data_encoding.t -type endorsable_payload = {proposal : proposal; prequorum : prequorum} +type attestable_payload = {proposal : proposal; prequorum : prequorum} -val endorsable_payload_encoding : endorsable_payload Data_encoding.t +val attestable_payload_encoding : attestable_payload Data_encoding.t type elected_block = { proposal : proposal; - endorsement_qc : Kind.attestation operation list; + attestation_qc : Kind.attestation operation list; } type level_state = { @@ -151,7 +151,7 @@ type level_state = { latest_proposal : proposal; is_latest_proposal_applied : bool; locked_round : locked_round option; - endorsable_payload : endorsable_payload option; + attestable_payload : attestable_payload option; elected_block : elected_block option; delegate_slots : delegate_slots; next_level_delegate_slots : delegate_slots; @@ -160,9 +160,9 @@ type level_state = { type phase = | Idle - | Awaiting_preendorsements + | Awaiting_preattestations | Awaiting_application - | Awaiting_endorsements + | Awaiting_attestations val phase_encoding : phase Data_encoding.t @@ -183,7 +183,7 @@ type t = state val update_current_phase : t -> phase -> t -(** Returns, among our *own* delegates, the delegate (and its endorsing slot) +(** Returns, among our *own* delegates, the delegate (and its attesting slot) that has a proposer slot at the given round and the current or next level, if any. *) val round_proposer : @@ -209,7 +209,7 @@ val event_encoding : event Data_encoding.t type state_data = { level_data : int32; locked_round_data : locked_round option; - endorsable_payload_data : endorsable_payload option; + attestable_payload_data : attestable_payload option; } val state_data_encoding : state_data Data_encoding.t @@ -219,12 +219,12 @@ val record_state : t -> unit tzresult Lwt.t val may_record_new_state : previous_state:t -> new_state:t -> unit tzresult Lwt.t -val load_endorsable_data : +val load_attestable_data : Protocol_client_context.full -> [`State] Baking_files.location -> state_data option tzresult Lwt.t -val may_load_endorsable_data : t -> t tzresult Lwt.t +val may_load_attestable_data : t -> t tzresult Lwt.t (** @param block default to [`Head 0]*) val compute_delegate_slots : @@ -250,7 +250,7 @@ val pp_proposal : Format.formatter -> proposal -> unit val pp_locked_round : Format.formatter -> locked_round -> unit -val pp_endorsable_payload : Format.formatter -> endorsable_payload -> unit +val pp_attestable_payload : Format.formatter -> attestable_payload -> unit val pp_elected_block : Format.formatter -> elected_block -> unit diff --git a/src/proto_alpha/lib_delegate/block_forge.ml b/src/proto_alpha/lib_delegate/block_forge.ml index 124131a087c977edb0b4b524291d88613798f3bf..2fe88270314af8a6754a4d6d269c3c2447e40889 100644 --- a/src/proto_alpha/lib_delegate/block_forge.ml +++ b/src/proto_alpha/lib_delegate/block_forge.ml @@ -312,7 +312,7 @@ let apply_with_context ~chain_id ~faked_protocol_data ~user_activated_upgrades pred_info chain_id in - (* We still need to filter endorsements. Two endorsements could be + (* We still need to filter attestations. Two attestations could be referring to the same slot. *) let* incremental, ordered_pool = Operation_selection.filter_consensus_operations_only diff --git a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml index c6737f064a5e7e6a618a956aebedebaea22c0142..de971e378b54354169215b421103b60372bb8ca3 100644 --- a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml +++ b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml @@ -64,8 +64,8 @@ type 'kind recorded_consensus = } type recorded_consensus_operations = { - endorsement : Kind.attestation recorded_consensus; - preendorsement : Kind.preattestation recorded_consensus; + attestation : Kind.attestation recorded_consensus; + preattestation : Kind.preattestation recorded_consensus; } type 'a state = { @@ -165,10 +165,10 @@ let lookup_recorded_consensus (type kind) consensus_key (op_kind : kind consensus_operation_type) map : kind recorded_consensus = match Delegate_map.find consensus_key map with | None -> No_operation_seen - | Some {endorsement; preendorsement} -> ( + | Some {attestation; preattestation} -> ( match op_kind with - | Attestation -> endorsement - | Preattestation -> preendorsement) + | Attestation -> attestation + | Preattestation -> preattestation) let add_consensus_operation (type kind) consensus_key (op_kind : kind consensus_operation_type) @@ -180,14 +180,14 @@ let add_consensus_operation (type kind) consensus_key Option.value ~default: { - endorsement = No_operation_seen; - preendorsement = No_operation_seen; + attestation = No_operation_seen; + preattestation = No_operation_seen; } x in match op_kind with - | Attestation -> Some {record with endorsement = recorded_operation} - | Preattestation -> Some {record with preendorsement = recorded_operation}) + | Attestation -> Some {record with attestation = recorded_operation} + | Preattestation -> Some {record with preattestation = recorded_operation}) map let get_validator_rights state cctxt level = @@ -230,8 +230,8 @@ let process_consensus_op (type kind) state cctxt in return_unit else - let* endorsing_rights = get_validator_rights state cctxt level in - match Slot.Map.find slot endorsing_rights with + let* attesting_rights = get_validator_rights state cctxt level in + match Slot.Map.find slot attesting_rights with | None -> (* We do not handle operations that do not have a valid slot *) return_unit @@ -324,7 +324,7 @@ let process_consensus_op (type kind) state cctxt | _ -> return_unit) let process_operations (cctxt : #Protocol_client_context.full) state - (endorsements : 'a list) ~packed_op chain_id = + (attestations : 'a list) ~packed_op chain_id = List.iter_es (fun op -> let {shell; protocol_data; _} = packed_op op in @@ -332,14 +332,14 @@ let process_operations (cctxt : #Protocol_client_context.full) state | Operation_data ({contents = Single (Preattestation {round; slot; level; _}); _} as protocol_data) -> - let new_preendorsement : Kind.preattestation Alpha_context.operation = + let new_preattestation : Kind.preattestation Alpha_context.operation = {shell; protocol_data} in process_consensus_op state cctxt Preattestation - new_preendorsement + new_preattestation chain_id level round @@ -347,14 +347,14 @@ let process_operations (cctxt : #Protocol_client_context.full) state | Operation_data ({contents = Single (Attestation {round; slot; level; _}); _} as protocol_data) -> - let new_endorsement : Kind.attestation Alpha_context.operation = + let new_attestation : Kind.attestation Alpha_context.operation = {shell; protocol_data} in process_consensus_op state cctxt Attestation - new_endorsement + new_attestation chain_id level round @@ -362,7 +362,7 @@ let process_operations (cctxt : #Protocol_client_context.full) state | _ -> (* not a consensus operation *) return_unit) - endorsements + attestations let context_block_header cctxt ~chain b_hash = Alpha_block_services.header cctxt ~chain ~block:(`Hash (b_hash, 0)) () @@ -468,8 +468,8 @@ let cleanup_old_operations state = filter state.blocks_table) (* Each new block is processed : - - Checking that every baker injected only once at this level - - Checking that every (pre)endorser operated only once at this level + - Check that every baker injected a proposal only once at the block's level and round + - Check that every baker (pre)attested only once at the block's level and round *) let process_new_block (cctxt : #Protocol_client_context.full) state {hash; chain_id; level; protocol; next_protocol; _} = @@ -485,7 +485,7 @@ let process_new_block (cctxt : #Protocol_client_context.full) state (Alpha_block_services.info cctxt ~chain ~block () >>= function | Ok block_info -> ( process_block cctxt state block_info >>=? fun () -> - (* Processing (pre)endorsements in the block *) + (* Processing (pre)attestations in the block *) match block_info.operations with | consensus_ops :: _ -> let packed_op {Alpha_block_services.shell; protocol_data; _} = diff --git a/src/proto_alpha/lib_delegate/node_rpc.ml b/src/proto_alpha/lib_delegate/node_rpc.ml index 2717b35e622ae407e4e137778830d9c5ad4f2a45..128691943e0377cc0afea770cd30e01a824a11a6 100644 --- a/src/proto_alpha/lib_delegate/node_rpc.ml +++ b/src/proto_alpha/lib_delegate/node_rpc.ml @@ -59,8 +59,8 @@ let preapply_block cctxt ~chain ~head ~timestamp ~protocol_data operations = operations ~protocol_data -let extract_prequorum preendorsements = - match preendorsements with +let extract_prequorum preattestations = + match preattestations with | h :: _ -> let ({protocol_data = {contents = Single (Preattestation content); _}; _}) = @@ -71,7 +71,7 @@ let extract_prequorum preendorsements = level = Raw_level.to_int32 content.level; round = content.round; block_payload_hash = content.block_payload_hash; - preendorsements; + preattestations; } | _ -> None @@ -88,7 +88,7 @@ let info_of_header_and_ops ~in_protocol block_hash block_header operations = (* The first block in the protocol is baked using the previous protocol, the encodings might change. The baker's logic is to consider final the first block of a new protocol and not - endorse it. Therefore, we do not need to have the correct + attest it. Therefore, we do not need to have the correct values here. *) ( dummy_payload_hash, Round.zero, @@ -107,12 +107,12 @@ let info_of_header_and_ops ~in_protocol block_hash block_header operations = (payload_hash, payload_round) | None -> assert false in - let preendorsements, quorum, dal_attestations, payload = + let preattestations, quorum, dal_attestations, payload = WithExceptions.Option.get ~loc:__LOC__ (Operation_pool.extract_operations_of_list_list operations) in - let prequorum = Option.bind preendorsements extract_prequorum in + let prequorum = Option.bind preattestations extract_prequorum in (payload_hash, payload_round, prequorum, quorum, dal_attestations, payload) in return diff --git a/src/proto_alpha/lib_delegate/operation_pool.ml b/src/proto_alpha/lib_delegate/operation_pool.ml index f3eee2463c1671b3e96e0a0218d4a00bf571dbef..7d9ca75987de45da86e69ec8e9f30049660ba412 100644 --- a/src/proto_alpha/lib_delegate/operation_pool.ml +++ b/src/proto_alpha/lib_delegate/operation_pool.ml @@ -215,17 +215,17 @@ type consensus_filter = { } (** From a pool of operations [operation_pool], the function filters - out the endorsements that are different from the [current_level], + out the attestations that are different from the [current_level], the [current_round] or the optional [current_block_payload_hash], - as well as preendorsements. *) -let filter_with_relevant_consensus_ops ~(endorsement_filter : consensus_filter) - ~(preendorsement_filter : consensus_filter option) operation_set = + as well as preattestations. *) +let filter_with_relevant_consensus_ops ~(attestation_filter : consensus_filter) + ~(preattestation_filter : consensus_filter option) operation_set = Operation_set.filter (fun {protocol_data; _} -> - match (protocol_data, preendorsement_filter) with - (* 1a. Remove preendorsements. *) + match (protocol_data, preattestation_filter) with + (* 1a. Remove preattestations. *) | Operation_data {contents = Single (Preattestation _); _}, None -> false - (* 1b. Filter preendorsements. *) + (* 1b. Filter preattestations. *) | ( Operation_data { contents = @@ -238,7 +238,7 @@ let filter_with_relevant_consensus_ops ~(endorsement_filter : consensus_filter) Compare.Int32.(Raw_level.to_int32 level = level') && Round.(round = round') && Block_payload_hash.(block_payload_hash = block_payload_hash') - (* 2. Filter endorsements. *) + (* 2. Filter attestations. *) | ( Operation_data { contents = @@ -246,23 +246,23 @@ let filter_with_relevant_consensus_ops ~(endorsement_filter : consensus_filter) _; }, _ ) -> - Compare.Int32.(Raw_level.to_int32 level = endorsement_filter.level) - && Round.(round = endorsement_filter.round) + Compare.Int32.(Raw_level.to_int32 level = attestation_filter.level) + && Round.(round = attestation_filter.round) && Block_payload_hash.( - block_payload_hash = endorsement_filter.payload_hash) + block_payload_hash = attestation_filter.payload_hash) (* 3. Preserve all non-consensus operations. *) | _ -> true) operation_set -let unpack_preendorsement packed_preendorsement = - let {shell; protocol_data = Operation_data data} = packed_preendorsement in +let unpack_preattestation packed_preattestation = + let {shell; protocol_data = Operation_data data} = packed_preattestation in match data with | {contents = Single (Preattestation _); _} -> Some ({shell; protocol_data = data} : Kind.preattestation Operation.t) | _ -> None -let unpack_endorsement packed_endorsement = - let {shell; protocol_data = Operation_data data} = packed_endorsement in +let unpack_attestation packed_attestation = + let {shell; protocol_data = Operation_data data} = packed_attestation in match data with | {contents = Single (Attestation _); _} -> Some ({shell; protocol_data = data} : Kind.attestation Operation.t) @@ -275,7 +275,7 @@ let unpack_dal_attestation packed_dal_attestation = Some ({shell; protocol_data = data} : Kind.dal_attestation Operation.t) | _ -> None -let filter_preendorsements ops = +let filter_preattestations ops = List.filter_map (function | { @@ -291,7 +291,7 @@ let filter_preendorsements ops = | _ -> None) ops -let filter_endorsements ops = +let filter_attestations ops = List.filter_map (function | { @@ -332,38 +332,38 @@ let ordered_pool_of_payload ~consensus_operations let extract_operations_of_list_list = function | [consensus; votes_payload; anonymous_payload; managers_payload] -> - let preendorsements, endorsements, dal_attestations = + let preattestations, attestations, dal_attestations = List.fold_left - (fun ( (preendorsements : Kind.preattestation Operation.t list), - (endorsements : Kind.attestation Operation.t list), + (fun ( (preattestations : Kind.preattestation Operation.t list), + (attestations : Kind.attestation Operation.t list), (dal_attestations : Kind.dal_attestation Operation.t list) ) packed_op -> let {shell; protocol_data = Operation_data data} = packed_op in match data with | {contents = Single (Preattestation _); _} -> - ( {shell; protocol_data = data} :: preendorsements, - endorsements, + ( {shell; protocol_data = data} :: preattestations, + attestations, dal_attestations ) | {contents = Single (Attestation _); _} -> - ( preendorsements, - {shell; protocol_data = data} :: endorsements, + ( preattestations, + {shell; protocol_data = data} :: attestations, dal_attestations ) | {contents = Single (Dal_attestation _); _} -> - ( preendorsements, - endorsements, + ( preattestations, + attestations, {shell; protocol_data = data} :: dal_attestations ) | _ -> (* unreachable *) - (preendorsements, endorsements, dal_attestations)) + (preattestations, attestations, dal_attestations)) ([], [], []) consensus (* N.b. the order doesn't matter *) in - let preendorsements = - if preendorsements = [] then None else Some preendorsements + let preattestations = + if preattestations = [] then None else Some preattestations in let payload = {votes_payload; anonymous_payload; managers_payload} in - Some (preendorsements, endorsements, dal_attestations, payload) + Some (preattestations, attestations, dal_attestations, payload) | _ -> None let filter_pool p {consensus; votes; anonymous; managers} = diff --git a/src/proto_alpha/lib_delegate/operation_pool.mli b/src/proto_alpha/lib_delegate/operation_pool.mli index 289061f11ae64415bbd557c6f3864d4b67231363..f9bf1f0c63d6398d26967b3b50011428d750a3b3 100644 --- a/src/proto_alpha/lib_delegate/operation_pool.mli +++ b/src/proto_alpha/lib_delegate/operation_pool.mli @@ -87,23 +87,23 @@ type consensus_filter = { } val filter_with_relevant_consensus_ops : - endorsement_filter:consensus_filter -> - preendorsement_filter:consensus_filter option -> + attestation_filter:consensus_filter -> + preattestation_filter:consensus_filter option -> Operation_set.t -> Operation_set.t -val unpack_preendorsement : +val unpack_preattestation : packed_operation -> Kind.preattestation operation option -val unpack_endorsement : packed_operation -> Kind.attestation operation option +val unpack_attestation : packed_operation -> Kind.attestation operation option val unpack_dal_attestation : packed_operation -> Kind.dal_attestation operation option -val filter_preendorsements : +val filter_preattestations : packed_operation list -> Kind.preattestation operation list -val filter_endorsements : +val filter_attestations : packed_operation list -> Kind.attestation operation list val ordered_to_list_list : ordered_pool -> packed_operation list list diff --git a/src/proto_alpha/lib_delegate/operation_worker.ml b/src/proto_alpha/lib_delegate/operation_worker.ml index 4fa7b7194d4e853a56be0e6aa2c16264e7649a18..eca993ef72b9b04c9f3c9bd41d027ede3cee2892 100644 --- a/src/proto_alpha/lib_delegate/operation_worker.ml +++ b/src/proto_alpha/lib_delegate/operation_worker.ml @@ -166,7 +166,7 @@ let compare_consensus_contents (op1 : consensus_content) Compare.or_else (Slot.compare op1.slot op2.slot) @@ fun () -> Block_payload_hash.compare op1.block_payload_hash op2.block_payload_hash -module Preendorsement_set = Set.Make (struct +module Preattestation_set = Set.Make (struct type t = Kind.preattestation operation let compare @@ -177,7 +177,7 @@ module Preendorsement_set = Set.Make (struct compare_consensus_contents op1 op2 end) -module Endorsement_set = Set.Make (struct +module Attestation_set = Set.Make (struct type t = Kind.attestation operation let compare @@ -193,8 +193,8 @@ type pqc_watched = { get_slot_voting_power : slot:Slot.t -> int option; consensus_threshold : int; mutable current_voting_power : int; - mutable preendorsements_received : Preendorsement_set.t; - mutable preendorsements_count : int; + mutable preattestations_received : Preattestation_set.t; + mutable preattestations_count : int; } type qc_watched = { @@ -202,8 +202,8 @@ type qc_watched = { get_slot_voting_power : slot:Slot.t -> int option; consensus_threshold : int; mutable current_voting_power : int; - mutable endorsements_received : Endorsement_set.t; - mutable endorsements_count : int; + mutable attestations_received : Attestation_set.t; + mutable attestations_count : int; } type watch_kind = Pqc_watch of pqc_watched | Qc_watch of qc_watched @@ -282,13 +282,13 @@ let reset_monitoring state = | None -> Lwt.return_unit | Some (Pqc_watch pqc_watched) -> pqc_watched.current_voting_power <- 0 ; - pqc_watched.preendorsements_count <- 0 ; - pqc_watched.preendorsements_received <- Preendorsement_set.empty ; + pqc_watched.preattestations_count <- 0 ; + pqc_watched.preattestations_received <- Preattestation_set.empty ; Lwt.return_unit | Some (Qc_watch qc_watched) -> qc_watched.current_voting_power <- 0 ; - qc_watched.endorsements_count <- 0 ; - qc_watched.endorsements_received <- Endorsement_set.empty ; + qc_watched.attestations_count <- 0 ; + qc_watched.attestations_received <- Attestation_set.empty ; Lwt.return_unit let update_monitoring ?(should_lock = true) state ops = @@ -303,17 +303,20 @@ let update_monitoring ?(should_lock = true) state ops = candidate_watched; get_slot_voting_power; consensus_threshold; - preendorsements_received; + preattestations_received; _; } as proposal_watched)) -> - let preendorsements = Operation_pool.filter_preendorsements ops in - let preendorsements = + let preattestations = Operation_pool.filter_preattestations ops in + let preattestations = List.filter - (fun new_preendo -> - not (Preendorsement_set.mem new_preendo preendorsements_received)) - preendorsements + (fun new_preattestation -> + not + (Preattestation_set.mem + new_preattestation + preattestations_received)) + preattestations in - let preendorsements_count, voting_power = + let preattestations_count, voting_power = List.fold_left (fun (count, power) (op : Kind.preattestation Operation.t) -> let { @@ -328,36 +331,36 @@ let update_monitoring ?(should_lock = true) state ops = then match get_slot_voting_power ~slot:consensus_content.slot with | Some op_power -> - proposal_watched.preendorsements_received <- - Preendorsement_set.add + proposal_watched.preattestations_received <- + Preattestation_set.add op - proposal_watched.preendorsements_received ; + proposal_watched.preattestations_received ; (succ count, power + op_power) | None -> - (* preendorsements that do not use the first slot of a + (* preattestations that do not use the first slot of a delegate are not added to the quorum *) (count, power) else (count, power)) (0, 0) - preendorsements + preattestations in proposal_watched.current_voting_power <- proposal_watched.current_voting_power + voting_power ; - proposal_watched.preendorsements_count <- - proposal_watched.preendorsements_count + preendorsements_count ; + proposal_watched.preattestations_count <- + proposal_watched.preattestations_count + preattestations_count ; if proposal_watched.current_voting_power >= consensus_threshold then ( Events.( emit pqc_reached ( proposal_watched.current_voting_power, - proposal_watched.preendorsements_count )) + proposal_watched.preattestations_count )) >>= fun () -> state.qc_event_stream.push (Some (Prequorum_reached ( candidate_watched, - Preendorsement_set.elements - proposal_watched.preendorsements_received ))) ; + Preattestation_set.elements + proposal_watched.preattestations_received ))) ; (* Once the event has been emitted, we cancel the monitoring *) cancel_monitoring state ; Lwt.return_unit) @@ -365,27 +368,27 @@ let update_monitoring ?(should_lock = true) state ops = Events.( emit preattestations_received - ( preendorsements_count, + ( preattestations_count, voting_power, proposal_watched.current_voting_power, - proposal_watched.preendorsements_count )) + proposal_watched.preattestations_count )) | Some (Qc_watch ({ candidate_watched; get_slot_voting_power; consensus_threshold; - endorsements_received; + attestations_received; _; } as proposal_watched)) -> - let endorsements = Operation_pool.filter_endorsements ops in - let endorsements = + let attestations = Operation_pool.filter_attestations ops in + let attestations = List.filter - (fun new_endo -> - not (Endorsement_set.mem new_endo endorsements_received)) - endorsements + (fun new_attestation -> + not (Attestation_set.mem new_attestation attestations_received)) + attestations in - let endorsements_count, voting_power = + let attestations_count, voting_power = List.fold_left (fun (count, power) (op : Kind.attestation Operation.t) -> let { @@ -400,36 +403,36 @@ let update_monitoring ?(should_lock = true) state ops = then match get_slot_voting_power ~slot:consensus_content.slot with | Some op_power -> - proposal_watched.endorsements_received <- - Endorsement_set.add + proposal_watched.attestations_received <- + Attestation_set.add op - proposal_watched.endorsements_received ; + proposal_watched.attestations_received ; (succ count, power + op_power) | None -> - (* endorsements that do not use the first slot of a delegate + (* attestations that do not use the first slot of a delegate are not added to the quorum *) (count, power) else (count, power)) (0, 0) - endorsements + attestations in proposal_watched.current_voting_power <- proposal_watched.current_voting_power + voting_power ; - proposal_watched.endorsements_count <- - proposal_watched.endorsements_count + endorsements_count ; + proposal_watched.attestations_count <- + proposal_watched.attestations_count + attestations_count ; if proposal_watched.current_voting_power >= consensus_threshold then ( Events.( emit qc_reached ( proposal_watched.current_voting_power, - proposal_watched.endorsements_count )) + proposal_watched.attestations_count )) >>= fun () -> state.qc_event_stream.push (Some (Quorum_reached ( candidate_watched, - Endorsement_set.elements - proposal_watched.endorsements_received ))) ; + Attestation_set.elements + proposal_watched.attestations_received ))) ; (* Once the event has been emitted, we cancel the monitoring *) cancel_monitoring state ; Lwt.return_unit) @@ -437,10 +440,10 @@ let update_monitoring ?(should_lock = true) state ops = Events.( emit attestations_received - ( endorsements_count, + ( attestations_count, voting_power, proposal_watched.current_voting_power, - proposal_watched.endorsements_count )) + proposal_watched.attestations_count )) let monitor_quorum state new_proposal_watched = Lwt_mutex.with_lock state.lock @@ fun () -> @@ -453,7 +456,7 @@ let monitor_quorum state new_proposal_watched = (* initialize with the currently present consensus operations *) update_monitoring ~should_lock:false state current_consensus_operations -let monitor_preendorsement_quorum state ~consensus_threshold +let monitor_preattestation_quorum state ~consensus_threshold ~get_slot_voting_power candidate_watched = let new_proposal = Some @@ -463,13 +466,13 @@ let monitor_preendorsement_quorum state ~consensus_threshold get_slot_voting_power; consensus_threshold; current_voting_power = 0; - preendorsements_received = Preendorsement_set.empty; - preendorsements_count = 0; + preattestations_received = Preattestation_set.empty; + preattestations_count = 0; }) in monitor_quorum state new_proposal -let monitor_endorsement_quorum state ~consensus_threshold ~get_slot_voting_power +let monitor_attestation_quorum state ~consensus_threshold ~get_slot_voting_power candidate_watched = let new_proposal = Some @@ -479,8 +482,8 @@ let monitor_endorsement_quorum state ~consensus_threshold ~get_slot_voting_power get_slot_voting_power; consensus_threshold; current_voting_power = 0; - endorsements_received = Endorsement_set.empty; - endorsements_count = 0; + attestations_received = Attestation_set.empty; + attestations_count = 0; }) in monitor_quorum state new_proposal @@ -491,23 +494,23 @@ let shutdown_worker state = (* Each time a new head is received, the operation_pool field of the state is cleaned/reset by this function. Instead of emptying it completely, we keep - the endorsements of at most 5 rounds and 1 level in the past, to be able to - include as much endorsements as possible in the next block if this baker is + the attestations of at most 5 rounds and 1 level in the past, to be able to + include as much attestations as possible in the next block if this baker is the proposer. This allows to handle the following situations: - The baker observes an EQC for (L, R), but a proposal arrived for (L, R+1). - After the flush, extra endorsements on top of (L, R) are 'Branch_refused', + After the flush, extra attestations on top of (L, R) are 'Branch_refused', and are not re-sent by the node. If the baker proposes at (L+1, 1), he should - be able to include these extra endorsements. Hence the cache for old rounds. + be able to include these extra attestations. Hence the cache for old rounds. - The baker receives a head at (L+1, 0) on top of (L, 0), but this head didn't reach consensus. If the baker who proposes at (L+1, 1) observed some - extra endorsements for (L, 0) that are not included in (L+1, 0), he may want - to add them. But these endorsements become 'Outdated' in the mempool once + extra attestations for (L, 0) that are not included in (L+1, 0), he may want + to add them. But these attestations become 'Outdated' in the mempool once (L+1, 0) is received. Hence the cache for previous level. *) let update_operations_pool state (head_level, head_round) = - let endorsements = + let attestations = let head_round_i32 = Round.to_int32 head_round in let head_level_i32 = head_level in Operation_pool.Operation_set.filter @@ -522,13 +525,13 @@ let update_operations_pool state (head_level, head_round) = let level_i32 = Raw_level.to_int32 level in let delta_round = Int32.sub head_round_i32 round_i32 in let delta_level = Int32.sub head_level_i32 level_i32 in - (* Only retain endorsements that are maximum 5 rounds old and + (* Only retain attestations that are maximum 5 rounds old and 1 level in the last *) Compare.Int32.(delta_round <= 5l && delta_level <= 1l) | _ -> false) state.operation_pool.consensus in - let operation_pool = {Operation_pool.empty with consensus = endorsements} in + let operation_pool = {Operation_pool.empty with consensus = attestations} in state.operation_pool <- operation_pool let create ?(monitor_node_operations = true) diff --git a/src/proto_alpha/lib_delegate/operation_worker.mli b/src/proto_alpha/lib_delegate/operation_worker.mli index f0bbb39d830a3bb24b79bae827e88b936116da54..348fe9b25a86c747dbaf39535dd63b4a5444027b 100644 --- a/src/proto_alpha/lib_delegate/operation_worker.mli +++ b/src/proto_alpha/lib_delegate/operation_worker.mli @@ -69,14 +69,14 @@ val get_quorum_event_stream : t -> event Lwt_stream.t (** {1 Observers} *) -val monitor_preendorsement_quorum : +val monitor_preattestation_quorum : t -> consensus_threshold:int -> get_slot_voting_power:(slot:Slot.t -> int option) -> candidate -> unit Lwt.t -val monitor_endorsement_quorum : +val monitor_attestation_quorum : t -> consensus_threshold:int -> get_slot_voting_power:(slot:Slot.t -> int option) -> diff --git a/src/proto_alpha/lib_delegate/state_transitions.ml b/src/proto_alpha/lib_delegate/state_transitions.ml index 05a7c1e0ddcfb68e87fad307f87d6fe35d4d8133..9182f937810e946a740289d42a8e24c6859b4ac1 100644 --- a/src/proto_alpha/lib_delegate/state_transitions.ml +++ b/src/proto_alpha/lib_delegate/state_transitions.ml @@ -84,11 +84,11 @@ let make_consensus_list state proposal = (* If we do not have any slots, we won't inject any operation but we will still participate to determine an elected block *) -let make_preendorse_action state proposal = - let preendorsements : (consensus_key_and_delegate * consensus_content) list = +let make_preattest_action state proposal = + let preattestations : (consensus_key_and_delegate * consensus_content) list = make_consensus_list state proposal in - Inject_preendorsements {preendorsements} + Inject_preattestations {preattestations} let update_proposal ~is_proposal_applied state proposal = Events.(emit updating_latest_proposal proposal.block.hash) >>= fun () -> @@ -119,9 +119,9 @@ let may_update_proposal ~is_proposal_applied state (proposal : proposal) = then update_proposal ~is_proposal_applied state proposal else Lwt.return state -let preendorse state proposal = +let preattest state proposal = if Baking_state.is_first_block_in_protocol proposal then - (* We do not preendorse the first transition block *) + (* We do not preattest the first transition block *) let new_state = update_current_phase state Idle in Lwt.return (new_state, Do_nothing) else @@ -131,10 +131,10 @@ let preendorse state proposal = (* We await for the block to be applied before updating its locked values. *) if state.level_state.is_latest_proposal_applied then - update_current_phase state Awaiting_preendorsements + update_current_phase state Awaiting_preattestations else update_current_phase state Awaiting_application in - Lwt.return (new_state, make_preendorse_action state proposal) + Lwt.return (new_state, make_preattest_action state proposal) let extract_pqc state (new_proposal : proposal) = match new_proposal.block.prequorum with @@ -155,22 +155,22 @@ let extract_pqc state (new_proposal : proposal) = | None -> (* cannot happen if the map is correctly populated *) acc - | Some endorsing_power -> acc + endorsing_power + | Some attesting_power -> acc + attesting_power in let voting_power = - List.fold_left add_voting_power 0 pqc.preendorsements + List.fold_left add_voting_power 0 pqc.preattestations in let consensus_threshold = state.global_state.constants.parametric.consensus_threshold in if Compare.Int.(voting_power >= consensus_threshold) then - Some (pqc.preendorsements, pqc.round) + Some (pqc.preattestations, pqc.round) else None -let may_update_endorsable_payload_with_internal_pqc state +let may_update_attestable_payload_with_internal_pqc state (new_proposal : proposal) = match - (new_proposal.block.prequorum, state.level_state.endorsable_payload) + (new_proposal.block.prequorum, state.level_state.attestable_payload) with | None, _ -> (* The proposal does not contain a PQC: no need to update *) @@ -185,11 +185,11 @@ let may_update_endorsable_payload_with_internal_pqc state better_prequorum.block_payload_hash = new_proposal.block.payload_hash)) ; assert ( Compare.Int32.(better_prequorum.level = new_proposal.block.shell.level)) ; - let new_endorsable_payload = + let new_attestable_payload = Some {proposal = new_proposal; prequorum = better_prequorum} in let new_level_state = - {state.level_state with endorsable_payload = new_endorsable_payload} + {state.level_state with attestable_payload = new_attestable_payload} in {state with level_state = new_level_state} @@ -249,20 +249,20 @@ let rec handle_proposal ~is_proposal_applied state (new_proposal : proposal) = Events.(emit skipping_invalid_proposal ()) >>= fun () -> do_nothing state | Outdated_proposal -> - (* Check whether we need to update our endorsable payload *) + (* Check whether we need to update our attestable payload *) let state = - may_update_endorsable_payload_with_internal_pqc state new_proposal + may_update_attestable_payload_with_internal_pqc state new_proposal in (* The proposal is outdated: we update to be able to extract - its included endorsements but we do not endorse it *) + its included attestations but we do not attest it *) Events.(emit outdated_proposal new_proposal.block.hash) >>= fun () -> may_update_proposal ~is_proposal_applied state new_proposal >>= fun state -> do_nothing state | Valid_proposal -> ( (* Valid_proposal => proposal.round = current_round *) - (* Check whether we need to update our endorsable payload *) + (* Check whether we need to update our attestable payload *) let new_state = - may_update_endorsable_payload_with_internal_pqc state new_proposal + may_update_attestable_payload_with_internal_pqc state new_proposal in may_update_proposal ~is_proposal_applied new_state new_proposal >>= fun new_state -> @@ -274,29 +274,29 @@ let rec handle_proposal ~is_proposal_applied state (new_proposal : proposal) = locked_round.payload_hash = new_proposal.block.payload_hash) then (* when the new head has the same payload as our - [locked_round], we accept it and preendorse *) - preendorse new_state new_proposal + [locked_round], we accept it and preattest *) + preattest new_state new_proposal else (* The payload is different *) match new_proposal.block.prequorum with | Some {round; _} when Round.(locked_round.round < round) -> - (* This PQC is above our locked_round, we can preendorse it *) - preendorse new_state new_proposal + (* This PQC is above our locked_round, we can preattest it *) + preattest new_state new_proposal | _ -> - (* We shouldn't preendorse this proposal, but we + (* We shouldn't preattest this proposal, but we should at least watch (pre)quorums events on it but only when it is applied otherwise we await for the proposal to be applied. *) if is_proposal_applied then let new_state = - update_current_phase new_state Awaiting_preendorsements + update_current_phase new_state Awaiting_preattestations in Lwt.return (new_state, Watch_proposal) else do_nothing new_state) | None -> (* Otherwise, we did not lock on any payload, thus we can - preendorse it *) - preendorse new_state new_proposal) + preattest it *) + preattest new_state new_proposal) else (* Last case: new_proposal_level > current_level *) (* Possible scenarios: @@ -317,7 +317,7 @@ let rec handle_proposal ~is_proposal_applied state (new_proposal : proposal) = is_latest_proposal_applied = is_proposal_applied; (* Unlock values *) locked_round = None; - endorsable_payload = None; + attestable_payload = None; elected_block = None; delegate_slots; next_level_delegate_slots; @@ -358,8 +358,8 @@ and may_switch_branch ~is_proposal_applied state new_proposal = trigger an [End_of_round] to participate *) Lwt.return (new_state, Synchronize_round round_update) in - let current_endorsable_payload = state.level_state.endorsable_payload in - match (current_endorsable_payload, new_proposal.block.prequorum) with + let current_attestable_payload = state.level_state.attestable_payload in + match (current_attestable_payload, new_proposal.block.prequorum) with | None, Some _ | None, None -> Events.(emit branch_proposal_has_better_fitness ()) >>= fun () -> (* The new branch contains a PQC (and we do not) or a better @@ -409,15 +409,15 @@ let may_register_early_prequorum state ((candidate, _) as received_prequorum) = do_nothing new_state (** Inject a fresh block proposal containing the current operations of the - mempool in [state] and the additional [endorsements] and [dal_attestations] + mempool in [state] and the additional [attestations] and [dal_attestations] for [delegate] at round [round]. *) -let propose_fresh_block_action ~endorsements ~dal_attestations ?last_proposal +let propose_fresh_block_action ~attestations ~dal_attestations ?last_proposal ~(predecessor : block_info) state delegate round = (* TODO check if there is a trace where we could not have updated the level *) (* The block to bake embeds the operations gathered by the worker. However, consensus operations that are not relevant for this block are filtered out. In the case of proposing a new fresh - block, the block is supposed to carry only endorsements for the + block, the block is supposed to carry only attestations for the previous level. *) let operation_pool = (* 1. Fetch operations from the mempool. *) @@ -442,9 +442,9 @@ let propose_fresh_block_action ~endorsements ~dal_attestations ?last_proposal [votes_payload; anonymous_payload; managers_payload] | None -> pool in - (* 2. Filter and only retain relevant endorsements. *) + (* 2. Filter and only retain relevant attestations. *) let relevant_consensus_operations = - let endorsement_filter = + let attestation_filter = { Operation_pool.level = predecessor.shell.level; round = predecessor.round; @@ -452,19 +452,19 @@ let propose_fresh_block_action ~endorsements ~dal_attestations ?last_proposal } in Operation_pool.filter_with_relevant_consensus_ops - ~endorsement_filter - ~preendorsement_filter:None + ~attestation_filter + ~preattestation_filter:None current_mempool.consensus in let filtered_mempool = {current_mempool with consensus = relevant_consensus_operations} in - (* 3. Add the additional given [endorsements] and [dal_attestations]. + (* 3. Add the additional given [attestations] and [dal_attestations]. N.b. this is a set: there won't be duplicates *) let pool = Operation_pool.add_operations filtered_mempool - (List.map Operation.pack endorsements) + (List.map Operation.pack attestations) in Operation_pool.add_operations pool @@ -485,9 +485,9 @@ let propose_block_action state delegate round (proposal : proposal) = (* Possible cases: 1. There was a proposal but the PQC was not reached. 2. There was a proposal and the PQC was reached. We repropose the - [endorsable_payload] if it exists, not the [locked_round] as it + [attestable_payload] if it exists, not the [locked_round] as it may be older. *) - match state.level_state.endorsable_payload with + match state.level_state.attestable_payload with | None -> Events.(emit no_attestable_payload_fresh_block ()) >>= fun () -> (* For case 1, we may re-inject with the same payload or a fresh @@ -495,17 +495,17 @@ let propose_block_action state delegate round (proposal : proposal) = proposal may have been rejected because the block may have been valid but may be considered "bad" (censored operations, empty block, etc.) by the other validators. *) - (* Invariant: there is no locked round if there is no endorsable + (* Invariant: there is no locked round if there is no attestable payload *) assert (state.level_state.locked_round = None) ; - let endorsements_in_last_proposal = proposal.block.quorum in + let attestations_in_last_proposal = proposal.block.quorum in (* Also insert the DAL attestations from the proposal, because the mempool may not contain them anymore *) (* TODO: https://gitlab.com/tezos/tezos/-/issues/4671 The block may therefore contain multiple attestations for the same delegate. *) let dal_attestations_in_last_proposal = proposal.block.dal_attestations in propose_fresh_block_action - ~endorsements:endorsements_in_last_proposal + ~attestations:attestations_in_last_proposal ~dal_attestations:dal_attestations_in_last_proposal state ~last_proposal:proposal.block @@ -514,15 +514,15 @@ let propose_block_action state delegate round (proposal : proposal) = round | Some {proposal; prequorum} -> Events.(emit repropose_block proposal.block.payload_hash) >>= fun () -> - (* For case 2, we re-inject the same block as [endorsable_round] - but we may add some left-overs endorsements. Therefore, the + (* For case 2, we re-inject the same block as [attestable_round] + but we may add some left-overs attestations. Therefore, the operations we need to include are: - - the proposal's included endorsements - - the potential missing new endorsements for the + - the proposal's included attestations + - the potential missing new attestations for the previous block - - the PQC of the endorsable payload *) + - the PQC of the attestable payload *) let consensus_operations = - (* Fetch preendorsements and endorsements from the mempool + (* Fetch preattestations and attestations from the mempool (that could be missing from the proposal), filter, then add consensus operations of the proposal itself, and convert into [packed_operation trace]. *) @@ -538,16 +538,16 @@ let propose_block_action state delegate round (proposal : proposal) = (fun set op -> Operation_pool.Operation_set.add op set) mempool_consensus_operations (List.map Operation.pack proposal.block.quorum - @ List.map Operation.pack prequorum.preendorsements) + @ List.map Operation.pack prequorum.preattestations) in - let endorsement_filter = + let attestation_filter = { Operation_pool.level = proposal.predecessor.shell.level; round = proposal.predecessor.round; payload_hash = proposal.predecessor.payload_hash; } in - let preendorsement_filter = + let preattestation_filter = Some { Operation_pool.level = prequorum.level; @@ -557,8 +557,8 @@ let propose_block_action state delegate round (proposal : proposal) = in Operation_pool.( filter_with_relevant_consensus_ops - ~endorsement_filter - ~preendorsement_filter + ~attestation_filter + ~preattestation_filter all_consensus_operations |> Operation_set.elements) in @@ -594,7 +594,7 @@ let end_of_round state current_round = (current_round, state.level_state.current_level, new_round)) >>= fun () -> (* We don't have any delegate that may propose a new block for - this round -- We will wait for preendorsements when the next + this round -- We will wait for preattestations when the next level block arrive. Meanwhile, we are idle *) let new_state = update_current_phase new_state Idle in do_nothing new_state @@ -623,9 +623,9 @@ let end_of_round state current_round = let time_to_bake_at_next_level state at_round = (* It is now time to update the state level *) - (* We need to keep track for which block we have 2f+1 *endorsements*, that is, + (* We need to keep track for which block we have 2f+1 *attestations*, that is, which will become the new predecessor_block *) - (* Invariant: endorsable_round >= round(elected block) >= locked_round *) + (* Invariant: attestable_round >= round(elected block) >= locked_round *) let round_proposer_opt = round_proposer state ~level:`Next at_round in match (state.level_state.elected_block, round_proposer_opt) with | None, _ | _, None -> @@ -633,9 +633,9 @@ let time_to_bake_at_next_level state at_round = triggered when we have a slot and an elected block *) assert false | Some elected_block, Some {consensus_key_and_delegate; _} -> - let endorsements = elected_block.endorsement_qc in + let attestations = elected_block.attestation_qc in let dal_attestations = - (* Unlike endorsements, we don't watch and store DAL attestations for + (* Unlike proposal attestations, we don't watch and store DAL attestations for each proposal, we'll retrieve them from the mempool *) [] in @@ -644,7 +644,7 @@ let time_to_bake_at_next_level state at_round = in let new_state = {state with level_state = new_level_state} in propose_fresh_block_action - ~endorsements + ~attestations ~dal_attestations ~predecessor:elected_block.proposal.block new_state @@ -657,14 +657,14 @@ let update_locked_round state round payload_hash = let new_level_state = {state.level_state with locked_round} in {state with level_state = new_level_state} -let make_endorse_action state proposal = - let endorsements : (consensus_key_and_delegate * consensus_content) list = +let make_attest_action state proposal = + let attestations : (consensus_key_and_delegate * consensus_content) list = make_consensus_list state proposal in - Inject_endorsements {endorsements} + Inject_attestations {attestations} -let prequorum_reached_when_awaiting_preendorsements state candidate - preendorsements = +let prequorum_reached_when_awaiting_preattestations state candidate + preattestations = let latest_proposal = state.level_state.latest_proposal in if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) then @@ -682,25 +682,25 @@ let prequorum_reached_when_awaiting_preendorsements state candidate level = latest_proposal.block.shell.level; round = latest_proposal.block.round; block_payload_hash = latest_proposal.block.payload_hash; - preendorsements - (* preendorsements may be nil when [consensus_threshold] is 0 *); + preattestations + (* preattestations may be nil when [consensus_threshold] is 0 *); } in - let new_endorsable_payload = {proposal = latest_proposal; prequorum} in + let new_attestable_payload = {proposal = latest_proposal; prequorum} in let new_level_state = let level_state_with_new_payload = { state.level_state with - endorsable_payload = Some new_endorsable_payload; + attestable_payload = Some new_attestable_payload; } in - match state.level_state.endorsable_payload with + match state.level_state.attestable_payload with | None -> level_state_with_new_payload - | Some endorsable_payload -> + | Some attestable_payload -> if Round.( - endorsable_payload.prequorum.round - < new_endorsable_payload.prequorum.round) + attestable_payload.prequorum.round + < new_attestable_payload.prequorum.round) then level_state_with_new_payload else state.level_state in @@ -711,10 +711,10 @@ let prequorum_reached_when_awaiting_preendorsements state candidate latest_proposal.block.round latest_proposal.block.payload_hash in - let new_state = update_current_phase new_state Awaiting_endorsements in - Lwt.return (new_state, make_endorse_action new_state latest_proposal) + let new_state = update_current_phase new_state Awaiting_attestations in + Lwt.return (new_state, make_attest_action new_state latest_proposal) -let quorum_reached_when_waiting_endorsements state candidate endorsement_qc = +let quorum_reached_when_waiting_attestations state candidate attestation_qc = let latest_proposal = state.level_state.latest_proposal in if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) then @@ -728,7 +728,7 @@ let quorum_reached_when_waiting_endorsements state candidate endorsement_qc = match state.level_state.elected_block with | None -> let elected_block = - Some {proposal = latest_proposal; endorsement_qc} + Some {proposal = latest_proposal; attestation_qc} in {state.level_state with elected_block} | Some _ -> @@ -750,9 +750,9 @@ let handle_expected_applied_proposal (state : Baking_state.t) = match new_state.round_state.delayed_prequorum with | None -> (* The application arrived before the prequorum: just wait for the prequorum. *) - let new_state = update_current_phase new_state Awaiting_preendorsements in + let new_state = update_current_phase new_state Awaiting_preattestations in do_nothing new_state - | Some (candidate, preendorsement_qc) -> + | Some (candidate, preattestation_qc) -> (* The application arrived after the prequorum: handle the prequorum received earlier. Start by resetting the delayed_prequorum *) @@ -766,10 +766,10 @@ let handle_expected_applied_proposal (state : Baking_state.t) = round_state = new_round_state; } in - prequorum_reached_when_awaiting_preendorsements + prequorum_reached_when_awaiting_preattestations new_state candidate - preendorsement_qc + preattestation_qc (* Hypothesis: - The state is not to be modified outside this module @@ -821,8 +821,8 @@ let step (state : Baking_state.t) (event : Baking_state.event) : else Events.(emit applied_expected_proposal_received proposal.block.hash) >>= fun () -> handle_expected_applied_proposal state - | Awaiting_endorsements, New_head_proposal proposal - | Awaiting_preendorsements, New_head_proposal proposal -> + | Awaiting_attestations, New_head_proposal proposal + | Awaiting_preattestations, New_head_proposal proposal -> Events.( emit new_head @@ -837,8 +837,8 @@ let step (state : Baking_state.t) (event : Baking_state.event) : (proposal.block.hash, proposal.block.shell.level, proposal.block.round)) >>= fun () -> handle_proposal ~is_proposal_applied:false state proposal | Awaiting_application, New_valid_proposal proposal - | Awaiting_endorsements, New_valid_proposal proposal - | Awaiting_preendorsements, New_valid_proposal proposal -> + | Awaiting_attestations, New_valid_proposal proposal + | Awaiting_preattestations, New_valid_proposal proposal -> Events.( emit new_valid_proposal @@ -850,20 +850,20 @@ let step (state : Baking_state.t) (event : Baking_state.event) : else Events.(emit new_valid_proposal_while_waiting_for_qc ()) >>= fun () -> handle_proposal ~is_proposal_applied:false state proposal - | Awaiting_application, Prequorum_reached (candidate, preendorsement_qc) -> - may_register_early_prequorum state (candidate, preendorsement_qc) - | Awaiting_preendorsements, Prequorum_reached (candidate, preendorsement_qc) + | Awaiting_application, Prequorum_reached (candidate, preattestation_qc) -> + may_register_early_prequorum state (candidate, preattestation_qc) + | Awaiting_preattestations, Prequorum_reached (candidate, preattestation_qc) -> - prequorum_reached_when_awaiting_preendorsements + prequorum_reached_when_awaiting_preattestations state candidate - preendorsement_qc - | Awaiting_endorsements, Quorum_reached (candidate, endorsement_qc) -> - quorum_reached_when_waiting_endorsements state candidate endorsement_qc + preattestation_qc + | Awaiting_attestations, Quorum_reached (candidate, attestation_qc) -> + quorum_reached_when_waiting_attestations state candidate attestation_qc (* Unreachable cases *) | Idle, (Prequorum_reached _ | Quorum_reached _) - | Awaiting_preendorsements, Quorum_reached _ - | Awaiting_endorsements, Prequorum_reached _ + | Awaiting_preattestations, Quorum_reached _ + | Awaiting_attestations, Prequorum_reached _ | Awaiting_application, Quorum_reached _ -> (* This cannot/should not happen *) do_nothing state diff --git a/src/proto_alpha/lib_delegate/state_transitions.mli b/src/proto_alpha/lib_delegate/state_transitions.mli index 9bf6740eea2fbdfbbe50d6fe3a91888a2442cc29..c0cd0317de1980ae9bad035740a4bd1ed33ca60c 100644 --- a/src/proto_alpha/lib_delegate/state_transitions.mli +++ b/src/proto_alpha/lib_delegate/state_transitions.mli @@ -44,7 +44,7 @@ val make_consensus_list : val may_update_proposal : is_proposal_applied:bool -> state -> proposal -> state Lwt.t -val preendorse : state -> proposal -> (state * action) Lwt.t +val preattest : state -> proposal -> (state * action) Lwt.t val extract_pqc : state -> proposal -> (Kind.preattestation operation list * Round.t) option @@ -53,7 +53,7 @@ val handle_proposal : is_proposal_applied:bool -> state -> proposal -> (state * action) Lwt.t val propose_fresh_block_action : - endorsements:Kind.attestation Operation.t list -> + attestations:Kind.attestation Operation.t list -> dal_attestations:Kind.dal_attestation Operation.t list -> ?last_proposal:block_info -> predecessor:block_info -> @@ -74,15 +74,15 @@ val time_to_bake_at_next_level : state -> Round.t -> (state * action) Lwt.t val update_locked_round : state -> Round.t -> Block_payload_hash.t -> state -val make_endorse_action : state -> proposal -> action +val make_attest_action : state -> proposal -> action -val prequorum_reached_when_awaiting_preendorsements : +val prequorum_reached_when_awaiting_preattestations : state -> Operation_worker.candidate -> Kind.preattestation operation list -> (state * action) Lwt.t -val quorum_reached_when_waiting_endorsements : +val quorum_reached_when_waiting_attestations : state -> Operation_worker.candidate -> Kind.attestation operation list ->