diff --git a/manifest/main.ml b/manifest/main.ml index d84bf063da508e08401fef1e30a46c9a38f2afd5..3b0357a1cbe65baf6d020332fd62860a8dd6943a 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4824,14 +4824,19 @@ end = struct "test_deactivation"; "test_delegation"; "test_double_baking"; - "test_double_endorsement"; - "test_double_preendorsement"; - "test_endorsement"; + (if N.(number >= 018) then "test_double_attestation" + else "test_double_endorsement"); + (if N.(number >= 018) then "test_double_preattestation" + else "test_double_preendorsement"); + (if N.(number >= 018) then "test_attestation" + else "test_endorsement"); "test_frozen_deposits"; "test_helpers_rpcs"; "test_participation"; - "test_preendorsement_functor"; - "test_preendorsement"; + (if N.(number >= 018) then "test_preattestation_functor" + else "test_preendorsement_functor"); + (if N.(number >= 018) then "test_preattestation" + else "test_preendorsement"); "test_seed"; ] ~path:(path // "lib_protocol/test/integration/consensus") diff --git a/src/proto_alpha/lib_protocol/test/README.md b/src/proto_alpha/lib_protocol/test/README.md index b0ec6d5b04644236e347a1aec12fb83aa5aaccaa..d938f4e7cb3d358c45acdfb6635c3528fefd7403 100644 --- a/src/proto_alpha/lib_protocol/test/README.md +++ b/src/proto_alpha/lib_protocol/test/README.md @@ -8,7 +8,7 @@ subdivision by theme: - `unit`: tests that sit below `Alpha_context`. - `integration`: tests that require passing around a context. - `michelson`: tests that involve Micheline expressions. - - `consensus`: tests for consensus: baking, endorsement, etc. + - `consensus`: tests for consensus: baking, attestation, etc. - `gas`: tests for gas. - `operations`: test for operations. - `pbt`: for property-based tests using `qcheck`. diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/dune b/src/proto_alpha/lib_protocol/test/integration/consensus/dune index 25d49561579fe52c4990c083118697e5b0790490..029ff07a2333a11fbd5868d50eb2e20338bd9aee 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/dune +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/dune @@ -32,14 +32,14 @@ test_deactivation test_delegation test_double_baking - test_double_endorsement - test_double_preendorsement - test_endorsement + test_double_attestation + test_double_preattestation + test_attestation test_frozen_deposits test_helpers_rpcs test_participation - test_preendorsement_functor - test_preendorsement + test_preattestation_functor + test_preattestation test_seed)) (executable diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_attestation.ml similarity index 81% rename from src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml rename to src/proto_alpha/lib_protocol/test/integration/consensus/test_attestation.ml index 00ee4bb3f3e7e98f9d3536f9955ca1f922ddcb75..208701a8e193c542c3be38947e7a5787de50c913 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_attestation.ml @@ -25,11 +25,11 @@ (** Testing ------- - Component: Protocol (endorsement) + Component: Protocol (attestation) Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ - -- --file test_endorsement.ml - Subject: Endorsing a block adds an extra layer of confidence - to the Tezos' PoS algorithm. The block endorsing + -- --file test_attestation.ml + Subject: Attesting a block adds an extra layer of confidence + to the Tezos' PoS algorithm. The block attesting operation must be included in the following block. *) @@ -42,8 +42,8 @@ let init_genesis ?policy () = (** {1 Positive tests} *) -(** Correct endorsement from the slot 0 endorser. *) -let test_simple_endorsement () = +(** Correct attestation from the slot 0 attester. *) +let test_simple_attestation () = let open Lwt_result_syntax in let* _genesis, attested_block = init_genesis () in Consensus_helpers.test_consensus_operation_all_modes @@ -51,7 +51,7 @@ let test_simple_endorsement () = ~attested_block Attestation -(** Test that the endorsement's branch does not affect its +(** Test that the attestation's branch does not affect its validity. *) let test_arbitrary_branch () = let open Lwt_result_syntax in @@ -62,8 +62,8 @@ let test_arbitrary_branch () = ~branch:Block_hash.zero Attestation -(** Correct endorsement with a level and a round that are both - different from {!test_simple_endorsement}. *) +(** Correct attestation with a level and a round that are both + different from {!test_simple_attestation}. *) let test_non_zero_round () = let open Lwt_result_syntax in let* _genesis, b = init_genesis () in @@ -100,16 +100,16 @@ 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_attesters (B block) in + let* attesters = Context.get_attesters (B block) in let delegate, slots = - (* Find an endorser with more than 1 slot. *) + (* Find an attester with more than 1 slot. *) WithExceptions.Option.get ~loc:__LOC__ (List.find_map (fun {RPC.Validators.delegate; slots; _} -> if Compare.List_length_with.(slots > 1) then Some (delegate, slots) else None) - endorsers) + attesters) in (* Check that the slots are sorted and have no duplicates. *) let rec check_sorted = function @@ -122,10 +122,10 @@ let delegate_and_second_slot block = in return (delegate, slot) -(** Test that the mempool accepts endorsements with a non-normalized +(** Test that the mempool accepts attestations with a non-normalized slot (that is, a slot that belongs to the delegate but is not the delegate's smallest slot) at all three allowed levels for - endorsements (and various rounds). *) + attestations (and various rounds). *) let test_mempool_second_slot () = let open Lwt_result_syntax in let* _genesis, grandparent = init_genesis () in @@ -152,7 +152,7 @@ let test_mempool_second_slot () = (** {2 Wrong slot} *) -(** Apply an endorsement with a negative slot. *) +(** Apply an attestation with a negative slot. *) let test_negative_slot () = Context.init_n 5 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun b -> @@ -168,7 +168,7 @@ let test_negative_slot () = (function | Data_encoding.Binary.Write_error _ -> return_unit | e -> Lwt.fail e) -(** Endorsement with a non-normalized slot (that is, a slot that +(** Attestation with a non-normalized slot (that is, a slot that belongs to the delegate but is not the delegate's smallest slot). It should fail in application and construction modes, but be accepted in mempool mode. *) @@ -195,16 +195,16 @@ let test_not_smallest_slot () = let delegate_and_someone_elses_slot block = let open Lwt_result_syntax in - let* endorsers = Context.get_attesters (B block) in + let* attesters = Context.get_attesters (B block) in let delegate, other_delegate_slot = - match endorsers with + match attesters with | [] | [_] -> assert false (* at least two delegates with rights *) | {delegate; _} :: {slots; _} :: _ -> (delegate, WithExceptions.Option.get ~loc:__LOC__ (List.hd slots)) in return (delegate, other_delegate_slot) -(** Endorsement with a slot that does not belong to the delegate. *) +(** Attestation with a slot that does not belong to the delegate. *) let test_not_own_slot () = let open Lwt_result_syntax in let* _genesis, b = init_genesis () in @@ -218,7 +218,7 @@ let test_not_own_slot () = | Alpha_context.Operation.Invalid_signature -> true | _ -> false) Attestation -(** In mempool mode, also test endorsements with a slot that does not +(** In mempool mode, also test attestations with a slot that does not belong to the delegate for various allowed levels and rounds. *) let test_mempool_not_own_slot () = let open Lwt_result_syntax in @@ -249,12 +249,12 @@ let error_old_level = function true | _ -> false -(** Endorsement that is one level too old, aka grandparent endorsement - (the endorsement is expected to point to the level of the - predecessor of the block/mempool containing the endorsement, but +(** Attestation that is one level too old, aka grandparent attestation + (the attestation is expected to point to the level of the + predecessor of the block/mempool containing the attestation, but instead it points to the grandparent's level). - This endorsement should fail in a block (application or + This attestation should fail in a block (application or construction), but be accepted in mempool mode. *) let test_one_level_too_old () = let open Lwt_result_syntax in @@ -269,7 +269,7 @@ let test_one_level_too_old () = ?mempool_error:None Attestation -(** Endorsement that is two levels too old (pointing to the +(** Attestation that is two levels too old (pointing to the great-grandparent instead of the predecessor). It should fail in all modes. *) let test_two_levels_too_old () = @@ -290,8 +290,8 @@ let error_future_level = function true | _ -> false -(** Endorsement that is one level in the future (pointing to the same - level as the block/mempool containing the endorsement instead of +(** Attestation that is one level in the future (pointing to the same + level as the block/mempool containing the attestation instead of its predecessor/head). It should fail in a block (application or construction) but succeed in a mempool. *) let test_one_level_in_the_future () = @@ -307,7 +307,7 @@ let test_one_level_in_the_future () = ?mempool_error:None Attestation -(** Endorsement that is two levels in the future. It should fail in +(** Attestation that is two levels in the future. It should fail in all modes. *) let test_two_levels_future () = let open Lwt_result_syntax in @@ -329,7 +329,7 @@ let error_old_round = function true | _ -> false -(** Endorsement that is one round too old. It should fail in a block +(** Attestation that is one round too old. It should fail in a block (application or construction) but succeed in a mempool. *) let test_one_round_too_old () = let open Lwt_result_syntax in @@ -345,7 +345,7 @@ let test_one_round_too_old () = ?mempool_error:None Attestation -(** Endorsement that is many rounds too old. It should fail in a block +(** Attestation that is many rounds too old. It should fail in a block (application or construction) but succeed in a mempool. *) let test_many_rounds_too_old () = let open Lwt_result_syntax in @@ -367,7 +367,7 @@ let error_future_round = function true | _ -> false -(** Endorsement that is one round in the future. It should fail in a +(** Attestation that is one round in the future. It should fail in a block (application or construction) but succeed in a mempool. *) let test_one_round_in_the_future () = let open Lwt_result_syntax in @@ -383,7 +383,7 @@ let test_one_round_in_the_future () = ?mempool_error:None Attestation -(** Endorsement that is many rounds in the future. It should fail in a +(** Attestation that is many rounds in the future. It should fail in a block (application or construction) but succeed in a mempool. *) let test_many_rounds_future () = let open Lwt_result_syntax in @@ -401,7 +401,7 @@ let test_many_rounds_future () = (** {2 Wrong payload hash} *) -(** Endorsement with an incorrect payload hash. It should fail in a +(** Attestation with an incorrect payload hash. It should fail in a block (application or construction) but succeed in a mempool. *) let test_wrong_payload_hash () = let open Lwt_result_syntax in @@ -433,13 +433,13 @@ let assert_conflict_error ~loc res = true | _ -> false) -(** Test that endorsements conflict with: - - an identical endorsement, and - - an endorsement on the same block with a different branch. +(** Test that attestations conflict with: + - an identical attestation, and + - an attestation on the same block with a different branch. - In mempool mode, also test that they conflict with an endorsement + In mempool mode, also test that they conflict with an attestation on the same level and round but with a different payload hash - (such an endorsement is invalid in application and construction modes). *) + (such an attestation is invalid in application and construction modes). *) let test_conflict () = let open Lwt_result_syntax in let* _genesis, b = init_genesis () in @@ -468,13 +468,13 @@ let test_conflict () = let* () = assert_mempool_conflict __LOC__ op_different_payload_hash in return_unit -(** In mempool mode, test that grandparent endorsements conflict with: - - an identical endorsement, - - an endorsement on the same block with a different branch, and - - an endorsement on the same block with a different payload hash. +(** In mempool mode, test that grandparent attestations conflict with: + - an identical attestation, + - an attestation on the same block with a different branch, and + - an attestation on the same block with a different payload hash. This test would make no sense in application or construction modes, - since grandparent endorsements fail anyway (as can be observed in + since grandparent attestations fail anyway (as can be observed in {!test_one_level_too_old}). *) let test_grandparent_conflict () = let open Lwt_result_syntax in @@ -497,9 +497,9 @@ let test_grandparent_conflict () = let* () = assert_conflict __LOC__ op_different_payload_hash in return_unit -(** In mempool mode, test that endorsements with the same future level +(** In mempool mode, test that attestations with the same future level and same non-zero round conflict. This is not tested in application - and construction modes since such endorsements would be invalid. *) + and construction modes since such attestations would be invalid. *) let test_future_level_conflict () = let open Lwt_result_syntax in let* _genesis, predecessor = init_genesis () in @@ -522,37 +522,37 @@ let test_future_level_conflict () = return_unit (** In mempool mode, test that there is no conflict between an - endorsement and a preendorsement for the same slot (here the first + attestation and a preattestation for the same slot (here the first slot), same level, and same round. *) -let test_no_conflict_with_preendorsement_mempool () = +let test_no_conflict_with_preattestation_mempool () = let open Lwt_result_syntax in - let* _genesis, endorsed_block = init_genesis () 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 + let* _genesis, attested_block = init_genesis () in + let* op_attestation = Op.attestation attested_block in + let* op_preattestation = Op.preattestation attested_block in + let* inc = Incremental.begin_construction ~mempool_mode:true attested_block in + let* inc = Incremental.add_operation inc op_attestation in + let* inc = Incremental.add_operation inc op_preattestation in let* _inc = Incremental.finalize_block inc in return_unit (** In application and construction (aka baking) modes, test that - there is no conflict between an endorsement and a preendorsement + there is no conflict between an attestation and a preattestation for the same slot (here the first slot). Note that the operations don't have the same level because the required levels for them to be valid are different. *) -let test_no_conflict_with_preendorsement_block () = +let test_no_conflict_with_preattestation_block () = let open Lwt_result_syntax in let* _genesis, predecessor = init_genesis () in let* round0_block = Block.bake predecessor in - let* op_endo = Op.attestation predecessor in - let* op_preendo = Op.preattestation round0_block in + let* op_attestation = Op.attestation predecessor in + let* op_preattestation = Op.preattestation round0_block in let bake_both_ops baking_mode = Block.bake ~baking_mode ~payload_round:(Some Round.zero) ~locked_round:(Some Round.zero) ~policy:(By_round 1) - ~operations:[op_endo; op_preendo] + ~operations:[op_attestation; op_preattestation] predecessor in let* (_ : Block.t) = bake_both_ops Application in @@ -560,11 +560,11 @@ let test_no_conflict_with_preendorsement_block () = return_unit (** In mempool mode, test that there is no conflict between - endorsements for the same slot (here the first slot) with various + attestations for the same slot (here the first slot) with various allowed levels and rounds. There are no similar tests in application and construction modes - because valid endorsements always have the same level and round. *) + because valid attestations always have the same level and round. *) let test_no_conflict_various_levels_and_rounds () = let open Lwt_result_syntax in let* genesis, grandparent = init_genesis () in @@ -574,8 +574,8 @@ let test_no_conflict_various_levels_and_rounds () = let* alt_predecessor = Block.bake ~policy:(By_round 1) grandparent in 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.attestation endorsed_block in + let add_attestation inc attested_block = + let* (op : packed_operation) = Op.attestation attested_block in let (Operation_data protocol_data) = op.protocol_data in let content = match protocol_data.contents with @@ -588,12 +588,12 @@ let test_no_conflict_various_levels_and_rounds () = (Round.to_int32 content.round) ; Incremental.add_operation inc op in - let* inc = add_endorsement inc grandparent in - let* inc = add_endorsement inc predecessor in - let* inc = add_endorsement inc future_block in - let* inc = add_endorsement inc alt_grandparent in - let* inc = add_endorsement inc alt_predecessor in - let* inc = add_endorsement inc alt_future in + let* inc = add_attestation inc grandparent in + let* inc = add_attestation inc predecessor in + let* inc = add_attestation inc future_block in + let* inc = add_attestation inc alt_grandparent in + let* inc = add_attestation inc alt_predecessor in + let* inc = add_attestation inc alt_future in let* _inc = Incremental.finalize_block inc in return_unit @@ -602,34 +602,34 @@ let test_no_conflict_various_levels_and_rounds () = Both positive and negative tests. *) (** Check that: - - a block with not enough endorsement cannot be baked; - - a block with enough endorsement is baked. *) -let test_endorsement_threshold ~sufficient_threshold () = + - a block with not enough attestation cannot be baked; + - a block with enough attestation is baked. *) +let test_attestation_threshold ~sufficient_threshold () = (* We choose a relative large number of accounts so that the probability that any delegate has [consensus_threshold] slots is low and most delegates have about 1 slot so we can get closer to the limit of [consensus_threshold]: we - check that a block with endorsing power [consensus_threshold - 1] won't be + check that a block with attesting power [consensus_threshold - 1] won't be baked. *) Context.init_n 10 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun b -> Context.get_constants (B b) >>=? fun {parametric = {consensus_threshold; _}; _} -> - Context.get_attesters (B b) >>=? fun endorsers_list -> + Context.get_attesters (B b) >>=? fun attesters_list -> Block.get_round b >>?= fun round -> List.fold_left_es - (fun (counter, endos) {Plugin.RPC.Validators.delegate; slots; _} -> + (fun (counter, attestations) {Plugin.RPC.Validators.delegate; slots; _} -> let new_counter = counter + List.length slots in if (sufficient_threshold && counter < consensus_threshold) || ((not sufficient_threshold) && new_counter < consensus_threshold) then - Op.attestation ~round ~delegate b >>=? fun endo -> - return (new_counter, endo :: endos) - else return (counter, endos)) + Op.attestation ~round ~delegate b >>=? fun attestation -> + return (new_counter, attestation :: attestations) + else return (counter, attestations)) (0, []) - endorsers_list - >>=? fun (_, endos) -> - Block.bake ~operations:endos b >>= fun b -> + attesters_list + >>=? fun (_, attestations) -> + Block.bake ~operations:attestations b >>= fun b -> if sufficient_threshold then return_unit else Assert.proto_error ~loc:__LOC__ b (function @@ -639,14 +639,14 @@ let test_endorsement_threshold ~sufficient_threshold () = let tests = [ (* Positive tests *) - Tztest.tztest "Simple endorsement" `Quick test_simple_endorsement; + Tztest.tztest "Simple attestation" `Quick test_simple_attestation; Tztest.tztest "Arbitrary branch" `Quick test_arbitrary_branch; Tztest.tztest "Non-zero round" `Quick test_non_zero_round; Tztest.tztest "Fitness gap" `Quick test_fitness_gap; Tztest.tztest "Mempool: non-smallest slot" `Quick test_mempool_second_slot; (* Negative tests *) (* Wrong slot *) - Tztest.tztest "Endorsement with slot -1" `Quick test_negative_slot; + Tztest.tztest "Attestation with slot -1" `Quick test_negative_slot; Tztest.tztest "Non-normalized slot" `Quick test_not_smallest_slot; Tztest.tztest "Not own slot" `Quick test_not_own_slot; Tztest.tztest "Mempool: not own slot" `Quick test_mempool_not_own_slot; @@ -667,28 +667,28 @@ let tests = Tztest.tztest "Grandparent conflict" `Quick test_grandparent_conflict; Tztest.tztest "Future level conflict" `Quick test_future_level_conflict; Tztest.tztest - "No conflict with preendorsement (mempool)" + "No conflict with preattestation (mempool)" `Quick - test_no_conflict_with_preendorsement_mempool; + test_no_conflict_with_preattestation_mempool; Tztest.tztest - "No conflict with preendorsement (block)" + "No conflict with preattestation (block)" `Quick - test_no_conflict_with_preendorsement_block; + test_no_conflict_with_preattestation_block; Tztest.tztest "No conflict with various levels and rounds" `Quick test_no_conflict_various_levels_and_rounds; (* Consensus threshold tests (one positive and one negative) *) Tztest.tztest - "sufficient endorsement threshold" + "sufficient attestation threshold" `Quick - (test_endorsement_threshold ~sufficient_threshold:true); + (test_attestation_threshold ~sufficient_threshold:true); Tztest.tztest - "insufficient endorsement threshold" + "insufficient attestation threshold" `Quick - (test_endorsement_threshold ~sufficient_threshold:false); + (test_attestation_threshold ~sufficient_threshold:false); ] let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("endorsement", tests)] + Alcotest_lwt.run ~__FILE__ Protocol.name [("attestation", tests)] |> Lwt_main.run 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 e50ef2d2c49b57ca14a7f0b0749d2b607485c962..0de0cdda0c8d1e170445e8795fa3a39c553e34b8 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 @@ -175,13 +175,13 @@ let get_contract_for_pkh contracts pkh = find_contract contracts (** Test that - - the block producer gets the bonus for including the endorsements; + - the block producer gets the bonus for including the attestations; - the payload producer gets the baking reward. The test checks this in two scenarios, in the first one the payload producer and the block producer are the same delegate, in the second one they are different. The first scenario is checked by first baking block [b1] and then - block [b2] at round 0 containing a number of endorsements for [b1] and the + block [b2] at round 0 containing a number of attestations for [b1] and the checking the balance of [b2]'s baker. For the second scenario another block [b2'] is build on top of [b1] by a different baker, using the same payload as [b2]. *) @@ -190,31 +190,32 @@ 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_attesters (B b1) >>=? fun endorsers -> + Context.get_attesters (B b1) >>=? fun attesters -> List.map_es (function | {Plugin.RPC.Validators.delegate; slots; _} -> return (delegate, slots)) - endorsers - >>=? fun endorsers -> - (* We let just a part of the endorsers vote; we assume here that 5 of 10 - endorsers will have together at least one slot (to pass the threshold), but + attesters + >>=? fun attesters -> + (* We let just a part of the attesters vote; we assume here that 5 of 10 + attesters will have together at least one slot (to pass the threshold), but not all slots (to make the test more interesting, otherwise we know the - total endorsing power). *) - let endorsers = List.take_n 5 endorsers in + total attesting power). *) + let attesters = List.take_n 5 attesters in List.map_ep - (fun (endorser, _slots) -> Op.attestation ~delegate:endorser b1) - endorsers - >>=? fun endos -> + (fun (attester, _slots) -> Op.attestation ~delegate:attester b1) + attesters + >>=? fun attestations -> let attesting_power = List.fold_left (fun acc (_pkh, slots) -> acc + List.length slots) 0 - endorsers + attesters in let fee = Tez.one in Op.transaction (B b1) ~fee baker_b1_contract baker_b1_contract Tez.one >>=? fun tx -> - Block.bake ~policy:(By_round 0) ~operations:(endos @ [tx]) b1 >>=? fun b2 -> + Block.bake ~policy:(By_round 0) ~operations:(attestations @ [tx]) b1 + >>=? fun b2 -> Context.get_baker (B b1) ~round:Round.zero >>=? fun baker_b2 -> get_contract_for_pkh contracts baker_b2 >>=? fun baker_b2_contract -> Context.Contract.balance (B b2) baker_b2_contract >>=? fun bal -> @@ -239,16 +240,16 @@ 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_attesters (B b2) >>=? fun endorsers -> + Context.get_attesters (B b2) >>=? fun attesters -> List.map_es (function | {Plugin.RPC.Validators.delegate; slots; _} -> return (delegate, slots)) - endorsers - >>=? fun preendorsers -> + attesters + >>=? fun preattesters -> List.map_ep - (fun (endorser, _slots) -> Op.preattestation ~delegate:endorser b2) - preendorsers - >>=? fun preendos -> + (fun (attester, _slots) -> Op.preattestation ~delegate:attester b2) + preattesters + >>=? fun preattestations -> Context.get_baker (B b1) ~round:Round.zero >>=? fun baker_b2 -> Context.get_bakers (B b1) >>=? fun bakers -> let baker_b2' = Context.get_first_different_baker baker_b2 bakers in @@ -256,7 +257,7 @@ let test_rewards_block_and_payload_producer () = ~payload_round:(Some Round.zero) ~locked_round:(Some Round.zero) ~policy:(By_account baker_b2') - ~operations:(preendos @ endos @ [tx]) + ~operations:(preattestations @ attestations @ [tx]) b1 >>=? fun b2' -> (* [baker_b2], as payload producer, gets the block reward and the fees *) @@ -274,7 +275,7 @@ let test_rewards_block_and_payload_producer () = in Assert.equal_tez ~loc:__LOC__ bal expected_balance >>=? fun () -> (* [baker_b2'] gets the bonus because he is the one who included the - endorsements *) + attestations *) get_contract_for_pkh contracts baker_b2' >>=? fun baker_b2'_contract -> Context.Contract.balance (B b2') baker_b2'_contract >>=? fun bal' -> Context.Delegate.current_frozen_deposits (B b2') 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 4907976532c49c4526b5d71e474700ef2989aadf..caa8c6eff2737e99ebd9bcbe7be64e63854e4d2c 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 @@ -208,7 +208,7 @@ let test_tz4_consensus_key () = Incremental.validate_operation ~expect_failure inc operation >>=? fun (_i : Incremental.t) -> return_unit -let test_endorsement_with_consensus_key () = +let test_attestation_with_consensus_key () = Context.init_with_constants1 constants >>=? fun (genesis, contracts) -> let account1_pkh = Context.Contract.pkh contracts in let consensus_account = Account.new_account () in @@ -220,14 +220,14 @@ 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.attestation ~delegate:account1_pkh ~slot b >>=? fun endorsement -> - Block.bake ~operation:endorsement b >>= fun res -> + Op.attestation ~delegate:account1_pkh ~slot b >>=? fun attestation -> + Block.bake ~operation:attestation b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Operation.Invalid_signature -> true | _ -> false) >>=? fun () -> - Op.attestation ~delegate:consensus_pkh ~slot b >>=? fun endorsement -> - Block.bake ~operation:endorsement b >>=? fun (_good_block : Block.t) -> + Op.attestation ~delegate:consensus_pkh ~slot b >>=? fun attestation -> + Block.bake ~operation:attestation b >>=? fun (_good_block : Block.t) -> return_unit let tests = @@ -298,7 +298,7 @@ let tests = `Quick (test_drain_empty_delegate ~exclude_ck:false); tztest "tz4 consensus key" `Quick test_tz4_consensus_key; - tztest "endorsement with ck" `Quick test_endorsement_with_consensus_key; + tztest "attestation with ck" `Quick test_attestation_with_consensus_key; ] let () = diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml index bbb6698639998e7c5157a4fd203b6c4f208eaead..5a6f3a367c63aff390d8b91f267a694895c7884c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml @@ -29,8 +29,8 @@ Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ -- --file test_deactivation.ml Subject: After a given number of cycles during which a delegate has not - made use of its baking and endorsing rights, its account will - be deactivated for validator selection. To bake/endorse + made use of its baking and attesting rights, its account will + be deactivated for validator selection. To bake/attest again, it will have to re-activate its account. *) 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_attestation.ml similarity index 71% rename from src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml rename to src/proto_alpha/lib_protocol/test/integration/consensus/test_double_attestation.ml index 06a63dee92b1b91ce9948d08e2b100ab2bf72f01..e6ae44b3d03ffe76163783ab812087084f60d541 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_attestation.ml @@ -25,11 +25,11 @@ (** Testing ------- - Component: Protocol (double endorsement) + Component: Protocol (double attestation) Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ - -- --file test_double_endorsement.ml - Subject: Double endorsement evidence operation may happen when an - endorser endorsed two different blocks on the same level. + -- --file test_double_attestation.ml + Subject: Double attestation evidence operation may happen when an + attester attested two different blocks on the same level. *) open Protocol @@ -48,7 +48,7 @@ let block_fork b = (* Tests *) (****************************************************************) -let order_endorsements ~correct_order op1 op2 = +let order_attestations ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in let c = Operation_hash.compare oph1 oph2 in @@ -56,39 +56,39 @@ let order_endorsements ~correct_order op1 op2 = else if c < 0 then (op2, op1) else (op1, op2) -let double_endorsement ctxt ?(correct_order = true) op1 op2 = - let e1, e2 = order_endorsements ~correct_order op1 op2 in +let double_attestation ctxt ?(correct_order = true) op1 op2 = + let e1, e2 = order_attestations ~correct_order op1 op2 in 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 +let double_preattestation ctxt ?(correct_order = true) op1 op2 = + let e1, e2 = order_attestations ~correct_order op1 op2 in Op.double_preattestation ctxt e1 e2 -(** This test verifies that when a "cheater" double endorses and +(** This test verifies that when a "cheater" double attests and doesn't have enough tokens to re-freeze of full deposit, we only freeze what we can (i.e. the remaining balance) but we check that another denunciation will slash 50% of the initial (expected) amount of the deposit. *) -(** Simple scenario where two endorsements are made from the same - delegate and exposed by a double_endorsement operation. Also verify +(** Simple scenario where two attestations are made from the same + delegate and exposed by a double_attestation operation. Also verify that punishment is operated. *) -let test_valid_double_endorsement_evidence () = +let test_valid_double_attestation_evidence () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> block_fork genesis >>=? fun (blk_1, blk_2) -> (* from blk_1 we bake blk_a and from blk_2 we bake blk_b so that - the same delegate endorses blk_a and blk_b and these 2 form - a valid double endorsement evidence; - - note that we cannot have double endorsement evidence + the same delegate attests blk_a and blk_b and these 2 form + a valid double attestation evidence; + - note that we cannot have double attestation evidence at the level of blk_1, blk_2 because both have as parent genesis - and so the endorsements are identical because the blocks blk_1, blk_2 + and so the attestations are identical because the blocks blk_1, blk_2 are identical. *) Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - 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 + Op.raw_attestation blk_a >>=? fun attestation_a -> + Op.raw_attestation blk_b >>=? fun attestation_b -> + let operation = double_attestation (B genesis) attestation_a attestation_b in Context.get_bakers (B blk_a) >>=? fun bakers -> let baker = Context.get_first_different_baker delegate bakers in Context.Delegate.full_balance (B blk_a) baker >>=? fun full_balance -> @@ -136,65 +136,65 @@ let test_valid_double_endorsement_evidence () = let real_reward = Test_tez.(full_balance_with_rewards -! full_balance) in Assert.equal_tez ~loc:__LOC__ expected_reward real_reward -(** Check that a double (pre)endorsement evidence with equivalent - endorsements but on different branches succeeds. *) +(** Check that a double (pre)attestation evidence with equivalent + attestations but on different branches succeeds. *) 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_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 + Context.get_attester (B blk) >>=? fun (attester, _slots) -> + Op.raw_attestation ~delegate:attester blk >>=? fun attestation_a -> + Op.raw_attestation ~branch:Block_hash.zero ~delegate:attester blk + >>=? fun attestation_b -> + let operation = double_attestation (B blk) attestation_a attestation_b in Block.bake ~operation blk >>=? fun _blk -> - Op.raw_preattestation ~delegate:endorser blk >>=? fun preendorsement_a -> - Op.raw_preattestation ~branch:Block_hash.zero ~delegate:endorser blk - >>=? fun preendorsement_b -> + Op.raw_preattestation ~delegate:attester blk >>=? fun preattestation_a -> + Op.raw_preattestation ~branch:Block_hash.zero ~delegate:attester blk + >>=? fun preattestation_b -> let operation = - double_preendorsement (B blk) preendorsement_a preendorsement_b + double_preattestation (B blk) preattestation_a preattestation_b in Block.bake ~operation blk >>=? fun _blk -> return_unit -(** Check that a double (pre)endorsement evidence succeeds when the +(** Check that a double (pre)attestation evidence succeeds when the operations have distinct slots (that both belong to the delegate) and are otherwise identical. *) 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_attesters (B blk) in + let* attesters = Context.get_attesters (B blk) in let delegate, slot1, slot2 = - (* Find an endorser with more than 1 slot. *) + (* Find an attester with more than 1 slot. *) WithExceptions.Option.get ~loc:__LOC__ (List.find_map - (fun (endorser : RPC.Validators.t) -> - match endorser.slots with - | slot1 :: slot2 :: _ -> Some (endorser.delegate, slot1, slot2) + (fun (attester : RPC.Validators.t) -> + match attester.slots with + | slot1 :: slot2 :: _ -> Some (attester.delegate, slot1, slot2) | _ -> None) - endorsers) + attesters) 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* attestation1 = Op.raw_attestation ~delegate ~slot:slot1 blk in + let* attestation2 = Op.raw_attestation ~delegate ~slot:slot2 blk in + let doubleA = double_attestation (B blk) attestation1 attestation2 in let* (_ : Block.t) = Block.bake ~operation:doubleA 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* preattestation1 = Op.raw_preattestation ~delegate ~slot:slot1 blk in + let* preattestation2 = Op.raw_preattestation ~delegate ~slot:slot2 blk in + let doubleB = double_preattestation (B blk) preattestation1 preattestation2 in let* (_ : Block.t) = Block.bake ~operation:doubleB blk in return_unit -(** Say a delegate double-endorses twice and say the 2 evidences are timely +(** Say a delegate double-attests twice and say the 2 evidences are timely included. Then the delegate can no longer bake. *) -let test_two_double_endorsement_evidences_leadsto_no_bake () = +let test_two_double_attestation_evidences_leadsto_no_bake () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - 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 + Op.raw_attestation blk_a >>=? fun attestation_a -> + Op.raw_attestation blk_b >>=? fun attestation_b -> + let operation = double_attestation (B genesis) attestation_a attestation_b in Context.get_bakers (B blk_a) >>=? fun bakers -> let baker = Context.get_first_different_baker delegate bakers in Context.Delegate.full_balance (B blk_a) baker @@ -204,10 +204,10 @@ 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_attestation blk_3 >>=? fun endorsement_3 -> - Op.raw_attestation blk_4 >>=? fun endorsement_4 -> + Op.raw_attestation blk_3 >>=? fun attestation_3 -> + Op.raw_attestation blk_4 >>=? fun attestation_4 -> let operation = - double_endorsement (B blk_with_evidence1) endorsement_3 endorsement_4 + double_attestation (B blk_with_evidence1) attestation_3 attestation_4 in Block.bake ~policy:(By_account baker) ~operation blk_3 >>=? fun blk_with_evidence2 -> @@ -223,14 +223,14 @@ let test_two_double_endorsement_evidences_leadsto_no_bake () = (* The following test scenarios are supposed to raise errors. *) (****************************************************************) -(** Check that an invalid double endorsement operation that exposes a - valid endorsement fails. *) -let test_invalid_double_endorsement () = +(** Check that an invalid double attestation operation that exposes a + valid attestation fails. *) +let test_invalid_double_attestation () = Context.init_n ~consensus_threshold:0 10 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun b -> - Op.raw_attestation b >>=? fun endorsement -> - Block.bake ~operation:(Operation.pack endorsement) b >>=? fun b -> - Op.double_attestation (B b) endorsement endorsement |> fun operation -> + Op.raw_attestation b >>=? fun attestation -> + Block.bake ~operation:(Operation.pack attestation) b >>=? fun b -> + Op.double_attestation (B b) attestation attestation |> fun operation -> Block.bake ~operation b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Validate_errors.Anonymous.Invalid_denunciation kind @@ -238,21 +238,21 @@ let test_invalid_double_endorsement () = true | _ -> false) -(** Check that an double endorsement operation that is invalid due to - incorrect ordering of the endorsements fails. *) -let test_invalid_double_endorsement_variant () = +(** Check that an double attestation operation that is invalid due to + incorrect ordering of the attestations fails. *) +let test_invalid_double_attestation_variant () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> Block.bake_until_cycle_end genesis >>=? fun b -> block_fork b >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> - Op.raw_attestation blk_a >>=? fun endorsement_a -> - Op.raw_attestation blk_b >>=? fun endorsement_b -> - double_endorsement + Op.raw_attestation blk_a >>=? fun attestation_a -> + Op.raw_attestation blk_b >>=? fun attestation_b -> + double_attestation (B genesis) ~correct_order:false - endorsement_a - endorsement_b + attestation_a + attestation_b |> fun operation -> Block.bake ~operation genesis >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function @@ -261,16 +261,16 @@ let test_invalid_double_endorsement_variant () = true | _ -> false) -(** Check that a future-cycle double endorsement fails. *) -let test_too_early_double_endorsement_evidence () = +(** Check that a future-cycle double attestation fails. *) +let test_too_early_double_attestation_evidence () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> Block.bake_until_cycle_end genesis >>=? fun b -> block_fork b >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_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 -> + Op.raw_attestation blk_a >>=? fun attestation_a -> + Op.raw_attestation blk_b >>=? fun attestation_b -> + double_attestation (B genesis) attestation_a attestation_b |> fun operation -> Block.bake ~operation genesis >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Validate_errors.Anonymous.Too_early_denunciation {kind; _} @@ -279,8 +279,8 @@ let test_too_early_double_endorsement_evidence () = | _ -> false) (** Check that after [max_slashing_period * blocks_per_cycle + 1], it is not possible - to create a double_endorsement anymore. *) -let test_too_late_double_endorsement_evidence () = + to create a double_attestation anymore. *) +let test_too_late_double_attestation_evidence () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> Context.get_constants (B genesis) >>=? fun Constants. @@ -288,11 +288,11 @@ 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_attestation blk_a >>=? fun endorsement_a -> - Op.raw_attestation blk_b >>=? fun endorsement_b -> + Op.raw_attestation blk_a >>=? fun attestation_a -> + Op.raw_attestation blk_b >>=? fun attestation_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 -> + double_attestation (B blk) attestation_a attestation_b |> fun operation -> Block.bake ~operation blk >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Validate_errors.Anonymous.Outdated_denunciation {kind; _} @@ -300,8 +300,8 @@ let test_too_late_double_endorsement_evidence () = true | _ -> false) -(** Check that an invalid double endorsement evidence that exposes two - endorsements made by two different endorsers fails. *) +(** Check that an invalid double attestation evidence that exposes two + attestations made by two different attesters fails. *) let test_different_delegates () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> Block.bake genesis >>=? fun genesis -> @@ -309,11 +309,11 @@ let test_different_delegates () = Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_first_different_attesters (B blk_b) - >>=? fun (endorser_a, endorser_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 -> + >>=? fun (attester_a, attester_b) -> + Op.raw_attestation ~delegate:attester_a.delegate blk_a >>=? fun e_a -> + Op.raw_attestation ~delegate:attester_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 -> + double_attestation (B blk_b) e_a e_b |> fun operation -> Block.bake ~operation blk_b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Validate_errors.Anonymous.Inconsistent_denunciation {kind; _} @@ -321,23 +321,23 @@ let test_different_delegates () = true | _ -> false) -(** Check that a double endorsement evidence that exposes a ill-formed - endorsement fails. *) +(** Check that a double attestation evidence that exposes a ill-formed + attestation fails. *) let test_wrong_delegate () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> block_fork genesis >>=? fun (blk_1, blk_2) -> 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_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 + Context.get_attester (B blk_a) >>=? fun (attester_a, _a_slots) -> + Op.raw_attestation ~delegate:attester_a blk_a >>=? fun attestation_a -> + Context.get_attester_n (B blk_b) 0 >>=? fun (attester0, _slots0) -> + Context.get_attester_n (B blk_b) 1 >>=? fun (attester1, _slots1) -> + let attester_b = + if Signature.Public_key_hash.equal attester_a attester0 then attester1 + else attester0 in - Op.raw_attestation ~delegate:endorser_b blk_b >>=? fun endorsement_b -> - double_endorsement (B blk_b) endorsement_a endorsement_b |> fun operation -> + Op.raw_attestation ~delegate:attester_b blk_b >>=? fun attestation_b -> + double_attestation (B blk_b) attestation_a attestation_b |> fun operation -> Block.bake ~operation blk_b >>= fun res -> Assert.proto_error ~loc:__LOC__ res (function | Validate_errors.Anonymous.Inconsistent_denunciation {kind; _} @@ -346,7 +346,7 @@ let test_wrong_delegate () = | _ -> false) let test_freeze_more_with_low_balance = - let get_endorsing_slots_for_account ctxt account = + let get_attesting_slots_for_account ctxt account = (* Get the slots of the given account in the given context. *) Context.get_attesters ctxt >>=? function | [d1; d2] -> @@ -356,32 +356,32 @@ let test_freeze_more_with_low_balance = else assert false) .slots | _ -> assert false - (* there are exactly two endorsers for this test. *) + (* there are exactly two attesters for this test. *) in - let double_endorse_and_punish b2 account1 = - (* Bake a block on top of [b2] that includes a double-endorsement + let double_attest_and_punish b2 account1 = + (* Bake a block on top of [b2] that includes a double-attestation denunciation of [account1]. *) block_fork b2 >>=? fun (blk_d1, blk_d2) -> Block.bake ~policy:(Block.By_account account1) blk_d1 >>=? fun blk_a -> Block.bake ~policy:(Block.By_account account1) blk_d2 >>=? fun blk_b -> - get_endorsing_slots_for_account (B blk_a) account1 >>=? fun slots_a -> + get_attesting_slots_for_account (B blk_a) account1 >>=? fun slots_a -> let slot = match List.hd slots_a with None -> assert false | Some s -> s in - Op.raw_attestation ~delegate:account1 ~slot blk_a >>=? fun end_a -> - get_endorsing_slots_for_account (B blk_b) account1 >>=? fun slots_b -> + Op.raw_attestation ~delegate:account1 ~slot blk_a >>=? fun attestation_a -> + get_attesting_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_attestation ~delegate:account1 ~slot blk_b >>=? fun end_b -> - let denunciation = double_endorsement (B b2) end_a end_b in + Op.raw_attestation ~delegate:account1 ~slot blk_b >>=? fun attestation_b -> + let denunciation = double_attestation (B b2) attestation_a attestation_b in Block.bake ~policy:(Excluding [account1]) b2 ~operations:[denunciation] in - let check_unique_endorser b account2 = + let check_unique_attester b account2 = 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." + | _ -> failwith "We are supposed to only have account2 as attester." in fun () -> let constants = @@ -422,7 +422,7 @@ let test_freeze_more_with_low_balance = >>=? fun () -> Assert.equal_tez ~loc:__LOC__ info1.frozen_deposits info2.frozen_deposits >>=? fun () -> - double_endorse_and_punish b2 account1 >>=? fun b3 -> + double_attest_and_punish b2 account1 >>=? fun b3 -> (* Denunciation has happened: we check that the full balance of [account1] is (still) equal to its deposit. *) Context.Delegate.info (B b3) account1 >>=? fun info3 -> @@ -448,7 +448,7 @@ let test_freeze_more_with_low_balance = (* We now bake until end of cycle only with [account2]: block of the new cycle are called cX below. *) Block.bake_until_cycle_end ~policy:(By_account account2) b3 >>=? fun c1 -> - double_endorse_and_punish c1 account1 >>=? fun c2 -> + double_attest_and_punish c1 account1 >>=? fun c2 -> (* Second denunciation has happened: we check that the full balance of [account1] reflects the slashing of 50% of the original deposit. Its current deposits are thus 0tz. *) @@ -475,24 +475,24 @@ let test_freeze_more_with_low_balance = [account1] is deactivated is 2 + [2 * preserved_cycles] from genesis. *) Assert.equal_bool ~loc:__LOC__ info5.deactivated false >>=? fun () -> (* account1 is still active, but has no rights. *) - check_unique_endorser d1 account2 >>=? fun () -> + check_unique_attester d1 account2 >>=? fun () -> Block.bake_until_cycle_end ~policy:(By_account account2) d1 >>=? fun e1 -> (* account1 has no rights and furthermore is no longer active. *) - check_unique_endorser e1 account2 >>=? fun () -> + check_unique_attester e1 account2 >>=? fun () -> Context.Delegate.info (B e1) account1 >>=? fun info6 -> Assert.equal_bool ~loc:__LOC__ info6.deactivated true -(** Injecting a valid double endorsement multiple times raises an error. *) -let test_two_double_endorsement_evidences_leads_to_duplicate_denunciation () = +(** Injecting a valid double attestation multiple times raises an error. *) +let test_two_double_attestation_evidences_leads_to_duplicate_denunciation () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - 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 + Op.raw_attestation blk_a >>=? fun attestation_a -> + Op.raw_attestation blk_b >>=? fun attestation_b -> + let operation = double_attestation (B genesis) attestation_a attestation_b in + let operation2 = double_attestation (B genesis) attestation_b attestation_a in Context.get_bakers (B blk_a) >>=? fun bakers -> let baker = Context.get_first_different_baker delegate bakers in Context.Delegate.full_balance (B blk_a) baker @@ -521,41 +521,41 @@ let test_two_double_endorsement_evidences_leads_to_duplicate_denunciation () = let tests = [ Tztest.tztest - "valid double endorsement evidence" + "valid double attestation evidence" `Quick - test_valid_double_endorsement_evidence; + test_valid_double_attestation_evidence; Tztest.tztest - "valid evidence with same (pre)endorsements on different branches" + "valid evidence with same (pre)attestations on different branches" `Quick test_different_branch; Tztest.tztest - "valid evidence with same (pre)endorsements on different slots" + "valid evidence with same (pre)attestations on different slots" `Quick test_different_slots; Tztest.tztest - "2 valid double endorsement evidences lead to not being able to bake" + "2 valid double attestation evidences lead to not being able to bake" `Quick - test_two_double_endorsement_evidences_leadsto_no_bake; + test_two_double_attestation_evidences_leadsto_no_bake; Tztest.tztest - "valid double endorsement injected multiple time" + "valid double attestation injected multiple time" `Quick - test_two_double_endorsement_evidences_leads_to_duplicate_denunciation; + test_two_double_attestation_evidences_leads_to_duplicate_denunciation; Tztest.tztest - "invalid double endorsement evidence" + "invalid double attestation evidence" `Quick - test_invalid_double_endorsement; + test_invalid_double_attestation; Tztest.tztest - "another invalid double endorsement evidence" + "another invalid double attestation evidence" `Quick - test_invalid_double_endorsement_variant; + test_invalid_double_attestation_variant; Tztest.tztest - "too early double endorsement evidence" + "too early double attestation evidence" `Quick - test_too_early_double_endorsement_evidence; + test_too_early_double_attestation_evidence; Tztest.tztest - "too late double endorsement evidence" + "too late double attestation evidence" `Quick - test_too_late_double_endorsement_evidence; + test_too_late_double_attestation_evidence; Tztest.tztest "different delegates" `Quick test_different_delegates; Tztest.tztest "wrong delegate" `Quick test_wrong_delegate; Tztest.tztest @@ -565,5 +565,5 @@ let tests = ] let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("double endorsement", tests)] + Alcotest_lwt.run ~__FILE__ Protocol.name [("double attestation", tests)] |> Lwt_main.run 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 307c244e1873c175cb7175cb69d1335503ad8487..ff6caf8f18bafec958bb497b43d61fe0a46e9665 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 @@ -95,8 +95,8 @@ let test_valid_double_baking_evidence () = >>=? fun initial_frozen_deposits -> Assert.equal_tez ~loc:__LOC__ initial_frozen_deposits frozen_deposits_before -(* auxiliary function used in [double_endorsement] *) -let order_endorsements ~correct_order op1 op2 = +(* auxiliary function used in [double_attestation] *) +let order_attestations ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in let c = Operation_hash.compare oph1 oph2 in @@ -105,13 +105,13 @@ let order_endorsements ~correct_order op1 op2 = else (op1, op2) (* auxiliary function used in - [test_valid_double_baking_followed_by_double_endorsing] and - [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 + [test_valid_double_baking_followed_by_double_attesting] and + [test_valid_double_attesting_followed_by_double_baking] *) +let double_attestation ctxt ?(correct_order = true) op1 op2 = + let e1, e2 = order_attestations ~correct_order op1 op2 in Op.double_attestation ctxt e1 e2 -let test_valid_double_baking_followed_by_double_endorsing () = +let test_valid_double_baking_followed_by_double_attesting () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, contracts) -> Context.get_first_different_bakers (B genesis) >>=? fun (baker1, baker2) -> Block.bake genesis >>=? fun b -> @@ -126,9 +126,9 @@ 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_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 + Op.raw_attestation ~delegate blk_a >>=? fun attestation_a -> + Op.raw_attestation ~delegate blk_b >>=? fun attestation_b -> + let operation = double_attestation (B genesis) attestation_a attestation_b in Block.bake ~policy:(By_account baker1) ~operation blk_with_db_evidence >>=? fun blk_final -> Context.Delegate.current_frozen_deposits (B blk_final) baker1 @@ -151,13 +151,13 @@ let test_valid_double_baking_followed_by_double_endorsing () = expected_frozen_deposits_after frozen_deposits_after -(* auxiliary function used in [test_valid_double_endorsing_followed_by_double_baking] *) +(* auxiliary function used in [test_valid_double_attesting_followed_by_double_baking] *) let block_fork_diff b = Context.get_first_different_bakers (B b) >>=? fun (baker_1, baker_2) -> Block.bake ~policy:(By_account baker_1) b >>=? fun blk_a -> Block.bake ~policy:(By_account baker_2) b >|=? fun blk_b -> (blk_a, blk_b) -let test_valid_double_endorsing_followed_by_double_baking () = +let test_valid_double_attesting_followed_by_double_baking () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, contracts) -> Context.get_first_different_bakers (B genesis) >>=? fun (baker1, baker2) -> block_fork_diff genesis >>=? fun (blk_1, blk_2) -> @@ -170,9 +170,9 @@ 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_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 + Op.raw_attestation ~delegate blk_a >>=? fun attestation_a -> + Op.raw_attestation ~delegate blk_b >>=? fun attestation_b -> + let operation = double_attestation (B genesis) attestation_a attestation_b in Block.bake ~policy:(By_account baker1) ~operation blk_a >>=? fun blk_with_de_evidence -> block_fork ~policy:(By_account baker1) contracts blk_1 @@ -219,22 +219,22 @@ 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_attesters (B b_with_evidence) >>=? fun endorsers -> + Context.get_attesters (B b_with_evidence) >>=? fun attesters -> List.map_es (function | {Plugin.RPC.Validators.delegate; slots; _} -> return (delegate, slots)) - endorsers - >>=? fun preendorsers -> + attesters + >>=? fun preattesters -> List.map_ep - (fun (endorser, _slots) -> - Op.preattestation ~delegate:endorser b_with_evidence) - preendorsers - >>=? fun preendos -> + (fun (attester, _slots) -> + Op.preattestation ~delegate:attester b_with_evidence) + preattesters + >>=? fun preattestations -> Block.bake ~payload_round:(Some Round.zero) ~locked_round:(Some Round.zero) ~policy:(By_account baker1) - ~operations:(preendos @ [db_evidence]) + ~operations:(preattestations @ [db_evidence]) b1 >>=? fun b' -> (* the frozen deposits of the double-signer [baker1] are slashed *) @@ -464,13 +464,13 @@ let tests = `Quick test_double_evidence; Tztest.tztest - "double baking followed by double endorsing" + "double baking followed by double attesting" `Quick - test_valid_double_baking_followed_by_double_endorsing; + test_valid_double_baking_followed_by_double_attesting; Tztest.tztest - "double endorsing followed by double baking" + "double attesting followed by double baking" `Quick - test_valid_double_endorsing_followed_by_double_baking; + test_valid_double_attesting_followed_by_double_baking; ] let () = 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_preattestation.ml similarity index 74% rename from src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml rename to src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preattestation.ml index 5520a1635960c0898f5044401055ff18c876b591..d23fa501015dc66fb27985601a93fbeef8668ab8 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_preattestation.ml @@ -25,10 +25,10 @@ (** Testing ------- - Component: Protocol (double preendorsement) in Full_construction & Application modes + Component: Protocol (double preattestation) in Full_construction & Application modes Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ - -- --file test_double_preendorsement.ml - Subject: These tests target different cases for double preendorsement *) + -- --file test_double_preattestation.ml + Subject: These tests target different cases for double preattestation *) open Protocol open Alpha_context @@ -54,7 +54,7 @@ end = struct (** Helper function for illformed denunciations construction *) - let pick_endorsers ctxt = + let pick_attesters ctxt = let module V = Plugin.RPC.Validators in Context.get_attesters ctxt >>=? function | a :: b :: _ -> @@ -68,8 +68,8 @@ end = struct true | _ -> false) - let malformed_double_preendorsement_denunciation - ?(include_endorsement = false) ?(block_round = 0) + let malformed_double_preattestation_denunciation + ?(include_attestation = false) ?(block_round = 0) ?(mk_evidence = fun ctxt p1 p2 -> Op.double_preattestation ctxt p1 p2) ~loc () = Context.init_n ~consensus_threshold:0 10 () @@ -77,7 +77,7 @@ end = struct bake genesis >>=? fun b1 -> bake ~policy:(By_round 0) b1 >>=? fun b2_A -> Op.attestation b1 >>=? fun e -> - let operations = if include_endorsement then [e] else [] in + let operations = if include_attestation then [e] else [] in bake ~policy:(By_round block_round) ~operations b1 >>=? fun b2_B -> Op.raw_preattestation b2_A >>=? fun op1 -> Op.raw_preattestation b2_B >>=? fun op2 -> @@ -119,7 +119,7 @@ end = struct Alcotest.fail (loc ^ ": Test should not succeed") let expected_success _loc baker pred bbad d1 d2 = - (* same preendorsers in case denunciation succeeds*) + (* same preattesters in case denunciation succeeds*) Assert.equal_pkh ~loc:__LOC__ d1 d2 >>=? fun () -> Context.get_constants (B pred) >>=? fun constants -> let p = @@ -128,7 +128,7 @@ end = struct in (* let's bake the block on top of pred without denunciating d1 *) bake ~policy:(By_account baker) pred >>=? fun bgood -> - (* Checking what the endorser lost *) + (* Checking what the attester lost *) Context.Delegate.current_frozen_deposits (B pred) d1 >>=? fun frozen_deposit -> Context.Delegate.full_balance (B bgood) d1 >>=? fun bal_good -> @@ -146,19 +146,20 @@ end = struct .staking_over_baking_global_limit) in let denun_reward = Test_tez.(lost_deposit /! divider) in - (* if the baker is the endorser, he'll only loose half of the deposits *) - let expected_endo_loss = + (* if the baker is the attester, he'll only loose half of the deposits *) + let expected_attester_loss = if Signature.Public_key_hash.equal baker d1 then Test_tez.(lost_deposit -! denun_reward) else lost_deposit in - Assert.equal_tez ~loc:__LOC__ expected_endo_loss diff_end_bal >>=? fun () -> + Assert.equal_tez ~loc:__LOC__ expected_attester_loss diff_end_bal + >>=? fun () -> (* Checking what the baker earned (or lost) *) Context.Delegate.full_balance (B bgood) baker >>=? fun bal_good -> Context.Delegate.full_balance (B bbad) baker >>=? fun bal_bad -> - (* if baker = endorser, the baker's balance in the good case is better, - because half of his deposits are burnt in the bad (double-preendorsement) - situation. In case baker <> endorser, bal_bad of the baker gets half of + (* if baker = attester, the baker's balance in the good case is better, + because half of his deposits are burnt in the bad (double-preattestation) + situation. In case baker <> attester, bal_bad of the baker gets half of burnt deposit of d1, so it's higher *) let high, low = @@ -167,11 +168,11 @@ end = struct in let diff_baker = Test_tez.(high -! low) in (* the baker has either earnt or lost (in case baker = d1) half of burnt - endorsement deposits *) + attestation deposits *) Assert.equal_tez ~loc:__LOC__ denun_reward diff_baker >>=? fun () -> return_unit - let order_preendorsements ~correct_order op1 op2 = + let order_preattestations ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in let c = Operation_hash.compare oph1 oph2 in @@ -180,29 +181,29 @@ end = struct else (op1, op2) (** Helper function for denunciations inclusion *) - let generic_double_preendorsement_denunciation ~nb_blocks_before_double + let generic_double_preattestation_denunciation ~nb_blocks_before_double ~nb_blocks_before_denunciation ?(test_expected_ok = fun _loc _baker _pred _bbad _d1 _d2 -> return_unit) ?(test_expected_ko = fun _loc _res -> return_unit) - ?(pick_endorsers = - fun ctxt -> pick_endorsers ctxt >>=? fun (a, _b) -> return (a, a)) ~loc + ?(pick_attesters = + fun ctxt -> pick_attesters ctxt >>=? fun (a, _b) -> return (a, a)) ~loc () = Context.init_n ~consensus_threshold:0 10 () >>=? fun (genesis, contracts) -> let addr = match List.hd contracts with None -> assert false | Some e -> e in - (* bake `nb_blocks_before_double blocks` before double preendorsing *) + (* bake `nb_blocks_before_double blocks` before double preattesting *) bake_n nb_blocks_before_double genesis >>=? fun blk -> - (* producing two differents blocks and two preendorsements op1 and op2 *) + (* producing two differents blocks and two preattestations op1 and op2 *) Op.transaction (B genesis) addr addr Tez.one_mutez >>=? fun trans -> bake ~policy:(By_round 0) blk >>=? fun head_A -> bake ~policy:(By_round 0) blk ~operations:[trans] >>=? fun head_B -> - pick_endorsers (B head_A) >>=? fun ((d1, _slots1), (d2, _slots2)) -> + pick_attesters (B head_A) >>=? fun ((d1, _slots1), (d2, _slots2)) -> (* default: d1 = d2 *) 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 *) + let op1, op2 = order_preattestations ~correct_order:true op1 op2 in + (* bake `nb_blocks_before_denunciation` before double preattestation denunciation *) bake_n nb_blocks_before_denunciation blk >>=? fun blk -> let op : Operation.packed = Op.double_preattestation (B blk) op1 op2 in Context.get_baker (B blk) ~round:Round.zero >>=? fun baker -> @@ -224,46 +225,46 @@ end = struct (* Tests *) (****************************************************************) - (** Preendorsing two blocks that are structurally equal is not punished *) - let malformed_double_preendorsement_denunciation_same_payload_hash_1 () = - malformed_double_preendorsement_denunciation ~loc:__LOC__ () + (** Preattesting two blocks that are structurally equal is not punished *) + let malformed_double_preattestation_denunciation_same_payload_hash_1 () = + malformed_double_preattestation_denunciation ~loc:__LOC__ () - (** Preendorsing two blocks that are structurally equal up to the endorsements + (** Preattesting two blocks that are structurally equal up to the attestations they include is not punished *) - let malformed_double_preendorsement_denunciation_same_payload_hash_2 () = - malformed_double_preendorsement_denunciation - (* including an endorsement in one of the blocks doesn't change its + let malformed_double_preattestation_denunciation_same_payload_hash_2 () = + malformed_double_preattestation_denunciation + (* including an attestation in one of the blocks doesn't change its payload hash *) - ~include_endorsement:true + ~include_attestation:true ~loc:__LOC__ () (** Denunciation evidence cannot have the same operations *) - let malformed_double_preendorsement_denunciation_same_preendorsement () = - malformed_double_preendorsement_denunciation - (* exactly the same preendorsement operation => illformed *) + let malformed_double_preattestation_denunciation_same_preattestation () = + malformed_double_preattestation_denunciation + (* exactly the same preattestation operation => illformed *) ~mk_evidence:(fun ctxt p1 _p2 -> Op.double_preattestation ctxt p1 p1) ~loc:__LOC__ () - (** Preendorsing two blocks with different rounds is not punished *) - let malformed_double_preendorsement_denunciation_different_rounds () = - malformed_double_preendorsement_denunciation ~loc:__LOC__ ~block_round:1 () + (** Preattesting two blocks with different rounds is not punished *) + let malformed_double_preattestation_denunciation_different_rounds () = + malformed_double_preattestation_denunciation ~loc:__LOC__ ~block_round:1 () - (** Preendorsing two blocks by two different validators is not punished *) - let malformed_double_preendorsement_denunciation_different_validators () = - generic_double_preendorsement_denunciation + (** Preattesting two blocks by two different validators is not punished *) + let malformed_double_preattestation_denunciation_different_validators () = + generic_double_preattestation_denunciation ~nb_blocks_before_double:0 ~nb_blocks_before_denunciation:2 ~test_expected_ok:unexpected_success ~test_expected_ko:inconsistent_denunciation - ~pick_endorsers (* pick different endorsers *) + ~pick_attesters (* pick different attesters *) ~loc:__LOC__ () (** Attempt a denunciation of a double-pre in the first block after genesis *) - let double_preendorsement_just_after_upgrade () = - generic_double_preendorsement_denunciation + let double_preattestation_just_after_upgrade () = + generic_double_preattestation_denunciation ~nb_blocks_before_double:0 ~nb_blocks_before_denunciation:1 ~test_expected_ok:expected_success @@ -273,9 +274,9 @@ end = struct (** Denunciation of double-pre at level L is injected at level L' = max_slashing_period. The denunciation is outdated. *) - let double_preendorsement_denunciation_during_slashing_period () = + let double_preattestation_denunciation_during_slashing_period () = max_slashing_period () >>=? fun max_slashing_period -> - generic_double_preendorsement_denunciation + generic_double_preattestation_denunciation ~nb_blocks_before_double:0 ~nb_blocks_before_denunciation:(max_slashing_period / 2) ~test_expected_ok:expected_success @@ -285,9 +286,9 @@ end = struct (** Denunciation of double-pre at level L is injected 1 block after unfreeze delay. Too late: denunciation is outdated. *) - let double_preendorsement_denunciation_after_slashing_period () = + let double_preattestation_denunciation_after_slashing_period () = max_slashing_period () >>=? fun max_slashing_period -> - generic_double_preendorsement_denunciation + generic_double_preattestation_denunciation ~nb_blocks_before_double:0 ~nb_blocks_before_denunciation:(max_slashing_period + 1) ~test_expected_ok:unexpected_success @@ -295,8 +296,8 @@ end = struct ~loc:__LOC__ () - let double_preendorsement ctxt ?(correct_order = true) op1 op2 = - let e1, e2 = order_preendorsements ~correct_order op1 op2 in + let double_preattestation ctxt ?(correct_order = true) op1 op2 = + let e1, e2 = order_preattestations ~correct_order op1 op2 in Op.double_preattestation ctxt e1 e2 let block_fork b = @@ -304,21 +305,21 @@ end = struct Block.bake ~policy:(By_account baker_1) b >>=? fun blk_a -> Block.bake ~policy:(By_account baker_2) b >|=? fun blk_b -> (blk_a, blk_b) - (** Injecting a valid double preendorsement multiple time raises an error. *) - let test_two_double_preendorsement_evidences_leads_to_duplicate_denunciation + (** Injecting a valid double preattestation multiple time raises an error. *) + let test_two_double_preattestation_evidences_leads_to_duplicate_denunciation () = Context.init2 ~consensus_threshold:0 () >>=? fun (genesis, _contracts) -> block_fork genesis >>=? fun (blk_1, blk_2) -> Block.bake blk_1 >>=? fun blk_a -> Block.bake blk_2 >>=? fun blk_b -> Context.get_attester (B blk_a) >>=? fun (delegate, _) -> - Op.raw_preattestation blk_a >>=? fun preendorsement_a -> - Op.raw_preattestation blk_b >>=? fun preendorsement_b -> + Op.raw_preattestation blk_a >>=? fun preattestation_a -> + Op.raw_preattestation blk_b >>=? fun preattestation_b -> let operation = - double_preendorsement (B genesis) preendorsement_a preendorsement_b + double_preattestation (B genesis) preattestation_a preattestation_b in let operation2 = - double_preendorsement (B genesis) preendorsement_b preendorsement_a + double_preattestation (B genesis) preattestation_b preattestation_a in Context.get_bakers (B blk_a) >>=? fun bakers -> let baker = Context.get_first_different_baker delegate bakers in @@ -347,42 +348,42 @@ end = struct [ (* illformed denunciations *) my_tztest - "ko: malformed_double_preendorsement_denunciation_same_payload_hash_1" + "ko: malformed_double_preattestation_denunciation_same_payload_hash_1" `Quick - malformed_double_preendorsement_denunciation_same_payload_hash_1; + malformed_double_preattestation_denunciation_same_payload_hash_1; my_tztest - "ko: malformed_double_preendorsement_denunciation_same_payload_hash_2" + "ko: malformed_double_preattestation_denunciation_same_payload_hash_2" `Quick - malformed_double_preendorsement_denunciation_same_payload_hash_2; + malformed_double_preattestation_denunciation_same_payload_hash_2; my_tztest - "ko: malformed_double_preendorsement_denunciation_different_rounds" + "ko: malformed_double_preattestation_denunciation_different_rounds" `Quick - malformed_double_preendorsement_denunciation_different_rounds; + malformed_double_preattestation_denunciation_different_rounds; my_tztest - "ko: malformed_double_preendorsement_denunciation_same_preendorsement" + "ko: malformed_double_preattestation_denunciation_same_preattestation" `Quick - malformed_double_preendorsement_denunciation_same_preendorsement; + malformed_double_preattestation_denunciation_same_preattestation; my_tztest - "ko: malformed_double_preendorsement_denunciation_different_validators" + "ko: malformed_double_preattestation_denunciation_different_validators" `Quick - malformed_double_preendorsement_denunciation_different_validators; + malformed_double_preattestation_denunciation_different_validators; my_tztest - "double_preendorsement_just_after_upgrade" + "double_preattestation_just_after_upgrade" `Quick - double_preendorsement_just_after_upgrade; + double_preattestation_just_after_upgrade; (* tests for unfreeze *) my_tztest - "double_preendorsement_denunciation_during_slashing_period" + "double_preattestation_denunciation_during_slashing_period" `Quick - double_preendorsement_denunciation_during_slashing_period; + double_preattestation_denunciation_during_slashing_period; my_tztest - "double_preendorsement_denunciation_after_slashing_period" + "double_preattestation_denunciation_after_slashing_period" `Quick - double_preendorsement_denunciation_after_slashing_period; + double_preattestation_denunciation_after_slashing_period; my_tztest - "valid double preendorsement injected multiple times" + "valid double preattestation injected multiple times" `Quick - test_two_double_preendorsement_evidences_leads_to_duplicate_denunciation; + test_two_double_preattestation_evidences_leads_to_duplicate_denunciation; ] end @@ -400,5 +401,5 @@ let tests = AppMode.tests @ ConstrMode.tests let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("double preendorsement", tests)] + Alcotest_lwt.run ~__FILE__ Protocol.name [("double preattestation", tests)] |> Lwt_main.run 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 b6ac56169e87a83937de0cf51b3f7c09ed6206b5..c27d952782e4451cd2c4580e8d7b7ab392a8e5be 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 @@ -135,7 +135,7 @@ let test_cannot_bake_with_zero_deposits () = (* N.B. there is no non-zero frozen deposits value for which one cannot bake: even with a small deposit one can still bake, though with a smaller probability (because the frozen deposits value impacts the active stake and the active - stake is the one used to determine baking/endorsing rights. *) + stake is the one used to determine baking/attesting rights. *) (* To make account1 have zero deposits, we unstake all its deposits. *) Context.Delegate.current_frozen_deposits (B genesis) account1 >>=? fun frozen_deposits -> @@ -286,26 +286,35 @@ 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_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_preattestation (B blk_a) preendo1 preendo2 + Op.raw_preattestation ~delegate:slashed_account blk_a + >>=? fun preattestation1 -> + Op.raw_preattestation ~delegate:slashed_account blk_b + >>=? fun preattestation2 -> + let preattestation1, preattestation2 = + order_ops preattestation1 preattestation2 + in + let double_preattestation_op = + Op.double_preattestation (B blk_a) preattestation1 preattestation2 in Block.bake ~policy:(By_account good_account) - ~operation:double_preendo_op + ~operation:double_preattestation_op blk_a >>=? fun b -> Op.transaction (B b) good_contract slashed_contract Alpha_context.Tez.one_cent >>=? 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_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_attestation (B blk_a) endo1 endo2 in - Block.bake ~policy:(By_account good_account) ~operation:double_endo_op b + Op.raw_attestation ~delegate:slashed_account blk_a >>=? fun attestation1 -> + Op.raw_attestation ~delegate:slashed_account blk_b >>=? fun attestation2 -> + let attestation1, attestation2 = order_ops attestation1 attestation2 in + let double_attestation_op = + Op.double_attestation (B blk_a) attestation1 attestation2 + in + Block.bake + ~policy:(By_account good_account) + ~operation:double_attestation_op + b >>=? fun b -> (* Assert that the [slashed_account]'s deposit is now 0 *) Context.Delegate.current_frozen_deposits (B b) slashed_account >>=? fun fd -> @@ -384,7 +393,7 @@ let test_deposits_not_unfrozen_after_deactivation () = in Context.Delegate.current_frozen_deposits (B genesis) account1 >>=? fun initial_frozen_deposits -> - (* [account1] will not participate (ie bake/endorse); we set the + (* [account1] will not participate (ie bake/attest); we set the expected last cycles at which it is considered active and at which it has non-zero deposits *) let last_active_cycle = 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 36b5b6f6e70887b75798c386a13397f0fb665431..339d4a3ef7ee05c7af2ff801cdad9151a98820e6 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 @@ -34,32 +34,32 @@ open Protocol open Alpha_context -(** [baker] bakes and [endorser] endorses *) -let bake_and_endorse_once (_b_pred, b_cur) baker endorser = +(** [baker] bakes and [attester] attests *) +let bake_and_attest_once (_b_pred, b_cur) baker attester = let open Context in - Context.get_attesters (B b_cur) >>=? fun endorsers_list -> + Context.get_attesters (B b_cur) >>=? fun attesters_list -> List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> - if Signature.Public_key_hash.equal delegate endorser then + if Signature.Public_key_hash.equal delegate attester then Some (delegate, slots) else None) - endorsers_list + attesters_list |> function | None -> assert false | Some (delegate, _slots) -> Block.get_round b_cur >>?= fun round -> - Op.attestation ~round ~delegate b_cur >>=? fun endorsement -> - Block.bake ~policy:(By_account baker) ~operation:endorsement b_cur + Op.attestation ~round ~delegate b_cur >>=? fun attestation -> + Block.bake ~policy:(By_account baker) ~operation:attestation b_cur (** We test that: - - a delegate that participates enough, gets its endorsing rewards at the end of the cycle, + - a delegate that participates enough, gets its attesting rewards at the end of the cycle, - a delegate that does not participating enough during a cycle, doesn't get rewarded. The case distinction is made by the boolean argument [sufficient_participation]. If [sufficient_participation] is true, - then a validator endorses for as long as the minimal required activity is not reached, - otherwise it does not endorse. + then a validator attests for as long as the minimal required activity is not reached, + otherwise it does not attest. Finally, we check the validator's balance at the end of the cycle. *) let test_participation ~sufficient_participation () = @@ -82,22 +82,22 @@ let test_participation ~sufficient_participation () = let del2 = Context.Contract.pkh account2 in Block.bake ~policy:(By_account del1) b0 >>=? fun b1 -> (* To separate concerns, only [del1] bakes: this way, we don't need to - consider baking rewards for [del2]. Delegate [del2] endorses only + consider baking rewards for [del2]. Delegate [del2] attests only if the target [minimal_nb_active_slots] is not reached; for the - rest, it is [del1] that endorses. *) + rest, it is [del1] that attests. *) List.fold_left_es - (fun (b_pred, b_crt, endorsing_power) level -> + (fun (b_pred, b_crt, attesting_power) level -> let int_level = Int32.of_int level in Environment.wrap_tzresult (Raw_level.of_int32 int_level) >>?= fun level -> 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 - then (del2, endorsing_power + endorsing_power_for_level) - else (del1, endorsing_power) + >>=? fun attesting_power_for_level -> + let attester, new_attesting_power = + if sufficient_participation && attesting_power < minimal_nb_active_slots + then (del2, attesting_power + attesting_power_for_level) + else (del1, attesting_power) in - bake_and_endorse_once (b_pred, b_crt) del1 endorser >>=? fun b -> - return (b_crt, b, new_endorsing_power)) + bake_and_attest_once (b_pred, b_crt) del1 attester >>=? fun b -> + return (b_crt, b, new_attesting_power)) (b0, b1, 0) (2 -- (blocks_per_cycle - 1)) >>=? fun (pred_b, b, _) -> @@ -109,15 +109,15 @@ let test_participation ~sufficient_participation () = balance of del2 at pred_b; consequently, no rewards could have been given 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. *) + balance of del2 at pred_b plus the attesting rewards. *) 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 - let expected_bal2_at_b = Int64.add bal2_at_pred_b endorsing_rewards in + let attesting_rewards = if sufficient_participation then er else 0L in + let expected_bal2_at_b = Int64.add bal2_at_pred_b attesting_rewards in Assert.equal_int64 ~loc:__LOC__ bal2_at_b expected_bal2_at_b -(* We bake and endorse with 1 out of 2 accounts; we monitor the result +(* We bake and attest with 1 out of 2 accounts; we monitor the result returned by the '../delegates//participation' RPC for the non-participating account. *) let test_participation_rpc () = @@ -137,17 +137,17 @@ let test_participation_rpc () = expected_cycle_activity * numerator / denominator in let allowed_missed_slots = expected_cycle_activity - minimal_cycle_activity in - let endorsing_reward_per_slot = + let attesting_reward_per_slot = Alpha_context.Delegate.Rewards.For_RPC.reward_from_constants csts.parametric ~reward_kind:Attesting_reward_per_slot in - let expected_endorsing_rewards = - Tez.mul_exn endorsing_reward_per_slot expected_cycle_activity + let expected_attesting_rewards = + Tez.mul_exn attesting_reward_per_slot expected_cycle_activity in Block.bake ~policy:(By_account del1) b0 >>=? fun b1 -> List.fold_left_es - (fun (b_pred, b_crt, total_endorsing_power) level_int -> + (fun (b_pred, b_crt, total_attesting_power) level_int -> Context.Delegate.participation (B b_crt) del2 >>=? fun info -> Assert.equal_int ~loc:__LOC__ @@ -161,7 +161,7 @@ let test_participation_rpc () = >>=? fun () -> Assert.equal_int ~loc:__LOC__ info.missed_levels (level_int - 1) >>=? fun () -> - let missed_slots = total_endorsing_power in + let missed_slots = total_attesting_power in Assert.equal_int ~loc:__LOC__ info.missed_slots missed_slots >>=? fun () -> let remaining_allowed_missed_slots = @@ -172,23 +172,23 @@ let test_participation_rpc () = info.remaining_allowed_missed_slots (max 0 remaining_allowed_missed_slots) >>=? fun () -> - let endorsing_rewards = - if remaining_allowed_missed_slots >= 0 then expected_endorsing_rewards + let attesting_rewards = + if remaining_allowed_missed_slots >= 0 then expected_attesting_rewards else Tez.zero in Assert.equal_tez ~loc:__LOC__ info.expected_attesting_rewards - endorsing_rewards + attesting_rewards >>=? fun () -> - bake_and_endorse_once (b_pred, b_crt) del1 del1 >>=? fun b -> + bake_and_attest_once (b_pred, b_crt) del1 del1 >>=? fun b -> (* [level_int] is the level of [b_crt] *) level_int |> Int32.of_int |> Raw_level.of_int32 |> Environment.wrap_tzresult >>?= fun level -> Context.get_attesting_power_for_delegate (B b_crt) ~level del2 - >>=? fun endorsing_power -> - return (b_crt, b, total_endorsing_power + endorsing_power)) + >>=? fun attesting_power -> + return (b_crt, b, total_attesting_power + attesting_power)) (b0, b1, 0) (1 -- (blocks_per_cycle - 2)) >>=? fun (_, _, _) -> return_unit diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preattestation.ml similarity index 73% rename from src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml rename to src/proto_alpha/lib_protocol/test/integration/consensus/test_preattestation.ml index f9d8a5774bc72aa81cdce144c59224d27afe64b5..835dd0b9147d43a69309710fe1dbfaafcc31d3d0 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preattestation.ml @@ -25,9 +25,9 @@ (** Testing ------- - Component: Protocol (preendorsement) + Component: Protocol (preattestation) Invocation: dune exec src/proto_alpha/lib_protocol/test/integration/consensus/main.exe \ - -- --file test_preendorsement.ml + -- --file test_preattestation.ml *) open Protocol @@ -45,17 +45,17 @@ let init_genesis ?policy () = (* Tests *) (****************************************************************) -(** Test that the preendorsement's branch does not affect its +(** Test that the preattestation's branch does not affect its validity. *) -let test_preendorsement_with_arbitrary_branch () = +let test_preattestation_with_arbitrary_branch () = Context.init1 () >>=? fun (genesis, _contract) -> Block.bake genesis >>=? fun blk -> 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 -(** Consensus operation for future level : apply a preendorsement with a level in the future *) -let test_consensus_operation_preendorsement_for_future_level () = +(** Consensus operation for future level : apply a preattestation with a level in the future *) +let test_consensus_operation_preattestation_for_future_level () = init_genesis () >>=? fun (_genesis, pred) -> let raw_level = Raw_level.of_int32 (Int32.of_int 10) in let level = match raw_level with Ok l -> l | Error _ -> assert false in @@ -71,8 +71,8 @@ let test_consensus_operation_preendorsement_for_future_level () = Preattestation Mempool -(** Consensus operation for old level : apply a preendorsement with a level in the past *) -let test_consensus_operation_preendorsement_for_old_level () = +(** Consensus operation for old level : apply a preattestation with a level in the past *) +let test_consensus_operation_preattestation_for_old_level () = init_genesis () >>=? fun (_genesis, grandparent) -> Block.bake grandparent >>=? fun pred -> let raw_level = Raw_level.of_int32 (Int32.of_int 0) in @@ -89,8 +89,8 @@ let test_consensus_operation_preendorsement_for_old_level () = Preattestation Mempool -(** Consensus operation for future round : apply a preendorsement with a round in the future *) -let test_consensus_operation_preendorsement_for_future_round () = +(** Consensus operation for future round : apply a preattestation with a round in the future *) +let test_consensus_operation_preattestation_for_future_round () = init_genesis () >>=? fun (_genesis, pred) -> Environment.wrap_tzresult (Round.of_int 21) >>?= fun round -> Consensus_helpers.test_consensus_operation @@ -100,8 +100,8 @@ let test_consensus_operation_preendorsement_for_future_round () = Preattestation Mempool -(** Consensus operation for old round : apply a preendorsement with a round in the past *) -let test_consensus_operation_preendorsement_for_old_round () = +(** Consensus operation for old round : apply a preattestation with a round in the past *) +let test_consensus_operation_preattestation_for_old_round () = init_genesis ~policy:(By_round 10) () >>=? fun (_genesis, pred) -> Environment.wrap_tzresult (Round.of_int 0) >>?= fun round -> Consensus_helpers.test_consensus_operation @@ -111,8 +111,8 @@ let test_consensus_operation_preendorsement_for_old_round () = Preattestation Mempool -(** Consensus operation on competing proposal : apply a preendorsement on a competing proposal *) -let test_consensus_operation_preendorsement_on_competing_proposal () = +(** Consensus operation on competing proposal : apply a preattestation on a competing proposal *) +let test_consensus_operation_preattestation_on_competing_proposal () = init_genesis () >>=? fun (_genesis, pred) -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ @@ -121,8 +121,8 @@ let test_consensus_operation_preendorsement_on_competing_proposal () = Preattestation Mempool -(** Unexpected preendorsements in block : apply a preendorsement with an incorrect round *) -let test_unexpected_preendorsements_in_blocks () = +(** Unexpected preattestations in block : apply a preattestation with an incorrect round *) +let test_unexpected_preattestations_in_blocks () = init_genesis () >>=? fun (_genesis, pred) -> Consensus_helpers.test_consensus_operation ~loc:__LOC__ @@ -133,7 +133,7 @@ let test_unexpected_preendorsements_in_blocks () = Preattestation Application -(** Round too high : apply a preendorsement with a too high round *) +(** Round too high : apply a preattestation with a too high round *) let test_too_high_round () = init_genesis () >>=? fun (_genesis, pred) -> let raw_level = Raw_level.of_int32 (Int32.of_int 2) in @@ -150,8 +150,8 @@ let test_too_high_round () = Preattestation Construction -(** Duplicate preendorsement : apply a preendorsement that has already been applied. *) -let test_duplicate_preendorsement () = +(** Duplicate preattestation : apply a preattestation that has already been applied. *) +let test_duplicate_preattestation () = init_genesis () >>=? fun (genesis, _) -> Block.bake genesis >>=? fun b -> Incremental.begin_construction ~mempool_mode:true b >>=? fun inc -> @@ -164,16 +164,16 @@ let test_duplicate_preendorsement () = res "Double inclusion of consensus operation" -(** Preendorsement for next level *) -let test_preendorsement_for_next_level () = +(** Preattestation for next level *) +let test_preattestation_for_next_level () = init_genesis () >>=? fun (genesis, _) -> Consensus_helpers.test_consensus_op_for_next ~genesis ~kind:`Preattestation ~next:`Level -(** Preendorsement for next round *) -let test_preendorsement_for_next_round () = +(** Preattestation for next round *) +let test_preattestation_for_next_round () = init_genesis () >>=? fun (genesis, _) -> Consensus_helpers.test_consensus_op_for_next ~genesis @@ -181,12 +181,12 @@ let test_preendorsement_for_next_round () = ~next:`Round let tests = - let module AppMode = Test_preendorsement_functor.BakeWithMode (struct + let module AppMode = Test_preattestation_functor.BakeWithMode (struct let name = "AppMode" let baking_mode = Block.Application end) in - let module ConstrMode = Test_preendorsement_functor.BakeWithMode (struct + let module ConstrMode = Test_preattestation_functor.BakeWithMode (struct let name = "ConstrMode" let baking_mode = Block.Baking @@ -194,48 +194,48 @@ let tests = AppMode.tests @ ConstrMode.tests @ [ Tztest.tztest - "Preendorsement with arbitrary branch" + "Preattestation with arbitrary branch" `Quick - test_preendorsement_with_arbitrary_branch; + test_preattestation_with_arbitrary_branch; Tztest.tztest - "Preendorsement for future level" + "Preattestation for future level" `Quick - test_consensus_operation_preendorsement_for_future_level; + test_consensus_operation_preattestation_for_future_level; Tztest.tztest - "Preendorsement for old level" + "Preattestation for old level" `Quick - test_consensus_operation_preendorsement_for_old_level; + test_consensus_operation_preattestation_for_old_level; Tztest.tztest - "Preendorsement for future round" + "Preattestation for future round" `Quick - test_consensus_operation_preendorsement_for_future_round; + test_consensus_operation_preattestation_for_future_round; Tztest.tztest - "Preendorsement for old round" + "Preattestation for old round" `Quick - test_consensus_operation_preendorsement_for_old_round; + test_consensus_operation_preattestation_for_old_round; Tztest.tztest - "Preendorsement on competing proposal" + "Preattestation on competing proposal" `Quick - test_consensus_operation_preendorsement_on_competing_proposal; + test_consensus_operation_preattestation_on_competing_proposal; Tztest.tztest - "Unexpected preendorsements in blocks" + "Unexpected preattestations in blocks" `Quick - test_unexpected_preendorsements_in_blocks; - Tztest.tztest "Preendorsements round too high" `Quick test_too_high_round; + test_unexpected_preattestations_in_blocks; + Tztest.tztest "Preattestations round too high" `Quick test_too_high_round; Tztest.tztest - "Duplicate preendorsement" + "Duplicate preattestation" `Quick - test_duplicate_preendorsement; + test_duplicate_preattestation; Tztest.tztest - "Preendorsement for next level" + "Preattestation for next level" `Quick - test_preendorsement_for_next_level; + test_preattestation_for_next_level; Tztest.tztest - "Preendorsement for next round" + "Preattestation for next round" `Quick - test_preendorsement_for_next_round; + test_preattestation_for_next_round; ] let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("preendorsement", tests)] + Alcotest_lwt.run ~__FILE__ Protocol.name [("preattestation", tests)] |> Lwt_main.run 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_preattestation_functor.ml similarity index 76% rename from src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml rename to src/proto_alpha/lib_protocol/test/integration/consensus/test_preattestation_functor.ml index f5607e0a93b69bd2746b63430d162a65346e7cbe..311e80cfefc1b5e456c775bdda481a7295b5faae 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_preendorsement_functor.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_preattestation_functor.ml @@ -25,8 +25,8 @@ (** Testing ------- - Component: Protocol (preendorsement) in Full_construction & Application modes - Subject: preendorsement inclusion in a block + Component: Protocol (preattestation) in Full_construction & Application modes + Subject: preattestation inclusion in a block *) open Protocol @@ -48,23 +48,23 @@ end = struct let bake = Block.bake ~baking_mode:Mode.baking_mode - let aux_simple_preendorsement_inclusion ?(payload_round = Some Round.zero) + let aux_simple_preattestation_inclusion ?(payload_round = Some Round.zero) ?(locked_round = Some Round.zero) ?(block_round = 1) - ?(preend_round = Round.zero) - ?(preendorsed_block = fun _predpred _pred curr -> curr) + ?(preattestation_round = Round.zero) + ?(preattested_block = fun _predpred _pred curr -> curr) ?(mk_ops = fun op -> [op]) ?(get_delegate_and_slot = fun _predpred _pred _curr -> return (None, None)) ?(post_process = Ok (fun _ -> return_unit)) ~loc () = Context.init_n ~consensus_threshold:1 5 () >>=? fun (genesis, _contracts) -> bake genesis >>=? fun b1 -> - Op.attestation b1 >>=? fun endo -> - bake b1 ~operations:[endo] >>=? fun b2 -> - let endorsed_block = preendorsed_block genesis b1 b2 in + Op.attestation b1 >>=? fun attestation -> + bake b1 ~operations:[attestation] >>=? fun b2 -> + let attested_block = preattested_block genesis b1 b2 in get_delegate_and_slot genesis b1 b2 >>=? fun (delegate, slot) -> - Op.preattestation ?delegate ?slot ~round:preend_round endorsed_block + Op.preattestation ?delegate ?slot ~round:preattestation_round attested_block >>=? fun p -> - let operations = endo :: (mk_ops @@ p) in + let operations = attestation :: (mk_ops @@ p) in bake ~payload_round ~locked_round @@ -84,12 +84,12 @@ end = struct (** OK: bake a block "_b2_1" at round 1, containing a PQC and a locked round of round 0 *) - let include_preendorsement_in_block_with_locked_round () = - aux_simple_preendorsement_inclusion ~loc:__LOC__ () + let include_preattestation_in_block_with_locked_round () = + aux_simple_preattestation_inclusion ~loc:__LOC__ () - (** KO: The same preendorsement injected twice in the PQC *) - let duplicate_preendorsement_in_pqc () = - aux_simple_preendorsement_inclusion (* inject the op twice *) + (** KO: The same preattestation injected twice in the PQC *) + let duplicate_preattestation_in_pqc () = + aux_simple_preattestation_inclusion (* inject the op twice *) ~mk_ops:(fun op -> [op; op]) ~loc:__LOC__ ~post_process: @@ -104,7 +104,7 @@ end = struct (** KO: locked round declared in the block is not smaller than that block's round *) let locked_round_not_before_block_round () = - aux_simple_preendorsement_inclusion + aux_simple_preattestation_inclusion (* default locked_round = 0 < block_round = 1 for this aux function *) ~block_round:0 ~loc:__LOC__ @@ -116,7 +116,7 @@ end = struct () (** KO: because we announce a locked_round, but we don't provide the - preendorsement quorum certificate in the operations *) + preattestation quorum certificate in the operations *) let with_locked_round_in_block_but_without_any_pqc () = (* This test only fails in Application mode. If full_construction mode, the given locked_round is not used / checked. Moreover, the test succeed in @@ -127,18 +127,18 @@ end = struct Error (function Fitness_repr.Wrong_fitness -> true | _ -> false) else Ok (fun _ -> return_unit) in - aux_simple_preendorsement_inclusion + aux_simple_preattestation_inclusion (* with declared locked_round but without a PQC in the ops *) ~mk_ops:(fun _p -> []) ~loc:__LOC__ ~post_process () - (** KO: The preendorsed block is the pred one, not the current one *) - let preendorsement_has_wrong_level () = - aux_simple_preendorsement_inclusion - (* preendorsement should be for _curr block to be valid *) - ~preendorsed_block:(fun _predpred pred _curr -> pred) + (** KO: The preattested block is the pred one, not the current one *) + let preattestation_has_wrong_level () = + aux_simple_preattestation_inclusion + (* preattestation should be for _curr block to be valid *) + ~preattested_block:(fun _predpred pred _curr -> pred) ~loc:__LOC__ ~post_process: (Error @@ -150,28 +150,28 @@ end = struct | _ -> false)) () - (** OK: explicit the correct endorser and preendorsing slot in the test *) - let preendorsement_in_block_with_good_slot () = - aux_simple_preendorsement_inclusion + (** OK: explicit the correct attester and preattesting slot in the test *) + let preattestation_in_block_with_good_slot () = + aux_simple_preattestation_inclusion ~get_delegate_and_slot:(fun _predpred _pred curr -> let module V = Plugin.RPC.Validators in 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 *)) + (* there is at least one attester with a slot *)) ~loc:__LOC__ () - (** KO: the used slot for injecting the endorsement is not the canonical one *) - let preendorsement_in_block_with_wrong_slot () = - aux_simple_preendorsement_inclusion + (** KO: the used slot for injecting the attestation is not the canonical one *) + let preattestation_in_block_with_wrong_slot () = + aux_simple_preattestation_inclusion ~get_delegate_and_slot:(fun _predpred _pred curr -> let module V = Plugin.RPC.Validators in Context.get_attesters (B curr) >>=? function | {V.delegate; V.slots = _ :: non_canonical_slot :: _; _} :: _ -> return (Some delegate, Some non_canonical_slot) | _ -> assert false - (* there is at least one endorser with a slot *)) + (* there is at least one attester with a slot *)) ~loc:__LOC__ ~post_process: (Error @@ -184,8 +184,8 @@ end = struct () (** KO: the delegate tries to injects with a canonical slot of another delegate *) - let preendorsement_in_block_with_wrong_signature () = - aux_simple_preendorsement_inclusion + let preattestation_in_block_with_wrong_signature () = + aux_simple_preattestation_inclusion ~get_delegate_and_slot:(fun _predpred _pred curr -> let module V = Plugin.RPC.Validators in Context.get_attesters (B curr) >>=? function @@ -193,7 +193,7 @@ end = struct (* the canonical slot s is not owned by the delegate "delegate" !*) return (Some delegate, Some s) | _ -> assert false - (* there is at least one endorser with a slot *)) + (* there is at least one attester with a slot *)) ~loc:__LOC__ ~post_process: (Error @@ -217,8 +217,8 @@ end = struct | _ -> false) else Ok (fun _ -> return_unit) in - aux_simple_preendorsement_inclusion - ~preend_round:Round.zero + aux_simple_preattestation_inclusion + ~preattestation_round:Round.zero ~locked_round:(Some (Round.succ Round.zero)) ~block_round:2 ~loc:__LOC__ @@ -231,13 +231,13 @@ end = struct let tests = [ my_tztest - "ok: include_preendorsement_in_block_with_locked_round" + "ok: include_preattestation_in_block_with_locked_round" `Quick - include_preendorsement_in_block_with_locked_round; + include_preattestation_in_block_with_locked_round; my_tztest - "ko: duplicate_preendorsement_in_pqc" + "ko: duplicate_preattestation_in_pqc" `Quick - duplicate_preendorsement_in_pqc; + duplicate_preattestation_in_pqc; my_tztest "ko:locked_round_not_before_block_round" `Quick @@ -247,21 +247,21 @@ end = struct `Quick with_locked_round_in_block_but_without_any_pqc; my_tztest - "ko: preendorsement_has_wrong_level" + "ko: preattestation_has_wrong_level" `Quick - preendorsement_has_wrong_level; + preattestation_has_wrong_level; my_tztest - "ok: preendorsement_in_block_with_good_slot" + "ok: preattestation_in_block_with_good_slot" `Quick - preendorsement_in_block_with_good_slot; + preattestation_in_block_with_good_slot; my_tztest - "ko: preendorsement_in_block_with_wrong_slot" + "ko: preattestation_in_block_with_wrong_slot" `Quick - preendorsement_in_block_with_wrong_slot; + preattestation_in_block_with_wrong_slot; my_tztest - "ko: preendorsement_in_block_with_wrong_signature" + "ko: preattestation_in_block_with_wrong_signature" `Quick - preendorsement_in_block_with_wrong_signature; + preattestation_in_block_with_wrong_signature; my_tztest "ko: locked_round_is_higher_than_pqc_round" `Quick 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 9955e5720ed23fc5466480434cba150f289020c6..4b542236f2086fb5bc992adea177a91760feffc6 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 @@ -279,7 +279,7 @@ let test_revelation_missing_and_late () = | Nonce_storage.Too_late_revelation -> true | _ -> false) -(** Test that we do not distribute endorsing rewards if the nonce was +(** Test that we do not distribute attesting rewards if the nonce was not revealed. *) let test_unrevealed () = let open Lwt_result_syntax in @@ -308,15 +308,15 @@ let test_unrevealed () = let blocks_per_commitment = Int32.to_int csts.parametric.blocks_per_commitment in - let bake_and_endorse_block ?policy (_pred_b, b) = + let bake_and_attest_block ?policy (_pred_b, b) = let* slots = Context.get_attesters (B b) in - let* endorsements = + let* attestations = List.map_es (fun {Plugin.RPC.Validators.consensus_key; _} -> Op.attestation ~delegate:consensus_key b) slots in - Block.bake ?policy ~operations:endorsements b + Block.bake ?policy ~operations:attestations b in (* Bake until commitment *) let* b = Block.bake_n (blocks_per_commitment - 2) b in @@ -325,7 +325,7 @@ let test_unrevealed () = let* b = Block.bake_until_cycle_end ~policy b in let* info_before = Context.Delegate.info (B b) delegate2 in let* b' = Block.bake ~policy b in - let* b = bake_and_endorse_block ~policy (b, b') in + let* b = bake_and_attest_block ~policy (b, b') in (* Finish cycle 1 excluding the first baker *) let* b = Block.bake_until_cycle_end ~policy b in let* info_after = Context.Delegate.info (B b) delegate2 in 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 579f79ebaf2cae09eb0c938c3297de2f3899ab09..099dfb2cb33edc4cbe1b94e031faa7f49804d97c 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 @@ -172,13 +172,13 @@ let test_not_tez_in_contract_to_pay_fee () = Incremental.add_operation inc op >>= fun inc -> Assert.proto_error_with_info ~loc:__LOC__ inc "Balance too low" -(* Set the endorser of the block as manager/delegate of the originated +(* Set the attester of the block as manager/delegate of the originated account. *) -let register_contract_get_endorser () = +let register_contract_get_attester () = Context.init1 () >>=? fun (b, contract) -> Incremental.begin_construction b >>=? fun inc -> - Context.get_attester (I inc) >|=? fun (account_endorser, _slots) -> - (inc, contract, account_endorser) + Context.get_attester (I inc) >|=? fun (account_attester, _slots) -> + (inc, contract, account_attester) (* Create multiple originated contracts and ask contract to pay the fee. *) let n_originations n ?credit ?fee () = diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml index e47518ed4e26febd73bc362b2e98f75985ff8a33..fec7043ee919a30435ad6e60190af84f8cf7d535 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml @@ -252,7 +252,7 @@ let context_init_tup tup ?(blocks_per_cycle = 4l) = accounts remain active during a voting period, which roughly translates to the following condition being assumed to hold: `blocks_per_voting_period <= preserved_cycles * blocks_per_cycle.` - We also set baking and endorsing rewards to zero in order to + We also set baking and attesting rewards to zero in order to ease accounting of exact baker stake. *) Context.init_gen tup diff --git a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml index 169f63696d5ad12c38327282677dabf0b3597c44..1174530beca9952653360c64c1dedf4215d18737 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml @@ -192,10 +192,10 @@ let liquidity_baking_subsidy_param () = get_reward ~reward_kind:Baking_reward_fixed_portion in baking_reward_fixed_portion +? baking_reward_bonus >>?= fun baking_rewards -> - let endorsing_reward_per_slot = + let attesting_reward_per_slot = get_reward ~reward_kind:Attesting_reward_per_slot in - endorsing_reward_per_slot *? Int64.of_int constants.consensus_committee_size + attesting_reward_per_slot *? Int64.of_int constants.consensus_committee_size >>?= fun validators_rewards -> baking_rewards +? validators_rewards >>?= fun total_rewards -> total_rewards /? 16L >>?= fun expected_subsidy -> 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 c601385cb1654513ad870c6efc62723d9320490c..27cf81624d366cd85018903a0130920ed8c85cea 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 @@ -27,11 +27,12 @@ open Protocol open Alpha_context open Validate_helpers -type dbl_endorsement_state = { +type dbl_attestation_state = { temporary : (Block.t * Block.t) option; - slashable_preend : + slashable_preattestations : (Kind.preattestation operation * Kind.preattestation operation) list; - slashable_end : (Kind.attestation operation * Kind.attestation operation) list; + slashable_attestations : + (Kind.attestation operation * Kind.attestation operation) list; } type state = { @@ -45,7 +46,7 @@ type state = { protocol_hashes : Protocol_hash.t list; slashable_bakes : (block_header * block_header) list; vdf : bool; - dbl_endorsement : dbl_endorsement_state; + dbl_attestation : dbl_attestation_state; manager : Manager.infos; } @@ -65,8 +66,12 @@ let init_manager_state bootstraps block = in {ctxt; accounts; flags = all_enabled} -let init_dbl_endorsement_state = - {temporary = None; slashable_preend = []; slashable_end = []} +let init_dbl_attestation_state = + { + temporary = None; + slashable_preattestations = []; + slashable_attestations = []; + } (** Initialize the state according to [state] initialisation for each operation kind. @@ -90,7 +95,7 @@ let init_state block ~voters ~(bootstraps : Contract.t list) = protocol_hashes = []; slashable_bakes = []; vdf = false; - dbl_endorsement = init_dbl_endorsement_state; + dbl_attestation = init_dbl_attestation_state; manager = init_manager_state bootstraps block; } @@ -319,10 +324,10 @@ let seed_nonce_descriptor = field of a double_evidence_state is used to transmit them to the next level in order to make the slashable operations. *) let register_temporary ba bb state : (Block.t * Block.t) option * state = - let pred_forks = state.dbl_endorsement.temporary in + let pred_forks = state.dbl_attestation.temporary in let temporary = Some (ba, bb) in - let dbl_endorsement = {state.dbl_endorsement with temporary} in - (pred_forks, {state with dbl_endorsement}) + let dbl_attestation = {state.dbl_attestation with temporary} in + (pred_forks, {state with dbl_attestation}) (** During the slashable period, at each level, two different heads for the same round are baked by the same baker. At the next level, @@ -337,10 +342,10 @@ let register_temporary ba bb state : (Block.t * Block.t) option * state = and two preattestation, can be made by two distinct attestations. Each pair is ordered in operation_hash order. Consequently, each pair can appear in a denunciation operation and will be valid. *) -let dbl_endorsement_prelude state = +let dbl_attestation_prelude state = let open Lwt_result_syntax in let* head_A = Block.bake ~policy:(By_round 0) state.block in - let* addr = pick_addr_endorser (B state.block) in + let* addr = pick_addr_attester (B state.block) in let ctr = Contract.Implicit addr in let* operation = Op.transaction (B state.block) ctr ctr Tez.one_mutez in let* head_B = Block.bake ~policy:(By_round 0) state.block ~operation in @@ -348,7 +353,7 @@ let dbl_endorsement_prelude state = match heads with | None -> return ([], state) | Some (b1, b2) -> - let* delegate1, delegate2 = pick_two_endorsers (B b1) in + let* delegate1, delegate2 = pick_two_attesters (B b1) in let* op1 = Op.raw_preattestation ~delegate:delegate1 b1 in let* op2 = Op.raw_preattestation ~delegate:delegate1 b2 in let op1, op2 = @@ -358,8 +363,8 @@ let dbl_endorsement_prelude state = assert (comp <> 0) ; if comp < 0 then (op1, op2) else (op2, op1) in - let slashable_preend = - (op1, op2) :: state.dbl_endorsement.slashable_preend + let slashable_preattestations = + (op1, op2) :: state.dbl_attestation.slashable_preattestations in let* op3 = Op.raw_attestation ~delegate:delegate2 b1 in let* op4 = Op.raw_attestation ~delegate:delegate2 b2 in @@ -370,18 +375,24 @@ let dbl_endorsement_prelude state = assert (comp <> 0) ; if comp < 0 then (op3, op4) else (op4, op3) in - let slashable_end = (op3, op4) :: state.dbl_endorsement.slashable_end in - let dbl_endorsement = - {state.dbl_endorsement with slashable_preend; slashable_end} + let slashable_attestations = + (op3, op4) :: state.dbl_attestation.slashable_attestations + in + let dbl_attestation = + { + state.dbl_attestation with + slashable_preattestations; + slashable_attestations; + } in - return ([], {state with dbl_endorsement}) + return ([], {state with dbl_attestation}) let double_consensus_descriptor = { parameters = Fun.id; required_cycle = (fun _params -> 2); required_block = (fun _ -> 0); - prelude = (From 2, dbl_endorsement_prelude); + prelude = (From 2, dbl_attestation_prelude); opt_prelude = None; candidates_generator = (fun state -> @@ -393,10 +404,10 @@ let double_consensus_descriptor = Op.double_attestation (Context.B state.block) op1 op2 in let candidates_pre = - List.map gen_dbl_pre state.dbl_endorsement.slashable_preend + List.map gen_dbl_pre state.dbl_attestation.slashable_preattestations in let candidates_end = - List.map gen_dbl_end state.dbl_endorsement.slashable_end + List.map gen_dbl_end state.dbl_attestation.slashable_attestations in return (candidates_pre @ candidates_end)); } @@ -433,7 +444,7 @@ let double_baking_descriptor = let* baker1, _baker2 = Context.get_first_different_bakers (B state.block) in - let* addr = pick_addr_endorser (B state.block) in + let* addr = pick_addr_attester (B state.block) in let ctr = Contract.Implicit addr in let* operation = Op.transaction (B state.block) ctr ctr Tez.one_mutez @@ -567,7 +578,7 @@ let vdf_revelation_descriptor = return [Op.vdf_revelation (B state.block) solution]); } -let preendorsement_descriptor = +let preattestation_descriptor = { parameters = Fun.id; required_cycle = (fun _ -> 1); @@ -592,7 +603,7 @@ let preendorsement_descriptor = List.filter_map_es gen state.delegates); } -let endorsement_descriptor = +let attestation_descriptor = { parameters = Fun.id; required_cycle = (fun _ -> 1); @@ -819,8 +830,8 @@ let manager_descriptor max_batch_size nb_accounts = } type op_kind = - | KEndorsement - | KPreendorsement + | KAttestation + | KPreattestation | KDalattestation | KBallotExp | KBallotProm @@ -836,8 +847,8 @@ type op_kind = let op_kind_of_packed_operation op = let (Operation_data {contents; _}) = op.protocol_data in match contents with - | Single (Preattestation _) -> KPreendorsement - | Single (Attestation _) -> KEndorsement + | Single (Preattestation _) -> KPreattestation + | Single (Attestation _) -> KAttestation | Single (Dal_attestation _) -> KDalattestation | Single (Seed_nonce_revelation _) -> KNonce | Single (Vdf_revelation _) -> KVdf @@ -857,8 +868,8 @@ let pp_op_kind fmt kind = fmt (match kind with | KManager -> "manager" - | KEndorsement -> "endorsement" - | KPreendorsement -> "preendorsement" + | KAttestation -> "attestation" + | KPreattestation -> "preattestation" | KDalattestation -> "dal_attestation" | KBallotExp -> "ballot" | KBallotProm -> "ballot" @@ -872,8 +883,8 @@ let pp_op_kind fmt kind = let descriptor_of ~nb_bootstrap ~max_batch_size = function | KManager -> manager_descriptor max_batch_size nb_bootstrap - | KEndorsement -> endorsement_descriptor - | KPreendorsement -> preendorsement_descriptor + | KAttestation -> attestation_descriptor + | KPreattestation -> preattestation_descriptor | KDalattestation -> dal_attestation_descriptor | KBallotExp -> ballot_exploration_descriptor | KBallotProm -> ballot_promotion_descriptor @@ -899,8 +910,8 @@ let nonce_generation_kinds = [KNonce; KVdf] let non_exclusive_kinds = [ KManager; - KEndorsement; - KPreendorsement; + KAttestation; + KPreattestation; KDalattestation; KActivate; KDbl_consensus; diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli index 5bf43d64d9b9ac091fce16794a1e9d157b87eae6..a253dbec124560ad02d373fea17e4220e45876be 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli @@ -29,15 +29,16 @@ open Validate_helpers (** {2 Generation state} *) -(** The state to generate valid double pre- and endorsement evidence +(** The state to generate valid double pre- and attestation evidence contains a temporary state for making the slashable evidence, and the lists of slashables operations, one for each kind: - preendorsement and endorsement. *) -type dbl_endorsement_state = { + preattestation and attestation. *) +type dbl_attestation_state = { temporary : (Block.t * Block.t) option; - slashable_preend : + slashable_preattestations : (Kind.preattestation operation * Kind.preattestation operation) list; - slashable_end : (Kind.attestation operation * Kind.attestation operation) list; + slashable_attestations : + (Kind.attestation operation * Kind.attestation operation) list; } (** Generic generation state collecting @@ -60,7 +61,7 @@ type state = { protocol_hashes : Protocol_hash.t list; slashable_bakes : (block_header * block_header) list; vdf : bool; - dbl_endorsement : dbl_endorsement_state; + dbl_attestation : dbl_attestation_state; manager : Manager.infos; } @@ -120,8 +121,8 @@ type descriptor = { [non_exclusive_kinds]. Otherwise, see, for example, how voting operation op_kinds are handled in {! test_covalidity.tests}. *) type op_kind = - | KEndorsement - | KPreendorsement + | KAttestation + | KPreattestation | KDalattestation | KBallotExp | KBallotProm diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/test_covalidity.ml b/src/proto_alpha/lib_protocol/test/integration/validate/test_covalidity.ml index a2e5e88fb495126a589f96505d4c85bb1a205f86..b9b3ac7c4b462ca13d27d549ca79d19813e54bdc 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/test_covalidity.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/test_covalidity.ml @@ -59,7 +59,7 @@ let pp_seed fmt = function let op_of_seed_gen = function Nonce -> KNonce | Vdf -> KVdf -let is_not_preendorsement op = +let is_not_preattestation op = let open Protocol.Alpha_context in let (Operation_data {contents; _}) = op.protocol_data in match contents with Single (Preattestation _) -> false | _ -> true @@ -106,7 +106,7 @@ let covalid_permutation_and_bake ks nb_bootstrap = QCheck2.Gen.shuffle_l candidates |> QCheck2.Gen.generate1 |> List.sort Protocol.Alpha_context.Operation.compare_by_passes - |> List.rev_filter is_not_preendorsement + |> List.rev_filter is_not_preattestation in (* Ensure that we can validate and apply this permutation *) let* (_ : Block.t) = diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml b/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml index 3418f015a441108eadba71af2e85f80260a4b52b..439db456ea92017532ea4af097969f9e5b3011f8 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/test_sanity.ml @@ -118,9 +118,9 @@ let covalidation_sanity () = failwith "no candidates was generated for kind '%a'" pp_op_kind kind | Some {protocol_data = Operation_data {contents; _}; _} -> ( match (contents, kind) with - | Single (Preattestation _), KPreendorsement -> return_unit + | Single (Preattestation _), KPreattestation -> return_unit | Single (Preattestation _), _ -> assert false - | Single (Attestation _), KEndorsement -> return_unit + | Single (Attestation _), KAttestation -> return_unit | Single (Attestation _), _ -> assert false | Single (Dal_attestation _), KDalattestation -> return_unit | Single (Dal_attestation _), _ -> assert false 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 1d93fa986479af1b1464f56ce4bfb9fec3d64bee..5b7310bf102e05c0ae4d0436a98982b9013e6df8 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 @@ -359,13 +359,13 @@ let secrets = (** {3 Context Manipulations } *) -let pick_two_endorsers ctxt = +let pick_two_attesters ctxt = let module V = Plugin.RPC.Validators in Context.get_attesters ctxt >>=? function | a :: b :: _ -> return (a.V.consensus_key, b.V.consensus_key) | _ -> assert false -let pick_addr_endorser ctxt = +let pick_addr_attester ctxt = let module V = Plugin.RPC.Validators in Context.get_attesters ctxt >>=? function | a :: _ -> return a.V.consensus_key diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml b/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml index a9086ffaf8a73280d1c2e2f05dd6b87afa9fd5f7..89e20e66ac50edb56e82f3dc1ab68317f539d2cc 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml @@ -61,7 +61,7 @@ let deposits = let+ staker in Receipt_repr.Deposits staker -let lost_endorsing_rewards = +let lost_attesting_rewards = let pkh, _, _ = Signature.generate_key () in Receipt_repr.Lost_attesting_rewards (pkh, false, false) @@ -96,7 +96,7 @@ let generate_balance = return Baking_bonuses; return Storage_fees; return Double_signing_punishments; - return lost_endorsing_rewards; + return lost_attesting_rewards; return Liquidity_baking_subsidies; return Burned; return commitments;