From 1398dba072c3f1a0c733aa2c07d4fae1d530e784 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 21 Jul 2023 16:08:31 +0200 Subject: [PATCH 1/5] alpha/test: rename endorsement in context helpers --- .../test/helpers/consensus_helpers.ml | 4 +- .../lib_protocol/test/helpers/context.ml | 50 +++++++++---------- .../lib_protocol/test/helpers/context.mli | 34 ++++++------- .../lib_protocol/test/helpers/op.ml | 4 +- .../test/integration/consensus/test_baking.ml | 8 +-- .../consensus/test_double_baking.ml | 6 +-- .../consensus/test_double_endorsement.ml | 22 ++++---- .../consensus/test_double_preendorsement.ml | 4 +- .../integration/consensus/test_endorsement.ml | 8 +-- .../consensus/test_participation.ml | 8 +-- .../consensus/test_preendorsement_functor.ml | 6 +-- .../test/integration/consensus/test_seed.ml | 2 +- .../operations/test_origination.ml | 2 +- .../validate/generator_descriptors.ml | 4 +- .../integration/validate/validate_helpers.ml | 6 +-- 15 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml index 56dce872e73d..787631784305 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml @@ -142,13 +142,13 @@ let test_consensus_operation_all_modes ?delegate ?slot ?level ?round let delegate_of_first_slot b = let module V = Plugin.RPC.Validators in - Context.get_endorsers b >|=? function + Context.get_attesters b >|=? function | {V.consensus_key; slots = s :: _; _} :: _ -> (consensus_key, s) | _ -> assert false let delegate_of_slot ?(different_slot = false) slot b = let module V = Plugin.RPC.Validators in - Context.get_endorsers b >|=? fun endorsers -> + Context.get_attesters b >|=? fun endorsers -> List.find_map (function | {V.consensus_key; slots = s :: _; _} diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index ccef51e9d989..f4ab8e722c6e 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -121,35 +121,35 @@ let rpc_ctxt = | I bl -> Incremental.rpc_ctxt#call_proto_service3 s bl a b c q i end -let get_endorsers ctxt = Plugin.RPC.Validators.get rpc_ctxt ctxt +let get_attesters ctxt = Plugin.RPC.Validators.get rpc_ctxt ctxt -let get_first_different_endorsers ctxt = - get_endorsers ctxt >|=? function x :: y :: _ -> (x, y) | _ -> assert false +let get_first_different_attesters ctxt = + get_attesters ctxt >|=? function x :: y :: _ -> (x, y) | _ -> assert false -let get_endorser ctxt = - get_endorsers ctxt >|=? fun endorsers -> - let endorser = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd endorsers in - (endorser.consensus_key, endorser.slots) +let get_attester ctxt = + get_attesters ctxt >|=? fun attesters -> + let attester = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd attesters in + (attester.consensus_key, attester.slots) -let get_endorser_slot ctxt pkh = - get_endorsers ctxt >|=? fun endorsers -> +let get_attester_slot ctxt pkh = + get_attesters ctxt >|=? fun attesters -> List.find_map (function | {Plugin.RPC.Validators.consensus_key; slots; _} -> if Signature.Public_key_hash.(consensus_key = pkh) then Some slots else None) - endorsers + attesters -let get_endorser_n ctxt n = - Plugin.RPC.Validators.get rpc_ctxt ctxt >|=? fun endorsers -> - let endorser = - WithExceptions.Option.get ~loc:__LOC__ @@ List.nth endorsers n +let get_attester_n ctxt n = + Plugin.RPC.Validators.get rpc_ctxt ctxt >|=? fun attesters -> + let attester = + WithExceptions.Option.get ~loc:__LOC__ @@ List.nth attesters n in - (endorser.consensus_key, endorser.slots) + (attester.consensus_key, attester.slots) -let get_endorsing_power_for_delegate ctxt ?level pkh = +let get_attesting_power_for_delegate ctxt ?level pkh = let levels = Option.map (fun level -> [level]) level in - Plugin.RPC.Validators.get rpc_ctxt ?levels ctxt >>=? fun endorsers -> + Plugin.RPC.Validators.get rpc_ctxt ?levels ctxt >>=? fun attesters -> let rec find_slots_for_delegate = function | [] -> return 0 | {Plugin.RPC.Validators.delegate; slots; _} :: t -> @@ -157,13 +157,13 @@ let get_endorsing_power_for_delegate ctxt ?level pkh = return (List.length slots) else find_slots_for_delegate t in - find_slots_for_delegate endorsers + find_slots_for_delegate attesters -let get_cumulated_endorsing_power_for_delegate ctxt ~levels pkh = +let get_cumulated_attesting_power_for_delegate ctxt ~levels pkh = let open Lwt_result_syntax in List.fold_left_es (fun accu level -> - let+ power = get_endorsing_power_for_delegate ctxt ~level pkh in + let+ power = get_attesting_power_for_delegate ctxt ~level pkh in accu + power) 0 levels @@ -223,7 +223,7 @@ let get_baking_reward_fixed_portion ctxt = csts ~reward_kind:Baking_reward_fixed_portion) -let get_bonus_reward ctxt ~endorsing_power = +let get_bonus_reward ctxt ~attesting_power = get_constants ctxt >>=? fun {Constants.parametric = {consensus_threshold; _} as csts; _} -> let baking_reward_bonus_per_slot = @@ -231,19 +231,19 @@ let get_bonus_reward ctxt ~endorsing_power = csts ~reward_kind:Baking_reward_bonus_per_slot in - let multiplier = max 0 (endorsing_power - consensus_threshold) in + let multiplier = max 0 (attesting_power - consensus_threshold) in return Test_tez.(baking_reward_bonus_per_slot *! Int64.of_int multiplier) -let get_endorsing_reward ctxt ~expected_endorsing_power = +let get_attesting_reward ctxt ~expected_attesting_power = get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> - let endorsing_reward_per_slot = + let attesting_reward_per_slot = Delegate.Rewards.For_RPC.reward_from_constants csts ~reward_kind:Attesting_reward_per_slot in Lwt.return (Environment.wrap_tzresult - Tez.(endorsing_reward_per_slot *? Int64.of_int expected_endorsing_power)) + Tez.(attesting_reward_per_slot *? Int64.of_int expected_attesting_power)) let get_liquidity_baking_subsidy ctxt = get_constants ctxt >>=? fun {Constants.parametric = csts; _} -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 7d2e72e8f1f3..8c13fc67acaf 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -36,39 +36,39 @@ val pred_branch : t -> Block_hash.t val get_level : t -> Raw_level.t tzresult -(** Given a context, returns the list of endorsers charactized by +(** Given a context, returns the list of attesters charactized by the [level], the public key hash of the [delegate], its [consensus_key] and its assigned [slots]. see {! Plugin.RPC.Validator.t}. *) -val get_endorsers : t -> Plugin.RPC.Validators.t list tzresult Lwt.t +val get_attesters : t -> Plugin.RPC.Validators.t list tzresult Lwt.t -(** Return the two first elements of the list returns by [get_endorsers]. *) -val get_first_different_endorsers : +(** Return the two first elements of the list returns by [get_attesters]. *) +val get_first_different_attesters : t -> (Plugin.RPC.Validators.t * Plugin.RPC.Validators.t) tzresult Lwt.t (** Return the first element [delegate,slot] of the list returns by - [get_endorsers], where [delegate] is the [consensus key] when + [get_attesters], where [delegate] is the [consensus key] when is set. *) -val get_endorser : t -> (public_key_hash * Slot.t list) tzresult Lwt.t +val get_attester : t -> (public_key_hash * Slot.t list) tzresult Lwt.t (** Given a [delegate], and a context [ctxt], if [delegate] is in - [get_endorsers ctxt] returns the [slots] of [delegate] otherwise + [get_attesters ctxt] returns the [slots] of [delegate] otherwise return [None]. *) -val get_endorser_slot : +val get_attester_slot : t -> public_key_hash -> Slot.t list option tzresult Lwt.t -(** Return the [n]th element of the list returns by [get_endorsers]. *) -val get_endorser_n : t -> int -> (public_key_hash * Slot.t list) tzresult Lwt.t +(** Return the [n]th element of the list returns by [get_attesters]. *) +val get_attester_n : t -> int -> (public_key_hash * Slot.t list) tzresult Lwt.t -(** Counts the number of endorsing slots that the given delegate has +(** Counts the number of attesting slots that the given delegate has in the requested level. If ommited, [level] defaults to the next level. *) -val get_endorsing_power_for_delegate : +val get_attesting_power_for_delegate : t -> ?level:Raw_level.t -> public_key_hash -> int tzresult Lwt.t -(** Sums the result of [get_endorsing_power_for_delegate] over a list +(** Sums the result of [get_attesting_power_for_delegate] over a list of levels. *) -val get_cumulated_endorsing_power_for_delegate : +val get_cumulated_attesting_power_for_delegate : t -> levels:Raw_level.t list -> public_key_hash -> int tzresult Lwt.t val get_current_voting_power : @@ -113,10 +113,10 @@ val default_test_constants : Constants.Parametric.t val get_baking_reward_fixed_portion : t -> Tez.t tzresult Lwt.t -val get_bonus_reward : t -> endorsing_power:int -> Tez.t tzresult Lwt.t +val get_bonus_reward : t -> attesting_power:int -> Tez.t tzresult Lwt.t -val get_endorsing_reward : - t -> expected_endorsing_power:int -> Tez.t tzresult Lwt.t +val get_attesting_reward : + t -> expected_attesting_power:int -> Tez.t tzresult Lwt.t val get_liquidity_baking_subsidy : t -> Tez.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 7f2c201b98b8..8dc4ef96342e 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -64,9 +64,9 @@ let mk_consensus_content_signer_and_branch ?delegate ?slot ?level ?round in let* delegate_pkh, slots = match delegate with - | None -> Context.get_endorser (B endorsed_block) + | None -> Context.get_attester (B endorsed_block) | Some del -> ( - let* slots = Context.get_endorser_slot (B endorsed_block) del in + let* slots = Context.get_attester_slot (B endorsed_block) del in match slots with | None -> return (del, []) | Some slots -> return (del, slots)) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml index 488a91f314cd..5985e2b670f9 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml @@ -190,7 +190,7 @@ let test_rewards_block_and_payload_producer () = Context.get_baker (B genesis) ~round:Round.zero >>=? fun baker_b1 -> get_contract_for_pkh contracts baker_b1 >>=? fun baker_b1_contract -> Block.bake ~policy:(By_round 0) genesis >>=? fun b1 -> - Context.get_endorsers (B b1) >>=? fun endorsers -> + Context.get_attesters (B b1) >>=? fun endorsers -> List.map_es (function | {Plugin.RPC.Validators.delegate; slots; _} -> return (delegate, slots)) @@ -205,7 +205,7 @@ let test_rewards_block_and_payload_producer () = (fun (endorser, _slots) -> Op.endorsement ~delegate:endorser b1) endorsers >>=? fun endos -> - let endorsing_power = + let attesting_power = List.fold_left (fun acc (_pkh, slots) -> acc + List.length slots) 0 @@ -221,7 +221,7 @@ let test_rewards_block_and_payload_producer () = Context.Delegate.current_frozen_deposits (B b2) baker_b2 >>=? fun frozen_deposit -> Context.get_baking_reward_fixed_portion (B b2) >>=? fun baking_reward -> - Context.get_bonus_reward (B b2) ~endorsing_power >>=? fun bonus_reward -> + Context.get_bonus_reward (B b2) ~attesting_power >>=? fun bonus_reward -> (if Signature.Public_key_hash.equal baker_b2 baker_b1 then Context.get_baking_reward_fixed_portion (B b1) else return Tez.zero) @@ -239,7 +239,7 @@ let test_rewards_block_and_payload_producer () = correspond to a slot of [baker_b2] and it includes the PQC for [b2]. We check that the fixed baking reward goes to the payload producer [baker_b2], while the bonus goes to the the block producer (aka baker) [baker_b2']. *) - Context.get_endorsers (B b2) >>=? fun endorsers -> + Context.get_attesters (B b2) >>=? fun endorsers -> List.map_es (function | {Plugin.RPC.Validators.delegate; slots; _} -> return (delegate, slots)) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml index c3711adaf09c..1deb7f5a0461 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml @@ -121,7 +121,7 @@ let test_valid_double_baking_followed_by_double_endorsing () = double_baking (B blk_a) blk_a.header blk_b.header |> fun operation -> Block.bake ~policy:(By_account baker2) ~operation blk_a >>=? fun blk_with_db_evidence -> - Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> + Context.get_first_different_attesters (B blk_a) >>=? fun (e1, e2) -> let delegate = if Signature.Public_key_hash.( = ) e1.delegate baker1 then e1.delegate else e2.delegate @@ -165,7 +165,7 @@ let test_valid_double_endorsing_followed_by_double_baking () = >>=? fun frozen_deposits_before -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> + Context.get_first_different_attesters (B blk_a) >>=? fun (e1, e2) -> let delegate = if Signature.Public_key_hash.( = ) e1.delegate baker1 then e1.delegate else e2.delegate @@ -219,7 +219,7 @@ let test_payload_producer_gets_evidence_rewards () = double_baking (B b1) b1.header b2.header |> fun db_evidence -> Block.bake ~policy:(By_account baker2) ~operation:db_evidence b1 >>=? fun b_with_evidence -> - Context.get_endorsers (B b_with_evidence) >>=? fun endorsers -> + Context.get_attesters (B b_with_evidence) >>=? fun endorsers -> List.map_es (function | {Plugin.RPC.Validators.delegate; slots; _} -> return (delegate, slots)) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml index 04f8adea921d..b51d5ab171d9 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml @@ -85,7 +85,7 @@ let test_valid_double_endorsement_evidence () = are identical. *) Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_endorser (B blk_a) >>=? fun (delegate, _) -> + Context.get_attester (B blk_a) >>=? fun (delegate, _) -> Op.raw_endorsement blk_a >>=? fun endorsement_a -> Op.raw_endorsement blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in @@ -141,7 +141,7 @@ let test_valid_double_endorsement_evidence () = let test_different_branch () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun blk -> - Context.get_endorser (B blk) >>=? fun (endorser, _slots) -> + Context.get_attester (B blk) >>=? fun (endorser, _slots) -> Op.raw_endorsement ~delegate:endorser blk >>=? fun endorsement_a -> Op.raw_endorsement ~branch:Block_hash.zero ~delegate:endorser blk >>=? fun endorsement_b -> @@ -162,7 +162,7 @@ let test_different_slots () = let open Lwt_result_syntax in let* genesis, _contracts = Context.init2 ~consensus_threshold:0 () in let* blk = Block.bake genesis in - let* endorsers = Context.get_endorsers (B blk) in + let* endorsers = Context.get_attesters (B blk) in let delegate, slot1, slot2 = (* Find an endorser with more than 1 slot. *) WithExceptions.Option.get @@ -191,7 +191,7 @@ let test_two_double_endorsement_evidences_leadsto_no_bake () = block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_endorser (B blk_a) >>=? fun (delegate, _) -> + Context.get_attester (B blk_a) >>=? fun (delegate, _) -> Op.raw_endorsement blk_a >>=? fun endorsement_a -> Op.raw_endorsement blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in @@ -308,7 +308,7 @@ let test_different_delegates () = block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_first_different_endorsers (B blk_b) + Context.get_first_different_attesters (B blk_b) >>=? fun (endorser_a, endorser_b) -> Op.raw_endorsement ~delegate:endorser_a.delegate blk_a >>=? fun e_a -> Op.raw_endorsement ~delegate:endorser_b.delegate blk_b >>=? fun e_b -> @@ -328,10 +328,10 @@ let test_wrong_delegate () = block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_endorser (B blk_a) >>=? fun (endorser_a, _a_slots) -> + Context.get_attester (B blk_a) >>=? fun (endorser_a, _a_slots) -> Op.raw_endorsement ~delegate:endorser_a blk_a >>=? fun endorsement_a -> - Context.get_endorser_n (B blk_b) 0 >>=? fun (endorser0, _slots0) -> - Context.get_endorser_n (B blk_b) 1 >>=? fun (endorser1, _slots1) -> + Context.get_attester_n (B blk_b) 0 >>=? fun (endorser0, _slots0) -> + Context.get_attester_n (B blk_b) 1 >>=? fun (endorser1, _slots1) -> let endorser_b = if Signature.Public_key_hash.equal endorser_a endorser0 then endorser1 else endorser0 @@ -348,7 +348,7 @@ let test_wrong_delegate () = let test_freeze_more_with_low_balance = let get_endorsing_slots_for_account ctxt account = (* Get the slots of the given account in the given context. *) - Context.get_endorsers ctxt >>=? function + Context.get_attesters ctxt >>=? function | [d1; d2] -> return (if Signature.Public_key_hash.equal account d1.delegate then d1 @@ -378,7 +378,7 @@ let test_freeze_more_with_low_balance = Block.bake ~policy:(Excluding [account1]) b2 ~operations:[denunciation] in let check_unique_endorser b account2 = - Context.get_endorsers (B b) >>=? function + Context.get_attesters (B b) >>=? function | [{delegate; _}] when Signature.Public_key_hash.equal account2 delegate -> return_unit | _ -> failwith "We are supposed to only have account2 as endorser." @@ -488,7 +488,7 @@ let test_two_double_endorsement_evidences_leads_to_duplicate_denunciation () = block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_endorser (B blk_a) >>=? fun (delegate, _) -> + Context.get_attester (B blk_a) >>=? fun (delegate, _) -> Op.raw_endorsement blk_a >>=? fun endorsement_a -> Op.raw_endorsement blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml index 69ec0b2397b3..a30341689650 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml @@ -56,7 +56,7 @@ end = struct let pick_endorsers ctxt = let module V = Plugin.RPC.Validators in - Context.get_endorsers ctxt >>=? function + Context.get_attesters ctxt >>=? function | a :: b :: _ -> return ((a.V.delegate, a.V.slots), (b.V.delegate, b.V.slots)) | _ -> assert false @@ -311,7 +311,7 @@ end = struct block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Context.get_endorser (B blk_a) >>=? fun (delegate, _) -> + Context.get_attester (B blk_a) >>=? fun (delegate, _) -> Op.raw_preendorsement blk_a >>=? fun preendorsement_a -> Op.raw_preendorsement blk_b >>=? fun preendorsement_b -> let operation = diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml index 3fa78e344331..8ec59da34067 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml @@ -100,7 +100,7 @@ let test_fitness_gap () = (** Return a delegate and its second smallest slot for the level of [block]. *) let delegate_and_second_slot block = let open Lwt_result_syntax in - let* endorsers = Context.get_endorsers (B block) in + let* endorsers = Context.get_attesters (B block) in let delegate, slots = (* Find an endorser with more than 1 slot. *) WithExceptions.Option.get @@ -156,7 +156,7 @@ let test_mempool_second_slot () = let test_negative_slot () = Context.init_n 5 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun b -> - Context.get_endorser (B b) >>=? fun (delegate, _slots) -> + Context.get_attester (B b) >>=? fun (delegate, _slots) -> Lwt.catch (fun () -> Op.endorsement @@ -195,7 +195,7 @@ let test_not_smallest_slot () = let delegate_and_someone_elses_slot block = let open Lwt_result_syntax in - let* endorsers = Context.get_endorsers (B block) in + let* endorsers = Context.get_attesters (B block) in let delegate, other_delegate_slot = match endorsers with | [] | [_] -> assert false (* at least two delegates with rights *) @@ -614,7 +614,7 @@ let test_endorsement_threshold ~sufficient_threshold () = Block.bake genesis >>=? fun b -> Context.get_constants (B b) >>=? fun {parametric = {consensus_threshold; _}; _} -> - Context.get_endorsers (B b) >>=? fun endorsers_list -> + Context.get_attesters (B b) >>=? fun endorsers_list -> Block.get_round b >>?= fun round -> List.fold_left_es (fun (counter, endos) {Plugin.RPC.Validators.delegate; slots; _} -> diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml index 755c8ff830dc..934b2a6f7039 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml @@ -37,7 +37,7 @@ open Alpha_context (** [baker] bakes and [endorser] endorses *) let bake_and_endorse_once (_b_pred, b_cur) baker endorser = let open Context in - Context.get_endorsers (B b_cur) >>=? fun endorsers_list -> + Context.get_attesters (B b_cur) >>=? fun endorsers_list -> List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> @@ -89,7 +89,7 @@ let test_participation ~sufficient_participation () = (fun (b_pred, b_crt, endorsing_power) level -> let int_level = Int32.of_int level in Environment.wrap_tzresult (Raw_level.of_int32 int_level) >>?= fun level -> - Context.get_endorsing_power_for_delegate (B b_crt) ~level del1 + Context.get_attesting_power_for_delegate (B b_crt) ~level del1 >>=? fun endorsing_power_for_level -> let endorser, new_endorsing_power = if sufficient_participation && endorsing_power < minimal_nb_active_slots @@ -110,7 +110,7 @@ let test_participation ~sufficient_participation () = to del2. - If sufficient participation, we check that the balance of del2 at b is the balance of del2 at pred_b plus the endorsing rewards. *) - Context.get_endorsing_reward (B b) ~expected_endorsing_power:expected_nb_slots + Context.get_attesting_reward (B b) ~expected_attesting_power:expected_nb_slots >|=? Tez.to_mutez >>=? fun er -> let endorsing_rewards = if sufficient_participation then er else 0L in @@ -186,7 +186,7 @@ let test_participation_rpc () = level_int |> Int32.of_int |> Raw_level.of_int32 |> Environment.wrap_tzresult >>?= fun level -> - Context.get_endorsing_power_for_delegate (B b_crt) ~level del2 + Context.get_attesting_power_for_delegate (B b_crt) ~level del2 >>=? fun endorsing_power -> return (b_crt, b, total_endorsing_power + endorsing_power)) (b0, b1, 0) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml index 565b5ecefbe8..ed51b5f1982e 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml @@ -155,7 +155,7 @@ end = struct aux_simple_preendorsement_inclusion ~get_delegate_and_slot:(fun _predpred _pred curr -> let module V = Plugin.RPC.Validators in - Context.get_endorsers (B curr) >>=? function + Context.get_attesters (B curr) >>=? function | {V.delegate; slots = s :: _; _} :: _ -> return (Some delegate, Some s) | _ -> assert false (* there is at least one endorser with a slot *)) @@ -167,7 +167,7 @@ end = struct aux_simple_preendorsement_inclusion ~get_delegate_and_slot:(fun _predpred _pred curr -> let module V = Plugin.RPC.Validators in - Context.get_endorsers (B curr) >>=? function + Context.get_attesters (B curr) >>=? function | {V.delegate; V.slots = _ :: non_canonical_slot :: _; _} :: _ -> return (Some delegate, Some non_canonical_slot) | _ -> assert false @@ -188,7 +188,7 @@ end = struct aux_simple_preendorsement_inclusion ~get_delegate_and_slot:(fun _predpred _pred curr -> let module V = Plugin.RPC.Validators in - Context.get_endorsers (B curr) >>=? function + Context.get_attesters (B curr) >>=? function | {V.delegate; _} :: {V.slots = s :: _; _} :: _ -> (* the canonical slot s is not owned by the delegate "delegate" !*) return (Some delegate, Some s) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml index aff634460909..b3e4ca6cdcf7 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml @@ -309,7 +309,7 @@ let test_unrevealed () = Int32.to_int csts.parametric.blocks_per_commitment in let bake_and_endorse_block ?policy (_pred_b, b) = - let* slots = Context.get_endorsers (B b) in + let* slots = Context.get_attesters (B b) in let* endorsements = List.map_es (fun {Plugin.RPC.Validators.consensus_key; _} -> diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_origination.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_origination.ml index 6a74f8becd95..579f79ebaf2c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_origination.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_origination.ml @@ -177,7 +177,7 @@ let test_not_tez_in_contract_to_pay_fee () = let register_contract_get_endorser () = Context.init1 () >>=? fun (b, contract) -> Incremental.begin_construction b >>=? fun inc -> - Context.get_endorser (I inc) >|=? fun (account_endorser, _slots) -> + Context.get_attester (I inc) >|=? fun (account_endorser, _slots) -> (inc, contract, account_endorser) (* Create multiple originated contracts and ask contract to pay the fee. *) diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml index a9de7aa1c98c..5a7e8e82cdc7 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml @@ -578,7 +578,7 @@ let preendorsement_descriptor = (fun state -> let open Lwt_result_syntax in let gen (delegate, ck_opt) = - let* slots_opt = Context.get_endorser_slot (B state.block) delegate in + let* slots_opt = Context.get_attester_slot (B state.block) delegate in let delegate = Option.value ~default:delegate ck_opt in match slots_opt with | None -> return_none @@ -603,7 +603,7 @@ let endorsement_descriptor = (fun state -> let open Lwt_result_syntax in let gen (delegate, ck_opt) = - let* slots_opt = Context.get_endorser_slot (B state.block) delegate in + let* slots_opt = Context.get_attester_slot (B state.block) delegate in let delegate = Option.value ~default:delegate ck_opt in match slots_opt with | None -> return_none diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml b/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml index 6091e4730daa..1d93fa986479 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml @@ -361,13 +361,13 @@ let secrets = let pick_two_endorsers ctxt = let module V = Plugin.RPC.Validators in - Context.get_endorsers ctxt >>=? function + Context.get_attesters ctxt >>=? function | a :: b :: _ -> return (a.V.consensus_key, b.V.consensus_key) | _ -> assert false let pick_addr_endorser ctxt = let module V = Plugin.RPC.Validators in - Context.get_endorsers ctxt >>=? function + Context.get_attesters ctxt >>=? function | a :: _ -> return a.V.consensus_key | _ -> assert false @@ -377,7 +377,7 @@ let init_params = let delegates_of_block block = let open Lwt_result_syntax in - let+ validators = Context.get_endorsers (B block) in + let+ validators = Context.get_attesters (B block) in List.map (fun Plugin.RPC.Validators.{consensus_key; slots; _} -> (consensus_key, slots)) -- GitLab From 2ef30c3c8dc6c3291557e7913e3c8bddb44deaa1 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 21 Jul 2023 16:16:44 +0200 Subject: [PATCH 2/5] alpha/test: rename endorsement in operation helpers --- .../test/helpers/consensus_helpers.ml | 8 +-- .../lib_protocol/test/helpers/op.ml | 46 ++++++------- .../lib_protocol/test/helpers/op.mli | 18 +++--- .../test/integration/consensus/test_baking.ml | 4 +- .../consensus/test_consensus_key.ml | 4 +- .../consensus/test_double_baking.ml | 12 ++-- .../consensus/test_double_endorsement.ml | 64 +++++++++---------- .../consensus/test_double_preendorsement.ml | 26 ++++---- .../integration/consensus/test_endorsement.ml | 34 +++++----- .../consensus/test_frozen_deposits.ml | 12 ++-- .../consensus/test_participation.ml | 2 +- .../consensus/test_preendorsement.ml | 6 +- .../consensus/test_preendorsement_functor.ml | 4 +- .../test/integration/consensus/test_seed.ml | 2 +- .../validate/generator_descriptors.ml | 16 ++--- 15 files changed, 129 insertions(+), 129 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml index 787631784305..18cefb2317d6 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml @@ -57,7 +57,7 @@ let test_consensus_operation ?delegate ?slot ?level ?round ?block_payload_hash let* operation = match kind with | Preendorsement -> - Op.preendorsement + Op.preattestation ?delegate ?slot ?level @@ -66,7 +66,7 @@ let test_consensus_operation ?delegate ?slot ?level ?round ?block_payload_hash ?branch endorsed_block | Endorsement -> - Op.endorsement + Op.attestation ?delegate ?slot ?level @@ -164,8 +164,8 @@ let delegate_of_slot ?(different_slot = false) slot b = let test_consensus_op_for_next ~genesis ~kind ~next = let dorsement ~endorsed_block ~delegate = match kind with - | `Preendorsement -> Op.preendorsement ~delegate endorsed_block - | `Endorsement -> Op.endorsement ~delegate endorsed_block + | `Preendorsement -> Op.preattestation ~delegate endorsed_block + | `Endorsement -> Op.attestation ~delegate endorsed_block in Block.bake genesis >>=? fun b1 -> (match next with diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 8dc4ef96342e..adca2dd33901 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -55,18 +55,18 @@ let mk_block_payload_hash payload_round (b : Block.t) = hashes let mk_consensus_content_signer_and_branch ?delegate ?slot ?level ?round - ?block_payload_hash ?branch endorsed_block = + ?block_payload_hash ?branch attested_block = let open Lwt_result_syntax in let branch = match branch with - | None -> endorsed_block.Block.header.shell.predecessor + | None -> attested_block.Block.header.shell.predecessor | Some branch -> branch in let* delegate_pkh, slots = match delegate with - | None -> Context.get_attester (B endorsed_block) + | None -> Context.get_attester (B attested_block) | Some del -> ( - let* slots = Context.get_attester_slot (B endorsed_block) del in + let* slots = Context.get_attester_slot (B attested_block) del in match slots with | None -> return (del, []) | Some slots -> return (del, slots)) @@ -77,28 +77,28 @@ let mk_consensus_content_signer_and_branch ?delegate ?slot ?level ?round let* level = match level with | None -> - let*? level = Context.get_level (B endorsed_block) in + let*? level = Context.get_level (B attested_block) in return level | Some level -> return level in let* round = match round with | None -> - let*? round = Block.get_round endorsed_block in + let*? round = Block.get_round attested_block in return round | Some round -> return round in let block_payload_hash = match block_payload_hash with - | None -> mk_block_payload_hash round endorsed_block + | None -> mk_block_payload_hash round attested_block | Some block_payload_hash -> block_payload_hash in let consensus_content = {slot; level; round; block_payload_hash} in let* signer = Account.find delegate_pkh in return (consensus_content, signer.sk, branch) -let raw_endorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch - endorsed_block = +let raw_attestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch + attested_block = let open Lwt_result_syntax in let* consensus_content, signer, branch = mk_consensus_content_signer_and_branch @@ -108,7 +108,7 @@ let raw_endorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch ?round ?block_payload_hash ?branch - endorsed_block + attested_block in let op = Single (Attestation consensus_content) in return @@ -118,23 +118,23 @@ let raw_endorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch branch op) -let endorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch - endorsed_block = +let attestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch + attested_block = let open Lwt_result_syntax in let* op = - raw_endorsement + raw_attestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch - endorsed_block + attested_block in return (Operation.pack op) -let raw_preendorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch - endorsed_block = +let raw_preattestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch + attested_block = let open Lwt_result_syntax in let* consensus_content, signer, branch = mk_consensus_content_signer_and_branch @@ -144,7 +144,7 @@ let raw_preendorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch ?round ?block_payload_hash ?branch - endorsed_block + attested_block in let op = Single (Preattestation consensus_content) in return @@ -154,18 +154,18 @@ let raw_preendorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch branch op) -let preendorsement ?delegate ?slot ?level ?round ?block_payload_hash ?branch - endorsed_block = +let preattestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch + attested_block = let open Lwt_result_syntax in let* op = - raw_preendorsement + raw_preattestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch - endorsed_block + attested_block in return (Operation.pack op) @@ -638,7 +638,7 @@ let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code = protocol_data = Operation_data {contents; signature = None}; } -let double_endorsement ctxt op1 op2 = +let double_attestation ctxt op1 op2 = let contents = Single (Double_attestation_evidence {op1; op2}) in let branch = Context.branch ctxt in { @@ -646,7 +646,7 @@ let double_endorsement ctxt op1 op2 = protocol_data = Operation_data {contents; signature = None}; } -let double_preendorsement ctxt op1 op2 = +let double_preattestation ctxt op1 op2 = let contents = Single (Double_preattestation_evidence {op1; op2}) in let branch = Context.branch ctxt in { diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index 54e017c7f5e2..05b439fdf84a 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -61,7 +61,7 @@ val sign : Finally, the operation [branch] can be specified. It defaults to the predecessor of the attested block. *) -val raw_endorsement : +val raw_attestation : ?delegate:public_key_hash -> ?slot:Slot.t -> ?level:Raw_level.t -> @@ -74,8 +74,8 @@ val raw_endorsement : (** Create an unpacked preattestation that is expected for a given [Block.t]. - Optional parameters are the same than {!raw_endorsement}. *) -val raw_preendorsement : + Optional parameters are the same than {!raw_attestation}. *) +val raw_preattestation : ?delegate:public_key_hash -> ?slot:Slot.t -> ?level:Raw_level.t -> @@ -86,8 +86,8 @@ val raw_preendorsement : Kind.preattestation Operation.t tzresult Lwt.t (** Create a packed attestation that is expected for a given - [Block.t] by packing the result of {!raw_endorsement}. *) -val endorsement : + [Block.t] by packing the result of {!raw_attestation}. *) +val attestation : ?delegate:public_key_hash -> ?slot:Slot.t -> ?level:Raw_level.t -> @@ -98,8 +98,8 @@ val endorsement : Operation.packed tzresult Lwt.t (** Create a packed preattestation that is expected for a given - [Block.t] by packing the result of {!raw_preendorsement}. *) -val preendorsement : + [Block.t] by packing the result of {!raw_preattestation}. *) +val preattestation : ?delegate:public_key_hash -> ?slot:Slot.t -> ?level:Raw_level.t -> @@ -273,13 +273,13 @@ val register_global_constant : value:Protocol.Alpha_context.Script.lazy_expr -> (Protocol.operation, tztrace) result Lwt.t -val double_endorsement : +val double_attestation : Context.t -> Kind.attestation Operation.t -> Kind.attestation Operation.t -> Operation.packed -val double_preendorsement : +val double_preattestation : Context.t -> Kind.preattestation Operation.t -> Kind.preattestation Operation.t -> diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml index 5985e2b670f9..e50ef2d2c49b 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml @@ -202,7 +202,7 @@ let test_rewards_block_and_payload_producer () = total endorsing power). *) let endorsers = List.take_n 5 endorsers in List.map_ep - (fun (endorser, _slots) -> Op.endorsement ~delegate:endorser b1) + (fun (endorser, _slots) -> Op.attestation ~delegate:endorser b1) endorsers >>=? fun endos -> let attesting_power = @@ -246,7 +246,7 @@ let test_rewards_block_and_payload_producer () = endorsers >>=? fun preendorsers -> List.map_ep - (fun (endorser, _slots) -> Op.preendorsement ~delegate:endorser b2) + (fun (endorser, _slots) -> Op.preattestation ~delegate:endorser b2) preendorsers >>=? fun preendos -> Context.get_baker (B b1) ~round:Round.zero >>=? fun baker_b2 -> diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml index 510be2e88f97..4907976532c4 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_consensus_key.ml @@ -220,13 +220,13 @@ let test_endorsement_with_consensus_key () = update_consensus_key blk' delegate consensus_pk >>=? fun b_pre -> Block.bake b_pre >>=? fun b -> let slot = Slot.of_int_do_not_use_except_for_parameters 0 in - Op.endorsement ~delegate:account1_pkh ~slot b >>=? fun endorsement -> + Op.attestation ~delegate:account1_pkh ~slot b >>=? fun endorsement -> Block.bake ~operation:endorsement b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Operation.Invalid_signature -> true | _ -> false) >>=? fun () -> - Op.endorsement ~delegate:consensus_pkh ~slot b >>=? fun endorsement -> + Op.attestation ~delegate:consensus_pkh ~slot b >>=? fun endorsement -> Block.bake ~operation:endorsement b >>=? fun (_good_block : Block.t) -> return_unit diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml index 1deb7f5a0461..307c244e1873 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml @@ -109,7 +109,7 @@ let order_endorsements ~correct_order op1 op2 = [test_valid_double_endorsing_followed_by_double_baking] *) let double_endorsement ctxt ?(correct_order = true) op1 op2 = let e1, e2 = order_endorsements ~correct_order op1 op2 in - Op.double_endorsement ctxt e1 e2 + Op.double_attestation ctxt e1 e2 let test_valid_double_baking_followed_by_double_endorsing () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, contracts) -> @@ -126,8 +126,8 @@ let test_valid_double_baking_followed_by_double_endorsing () = if Signature.Public_key_hash.( = ) e1.delegate baker1 then e1.delegate else e2.delegate in - Op.raw_endorsement ~delegate blk_a >>=? fun endorsement_a -> - Op.raw_endorsement ~delegate blk_b >>=? fun endorsement_b -> + Op.raw_attestation ~delegate blk_a >>=? fun endorsement_a -> + Op.raw_attestation ~delegate blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in Block.bake ~policy:(By_account baker1) ~operation blk_with_db_evidence >>=? fun blk_final -> @@ -170,8 +170,8 @@ let test_valid_double_endorsing_followed_by_double_baking () = if Signature.Public_key_hash.( = ) e1.delegate baker1 then e1.delegate else e2.delegate in - Op.raw_endorsement ~delegate blk_a >>=? fun endorsement_a -> - Op.raw_endorsement ~delegate blk_b >>=? fun endorsement_b -> + Op.raw_attestation ~delegate blk_a >>=? fun endorsement_a -> + Op.raw_attestation ~delegate blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in Block.bake ~policy:(By_account baker1) ~operation blk_a >>=? fun blk_with_de_evidence -> @@ -227,7 +227,7 @@ let test_payload_producer_gets_evidence_rewards () = >>=? fun preendorsers -> List.map_ep (fun (endorser, _slots) -> - Op.preendorsement ~delegate:endorser b_with_evidence) + Op.preattestation ~delegate:endorser b_with_evidence) preendorsers >>=? fun preendos -> Block.bake diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml index b51d5ab171d9..06a63dee92b1 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml @@ -58,11 +58,11 @@ let order_endorsements ~correct_order op1 op2 = let double_endorsement ctxt ?(correct_order = true) op1 op2 = let e1, e2 = order_endorsements ~correct_order op1 op2 in - Op.double_endorsement ctxt e1 e2 + Op.double_attestation ctxt e1 e2 let double_preendorsement ctxt ?(correct_order = true) op1 op2 = let e1, e2 = order_endorsements ~correct_order op1 op2 in - Op.double_preendorsement ctxt e1 e2 + Op.double_preattestation ctxt e1 e2 (** This test verifies that when a "cheater" double endorses and doesn't have enough tokens to re-freeze of full deposit, we only @@ -86,8 +86,8 @@ let test_valid_double_endorsement_evidence () = Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - Op.raw_endorsement blk_a >>=? fun endorsement_a -> - Op.raw_endorsement blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun endorsement_a -> + Op.raw_attestation blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in Context.get_bakers (B blk_a) >>=? fun bakers -> let baker = Context.get_first_different_baker delegate bakers in @@ -142,13 +142,13 @@ let test_different_branch () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun blk -> Context.get_attester (B blk) >>=? fun (endorser, _slots) -> - Op.raw_endorsement ~delegate:endorser blk >>=? fun endorsement_a -> - Op.raw_endorsement ~branch:Block_hash.zero ~delegate:endorser blk + Op.raw_attestation ~delegate:endorser blk >>=? fun endorsement_a -> + Op.raw_attestation ~branch:Block_hash.zero ~delegate:endorser blk >>=? fun endorsement_b -> let operation = double_endorsement (B blk) endorsement_a endorsement_b in Block.bake ~operation blk >>=? fun _blk -> - Op.raw_preendorsement ~delegate:endorser blk >>=? fun preendorsement_a -> - Op.raw_preendorsement ~branch:Block_hash.zero ~delegate:endorser blk + Op.raw_preattestation ~delegate:endorser blk >>=? fun preendorsement_a -> + Op.raw_preattestation ~branch:Block_hash.zero ~delegate:endorser blk >>=? fun preendorsement_b -> let operation = double_preendorsement (B blk) preendorsement_a preendorsement_b @@ -174,12 +174,12 @@ let test_different_slots () = | _ -> None) endorsers) in - let* endorsement1 = Op.raw_endorsement ~delegate ~slot:slot1 blk in - let* endorsement2 = Op.raw_endorsement ~delegate ~slot:slot2 blk in + let* endorsement1 = Op.raw_attestation ~delegate ~slot:slot1 blk in + let* endorsement2 = Op.raw_attestation ~delegate ~slot:slot2 blk in let doubleA = double_endorsement (B blk) endorsement1 endorsement2 in let* (_ : Block.t) = Block.bake ~operation:doubleA blk in - let* preendorsement1 = Op.raw_preendorsement ~delegate ~slot:slot1 blk in - let* preendorsement2 = Op.raw_preendorsement ~delegate ~slot:slot2 blk in + let* preendorsement1 = Op.raw_preattestation ~delegate ~slot:slot1 blk in + let* preendorsement2 = Op.raw_preattestation ~delegate ~slot:slot2 blk in let doubleB = double_preendorsement (B blk) preendorsement1 preendorsement2 in let* (_ : Block.t) = Block.bake ~operation:doubleB blk in return_unit @@ -192,8 +192,8 @@ let test_two_double_endorsement_evidences_leadsto_no_bake () = Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - Op.raw_endorsement blk_a >>=? fun endorsement_a -> - Op.raw_endorsement blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun endorsement_a -> + Op.raw_attestation blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in Context.get_bakers (B blk_a) >>=? fun bakers -> let baker = Context.get_first_different_baker delegate bakers in @@ -204,8 +204,8 @@ let test_two_double_endorsement_evidences_leadsto_no_bake () = block_fork blk_with_evidence1 >>=? fun (blk_30, blk_40) -> Block.bake blk_30 >>=? fun blk_3 -> Block.bake blk_40 >>=? fun blk_4 -> - Op.raw_endorsement blk_3 >>=? fun endorsement_3 -> - Op.raw_endorsement blk_4 >>=? fun endorsement_4 -> + Op.raw_attestation blk_3 >>=? fun endorsement_3 -> + Op.raw_attestation blk_4 >>=? fun endorsement_4 -> let operation = double_endorsement (B blk_with_evidence1) endorsement_3 endorsement_4 in @@ -228,9 +228,9 @@ let test_two_double_endorsement_evidences_leadsto_no_bake () = let test_invalid_double_endorsement () = Context.init_n ~consensus_threshold:0 10 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun b -> - Op.raw_endorsement b >>=? fun endorsement -> + Op.raw_attestation b >>=? fun endorsement -> Block.bake ~operation:(Operation.pack endorsement) b >>=? fun b -> - Op.double_endorsement (B b) endorsement endorsement |> fun operation -> + Op.double_attestation (B b) endorsement endorsement |> fun operation -> Block.bake ~operation b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Validate_errors.Anonymous.Invalid_denunciation kind @@ -246,8 +246,8 @@ let test_invalid_double_endorsement_variant () = block_fork b >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Op.raw_endorsement blk_a >>=? fun endorsement_a -> - Op.raw_endorsement blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun endorsement_a -> + Op.raw_attestation blk_b >>=? fun endorsement_b -> double_endorsement (B genesis) ~correct_order:false @@ -268,8 +268,8 @@ let test_too_early_double_endorsement_evidence () = block_fork b >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Op.raw_endorsement blk_a >>=? fun endorsement_a -> - Op.raw_endorsement blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun endorsement_a -> + Op.raw_attestation blk_b >>=? fun endorsement_b -> double_endorsement (B genesis) endorsement_a endorsement_b |> fun operation -> Block.bake ~operation genesis >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function @@ -288,8 +288,8 @@ let test_too_late_double_endorsement_evidence () = block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Op.raw_endorsement blk_a >>=? fun endorsement_a -> - Op.raw_endorsement blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun endorsement_a -> + Op.raw_attestation blk_b >>=? fun endorsement_b -> Block.bake_n ((max_slashing_period * Int32.to_int blocks_per_cycle) + 1) blk_a >>=? fun blk -> double_endorsement (B blk) endorsement_a endorsement_b |> fun operation -> @@ -310,8 +310,8 @@ let test_different_delegates () = Block.bake blk_2 >>=? fun blk_b -> Context.get_first_different_attesters (B blk_b) >>=? fun (endorser_a, endorser_b) -> - Op.raw_endorsement ~delegate:endorser_a.delegate blk_a >>=? fun e_a -> - Op.raw_endorsement ~delegate:endorser_b.delegate blk_b >>=? fun e_b -> + Op.raw_attestation ~delegate:endorser_a.delegate blk_a >>=? fun e_a -> + Op.raw_attestation ~delegate:endorser_b.delegate blk_b >>=? fun e_b -> Block.bake ~operation:(Operation.pack e_b) blk_b >>=? fun (_ : Block.t) -> double_endorsement (B blk_b) e_a e_b |> fun operation -> Block.bake ~operation blk_b >>= fun res -> @@ -329,14 +329,14 @@ let test_wrong_delegate () = Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (endorser_a, _a_slots) -> - Op.raw_endorsement ~delegate:endorser_a blk_a >>=? fun endorsement_a -> + Op.raw_attestation ~delegate:endorser_a blk_a >>=? fun endorsement_a -> Context.get_attester_n (B blk_b) 0 >>=? fun (endorser0, _slots0) -> Context.get_attester_n (B blk_b) 1 >>=? fun (endorser1, _slots1) -> let endorser_b = if Signature.Public_key_hash.equal endorser_a endorser0 then endorser1 else endorser0 in - Op.raw_endorsement ~delegate:endorser_b blk_b >>=? fun endorsement_b -> + Op.raw_attestation ~delegate:endorser_b blk_b >>=? fun endorsement_b -> double_endorsement (B blk_b) endorsement_a endorsement_b |> fun operation -> Block.bake ~operation blk_b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function @@ -368,12 +368,12 @@ let test_freeze_more_with_low_balance = let slot = match List.hd slots_a with None -> assert false | Some s -> s in - Op.raw_endorsement ~delegate:account1 ~slot blk_a >>=? fun end_a -> + Op.raw_attestation ~delegate:account1 ~slot blk_a >>=? fun end_a -> get_endorsing_slots_for_account (B blk_b) account1 >>=? fun slots_b -> let slot = match List.hd slots_b with None -> assert false | Some s -> s in - Op.raw_endorsement ~delegate:account1 ~slot blk_b >>=? fun end_b -> + Op.raw_attestation ~delegate:account1 ~slot blk_b >>=? fun end_b -> let denunciation = double_endorsement (B b2) end_a end_b in Block.bake ~policy:(Excluding [account1]) b2 ~operations:[denunciation] in @@ -489,8 +489,8 @@ let test_two_double_endorsement_evidences_leads_to_duplicate_denunciation () = Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - Op.raw_endorsement blk_a >>=? fun endorsement_a -> - Op.raw_endorsement blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun endorsement_a -> + Op.raw_attestation blk_b >>=? fun endorsement_b -> let operation = double_endorsement (B genesis) endorsement_a endorsement_b in let operation2 = double_endorsement (B genesis) endorsement_b endorsement_a in Context.get_bakers (B blk_a) >>=? fun bakers -> diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml index a30341689650..5520a1635960 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml @@ -70,17 +70,17 @@ end = struct let malformed_double_preendorsement_denunciation ?(include_endorsement = false) ?(block_round = 0) - ?(mk_evidence = fun ctxt p1 p2 -> Op.double_preendorsement ctxt p1 p2) + ?(mk_evidence = fun ctxt p1 p2 -> Op.double_preattestation ctxt p1 p2) ~loc () = Context.init_n ~consensus_threshold:0 10 () >>=? fun (genesis, _contracts) -> bake genesis >>=? fun b1 -> bake ~policy:(By_round 0) b1 >>=? fun b2_A -> - Op.endorsement b1 >>=? fun e -> + Op.attestation b1 >>=? fun e -> let operations = if include_endorsement then [e] else [] in bake ~policy:(By_round block_round) ~operations b1 >>=? fun b2_B -> - Op.raw_preendorsement b2_A >>=? fun op1 -> - Op.raw_preendorsement b2_B >>=? fun op2 -> + Op.raw_preattestation b2_A >>=? fun op1 -> + Op.raw_preattestation b2_B >>=? fun op2 -> let op = mk_evidence (B genesis) op1 op2 in bake b1 ~operations:[op] >>= fun res -> invalid_denunciation loc res @@ -199,23 +199,23 @@ end = struct bake ~policy:(By_round 0) blk ~operations:[trans] >>=? fun head_B -> pick_endorsers (B head_A) >>=? fun ((d1, _slots1), (d2, _slots2)) -> (* default: d1 = d2 *) - Op.raw_preendorsement ~delegate:d1 head_A >>=? fun op1 -> - Op.raw_preendorsement ~delegate:d2 head_B >>=? fun op2 -> + Op.raw_preattestation ~delegate:d1 head_A >>=? fun op1 -> + Op.raw_preattestation ~delegate:d2 head_B >>=? fun op2 -> let op1, op2 = order_preendorsements ~correct_order:true op1 op2 in (* bake `nb_blocks_before_denunciation` before double preend. denunciation *) bake_n nb_blocks_before_denunciation blk >>=? fun blk -> - let op : Operation.packed = Op.double_preendorsement (B blk) op1 op2 in + let op : Operation.packed = Op.double_preattestation (B blk) op1 op2 in Context.get_baker (B blk) ~round:Round.zero >>=? fun baker -> bake ~policy:(By_account baker) blk ~operations:[op] >>= function | Ok new_head -> test_expected_ok loc baker blk new_head d1 d2 >>=? fun () -> let op : Operation.packed = - Op.double_preendorsement (B new_head) op2 op1 + Op.double_preattestation (B new_head) op2 op1 in bake new_head ~operations:[op] >>= invalid_denunciation loc >>=? fun () -> let op : Operation.packed = - Op.double_preendorsement (B new_head) op1 op2 + Op.double_preattestation (B new_head) op1 op2 in bake new_head ~operations:[op] >>= already_denounced loc | Error _ as res -> test_expected_ko loc res @@ -242,7 +242,7 @@ end = struct let malformed_double_preendorsement_denunciation_same_preendorsement () = malformed_double_preendorsement_denunciation (* exactly the same preendorsement operation => illformed *) - ~mk_evidence:(fun ctxt p1 _p2 -> Op.double_preendorsement ctxt p1 p1) + ~mk_evidence:(fun ctxt p1 _p2 -> Op.double_preattestation ctxt p1 p1) ~loc:__LOC__ () @@ -297,7 +297,7 @@ end = struct let double_preendorsement ctxt ?(correct_order = true) op1 op2 = let e1, e2 = order_preendorsements ~correct_order op1 op2 in - Op.double_preendorsement ctxt e1 e2 + Op.double_preattestation ctxt e1 e2 let block_fork b = Context.get_first_different_bakers (B b) >>=? fun (baker_1, baker_2) -> @@ -312,8 +312,8 @@ end = struct Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - Op.raw_preendorsement blk_a >>=? fun preendorsement_a -> - Op.raw_preendorsement blk_b >>=? fun preendorsement_b -> + Op.raw_preattestation blk_a >>=? fun preendorsement_a -> + Op.raw_preattestation blk_b >>=? fun preendorsement_b -> let operation = double_preendorsement (B genesis) preendorsement_a preendorsement_b in diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml index 8ec59da34067..99cceae006a5 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml @@ -78,7 +78,7 @@ let test_non_zero_round () = let test_fitness_gap () = let open Lwt_result_syntax in let* _genesis, pred_b = init_genesis () in - let* operation = Op.endorsement pred_b in + let* operation = Op.attestation pred_b in let* b = Block.bake ~operation pred_b in let fitness = match Fitness.from_raw b.header.shell.fitness with @@ -159,7 +159,7 @@ let test_negative_slot () = Context.get_attester (B b) >>=? fun (delegate, _slots) -> Lwt.catch (fun () -> - Op.endorsement + Op.attestation ~delegate ~slot:(Slot.of_int_do_not_use_except_for_parameters (-1)) b @@ -443,8 +443,8 @@ let assert_conflict_error ~loc res = let test_conflict () = let open Lwt_result_syntax in let* _genesis, b = init_genesis () in - let* op = Op.endorsement b in - let* op_different_branch = Op.endorsement ~branch:Block_hash.zero b in + let* op = Op.attestation b in + let* op_different_branch = Op.attestation ~branch:Block_hash.zero b in (* Test in application and construction (aka baking) modes *) let assert_conflict loc baking_mode tested_op = Block.bake ~baking_mode ~operations:[op; tested_op] b @@ -463,7 +463,7 @@ let test_conflict () = let* () = assert_mempool_conflict __LOC__ op in let* () = assert_mempool_conflict __LOC__ op_different_branch in let* op_different_payload_hash = - Op.endorsement ~block_payload_hash:Block_payload_hash.zero b + Op.attestation ~block_payload_hash:Block_payload_hash.zero b in let* () = assert_mempool_conflict __LOC__ op_different_payload_hash in return_unit @@ -480,12 +480,12 @@ let test_grandparent_conflict () = let open Lwt_result_syntax in let* _genesis, grandparent = init_genesis () in let* predecessor = Block.bake grandparent in - let* op = Op.endorsement grandparent in + let* op = Op.attestation grandparent in let* op_different_branch = - Op.endorsement ~branch:Block_hash.zero grandparent + Op.attestation ~branch:Block_hash.zero grandparent in let* op_different_payload_hash = - Op.endorsement ~block_payload_hash:Block_payload_hash.zero grandparent + Op.attestation ~block_payload_hash:Block_payload_hash.zero grandparent in let* inc = Incremental.begin_construction ~mempool_mode:true predecessor in let* inc = Incremental.validate_operation inc op in @@ -504,12 +504,12 @@ let test_future_level_conflict () = let open Lwt_result_syntax in let* _genesis, predecessor = init_genesis () in let* future_block = Block.bake ~policy:(By_round 10) predecessor in - let* op = Op.endorsement future_block in + let* op = Op.attestation future_block in let* op_different_branch = - Op.endorsement ~branch:Block_hash.zero future_block + Op.attestation ~branch:Block_hash.zero future_block in let* op_different_payload_hash = - Op.endorsement ~block_payload_hash:Block_payload_hash.zero future_block + Op.attestation ~block_payload_hash:Block_payload_hash.zero future_block in let* inc = Incremental.begin_construction ~mempool_mode:true predecessor in let* inc = Incremental.validate_operation inc op in @@ -527,8 +527,8 @@ let test_future_level_conflict () = let test_no_conflict_with_preendorsement_mempool () = let open Lwt_result_syntax in let* _genesis, endorsed_block = init_genesis () in - let* op_endo = Op.endorsement endorsed_block in - let* op_preendo = Op.preendorsement endorsed_block in + let* op_endo = Op.attestation endorsed_block in + let* op_preendo = Op.preattestation endorsed_block in let* inc = Incremental.begin_construction ~mempool_mode:true endorsed_block in let* inc = Incremental.add_operation inc op_endo in let* inc = Incremental.add_operation inc op_preendo in @@ -544,8 +544,8 @@ let test_no_conflict_with_preendorsement_block () = let open Lwt_result_syntax in let* _genesis, predecessor = init_genesis () in let* round0_block = Block.bake predecessor in - let* op_endo = Op.endorsement predecessor in - let* op_preendo = Op.preendorsement round0_block in + let* op_endo = Op.attestation predecessor in + let* op_preendo = Op.preattestation round0_block in let bake_both_ops baking_mode = Block.bake ~baking_mode @@ -575,7 +575,7 @@ let test_no_conflict_various_levels_and_rounds () = let* alt_future = Block.bake ~policy:(By_round 10) alt_predecessor in let* inc = Incremental.begin_construction ~mempool_mode:true predecessor in let add_endorsement inc endorsed_block = - let* (op : packed_operation) = Op.endorsement endorsed_block in + let* (op : packed_operation) = Op.attestation endorsed_block in let (Operation_data protocol_data) = op.protocol_data in let content = match protocol_data.contents with @@ -623,7 +623,7 @@ let test_endorsement_threshold ~sufficient_threshold () = (sufficient_threshold && counter < consensus_threshold) || ((not sufficient_threshold) && new_counter < consensus_threshold) then - Op.endorsement ~round ~delegate b >>=? fun endo -> + Op.attestation ~round ~delegate b >>=? fun endo -> return (new_counter, endo :: endos) else return (counter, endos)) (0, []) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml index 9c856c3239a4..b6ac56169e87 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml @@ -286,11 +286,11 @@ let test_may_not_bake_again_after_full_deposit_slash () = Block.bake ~policy:(By_account slashed_account) ~operation genesis >>=? fun blk_a -> Block.bake ~policy:(By_account slashed_account) genesis >>=? fun blk_b -> - Op.raw_preendorsement ~delegate:slashed_account blk_a >>=? fun preendo1 -> - Op.raw_preendorsement ~delegate:slashed_account blk_b >>=? fun preendo2 -> + Op.raw_preattestation ~delegate:slashed_account blk_a >>=? fun preendo1 -> + Op.raw_preattestation ~delegate:slashed_account blk_b >>=? fun preendo2 -> let preendo1, preendo2 = order_ops preendo1 preendo2 in let double_preendo_op = - Op.double_preendorsement (B blk_a) preendo1 preendo2 + Op.double_preattestation (B blk_a) preendo1 preendo2 in Block.bake ~policy:(By_account good_account) @@ -301,10 +301,10 @@ let test_may_not_bake_again_after_full_deposit_slash () = >>=? fun operation -> Block.bake ~policy:(By_account slashed_account) ~operation b >>=? fun blk_a -> Block.bake ~policy:(By_account slashed_account) b >>=? fun blk_b -> - Op.raw_endorsement ~delegate:slashed_account blk_a >>=? fun endo1 -> - Op.raw_endorsement ~delegate:slashed_account blk_b >>=? fun endo2 -> + Op.raw_attestation ~delegate:slashed_account blk_a >>=? fun endo1 -> + Op.raw_attestation ~delegate:slashed_account blk_b >>=? fun endo2 -> let endo1, endo2 = order_ops endo1 endo2 in - let double_endo_op = Op.double_endorsement (B blk_a) endo1 endo2 in + let double_endo_op = Op.double_attestation (B blk_a) endo1 endo2 in Block.bake ~policy:(By_account good_account) ~operation:double_endo_op b >>=? fun b -> (* Assert that the [slashed_account]'s deposit is now 0 *) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml index 934b2a6f7039..36b5b6f6e708 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml @@ -49,7 +49,7 @@ let bake_and_endorse_once (_b_pred, b_cur) baker endorser = | None -> assert false | Some (delegate, _slots) -> Block.get_round b_cur >>?= fun round -> - Op.endorsement ~round ~delegate b_cur >>=? fun endorsement -> + Op.attestation ~round ~delegate b_cur >>=? fun endorsement -> Block.bake ~policy:(By_account baker) ~operation:endorsement b_cur (** We test that: diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml index e4cc2936e71f..adf753e838db 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml @@ -50,7 +50,7 @@ let init_genesis ?policy () = let test_preendorsement_with_arbitrary_branch () = Context.init1 () >>=? fun (genesis, _contract) -> Block.bake genesis >>=? fun blk -> - Op.preendorsement ~branch:Block_hash.zero blk >>=? fun operation -> + Op.preattestation ~branch:Block_hash.zero blk >>=? fun operation -> Incremental.begin_construction ~mempool_mode:true blk >>=? fun inc -> Incremental.validate_operation inc operation >>=? fun _inc -> return_unit @@ -155,9 +155,9 @@ let test_duplicate_preendorsement () = init_genesis () >>=? fun (genesis, _) -> Block.bake genesis >>=? fun b -> Incremental.begin_construction ~mempool_mode:true b >>=? fun inc -> - Op.preendorsement b >>=? fun operation -> + Op.preattestation b >>=? fun operation -> Incremental.add_operation inc operation >>=? fun inc -> - Op.preendorsement b >>=? fun operation -> + Op.preattestation b >>=? fun operation -> Incremental.add_operation inc operation >>= fun res -> Assert.proto_error_with_info ~loc:__LOC__ diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml index ed51b5f1982e..f5607e0a93b6 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml @@ -58,11 +58,11 @@ end = struct ?(post_process = Ok (fun _ -> return_unit)) ~loc () = Context.init_n ~consensus_threshold:1 5 () >>=? fun (genesis, _contracts) -> bake genesis >>=? fun b1 -> - Op.endorsement b1 >>=? fun endo -> + Op.attestation b1 >>=? fun endo -> bake b1 ~operations:[endo] >>=? fun b2 -> let endorsed_block = preendorsed_block genesis b1 b2 in get_delegate_and_slot genesis b1 b2 >>=? fun (delegate, slot) -> - Op.preendorsement ?delegate ?slot ~round:preend_round endorsed_block + Op.preattestation ?delegate ?slot ~round:preend_round endorsed_block >>=? fun p -> let operations = endo :: (mk_ops @@ p) in bake diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml index b3e4ca6cdcf7..9955e5720ed2 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml @@ -313,7 +313,7 @@ let test_unrevealed () = let* endorsements = List.map_es (fun {Plugin.RPC.Validators.consensus_key; _} -> - Op.endorsement ~delegate:consensus_key b) + Op.attestation ~delegate:consensus_key b) slots in Block.bake ?policy ~operations:endorsements b diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml index 5a7e8e82cdc7..c601385cb165 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml @@ -349,8 +349,8 @@ let dbl_endorsement_prelude state = | None -> return ([], state) | Some (b1, b2) -> let* delegate1, delegate2 = pick_two_endorsers (B b1) in - let* op1 = Op.raw_preendorsement ~delegate:delegate1 b1 in - let* op2 = Op.raw_preendorsement ~delegate:delegate1 b2 in + let* op1 = Op.raw_preattestation ~delegate:delegate1 b1 in + let* op2 = Op.raw_preattestation ~delegate:delegate1 b2 in let op1, op2 = let comp = Operation_hash.compare (Operation.hash op1) (Operation.hash op2) @@ -361,8 +361,8 @@ let dbl_endorsement_prelude state = let slashable_preend = (op1, op2) :: state.dbl_endorsement.slashable_preend in - let* op3 = Op.raw_endorsement ~delegate:delegate2 b1 in - let* op4 = Op.raw_endorsement ~delegate:delegate2 b2 in + let* op3 = Op.raw_attestation ~delegate:delegate2 b1 in + let* op4 = Op.raw_attestation ~delegate:delegate2 b2 in let op3, op4 = let comp = Operation_hash.compare (Operation.hash op3) (Operation.hash op4) @@ -387,10 +387,10 @@ let double_consensus_descriptor = (fun state -> let open Lwt_result_syntax in let gen_dbl_pre (op1, op2) = - Op.double_preendorsement (Context.B state.block) op1 op2 + Op.double_preattestation (Context.B state.block) op1 op2 in let gen_dbl_end (op1, op2) = - Op.double_endorsement (Context.B state.block) op1 op2 + Op.double_attestation (Context.B state.block) op1 op2 in let candidates_pre = List.map gen_dbl_pre state.dbl_endorsement.slashable_preend @@ -586,7 +586,7 @@ let preendorsement_descriptor = match slots with | [] -> return_none | _ :: _ -> - let* op = Op.preendorsement ~delegate state.block in + let* op = Op.preattestation ~delegate state.block in return_some op) in List.filter_map_es gen state.delegates); @@ -611,7 +611,7 @@ let endorsement_descriptor = match slots with | [] -> return_none | _ :: _ -> - let* op = Op.endorsement ~delegate state.block in + let* op = Op.attestation ~delegate state.block in return_some op) in List.filter_map_es gen state.delegates); -- GitLab From 3a5c700e2deac267eec96908b31efb401b62008f Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 21 Jul 2023 16:31:25 +0200 Subject: [PATCH 3/5] alpha/test: rename endorsement in consensus_helpers --- .../test/helpers/consensus_helpers.ml | 42 +++++----- .../integration/consensus/test_endorsement.ml | 76 +++++++++---------- .../consensus/test_preendorsement.ml | 32 ++++---- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml index 18cefb2317d6..c49fcab6003c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/consensus_helpers.ml @@ -33,30 +33,30 @@ let show_mode = function | Construction -> "Construction" | Mempool -> "Mempool" -type kind = Preendorsement | Endorsement +type kind = Preattestation | Attestation -(** Craft an endorsement or preendorsement, and bake a block +(** Craft an attestation or preattestation, and bake a block containing it (in application or construction modes) or inject it into a mempool. When [error] is [None], check that it succeeds, otherwise check that it fails as specified by [error]. - By default, the (pre)endorsement is for the first slot and is + By default, the (pre)attestation is for the first slot and is signed by the delegate that owns this slot. Moreover, the operation - points to the given [endorsed_block]: in other words, it has that + points to the given [attested_block]: in other words, it has that block's level, round, payload hash, and its branch is the predecessor of that block. Optional arguments allow to override these default parameters. The [predecessor] is used as the predecessor of the baked block or the head of the mempool. When it is not provided, we use the - [endorsed_block] for this. *) + [attested_block] for this. *) let test_consensus_operation ?delegate ?slot ?level ?round ?block_payload_hash - ?branch ~endorsed_block ?(predecessor = endorsed_block) ?error ~loc kind + ?branch ~attested_block ?(predecessor = attested_block) ?error ~loc kind mode = let open Lwt_result_syntax in let* operation = match kind with - | Preendorsement -> + | Preattestation -> Op.preattestation ?delegate ?slot @@ -64,8 +64,8 @@ let test_consensus_operation ?delegate ?slot ?level ?round ?block_payload_hash ?round ?block_payload_hash ?branch - endorsed_block - | Endorsement -> + attested_block + | Attestation -> Op.attestation ?delegate ?slot @@ -73,7 +73,7 @@ let test_consensus_operation ?delegate ?slot ?level ?round ?block_payload_hash ?round ?block_payload_hash ?branch - endorsed_block + attested_block in let check_error res = match error with @@ -100,7 +100,7 @@ let test_consensus_operation ?delegate ?slot ?level ?round ?block_payload_hash check_error res let test_consensus_operation_all_modes_different_outcomes ?delegate ?slot ?level - ?round ?block_payload_hash ?branch ~endorsed_block ?predecessor ~loc + ?round ?block_payload_hash ?branch ~attested_block ?predecessor ~loc ?application_error ?construction_error ?mempool_error kind = List.iter_es (fun (mode, error) -> @@ -111,7 +111,7 @@ let test_consensus_operation_all_modes_different_outcomes ?delegate ?slot ?level ?round ?block_payload_hash ?branch - ~endorsed_block + ~attested_block ?predecessor ?error ~loc:(Format.sprintf "%s (%s mode)" loc (show_mode mode)) @@ -124,7 +124,7 @@ let test_consensus_operation_all_modes_different_outcomes ?delegate ?slot ?level ] let test_consensus_operation_all_modes ?delegate ?slot ?level ?round - ?block_payload_hash ?branch ~endorsed_block ?predecessor ?error ~loc kind = + ?block_payload_hash ?branch ~attested_block ?predecessor ?error ~loc kind = test_consensus_operation_all_modes_different_outcomes ?delegate ?slot @@ -132,7 +132,7 @@ let test_consensus_operation_all_modes ?delegate ?slot ?level ?round ?round ?block_payload_hash ?branch - ~endorsed_block + ~attested_block ?predecessor ~loc ?application_error:error @@ -148,7 +148,7 @@ let delegate_of_first_slot b = let delegate_of_slot ?(different_slot = false) slot b = let module V = Plugin.RPC.Validators in - Context.get_attesters b >|=? fun endorsers -> + Context.get_attesters b >|=? fun attesters -> List.find_map (function | {V.consensus_key; slots = s :: _; _} @@ -156,16 +156,16 @@ let delegate_of_slot ?(different_slot = false) slot b = else Slot.equal s slot -> Some consensus_key | _ -> None) - endorsers + attesters |> function | None -> assert false | Some d -> d let test_consensus_op_for_next ~genesis ~kind ~next = - let dorsement ~endorsed_block ~delegate = + let dorsement ~attested_block ~delegate = match kind with - | `Preendorsement -> Op.preattestation ~delegate endorsed_block - | `Endorsement -> Op.attestation ~delegate endorsed_block + | `Preattestation -> Op.preattestation ~delegate attested_block + | `Attestation -> Op.attestation ~delegate attested_block in Block.bake genesis >>=? fun b1 -> (match next with @@ -174,9 +174,9 @@ let test_consensus_op_for_next ~genesis ~kind ~next = >>=? fun b2 -> Incremental.begin_construction ~mempool_mode:true b1 >>=? fun inc -> delegate_of_first_slot (B b1) >>=? fun (delegate, slot) -> - dorsement ~endorsed_block:b1 ~delegate >>=? fun operation -> + dorsement ~attested_block:b1 ~delegate >>=? fun operation -> Incremental.add_operation inc operation >>=? fun inc -> delegate_of_slot ~different_slot:true slot (B b2) >>=? fun delegate -> - dorsement ~endorsed_block:b2 ~delegate >>=? fun operation -> + dorsement ~attested_block:b2 ~delegate >>=? fun operation -> Incremental.add_operation inc operation >>=? fun (_ : Incremental.t) -> return_unit diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml index 99cceae006a5..00ee4bb3f3e7 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml @@ -45,33 +45,33 @@ let init_genesis ?policy () = (** Correct endorsement from the slot 0 endorser. *) let test_simple_endorsement () = let open Lwt_result_syntax in - let* _genesis, endorsed_block = init_genesis () in + let* _genesis, attested_block = init_genesis () in Consensus_helpers.test_consensus_operation_all_modes ~loc:__LOC__ - ~endorsed_block - Endorsement + ~attested_block + Attestation (** Test that the endorsement's branch does not affect its validity. *) let test_arbitrary_branch () = let open Lwt_result_syntax in - let* _genesis, endorsed_block = init_genesis () in + let* _genesis, attested_block = init_genesis () in Consensus_helpers.test_consensus_operation_all_modes ~loc:__LOC__ - ~endorsed_block + ~attested_block ~branch:Block_hash.zero - Endorsement + Attestation (** Correct endorsement with a level and a round that are both different from {!test_simple_endorsement}. *) let test_non_zero_round () = let open Lwt_result_syntax in let* _genesis, b = init_genesis () in - let* endorsed_block = Block.bake ~policy:(By_round 10) b in + let* attested_block = Block.bake ~policy:(By_round 10) b in Consensus_helpers.test_consensus_operation_all_modes ~loc:__LOC__ - ~endorsed_block - Endorsement + ~attested_block + Attestation (** Fitness gap: this is a straightforward update from Emmy to Tenderbake, that is, check that the level is incremented in a child block. *) @@ -131,15 +131,15 @@ let test_mempool_second_slot () = let* _genesis, grandparent = init_genesis () in let* predecessor = Block.bake grandparent ~policy:(By_round 3) in let* future_block = Block.bake predecessor ~policy:(By_round 5) in - let check_non_smallest_slot_ok loc endorsed_block = - let* delegate, slot = delegate_and_second_slot endorsed_block in + let check_non_smallest_slot_ok loc attested_block = + let* delegate, slot = delegate_and_second_slot attested_block in Consensus_helpers.test_consensus_operation ~loc - ~endorsed_block + ~attested_block ~predecessor ~delegate ~slot - Endorsement + Attestation Mempool in let* () = check_non_smallest_slot_ok __LOC__ grandparent in @@ -185,13 +185,13 @@ let test_not_smallest_slot () = in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:b + ~attested_block:b ~delegate ~slot ~application_error:error_wrong_slot ~construction_error:error_wrong_slot ?mempool_error:None - Endorsement + Attestation let delegate_and_someone_elses_slot block = let open Lwt_result_syntax in @@ -211,12 +211,12 @@ let test_not_own_slot () = let* delegate, other_delegate_slot = delegate_and_someone_elses_slot b in Consensus_helpers.test_consensus_operation_all_modes ~loc:__LOC__ - ~endorsed_block:b + ~attested_block:b ~delegate ~slot:other_delegate_slot ~error:(function | Alpha_context.Operation.Invalid_signature -> true | _ -> false) - Endorsement + Attestation (** In mempool mode, also test endorsements with a slot that does not belong to the delegate for various allowed levels and rounds. *) @@ -229,12 +229,12 @@ let test_mempool_not_own_slot () = let* delegate, other_delegate_slot = delegate_and_someone_elses_slot b in Consensus_helpers.test_consensus_operation ~loc - ~endorsed_block:b + ~attested_block:b ~delegate ~slot:other_delegate_slot ~error:(function | Alpha_context.Operation.Invalid_signature -> true | _ -> false) - Endorsement + Attestation Mempool in let* () = check_not_own_slot_fails __LOC__ grandparent in @@ -262,12 +262,12 @@ let test_one_level_too_old () = let* predecessor = Block.bake grandparent in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:grandparent + ~attested_block:grandparent ~predecessor ~application_error:error_old_level ~construction_error:error_old_level ?mempool_error:None - Endorsement + Attestation (** Endorsement that is two levels too old (pointing to the great-grandparent instead of the predecessor). It should fail in @@ -279,10 +279,10 @@ let test_two_levels_too_old () = let* predecessor = Block.bake grandparent in Consensus_helpers.test_consensus_operation_all_modes ~loc:__LOC__ - ~endorsed_block:greatgrandparent + ~attested_block:greatgrandparent ~predecessor ~error:error_old_level - Endorsement + Attestation let error_future_level = function | Validate_errors.Consensus.Consensus_operation_for_future_level {kind; _} @@ -300,12 +300,12 @@ let test_one_level_in_the_future () = let* next_level_block = Block.bake predecessor in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:next_level_block + ~attested_block:next_level_block ~predecessor ~application_error:error_future_level ~construction_error:error_future_level ?mempool_error:None - Endorsement + Attestation (** Endorsement that is two levels in the future. It should fail in all modes. *) @@ -316,10 +316,10 @@ let test_two_levels_future () = let* after_next_level_block = Block.bake next_level_block in Consensus_helpers.test_consensus_operation_all_modes ~loc:__LOC__ - ~endorsed_block:after_next_level_block + ~attested_block:after_next_level_block ~predecessor ~error:error_future_level - Endorsement + Attestation (** {2 Wrong round} *) @@ -338,12 +338,12 @@ let test_one_round_too_old () = let* predecessor = Block.bake ~policy:(By_round 1) b in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:round0_block + ~attested_block:round0_block ~predecessor ~application_error:error_old_round ~construction_error:error_old_round ?mempool_error:None - Endorsement + Attestation (** Endorsement that is many rounds too old. It should fail in a block (application or construction) but succeed in a mempool. *) @@ -354,12 +354,12 @@ let test_many_rounds_too_old () = let* predecessor = Block.bake ~policy:(By_round 15) b in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:round5_block + ~attested_block:round5_block ~predecessor ~application_error:error_old_round ~construction_error:error_old_round ?mempool_error:None - Endorsement + Attestation let error_future_round = function | Validate_errors.Consensus.Consensus_operation_for_future_round {kind; _} @@ -376,12 +376,12 @@ let test_one_round_in_the_future () = let* round1_block = Block.bake ~policy:(By_round 1) b in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:round1_block + ~attested_block:round1_block ~predecessor ~application_error:error_future_round ~construction_error:error_future_round ?mempool_error:None - Endorsement + Attestation (** Endorsement that is many rounds in the future. It should fail in a block (application or construction) but succeed in a mempool. *) @@ -392,12 +392,12 @@ let test_many_rounds_future () = let* round15_block = Block.bake ~policy:(By_round 15) b in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block:round15_block + ~attested_block:round15_block ~predecessor ~application_error:error_future_round ~construction_error:error_future_round ?mempool_error:None - Endorsement + Attestation (** {2 Wrong payload hash} *) @@ -405,7 +405,7 @@ let test_many_rounds_future () = block (application or construction) but succeed in a mempool. *) let test_wrong_payload_hash () = let open Lwt_result_syntax in - let* _genesis, endorsed_block = init_genesis () in + let* _genesis, attested_block = init_genesis () in let error_wrong_payload_hash = function | Validate_errors.Consensus.Wrong_payload_hash_for_consensus_operation {kind; _} @@ -415,12 +415,12 @@ let test_wrong_payload_hash () = in Consensus_helpers.test_consensus_operation_all_modes_different_outcomes ~loc:__LOC__ - ~endorsed_block + ~attested_block ~block_payload_hash:Block_payload_hash.zero ~application_error:error_wrong_payload_hash ~construction_error:error_wrong_payload_hash ?mempool_error:None - Endorsement + Attestation (** {1 Conflict tests} diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml index adf753e838db..f9d8a5774bc7 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml @@ -61,14 +61,14 @@ let test_consensus_operation_preendorsement_for_future_level () = let level = match raw_level with Ok l -> l | Error _ -> assert false in Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~level ~error:(function | Validate_errors.Consensus.Consensus_operation_for_future_level {kind; _} when kind = Validate_errors.Consensus.Preattestation -> true | _ -> false) - Preendorsement + Preattestation Mempool (** Consensus operation for old level : apply a preendorsement with a level in the past *) @@ -79,14 +79,14 @@ let test_consensus_operation_preendorsement_for_old_level () = let level = match raw_level with Ok l -> l | Error _ -> assert false in Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~level ~error:(function | Validate_errors.Consensus.Consensus_operation_for_old_level {kind; _} when kind = Validate_errors.Consensus.Preattestation -> true | _ -> false) - Preendorsement + Preattestation Mempool (** Consensus operation for future round : apply a preendorsement with a round in the future *) @@ -95,9 +95,9 @@ let test_consensus_operation_preendorsement_for_future_round () = Environment.wrap_tzresult (Round.of_int 21) >>?= fun round -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~round - Preendorsement + Preattestation Mempool (** Consensus operation for old round : apply a preendorsement with a round in the past *) @@ -106,9 +106,9 @@ let test_consensus_operation_preendorsement_for_old_round () = Environment.wrap_tzresult (Round.of_int 0) >>?= fun round -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~round - Preendorsement + Preattestation Mempool (** Consensus operation on competing proposal : apply a preendorsement on a competing proposal *) @@ -116,9 +116,9 @@ let test_consensus_operation_preendorsement_on_competing_proposal () = init_genesis () >>=? fun (_genesis, pred) -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~block_payload_hash:Block_payload_hash.zero - Preendorsement + Preattestation Mempool (** Unexpected preendorsements in block : apply a preendorsement with an incorrect round *) @@ -126,11 +126,11 @@ let test_unexpected_preendorsements_in_blocks () = init_genesis () >>=? fun (_genesis, pred) -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~error:(function | Validate_errors.Consensus.Unexpected_preattestation_in_block -> true | _ -> false) - Preendorsement + Preattestation Application (** Round too high : apply a preendorsement with a too high round *) @@ -141,13 +141,13 @@ let test_too_high_round () = Environment.wrap_tzresult (Round.of_int 1) >>?= fun round -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ - ~endorsed_block:pred + ~attested_block:pred ~round ~level ~error:(function | Validate_errors.Consensus.Preattestation_round_too_high _ -> true | _ -> false) - Preendorsement + Preattestation Construction (** Duplicate preendorsement : apply a preendorsement that has already been applied. *) @@ -169,7 +169,7 @@ let test_preendorsement_for_next_level () = init_genesis () >>=? fun (genesis, _) -> Consensus_helpers.test_consensus_op_for_next ~genesis - ~kind:`Preendorsement + ~kind:`Preattestation ~next:`Level (** Preendorsement for next round *) @@ -177,7 +177,7 @@ let test_preendorsement_for_next_round () = init_genesis () >>=? fun (genesis, _) -> Consensus_helpers.test_consensus_op_for_next ~genesis - ~kind:`Preendorsement + ~kind:`Preattestation ~next:`Round let tests = -- GitLab From 864b66011604a8eeb68610bdf5f630e379d0cee4 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 21 Jul 2023 16:34:21 +0200 Subject: [PATCH 4/5] alpha/test: rename endorsement in operation_generator --- .../test/helpers/operation_generator.ml | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml index 026987c443e9..0c7b2c87e2f1 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml @@ -49,14 +49,14 @@ let all_passes = [`PConsensus; `PAnonymous; `PVote; `PManager] let all_non_manager_passes = [`PConsensus; `PAnonymous; `PVote] -let consensus_kinds = [`KPreendorsement; `KEndorsement; `KDal_attestation] +let consensus_kinds = [`KPreattestation; `KAttestation; `KDal_attestation] let anonymous_kinds = [ `KSeed_nonce_revelation; `KVdf_revelation; - `KDouble_endorsement; - `KDouble_preendorsement; + `KDouble_attestation; + `KDouble_preattestation; `KDouble_baking; `KActivate_account; ] @@ -95,13 +95,13 @@ let pp_kind fmt k = fmt "%s" (match k with - | `KPreendorsement -> "KPreendorsement" - | `KEndorsement -> "KEndorsement" + | `KPreattestation -> "KPreattestation" + | `KAttestation -> "KAttestation" | `KDal_attestation -> "KDal_attestation" | `KSeed_nonce_revelation -> "KSeed_nonce_revelation" | `KVdf_revelation -> "KVdf_revelation" - | `KDouble_endorsement -> "KDouble_endorsement" - | `KDouble_preendorsement -> "KDouble_preendorsement" + | `KDouble_attestation -> "KDouble_attestation" + | `KDouble_preattestation -> "KDouble_preattestation" | `KDouble_baking -> "KDouble_baking" | `KActivate_account -> "KActivate_account" | `KProposals -> "KProposals" @@ -377,12 +377,12 @@ let generate_operation gen_op = let+ op = generate_op gen_op in Operation.pack op -let generate_preendorsement = +let generate_preattestation = let open QCheck2.Gen in let+ cc = generate_consensus_content in Preattestation cc -let generate_endorsement = +let generate_attestation = let open QCheck2.Gen in let+ cc = generate_consensus_content in Attestation cc @@ -405,16 +405,16 @@ let generate_seed_nonce_revelation = let+ nonce = random_nonce in Seed_nonce_revelation {level; nonce} -let generate_double_preendorsement = +let generate_double_preattestation = let open QCheck2.Gen in - let* op1 = generate_op generate_preendorsement in - let+ op2 = generate_op generate_preendorsement in + let* op1 = generate_op generate_preattestation in + let+ op2 = generate_op generate_preattestation in Double_preattestation_evidence {op1; op2} -let generate_double_endorsement = +let generate_double_attestation = let open QCheck2.Gen in - let* op1 = generate_op generate_endorsement in - let+ op2 = generate_op generate_endorsement in + let* op1 = generate_op generate_attestation in + let+ op2 = generate_op generate_attestation in Double_attestation_evidence {op1; op2} let generate_double_baking = @@ -631,13 +631,13 @@ let generate_non_manager_operation = let* pass = oneofl all_non_manager_passes in let* kind = oneofl (pass_to_operation_kinds pass) in match kind with - | `KPreendorsement -> generate_operation generate_preendorsement - | `KEndorsement -> generate_operation generate_endorsement + | `KPreattestation -> generate_operation generate_preattestation + | `KAttestation -> generate_operation generate_attestation | `KDal_attestation -> generate_operation generate_dal_attestation | `KSeed_nonce_revelation -> generate_operation generate_seed_nonce_revelation | `KVdf_revelation -> generate_operation generate_vdf_revelation - | `KDouble_endorsement -> generate_operation generate_double_endorsement - | `KDouble_preendorsement -> generate_operation generate_double_preendorsement + | `KDouble_attestation -> generate_operation generate_double_attestation + | `KDouble_preattestation -> generate_operation generate_double_preattestation | `KDouble_baking -> generate_operation generate_double_baking | `KActivate_account -> generate_operation generate_activate_account | `KProposals -> generate_operation generate_proposals @@ -705,15 +705,15 @@ let generate_operation = let* kind = oneofl (pass_to_operation_kinds pass) in let+ packed_operation = match kind with - | `KPreendorsement -> generate_operation generate_preendorsement - | `KEndorsement -> generate_operation generate_endorsement + | `KPreattestation -> generate_operation generate_preattestation + | `KAttestation -> generate_operation generate_attestation | `KDal_attestation -> generate_operation generate_dal_attestation | `KSeed_nonce_revelation -> generate_operation generate_seed_nonce_revelation | `KVdf_revelation -> generate_operation generate_vdf_revelation - | `KDouble_endorsement -> generate_operation generate_double_endorsement - | `KDouble_preendorsement -> - generate_operation generate_double_preendorsement + | `KDouble_attestation -> generate_operation generate_double_attestation + | `KDouble_preattestation -> + generate_operation generate_double_preattestation | `KDouble_baking -> generate_operation generate_double_baking | `KActivate_account -> generate_operation generate_activate_account | `KProposals -> generate_operation generate_proposals -- GitLab From 7faa3f93955116eb17e6f4f31134d7cebf8ed8d7 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 21 Jul 2023 16:36:23 +0200 Subject: [PATCH 5/5] alpha/test: rename endorsement in rewards --- .../lib_protocol/test/helpers/rewards.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/rewards.ml b/src/proto_alpha/lib_protocol/test/helpers/rewards.ml index bc9c833a8221..9499ddbba961 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/rewards.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/rewards.ml @@ -26,7 +26,7 @@ (** The tables are precomputed using this the following formulas: -let max_endos = 256 +let max_attestations = 256 let max_reward = 40 let r = 0.5 @@ -43,12 +43,12 @@ let baking_rewards = else a in - let r = r_aux /. (float_of_int max_endos) in + let r = r_aux /. (float_of_int max_attestations) in let r = 1_000_000. *. r in Float.to_int ((float_of_int e) *. (ceil r)) in let ps = 0 -- 2 in - let es = 0 -- max_endos in + let es = 0 -- max_attestations in List.map (fun p -> List.map (fun e -> @@ -57,18 +57,18 @@ let baking_rewards = ) ps |> Array.of_list -let endorsing_rewards = +let attesting_rewards = let reward p e = let r_aux = (1. -. r) *. (float_of_int max_reward) /. - (float_of_int max_endos) in + (float_of_int max_attestations) in let r = if p = 0 then r_aux else r_aux /. b in let r = 1_000_000. *. r in Float.to_int ((float_of_int e) *. (floor r)) in let ps = 0 -- 2 in - let es = 0 -- max_endos in + let es = 0 -- max_attestations in List.map (fun p -> List.map (fun e -> @@ -859,7 +859,7 @@ let baking_rewards : int array array = |]; |] -let endorsing_rewards : int array array = +let attesting_rewards : int array array = [| [| 0; -- GitLab