From 58a726beba9bf961ebc01a48630da8023755d463 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 21 Jul 2023 15:57:38 +0200 Subject: [PATCH] lib_delegate/test: rename endorsement --- src/proto_alpha/lib_delegate/test/README.md | 4 +- .../test/mockup_simulator/faked_services.ml | 14 +- .../test/mockup_simulator/mockup_simulator.ml | 6 +- .../mockup_simulator/mockup_simulator.mli | 8 +- .../lib_delegate/test/test_scenario.ml | 166 +++++++++--------- 5 files changed, 99 insertions(+), 99 deletions(-) diff --git a/src/proto_alpha/lib_delegate/test/README.md b/src/proto_alpha/lib_delegate/test/README.md index 6b745df188f9..7fd4de1c2ee5 100644 --- a/src/proto_alpha/lib_delegate/test/README.md +++ b/src/proto_alpha/lib_delegate/test/README.md @@ -92,8 +92,8 @@ them will have (see the docs for `Mockup_simulator.run`): run ~config [(3, (module Default_hooks)); (2, (module Default_hooks))] ``` -Note that delegate selection affects both (pre-)endorsing and voting power. -Delegates that do not have proposer slots will not be able to (pre-)endorse. +Note that delegate selection affects both (pre-)attesting and voting power. +Delegates that do not have proposer slots will not be able to (pre-)attest. Voting power of delegates who have proposer slots will be proportional to the number of slots they have. diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml index 533c0d99036e..a02cd44fe5db 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml @@ -7,14 +7,14 @@ module Block_services_alpha = Protocol_client_context.Alpha_block_services module type Mocked_services_hooks = sig type mempool = Mockup.M.Block_services.Mempool.t - (** The baker and endorser rely on this stream to be notified of new + (** The baker relies on this stream to be notified of new valid blocks. *) val monitor_validated_blocks : unit -> (Chain_id.t * Block_hash.t * Block_header.t * Operation.t list list) Tezos_rpc.Answer.stream - (** The baker and endorser rely on this stream to be notified of new + (** The baker relies on this stream to be notified of new heads. *) val monitor_heads : unit -> (Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream @@ -50,19 +50,19 @@ module type Mocked_services_hooks = sig Operation.t trace trace -> unit tzresult Lwt.t - (** [inject_operation] is used by the endorser (or the client) to inject - operations, including endorsements. *) + (** [inject_operation] is used by the baker (or the client) to inject + operations, including attestations. *) val inject_operation : Operation.t -> Operation_hash.t tzresult Lwt.t (** [pending_operations] returns the current contents of the mempool. It is used by the baker to fetch operations to potentially include in the - block being baked. These operations might include endorsements. If - there aren't enough endorsements, the baker waits on + block being baked. These operations might include attestations. If + there aren't enough attestations, the baker waits on [monitor_operations]. *) val pending_operations : unit -> mempool Lwt.t (** Return a stream of list of operations. Used by the baker to wait on - endorsements. Invariant: the stream becomes empty when the node changes + attestations. Invariant: the stream becomes empty when the node changes head. *) val monitor_operations : version:Block_services.version -> diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 4d3cbfc8892f..4d7b579a83fa 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -335,7 +335,7 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : blocks from "normal" blocks by comparing the [proto_level] of the shell header and its predecessor. If the predecessor's one is different, it must mean that we are considering an - activation block and must not endorse. Here, we do a bit of + activation block and must not attest. Here, we do a bit of hacking in order to return a different proto_level for the predecessor of the genesis block which is considered as the current protocol activation block. To perfectly mimic what is @@ -1368,7 +1368,7 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) signature unsigned_operation_bytes)) -let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_preattestation ?level ?round (op_hash : Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1396,7 +1396,7 @@ let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) | _ -> return false) | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) -let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_attestation ?level ?round (op_hash : Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli index d9da9a19074f..590e1cca1089 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli @@ -226,11 +226,11 @@ val mempool_has_op_ref : (** Check if an operation is signed by the given delegate. *) val op_is_signed_by : public_key:Signature.public_key -> op_predicate -(** Check that an operation is a preendorsement. *) -val op_is_preendorsement : ?level:int32 -> ?round:int32 -> op_predicate +(** Check that an operation is a preattestation. *) +val op_is_preattestation : ?level:int32 -> ?round:int32 -> op_predicate -(** Check that an operation is an endorsement. *) -val op_is_endorsement : ?level:int32 -> ?round:int32 -> op_predicate +(** Check that an operation is an attestation. *) +val op_is_attestation : ?level:int32 -> ?round:int32 -> op_predicate (** Combine two predicates. *) val op_is_both : op_predicate -> op_predicate -> op_predicate diff --git a/src/proto_alpha/lib_delegate/test/test_scenario.ml b/src/proto_alpha/lib_delegate/test/test_scenario.ml index bfd1ed1b7c4d..06bef308dfe7 100644 --- a/src/proto_alpha/lib_delegate/test/test_scenario.ml +++ b/src/proto_alpha/lib_delegate/test/test_scenario.ml @@ -62,7 +62,7 @@ let test_level_5 () = in run ~config [(3, (module Hooks)); (2, (module Hooks))] -let test_preendorse_on_valid () = +let test_preattest_on_valid () = let level_to_reach = 2l in let round_to_reach = 1l in let module Hooks : Hooks = struct @@ -180,19 +180,19 @@ let test_reset_delayed_pqc () = Scenario T1 1. Node A proposes at the round 0. -2. Both node A and node B preendorse. +2. Both node A and node B preattest. 3. Node A stops. -4. Node B endorses in the round 0 and locks. No decision is taken at the - round 0 because A did not endorse. +4. Node B attests in the round 0 and locks. No decision is taken at the + round 0 because A did not attest. 5. We check that in round 1 (the next slot for B), B proposes the same value as A proposed in the round 0, not a new proposal. *) let test_scenario_t1 () = let original_proposal = ref None in - let a_preendorsed = ref false in - let b_preendorsed = ref false in - let b_endorsed = ref false in + let a_preattested = ref false in + let b_preattested = ref false in + let b_attested = ref false in let b_reproposed = ref false in (* Here we use custom hooks to make each node/baker behave according to its role in the scenario. *) @@ -205,17 +205,17 @@ let test_scenario_t1 () = ~predicate: (op_is_both (op_is_signed_by ~public_key:Mockup_simulator.bootstrap1) - (op_is_preendorsement ~level:1l ~round:0l)) - ~var:a_preendorsed + (op_is_preattestation ~level:1l ~round:0l)) + ~var:a_preattested - let stop_on_event _ = !a_preendorsed + let stop_on_event _ = !a_preattested end in let module Node_b_hooks : Hooks = struct include Default_hooks let check_block_before_processing ~level ~round ~block_hash ~block_header ~(protocol_data : Protocol.Alpha_context.Block_header.protocol_data) = - (match (!b_endorsed, level, round) with + (match (!b_attested, level, round) with | false, 1l, 0l -> (* If any of the checks fails the whole scenario will fail. *) check_block_signature @@ -246,16 +246,16 @@ let test_scenario_t1 () = ~predicate: (op_is_both (op_is_signed_by ~public_key:Mockup_simulator.bootstrap2) - (op_is_preendorsement ~level:1l ~round:0l)) - ~var:b_preendorsed + (op_is_preattestation ~level:1l ~round:0l)) + ~var:b_preattested >>=? fun () -> mempool_has_op_ref ~mempool ~predicate: (op_is_both (op_is_signed_by ~public_key:Mockup_simulator.bootstrap2) - (op_is_preendorsement ~level:1l ~round:0l)) - ~var:b_endorsed + (op_is_preattestation ~level:1l ~round:0l)) + ~var:b_attested let stop_on_event _ = !b_reproposed end in @@ -322,8 +322,8 @@ Scenario T3 1. There are four nodes: A, B, C, and D. 2. C is the proposer at the round 0. It sends the proposal, which is received by all bakers except for D. -3. Due to how the messages propagate, only B sees 3 preendorsements. It - endorses and locks. Other nodes all see fewer than 3 preendorsements. +3. Due to how the messages propagate, only B sees 3 preattestations. It + attests and locks. Other nodes all see fewer than 3 preattestations. A -> A and B B -> B @@ -333,7 +333,7 @@ Scenario T3 D -> D, B, C -5. B does not preendorse because it is locked. +5. B does not preattest because it is locked. 6. No decision is taken at the round 1. 7. B proposes at the round 2. There are no more problems with propagation of messages, so a decision is reached. @@ -351,9 +351,9 @@ let test_scenario_t3 () = let on_inject_operation ~op_hash ~op = if !b_observed_pqc then return (op_hash, op, [Pass; Pass; Pass; Pass]) else - op_is_preendorsement ~level:1l ~round:0l op_hash op - >>=? fun is_preendorsement -> - if is_preendorsement then + op_is_preattestation ~level:1l ~round:0l op_hash op + >>=? fun is_preattestation -> + if is_preattestation then return (op_hash, op, [Pass; Pass; Block; Block]) else failwith "unexpected operation from the node D" @@ -387,19 +387,19 @@ let test_scenario_t3 () = let on_inject_operation ~op_hash ~op = if !b_observed_pqc then return (op_hash, op, [Pass; Pass; Pass; Pass]) else - op_is_preendorsement ~level:1l ~round:0l op_hash op - >>=? fun is_preendorsement -> - if is_preendorsement then + op_is_preattestation ~level:1l ~round:0l op_hash op + >>=? fun is_preattestation -> + if is_preattestation then return (op_hash, op, [Block; Pass; Block; Block]) else failwith "unexpected operation from the node B" let check_mempool_after_processing ~mempool = let predicate op_hash op = - op_is_preendorsement ~level:1l ~round:0l op_hash op + op_is_preattestation ~level:1l ~round:0l op_hash op in mempool_count_ops ~mempool ~predicate >>=? fun n -> if n > 3 then - failwith "B received too many preendorsements, expected to see only 3" + failwith "B received too many preattestations, expected to see only 3" else if n = 3 then ( b_observed_pqc := true ; return_unit) @@ -432,9 +432,9 @@ let test_scenario_t3 () = let on_inject_operation ~op_hash ~op = if !b_observed_pqc then return (op_hash, op, [Pass; Pass; Pass; Pass]) else - op_is_preendorsement ~level:1l ~round:0l op_hash op - >>=? fun is_preendorsement -> - if is_preendorsement then + op_is_preattestation ~level:1l ~round:0l op_hash op + >>=? fun is_preattestation -> + if is_preattestation then return (op_hash, op, [Block; Pass; Pass; Block]) else failwith "unexpected operation from the node C" @@ -500,7 +500,7 @@ Scenario F1 1. Node C (bootstrap3) proposes at level 1 round 0, its proposal reaches all nodes. -2. Propagation of preendorsements happens in such a way that only Node A +2. Propagation of preattestations happens in such a way that only Node A (bootstrap1) observes PQC: A -> A @@ -858,7 +858,7 @@ Scenario M3 bootstrap2 in delegate selection they have equal voting power. Therefore it is necessary to have 2 votes for prequorums (which is achieved when A is proposing) and 2 votes for quorums (impossible because B has no way to - obtain PQC and thus cannot send endorsements). + obtain PQC and thus cannot send attestations). *) @@ -927,11 +927,11 @@ Scenario M4 2. A proposes at level 1 round 0. Its proposal reaches A, B, C, and D, but with a delay of 0.5 seconds. 3. 3 votes are enough for consensus, because voting powers of all delegates - are equal. Preendorsements propagate freely, however endorsements from C + are equal. Preattestations propagate freely, however attestations from C are blocked. 4. Check that at level 1 round 0 quorum is reached (from the point of view - of A). This means that D sends an endorsement despite receiving - preendorsements before the proposal. + of A). This means that D sends an attestation despite receiving + preattestations before the proposal. *) @@ -960,11 +960,11 @@ let test_scenario_m4 () = let check_mempool_after_processing ~mempool = let predicate op_hash op = - op_is_endorsement ~level:1l ~round:0l op_hash op + op_is_attestation ~level:1l ~round:0l op_hash op in mempool_count_ops ~mempool ~predicate >>=? fun n -> if n > 3 then - failwith "A received too many endorsements, expected to see only 3" + failwith "A received too many attestations, expected to see only 3" else if n = 3 then ( a_observed_qc := true ; return_unit) @@ -981,12 +981,12 @@ let test_scenario_m4 () = include Default_hooks let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_attestation -> return ( op_hash, op, - if is_endorsement then [Block; Block; Block; Block] + if is_attestation then [Block; Block; Block; Block] else [Pass; Pass; Pass; Pass] ) let stop_on_event = stop_on_event0 @@ -1029,7 +1029,7 @@ Scenario M5 1. There are four bakers: A, B, C, and D. 2. A proposes at level 1 round 0. Its proposal reaches A, B, C, and D, but with a delay of 1 second. There are no problems with propagation of - preendorsements and endorsements. + preattestations and attestations. 3. At the level 1 all four bakers have proposer slots, however we block possible proposals from B and C at higher rounds. 4. Check that D proposes at the level 2 round 0, which means that it has @@ -1142,12 +1142,12 @@ let test_scenario_m6 () = return (block_hash, block_header, operations, propagation_vector) let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> return ( op_hash, op, - if is_a10_endorsement then [Pass; Block; Block; Block] + if is_a10_attestation then [Pass; Block; Block; Block] else [Pass; Pass; Pass; Pass] ) let stop_on_event = stop_on_event0 @@ -1176,12 +1176,12 @@ let test_scenario_m6 () = return (block_hash, block_header, operations, propagation_vector) let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> return ( op_hash, op, - if is_a10_endorsement then [Pass; Block; Block; Block] + if is_a10_attestation then [Pass; Block; Block; Block] else [Pass; Pass; Pass; Pass] ) let stop_on_event = stop_on_event0 @@ -1194,12 +1194,12 @@ let test_scenario_m6 () = return (block_hash, block_header, operations, [Pass; Pass; Pass; Pass]) let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> return ( op_hash, op, - if is_a10_endorsement then [Pass; Block; Block; Block] + if is_a10_attestation then [Pass; Block; Block; Block] else [Pass; Pass; Pass; Pass] ) let stop_on_event = stop_on_event0 @@ -1283,12 +1283,12 @@ let test_scenario_m7 () = return (block_hash, block_header, operations, [Pass; Pass; Pass; Pass]) let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> return ( op_hash, op, - if is_a10_endorsement then [Pass; Block; Block; Block] + if is_a10_attestation then [Pass; Block; Block; Block] else [Pass; Pass; Pass; Pass] ) let stop_on_event = stop_on_event0 @@ -1308,14 +1308,14 @@ let test_scenario_m7 () = return (block_hash, block_header, operations, propagation_vector) let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> - op_is_preendorsement ~level:2l op_hash op - >>=? fun level2_preendorsement -> - op_is_endorsement ~level:2l op_hash op >>=? fun level2_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> + op_is_preattestation ~level:2l op_hash op + >>=? fun level2_preattestation -> + op_is_attestation ~level:2l op_hash op >>=? fun level2_attestation -> let propagation_vector = match - (is_a10_endorsement, level2_preendorsement, level2_endorsement) + (is_a10_attestation, level2_preattestation, level2_attestation) with | true, _, _ -> [Pass; Block; Block; Block] | _, true, _ | _, _, true -> [Block; Block; Block; Block] @@ -1346,17 +1346,17 @@ let test_scenario_m7 () = | _ -> return_unit let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> - op_is_preendorsement ~level:2l op_hash op - >>=? fun level2_preendorsement -> - op_is_endorsement ~level:2l op_hash op >>=? fun level2_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> + op_is_preattestation ~level:2l op_hash op + >>=? fun level2_preattestation -> + op_is_attestation ~level:2l op_hash op >>=? fun level2_attestation -> let propagation_vector = match - ( is_a10_endorsement, + ( is_a10_attestation, !c_received_2_1, - level2_preendorsement, - level2_endorsement ) + level2_preattestation, + level2_attestation ) with | true, _, _, _ -> [Pass; Block; Block; Block] | _, false, true, _ | _, false, _, true -> [Block; Block; Block; Block] @@ -1387,17 +1387,17 @@ let test_scenario_m7 () = | _ -> return_unit let on_inject_operation ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> - op_is_preendorsement ~level:2l op_hash op - >>=? fun level2_preendorsement -> - op_is_endorsement ~level:2l op_hash op >>=? fun level2_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> + op_is_preattestation ~level:2l op_hash op + >>=? fun level2_preattestation -> + op_is_attestation ~level:2l op_hash op >>=? fun level2_attestation -> let propagation_vector = match - ( is_a10_endorsement, + ( is_a10_attestation, !d_received_2_1, - level2_preendorsement, - level2_endorsement ) + level2_preattestation, + level2_attestation ) with | true, _, _, _ -> [Pass; Block; Block; Block] | _, false, true, _ | _, false, _, true -> [Block; Block; Block; Block] @@ -1464,15 +1464,15 @@ let test_scenario_m8 () = | _ -> false in let on_inject_operation0 ~op_hash ~op = - op_is_endorsement ~level:1l ~round:0l op_hash op - >>=? fun is_a10_endorsement -> - op_is_endorsement ~level:2l ~round:0l op_hash op - >>=? fun is_b20_endorsement -> - op_is_endorsement ~level:2l ~round:1l op_hash op - >>=? fun is_c21_endorsement -> + op_is_attestation ~level:1l ~round:0l op_hash op + >>=? fun is_a10_attestation -> + op_is_attestation ~level:2l ~round:0l op_hash op + >>=? fun is_b20_attestation -> + op_is_attestation ~level:2l ~round:1l op_hash op + >>=? fun is_c21_attestation -> let propagation_vector = - if is_a10_endorsement then [Pass; Block; Block; Block] - else if is_b20_endorsement || is_c21_endorsement then + if is_a10_attestation then [Pass; Block; Block; Block] + else if is_b20_attestation || is_c21_attestation then [Block; Block; Block; Block] else [Pass; Pass; Pass; Pass] in @@ -1597,7 +1597,7 @@ let () = [ (Protocol.name ^ ": reaches level 5", test_level_5); ( Protocol.name ^ ": cannot progress without new head", - test_preendorse_on_valid ); + test_preattest_on_valid ); (Protocol.name ^ ": reset delayed pqc", test_reset_delayed_pqc); (Protocol.name ^ ": scenario t1", test_scenario_t1); (Protocol.name ^ ": scenario t2", test_scenario_t2); -- GitLab