From 32af64aa141e1a951dd81abd86ce6cc4b6720dfd Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 26 Jul 2023 10:46:07 +0200 Subject: [PATCH 1/5] tezt/tests: revamp propagation of future endorsement test --- tezt/tests/prevalidator.ml | 426 ++++++++++++++----------------------- 1 file changed, 154 insertions(+), 272 deletions(-) diff --git a/tezt/tests/prevalidator.ml b/tezt/tests/prevalidator.ml index 9941e642c9ca..8b743714849e 100644 --- a/tezt/tests/prevalidator.ml +++ b/tezt/tests/prevalidator.ml @@ -2060,6 +2060,159 @@ module Revamped = struct client3 in unit + + (** This test checks that future endorsements are correctly propagated, either + immediately or when the head is sufficiently incremented. *) + let propagation_future_endorsement = + Protocol.register_test + ~__FILE__ + ~title:"Ensure that future endorsements are propagated" + ~tags:["endorsement"; "mempool"; "branch_delayed"] + ~supports:Protocol.(From_protocol (number Nairobi)) + @@ fun protocol -> + log_step 1 "Initialize 3 nodes, connect them, and activate the protocol." ; + let nodes_args = Node.[Synchronisation_threshold 0; Private_mode] in + let event_sections_levels = [("prevalidator", `Debug)] in + let* node_1, client_1 = Client.init_with_node ~nodes_args `Client () + and* node_2, client_2 = + Client.init_with_node ~event_sections_levels ~nodes_args `Client () + and* node_3, client_3 = + Client.init_with_node ~event_sections_levels ~nodes_args `Client () + in + let* () = Client.Admin.trust_address client_1 ~peer:node_2 + and* () = Client.Admin.trust_address client_2 ~peer:node_1 + and* () = Client.Admin.trust_address client_2 ~peer:node_3 + and* () = Client.Admin.trust_address client_3 ~peer:node_2 in + let* () = Client.Admin.connect_address client_1 ~peer:node_2 + and* () = Client.Admin.connect_address client_2 ~peer:node_3 in + let* () = Client.activate_protocol_and_wait ~protocol client_1 in + let* _ = Node.wait_for_level node_2 1 + and* _ = Node.wait_for_level node_3 1 in + + log_step 2 "Disconnect all the nodes from each other." ; + let* node_1_id = Node.wait_for_identity node_1 + and* node_2_id = Node.wait_for_identity node_2 + and* node_3_id = Node.wait_for_identity node_3 in + let* () = Client.Admin.kick_peer client_1 ~peer:node_2_id + and* () = Client.Admin.kick_peer client_2 ~peer:node_1_id + and* () = Client.Admin.kick_peer client_2 ~peer:node_3_id + and* () = Client.Admin.kick_peer client_3 ~peer:node_2_id in + + let retrieve_attestation client = + let* mempool = + RPC.Client.call client + @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + in + let op = List.hd JSON.(mempool |-> "validated" |> as_list) in + let oph = JSON.(op |-> "hash" |> as_string) in + let branch = JSON.(op |-> "branch" |> as_string) in + let content = JSON.(op |-> "contents" |> as_list |> List.hd) in + let kind = JSON.(content |-> "kind" |> as_string) in + let expected_kind = + if Protocol.number protocol < 018 then "endorsement" else "attestation" + in + Check.( + (expected_kind = kind) + string + ~error_msg:"Invalid operation kind, expected: %L, got %R") ; + let slot = JSON.(content |-> "slot" |> as_int) in + let level = JSON.(content |-> "level" |> as_int) in + let round = JSON.(content |-> "round" |> as_int) in + let block_payload_hash = + JSON.(content |-> "block_payload_hash" |> as_string) + in + let op = + Operation.Consensus.attestation + ~use_legacy_name:true + ~slot + ~level + ~round + ~block_payload_hash + in + return (op, branch, oph) + in + + log_step + 3 + "Bake a block on node_1 then inject an endorsement, which is one level \ + in the future from the perspective of nodes 2 and 3. Retrieve the hash \ + and bytes representing this endorsement, called future1 from now on." ; + let* () = Client.bake_for_and_wait ~node:node_1 client_1 in + let injection_waiter = Node.wait_for_request ~request:`Inject node_1 in + let* () = Client.attest_for client_1 ~force:true ~protocol in + let* () = injection_waiter in + let* op_future1, branch_future1, oph_future1 = + retrieve_attestation client_1 + in + + log_step + 4 + "Bake another block on node_1 then inject another endorsement, which is \ + two levels in the future from the perspective of nodes 2 and 3. \ + Retrieve the hash and bytes representing this endorsement, called \ + future2." ; + let* () = Node_event_level.bake_wait_log node_1 client_1 in + + let injection_waiter2 = Node.wait_for_request ~request:`Inject node_1 in + let* () = Client.attest_for client_1 ~force:true ~protocol in + let* () = injection_waiter2 in + let* op_future2, branch_future2, oph_future2 = + retrieve_attestation client_1 + in + + log_step 5 "Inject both endorsements in node_2." ; + let* _ = + Operation.Consensus.inject + ~force:true + ~branch:branch_future1 + ~signer:Constant.bootstrap1 + op_future1 + client_2 + in + let* _ = + Operation.Consensus.inject + ~force:true + ~branch:branch_future2 + ~signer:Constant.bootstrap1 + op_future2 + client_2 + in + + log_step 6 "Reconnect node_2 and node_3, and synchronize their mempools." ; + let* () = Client.Admin.trust_address client_2 ~peer:node_3 + and* () = Client.Admin.trust_address client_3 ~peer:node_2 in + let* () = Client.Admin.connect_address client_2 ~peer:node_3 in + let* () = synchronize_mempool client_3 node_3 in + + log_step + 7 + "Check that both endorsements are in the mempool of node_2: future1 is \ + validated; future2 is branch_delayed." ; + let* () = + check_mempool + ~validated:[oph_future1] + ~branch_delayed:[oph_future2] + client_2 + in + + log_step 8 "Check that future1 is validated in node_3 mempool." ; + let* () = check_mempool ~validated:[oph_future1] client_3 in + + log_step + 9 + "Bake one block on node_2 and synchronize its mempool. Check that \ + future1 is now validated, as well as future2." ; + let* () = Node_event_level.bake_wait_log node_2 client_2 in + let* () = synchronize_mempool client_2 node_2 in + let* () = check_mempool ~validated:[oph_future1; oph_future2] client_2 in + + log_step + 10 + "Synchronize the mempool of node_3. Check that future1 and future2 are \ + validated." ; + let* () = synchronize_mempool client_3 node_3 in + let* () = check_mempool ~validated:[oph_future1; oph_future2] client_3 in + unit end let check_operation_is_in_applied_mempool ops oph = @@ -2124,9 +2277,6 @@ let pp_mempool_count fmt outdated unprocessed -(** Wait for an injection request event. *) -let wait_for_injection = Node.wait_for_request ~request:`Inject - (** Matches events which contain an flush request. For example: @@ -2214,274 +2364,6 @@ let forge_and_inject_operation ~branch ~fee ~gas_limit ~source ~destination (* TODO: add a test than ensure that we cannot have more than 1000 branch delayed/branch refused/refused *) -let check_if_op_is_in_mempool client ~classification oph = - let* ops = - RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"1" () - in - let open JSON in - let search_in ops c = - List.exists - (fun op -> get "hash" op |> as_string = oph) - (ops |-> c |> as_list) - in - match classification with - | Some c -> - let res = search_in ops c in - if not res then Test.fail "%s not found in %s" oph c else unit - | None -> - let res = - List.exists - (fun c -> search_in ops c) - ["applied"; "branch_refused"; "branch_delayed"; "refused"; "outdated"] - in - if res then Test.fail "%s found in mempool" oph else unit - -let get_endorsement_as_bytes client = - let* mempool = - RPC.Client.call client @@ RPC.get_chain_mempool_pending_operations () - in - let open JSON in - let ops_list = as_list (mempool |-> "applied") in - let op = - match ops_list with - | [op] -> op - | _ -> - Test.fail - "Applied field of mempool should contain one and only one operation" - in - let hash = JSON.get "hash" op |> as_string in - let shell = - let branch = JSON.as_string (JSON.get "branch" op) in - match Data_encoding.Json.from_string (sf {|{"branch":"%s"}|} branch) with - | Ok b -> - Data_encoding.Json.destruct Tezos_base.Operation.shell_header_encoding b - | Error e -> Test.fail "Data_encoding branch from %s error %s" branch e - in - let contents = - match JSON.as_list (JSON.get "contents" op) with - | [content] -> content - | _ -> Test.fail "Contents should countain only one element" - in - let slot = - let slot_elt = JSON.get "slot" contents |> JSON.as_int in - match Data_encoding.Json.from_string (sf {|%d|} slot_elt) with - | Ok e -> - Data_encoding.Json.destruct - Tezos_protocol_alpha.Protocol.Slot_repr.encoding - e - | Error _ -> Test.fail "foo" - in - - let get_signature op = - let signature = JSON.get "signature" op |> JSON.as_string in - match Data_encoding.Json.from_string (sf {|"%s"|} signature) with - | Ok s -> Data_encoding.Json.destruct Tezos_crypto.Signature.encoding s - | Error e -> - Test.fail - "Data_encoding signature from string %s : error %s" - signature - e - in - let wrapped_bytes = - let signature = get_signature op in - let kind = JSON.get "kind" contents |> JSON.as_string in - if not (kind = "endorsement") then - Test.fail "Operation kind should be endorsement, got %s" kind ; - let level = - Tezos_protocol_alpha.Protocol.Raw_level_repr.of_int32_exn - (Int32.of_int (JSON.get "level" contents |> JSON.as_int)) - in - let round = - let round = JSON.get "round" contents |> JSON.as_int in - match - Tezos_protocol_alpha.Protocol.Round_repr.of_int32 (Int32.of_int round) - with - | Ok round -> round - | Error _ -> - Test.fail - "Could not create a round with %d (from the mempool result) " - round - in - let block_payload_hash = - let block_payload_hash = - JSON.get "block_payload_hash" contents |> JSON.as_string - in - Tezos_protocol_alpha.Protocol.Block_payload_hash.of_b58check_exn - block_payload_hash - in - let wrapped = - Tezos_protocol_alpha.Protocol.Operation_repr. - { - shell; - protocol_data = - Operation_data - { - contents = - Single (Attestation {slot; round; level; block_payload_hash}); - signature = Some signature; - }; - } - in - Data_encoding.Binary.to_bytes_exn - Tezos_protocol_alpha.Protocol.Operation_repr.encoding - wrapped - in - Lwt.return (wrapped_bytes, hash) - -let mempool_synchronisation client node = - let waiter = Node.wait_for_request ~request:`Notify node in - let* _ = - RPC.Client.call client @@ RPC.post_chain_mempool_request_operations () - in - waiter - -(** This test checks that future endorsements are correctly - propagated, either immediately or when the head is sufficiently - incremented. *) -let propagation_future_endorsement = - Protocol.register_test - ~__FILE__ - ~title:"Ensure that future endorsements are propagated" - ~tags:["endorsement"; "mempool"; "branch_delayed"] - @@ fun protocol -> - (* For this test to be moved to {!Revamped}, we need to update its - auxiliary functions. Notably, {!get_endorsement_as_bytes} should - use the {!Operation} module to build the endorsement bytes. *) - let log_step = Revamped.log_step in - log_step 1 "Initialize 3 nodes, connect them, and activate the protocol." ; - let* node_1 = Node.init [Synchronisation_threshold 0; Private_mode] - and* node_2 = - Node.init - ~event_sections_levels:[("prevalidator", `Debug)] - [Synchronisation_threshold 0; Private_mode] - and* node_3 = - Node.init - ~event_sections_levels:[("prevalidator", `Debug)] - [Synchronisation_threshold 0; Private_mode] - in - let* client_1 = Client.init ~endpoint:(Node node_1) () - and* client_2 = Client.init ~endpoint:(Node node_2) () - and* client_3 = Client.init ~endpoint:(Node node_3) () in - let* () = Client.Admin.trust_address client_1 ~peer:node_2 - and* () = Client.Admin.trust_address client_2 ~peer:node_1 - and* () = Client.Admin.trust_address client_2 ~peer:node_3 - and* () = Client.Admin.trust_address client_3 ~peer:node_2 in - let* () = Client.Admin.connect_address client_1 ~peer:node_2 - and* () = Client.Admin.connect_address client_2 ~peer:node_3 in - let* () = Client.activate_protocol_and_wait ~protocol client_1 in - let* _ = Node.wait_for_level node_2 1 and* _ = Node.wait_for_level node_3 1 in - log_step 2 "Disconnect all the nodes from each other." ; - let* node_1_id = Node.wait_for_identity node_1 - and* node_2_id = Node.wait_for_identity node_2 - and* node_3_id = Node.wait_for_identity node_3 in - let* () = Client.Admin.kick_peer client_1 ~peer:node_2_id - and* () = Client.Admin.kick_peer client_2 ~peer:node_1_id - and* () = Client.Admin.kick_peer client_2 ~peer:node_3_id - and* () = Client.Admin.kick_peer client_3 ~peer:node_2_id in - log_step - 3 - "Bake a block on node_1 then inject an endorsement, which is one level in \ - the future from the perspective of nodes 2 and 3. Retrieve the hash and \ - bytes representing this endorsement, called future1 from now on." ; - let* () = Node_event_level.bake_wait_log node_1 client_1 in - let injection_waiter = wait_for_injection node_1 in - let* () = Client.attest_for client_1 ~force:true ~protocol in - let* () = injection_waiter in - let* bytes_future1, oph_future1 = get_endorsement_as_bytes client_1 in - log_step - 4 - "Bake another block on node_1 then inject another endorsement, which is \ - two levels in the future from the perspective of nodes 2 and 3. Retrieve \ - the hash and bytes representing this endorsement, called future2." ; - let* () = Node_event_level.bake_wait_log node_1 client_1 in - let injection_waiter2 = wait_for_injection node_1 in - let* () = Client.attest_for client_1 ~force:true ~protocol in - let* () = injection_waiter2 in - let* bytes_future2, oph_future2 = get_endorsement_as_bytes client_1 in - log_step 5 "Inject both endorsements in node_2." ; - let inject_bytes_in_node_2 bytes = - let (`Hex bytes) = Hex.of_bytes bytes in - let injection_waiter = wait_for_injection node_2 in - let* (_ : JSON.t) = - RPC.Client.call client_2 - @@ RPC.post_private_injection_operation (Data (`String bytes)) - in - injection_waiter - in - let* () = inject_bytes_in_node_2 bytes_future1 in - let* () = inject_bytes_in_node_2 bytes_future2 in - log_step 6 "Reconnect node_2 and node_3, and synchronize their mempools." ; - let* () = Client.Admin.trust_address client_2 ~peer:node_3 - and* () = Client.Admin.trust_address client_3 ~peer:node_2 in - let* () = Client.Admin.connect_address client_2 ~peer:node_3 in - let* () = mempool_synchronisation client_3 node_3 in - log_step - 7 - "Check that both endorsements are in the mempool of node_2: future1 is \ - branch_delayed for protocols 016 and before, and applied for protocol 017 \ - on; future2 is branch_delayed for all protocols." ; - (* From protocol N on, consensus operations that are one level in - the future are accepted and propagated by the mempool. *) - let accept_one_level_in_future = Protocol.number protocol >= 017 in - let* () = - let classification = - Some (if accept_one_level_in_future then "applied" else "branch_delayed") - in - check_if_op_is_in_mempool client_2 ~classification oph_future1 - in - let* () = - let classification = Some "branch_delayed" in - check_if_op_is_in_mempool client_2 ~classification oph_future2 - in - log_step - 8 - "Check that none of the endorsements is in node_3 mempool for protocols \ - 016 and before. For protocol 017 on, only future1 is present (and \ - applied) in node_3 mempool." ; - let* () = - let classification = - if accept_one_level_in_future then Some "applied" else None - in - check_if_op_is_in_mempool client_3 ~classification oph_future1 - in - let* () = - check_if_op_is_in_mempool client_3 ~classification:None oph_future2 - in - log_step - 9 - "Bake one block on node_2 and synchronize its mempool. Check that future1 \ - is now applied for all protocols, and future2 is also applied for \ - protocol 017 on." ; - let* () = Node_event_level.bake_wait_log node_2 client_2 in - let* () = mempool_synchronisation client_2 node_2 in - let* () = - let classification = Some "applied" in - check_if_op_is_in_mempool client_2 ~classification oph_future1 - in - let* () = - let classification = - Some (if accept_one_level_in_future then "applied" else "branch_delayed") - in - check_if_op_is_in_mempool client_2 ~classification oph_future2 - in - log_step - 10 - "Synchronize the mempool of node_3. Check that future1 is present and \ - applied for both protocols, and so is future2 for protocol 017 on." ; - let* () = mempool_synchronisation client_3 node_3 in - let* () = - let classification = Some "applied" in - check_if_op_is_in_mempool client_3 ~classification oph_future1 - in - let* () = - let classification = - if accept_one_level_in_future then Some "applied" else None - in - check_if_op_is_in_mempool client_3 ~classification oph_future2 - in - unit - let check_empty_operation__ddb ddb = let open JSON in let op_db_length = as_int (ddb |-> "operation_db" |-> "table_length") in @@ -3908,7 +3790,7 @@ let register ~protocols = Revamped.inject_operations protocols ; Revamped.test_inject_manager_batch protocols ; Revamped.mempool_disabled protocols ; - propagation_future_endorsement protocols ; + Revamped.propagation_future_endorsement protocols ; forge_pre_filtered_operation protocols ; refetch_failed_operation protocols ; ban_operation_and_check_applied protocols ; -- GitLab From 419788b02b61f1370200e4d2704b474e74129e5f Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 24 Jul 2023 16:25:48 +0200 Subject: [PATCH 2/5] tezt/tests: rename endorsement in prevalidator --- tezt/tests/prevalidator.ml | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/tezt/tests/prevalidator.ml b/tezt/tests/prevalidator.ml index 8b743714849e..e5aba9beca2f 100644 --- a/tezt/tests/prevalidator.ml +++ b/tezt/tests/prevalidator.ml @@ -197,22 +197,22 @@ module Revamped = struct in Check.((mempool = mempool_after_empty_block) Mempool.typ ~error_msg) ; - log_step 6 "Inject endorsement operations." ; + log_step 6 "Inject attestation operations." ; let* () = Client.attest_for client ~protocol ~force:true in - let* mempool_with_endorsement = Mempool.get_mempool client in + let* mempool_with_attestation = Mempool.get_mempool client in - log_step 7 "Check endorsement is validated." ; + log_step 7 "Check attestation is validated." ; let mempool_diff = - Mempool.symmetric_diff mempool_after_empty_block mempool_with_endorsement + Mempool.symmetric_diff mempool_after_empty_block mempool_with_attestation in - (* [mempool_diff] should contain only the validated endorsement. *) + (* [mempool_diff] should contain only the validated attestation. *) let mempool_expected = let open Mempool in try {empty with validated = [List.hd mempool_diff.validated]} with Not_found -> {empty with validated = [""]} in - let error_msg = "endorsement is not validated: expected %L, got %R" in + let error_msg = "attestation is not validated: expected %L, got %R" in Check.((mempool_expected = mempool_diff) Mempool.typ ~error_msg) ; log_step 8 "Bake with an empty mempool twice." ; @@ -225,11 +225,11 @@ module Revamped = struct in let* last_mempool = Mempool.get_mempool client in - log_step 9 "Check endorsement is classified 'Outdated'." ; + log_step 9 "Check attestation is classified 'Outdated'." ; let error_msg = "one validated operation was lost: expected %L, got %R" in - Check.((mempool_with_endorsement = last_mempool) Mempool.typ ~error_msg) ; + Check.((mempool_with_attestation = last_mempool) Mempool.typ ~error_msg) ; let error_msg = - "endorsement is not classified as 'outdated': length expected %L, got %R" + "attestation is not classified as 'outdated': length expected %L, got %R" in Check.( (List.compare_length_with last_mempool.outdated 1 = 0) int ~error_msg) ; @@ -374,12 +374,12 @@ module Revamped = struct let* () = Client.Admin.connect_address client1 ~peer:node2 in (* TODO: this test should be adapt once the [bake for] command will have - an option to not automatically add an endorsement to a block that is + an option to not automatically add an attestation to a block that is being bake. Only one operation will be reclassified after that. *) log_step 13 "Check that %s is set to be reclassified on new branch as well as the \ - endorsement from the head increment on node1." + attestation from the head increment on node1." oph2 ; let* pending = bake_waiter1 in let error_msg = @@ -390,7 +390,7 @@ module Revamped = struct log_step 14 "Check that the mempool of node1 still contains %s as branch_refused \ - operation and that the endorsement from the head increment block is now \ + operation and that the attestation from the head increment block is now \ outdated." oph2 ; let* mempool = Mempool.get_mempool client1 in @@ -1215,10 +1215,10 @@ module Revamped = struct let* client = Client.init ~endpoint:(Node node) () in let* () = Client.activate_protocol_and_wait ~protocol client in - log_step 2 "Bake an empty block to be able to endorse it." ; + log_step 2 "Bake an empty block to be able to attest it." ; let* _ = bake_for ~empty:true ~protocol ~wait_for_flush:true node client in - log_step 3 "Endorse with bootstrap1." ; + log_step 3 "Attest with bootstrap1." ; let* _ = Client.attest_for ~protocol @@ -1227,7 +1227,7 @@ module Revamped = struct client in - log_step 3 "Endorse with bootstrap2." ; + log_step 3 "Attest with bootstrap2." ; let* _ = Client.attest_for ~protocol @@ -1236,7 +1236,7 @@ module Revamped = struct client in - log_step 4 "Check that both endorsements are in the validated mempool." ; + log_step 4 "Check that both attestations are in the validated mempool." ; let* mempool = Mempool.get_mempool client in Check.( (2 = List.length mempool.validated) @@ -1244,11 +1244,11 @@ module Revamped = struct ~error_msg: "number of mempool validated operations expected to be %L, got %R") ; - log_step 5 "Bake two empty block to force endorsements to be outdated." ; + log_step 5 "Bake two empty block to force attestations to be outdated." ; let* _ = bake_for ~empty:true ~protocol ~wait_for_flush:true node client in let* _ = bake_for ~empty:true ~protocol ~wait_for_flush:true node client in - log_step 4 "Check that only one endorsement is in the outdated mempool." ; + log_step 4 "Check that only one attestation is in the outdated mempool." ; let* mempool = Mempool.get_mempool client in Check.( (max_refused_operations = List.length mempool.outdated) @@ -2061,13 +2061,13 @@ module Revamped = struct in unit - (** This test checks that future endorsements are correctly propagated, either + (** This test checks that future attestations are correctly propagated, either immediately or when the head is sufficiently incremented. *) - let propagation_future_endorsement = + let propagation_future_attestation = Protocol.register_test ~__FILE__ - ~title:"Ensure that future endorsements are propagated" - ~tags:["endorsement"; "mempool"; "branch_delayed"] + ~title:"Ensure that future attestations are propagated" + ~tags:["attestation"; "mempool"; "branch_delayed"] ~supports:Protocol.(From_protocol (number Nairobi)) @@ fun protocol -> log_step 1 "Initialize 3 nodes, connect them, and activate the protocol." ; @@ -2134,9 +2134,9 @@ module Revamped = struct log_step 3 - "Bake a block on node_1 then inject an endorsement, which is one level \ + "Bake a block on node_1 then inject an attestation, which is one level \ in the future from the perspective of nodes 2 and 3. Retrieve the hash \ - and bytes representing this endorsement, called future1 from now on." ; + and bytes representing this attestation, called future1 from now on." ; let* () = Client.bake_for_and_wait ~node:node_1 client_1 in let injection_waiter = Node.wait_for_request ~request:`Inject node_1 in let* () = Client.attest_for client_1 ~force:true ~protocol in @@ -2147,9 +2147,9 @@ module Revamped = struct log_step 4 - "Bake another block on node_1 then inject another endorsement, which is \ + "Bake another block on node_1 then inject another attestation, which is \ two levels in the future from the perspective of nodes 2 and 3. \ - Retrieve the hash and bytes representing this endorsement, called \ + Retrieve the hash and bytes representing this attestation, called \ future2." ; let* () = Node_event_level.bake_wait_log node_1 client_1 in @@ -2160,7 +2160,7 @@ module Revamped = struct retrieve_attestation client_1 in - log_step 5 "Inject both endorsements in node_2." ; + log_step 5 "Inject both attestations in node_2." ; let* _ = Operation.Consensus.inject ~force:true @@ -2186,7 +2186,7 @@ module Revamped = struct log_step 7 - "Check that both endorsements are in the mempool of node_2: future1 is \ + "Check that both attestations are in the mempool of node_2: future1 is \ validated; future2 is branch_delayed." ; let* () = check_mempool @@ -3790,7 +3790,7 @@ let register ~protocols = Revamped.inject_operations protocols ; Revamped.test_inject_manager_batch protocols ; Revamped.mempool_disabled protocols ; - Revamped.propagation_future_endorsement protocols ; + Revamped.propagation_future_attestation protocols ; forge_pre_filtered_operation protocols ; refetch_failed_operation protocols ; ban_operation_and_check_applied protocols ; -- GitLab From 2f15877e05029d53b45062ac9b7ac618c18bb9d8 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 24 Jul 2023 16:28:18 +0200 Subject: [PATCH 3/5] tezt/tests: rename endorsement in tenderbake --- tezt/tests/tenderbake.ml | 63 ++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/tezt/tests/tenderbake.ml b/tezt/tests/tenderbake.ml index f7e6ddae70fe..f7671f45113d 100644 --- a/tezt/tests/tenderbake.ml +++ b/tezt/tests/tenderbake.ml @@ -39,7 +39,7 @@ let transfer_data = let baker = Constant.bootstrap5.alias let default_overrides = - [(* ensure that blocks must be endorsed *) (["consensus_threshold"], `Int 6)] + [(* ensure that blocks must be attested *) (["consensus_threshold"], `Int 6)] let init ?(overrides = default_overrides) protocol = let* sandbox_node = Node.init [Synchronisation_threshold 0; Private_mode] in @@ -62,7 +62,7 @@ let init ?(overrides = default_overrides) protocol = let bootstrap_accounts = List.tl Constant.all_secret_keys -let endorsers = +let attesters = [ Constant.bootstrap1.alias; Constant.bootstrap2.alias; @@ -71,11 +71,11 @@ let endorsers = Constant.bootstrap5.alias; ] -let endorse endpoint protocol client endorsers = - Client.attest_for ~endpoint ~protocol ~key:endorsers ~force:true client +let attest endpoint protocol client attesters = + Client.attest_for ~endpoint ~protocol ~key:attesters ~force:true client -let preendorse endpoint protocol client preendorsers = - Client.preattest_for ~endpoint ~protocol ~key:preendorsers ~force:true client +let preattest endpoint protocol client preattesters = + Client.preattest_for ~endpoint ~protocol ~key:preattesters ~force:true client let test_bake_two = Protocol.register_test @@ -112,12 +112,12 @@ let test_low_level_commands = Protocol.register_test ~__FILE__ ~title:"Tenderbake low level commands" - ~tags:["propose"; "endorse"; "preendorse"; "tenderbake"; "low_level"] + ~tags:["propose"; "attest"; "preattest"; "tenderbake"; "low_level"] @@ fun protocol -> let* _proto_hash, endpoint, client, _node = init protocol in - Log.info "Doing a propose -> preendorse -> endorse cycle" ; - let proposer = endorsers in - let preendorsers = endorsers in + Log.info "Doing a propose -> preattest -> attest cycle" ; + let proposer = attesters in + let preattesters = attesters in let* () = Client.transfer ~amount:(Tez.of_int 3) @@ -126,8 +126,8 @@ let test_low_level_commands = client in let* () = Client.propose_for client ~protocol ~endpoint ~key:proposer in - let* () = preendorse endpoint protocol client preendorsers in - let* () = endorse endpoint protocol client endorsers in + let* () = preattest endpoint protocol client preattesters in + let* () = attest endpoint protocol client attesters in let* () = Client.transfer ~amount:(Tez.of_int 2) @@ -136,8 +136,8 @@ let test_low_level_commands = client in let* () = Client.propose_for client ~protocol ~endpoint ~key:proposer in - let* () = preendorse endpoint protocol client preendorsers in - let* () = endorse endpoint protocol client endorsers in + let* () = preattest endpoint protocol client preattesters in + let* () = attest endpoint protocol client attesters in let* () = Client.propose_for client ~protocol ~endpoint ~key:proposer in Lwt.return_unit @@ -180,7 +180,7 @@ let find_bootstrap_account_not_in unwanted = (String.concat ", " @@ List.map (fun Account.{alias; _} -> alias) unwanted) -(* Run one node, and bake, preendorse, and endorse using the +(* Run one node, and bake, preattest, and attest using the client commands. *) let test_manual_bake = let minimal_block_delay = 1 in @@ -188,7 +188,7 @@ let test_manual_bake = ~__FILE__ ~title:"Tenderbake manual bake" ~tags: - ["propose"; "endorse"; "preendorse"; "tenderbake"; "low_level"; "manual"] + ["propose"; "attest"; "preattest"; "tenderbake"; "low_level"; "manual"] @@ fun protocol -> let* _proto_hash, _endpoint, client, node = init @@ -240,8 +240,8 @@ let test_manual_bake = Log.info "Wait for level 2" ; let* (_ : int) = Node.wait_for_level node 2 in - Log.info "Preendorse" ; - let endorsers = + Log.info "Preattest" ; + let attesters = [ Constant.bootstrap1.alias; Constant.bootstrap2.alias; @@ -249,7 +249,7 @@ let test_manual_bake = Constant.bootstrap4.alias; ] in - let* () = Client.preattest_for ~protocol ~key:endorsers ~force:true client in + let* () = Client.preattest_for ~protocol ~key:attesters ~force:true client in let giver = "bootstrap1" in Log.info "Transfer from giver %s to recipient %s" giver recipient.alias ; @@ -274,8 +274,8 @@ let test_manual_bake = in Log.info "Transfer injected with operation hash %s" operation_hash ; - Log.info "Endorse" ; - let* () = Client.attest_for ~protocol ~key:endorsers ~force:true client in + Log.info "Attest" ; + let* () = Client.attest_for ~protocol ~key:attesters ~force:true client in Log.info "Test that %s is pending" operation_hash ; let* pending_ops = @@ -330,7 +330,7 @@ let test_manual_bake_null_threshold = ~__FILE__ ~title:"Tenderbake manual bake null threshold" ~tags: - ["propose"; "endorse"; "preendorse"; "tenderbake"; "low_level"; "manual"] + ["propose"; "attest"; "preattest"; "tenderbake"; "low_level"; "manual"] @@ fun protocol -> let* _proto_hash, _endpoint, client, node = init @@ -407,19 +407,12 @@ let test_repropose = ~__FILE__ ~title:"Tenderbake low level repropose" ~tags: - [ - "propose"; - "endorse"; - "preendorse"; - "tenderbake"; - "low_level"; - "repropose"; - ] + ["propose"; "attest"; "preattest"; "tenderbake"; "low_level"; "repropose"] @@ fun protocol -> let* _proto_hash, endpoint, client, _node = init protocol in - Log.info "Doing a propose -> preendorse -> endorse cycle" ; - let proposer = endorsers in - let preendorsers = endorsers in + Log.info "Doing a propose -> preattest -> attest cycle" ; + let proposer = attesters in + let preattesters = attesters in let* () = Client.transfer ~amount:(Tez.of_int 3) @@ -428,8 +421,8 @@ let test_repropose = client in let* () = Client.propose_for client ~protocol ~endpoint ~key:proposer in - let* () = preendorse endpoint protocol client preendorsers in - let* () = endorse endpoint protocol client endorsers in + let* () = preattest endpoint protocol client preattesters in + let* () = attest endpoint protocol client attesters in let* () = Client.transfer ~amount:(Tez.of_int 2) -- GitLab From 1cc6146a08b1cea940d8aa9f84436153a8fdb566 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 24 Jul 2023 16:29:41 +0200 Subject: [PATCH 4/5] tezt/tests: rename endorsement in protocol_migration --- tezt/tests/protocol_migration.ml | 47 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/tezt/tests/protocol_migration.ml b/tezt/tests/protocol_migration.ml index d94eb32f76a1..72bc5b83315a 100644 --- a/tezt/tests/protocol_migration.ml +++ b/tezt/tests/protocol_migration.ml @@ -332,19 +332,23 @@ let list_count_p p l = in aux 0 l -let is_endorsement op = +let is_attestation ~protocol op = let kind = JSON.(op |-> "contents" |=> 0 |-> "kind" |> as_string) in - String.equal kind "endorsement" + String.equal + kind + (if Protocol.(number protocol >= 18) then "attestation" else "endorsement") (** Check that the given json list of operations contains - [expected_count] endorsements. *) -let check_endorsements ~expected_count consensus_ops = - let actual_count = list_count_p is_endorsement (JSON.as_list consensus_ops) in + [expected_count] attestations. *) +let check_attestations ~protocol ~expected_count consensus_ops = + let actual_count = + list_count_p (is_attestation ~protocol) (JSON.as_list consensus_ops) + in Check.((expected_count = actual_count) int) - ~error_msg:"Expected %L endorsements but got %R." + ~error_msg:"Expected %L attestations but got %R." -(** Check that the block at [level] contains [expected_count] endorsements. *) -let check_endorsements_in_block ~level ~expected_count client = +(** Check that the block at [level] contains [expected_count] attestations. *) +let check_attestations_in_block ~protocol ~level ~expected_count client = let* consensus_operations = RPC.Client.call client @@ RPC.get_chain_block_operations_validation_pass @@ -352,7 +356,7 @@ let check_endorsements_in_block ~level ~expected_count client = ~validation_pass:0 (* consensus operations pass *) () in - Lwt.return (check_endorsements ~expected_count consensus_operations) + Lwt.return (check_attestations ~protocol ~expected_count consensus_operations) (** [start_protocol ~expected_bake_for_blocks ~protocol client] sets up a protocol with some specific easily tunable parameters (consensus threshold, @@ -381,7 +385,7 @@ let start_protocol ?consensus_threshold ?round_duration in let* parameter_file = (* Default value of consensus_threshold is 0, means we do not need - endorsements, let's set it up as in mainnet. *) + attestations, let's set it up as in mainnet. *) let consensus_committee_size = JSON.(get "consensus_committee_size" parameters |> as_int) in @@ -411,11 +415,11 @@ let start_protocol ?consensus_threshold ?round_duration (** Test that migration occuring through baker daemons - does not halt the chain; - - and that the migration block is not endorsed by the newer + - and that the migration block is not attested by the newer protocol's baker. This has become an issue of sort after updating the consensus protocol to - Tenderbake. For one, endorsements have become mandatory, and not only a sign + Tenderbake. For one, attestations have become mandatory, and not only a sign of healthiness. Then, a special case for the migration block was built-in as a way to deal with first ever migration, in terms of consensus protocol, was from Emmy* to Tenderbake. @@ -428,7 +432,7 @@ let test_migration_with_bakers ?(migration_level = 4) ~__FILE__ ~title: (Printf.sprintf - "chain progress/endorsement of migration block from %s to %s with \ + "chain progress/attestation of migration block from %s to %s with \ baker daemons" (Protocol.tag migrate_from) (Protocol.tag migrate_to)) @@ -437,7 +441,7 @@ let test_migration_with_bakers ?(migration_level = 4) "protocol"; "migration"; "baker"; - "endorsing"; + "attesting"; "metadata"; "from_" ^ Protocol.tag migrate_from; "to_" ^ Protocol.tag migrate_to; @@ -477,9 +481,10 @@ let test_migration_with_bakers ?(migration_level = 4) let* _ret = Node.wait_for_level node last_interesting_level in Log.info - "Checking migration block has not been endorsed -- this is a special case" ; + "Checking migration block has not been attested -- this is a special case" ; let* () = - check_endorsements_in_block + check_attestations_in_block + ~protocol:migrate_from ~level:(migration_level + 1) ~expected_count:0 client @@ -533,7 +538,7 @@ let test_forked_migration_manual ?(migration_level = 4) "protocol"; "migration"; "baker"; - "endorsing"; + "attesting"; "fork"; "manual"; "from_" ^ Protocol.tag migrate_from; @@ -732,7 +737,7 @@ let test_forked_migration_bakers ~migrate_from ~migrate_to = "protocol"; "migration"; "baker"; - "endorsing"; + "attesting"; "fork"; "from_" ^ Protocol.tag migrate_from; "to_" ^ Protocol.tag migrate_to; @@ -830,7 +835,7 @@ let test_forked_migration_bakers ~migrate_from ~migrate_to = let pre_migration_level = migration_level - 1 in Log.info "Wait for a quorum event on a proposal at pre-migration level %d. At this \ - point, we know that endorsements on this proposal have been propagated, \ + point, we know that attestations on this proposal have been propagated, \ so everyone will be able to progress to the next level even if the \ network gets split." pre_migration_level ; @@ -843,7 +848,7 @@ let test_forked_migration_bakers ~migrate_from ~migrate_to = let post_migration_level = migration_level + 1 in Log.info - "Migration blocks are not endorsed, so each cluster should be able to \ + "Migration blocks are not attested, so each cluster should be able to \ propose blocks for the post-migration level %d. However, since none of \ the clusters has enough voting power to reach the consensus_threshold, \ they should not be able to propose blocks for higher levels.\n\ @@ -916,7 +921,7 @@ let test_forked_migration_bakers ~migrate_from ~migrate_to = let expected_count = if level_from = post_migration_level then 0 else n_delegates in - check_endorsements ~expected_count consensus_ops ; + check_attestations ~protocol:migrate_from ~expected_count consensus_ops ; check_blocks ~level_from:(level_from + 1) ~level_to) in check_blocks ~level_from ~level_to -- GitLab From b30bcd229a46fb5a9af8507df1d5bf31b192083a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 24 Jul 2023 16:37:19 +0200 Subject: [PATCH 5/5] tezt/tests: rename endorsement in other files --- tezt/tests/baker_operations_cli_options.ml | 8 ++++---- tezt/tests/baking.ml | 8 ++++---- tezt/tests/dal.ml | 4 ++-- tezt/tests/large_metadata.ml | 6 +++--- tezt/tests/precheck.ml | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tezt/tests/baker_operations_cli_options.ml b/tezt/tests/baker_operations_cli_options.ml index 653e9347ec44..a6035adfaf27 100644 --- a/tezt/tests/baker_operations_cli_options.ml +++ b/tezt/tests/baker_operations_cli_options.ml @@ -197,7 +197,7 @@ let all_empty block = |> List.for_all @@ fun l -> l |> as_list |> function [] -> true | _ -> false -let only_has_endorsements block = +let only_has_consensus block = let open JSON in List.for_all Fun.id @@ -214,10 +214,10 @@ let check_block_all_empty ~__LOC__ client = ~error_msg:"Expected an empty operation list." ; unit -let check_block_only_has_endorsements ?block ~__LOC__ client = +let check_block_only_has_consensus ?block ~__LOC__ client = let* head = RPC.Client.call client @@ RPC.get_chain_block ?block () in Check.is_true - (only_has_endorsements head) + (only_has_consensus head) ~__LOC__ ~error_msg:"Expected an empty operation list." ; unit @@ -431,7 +431,7 @@ let test_baker_external_operations = let level_succ = level + 1 in let* (_ : int) = Node.wait_for_level node level_succ in let* () = - check_block_only_has_endorsements + check_block_only_has_consensus ~__LOC__ ~block:(string_of_int level_succ) client diff --git a/tezt/tests/baking.ml b/tezt/tests/baking.ml index b59d55a41815..aaad89839db9 100644 --- a/tezt/tests/baking.ml +++ b/tezt/tests/baking.ml @@ -357,11 +357,11 @@ let check_ordering ops = let assert_block_is_well_baked block expected_number_manager_op = match JSON.(as_list (block |-> "operations")) with - | [endorsement_ops; vote_ops; anonymous_ops; manager_ops] -> - (* There very well might be endorsement operations *) + | [consensus_ops; vote_ops; anonymous_ops; manager_ops] -> + (* There very well might be attestation operations *) Log.debug - "%d endorsement operations" - (List.length (JSON.as_list endorsement_ops)) ; + "%d consensus operations" + (List.length (JSON.as_list consensus_ops)) ; List.iter (fun l -> assert (JSON.as_list l = [])) [vote_ops; anonymous_ops] ; diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index 405696ba5324..fcb5f9083ff1 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -872,7 +872,7 @@ let test_slots_attestation_operation_dal_committee_membership_check _protocol let level = Node.get_level node + 1 in let* (`OpHash _oph) = (* The attestation from the new account should fail as - the new account is not an endorser and cannot be on the DAL committee. *) + the new account is not an attester and cannot be on the DAL committee. *) Operation.Consensus.( inject ~error: @@ -888,7 +888,7 @@ let test_slots_attestation_operation_dal_committee_membership_check _protocol in let* (`OpHash _oph) = (* The attestation from the bootstrap account should succeed as - the bootstrap node is an endorser and is on the DAL committee by default. *) + the bootstrap node is an attester and is on the DAL committee by default. *) Operation.Consensus.( inject ~signer:Constant.bootstrap1 diff --git a/tezt/tests/large_metadata.ml b/tezt/tests/large_metadata.ml index aa58e0191d7f..abaaf3f1eda3 100644 --- a/tezt/tests/large_metadata.ml +++ b/tezt/tests/large_metadata.ml @@ -118,7 +118,7 @@ let metadata_is_available_deprecated ?(force_metadata = false) client exponent = assert (length_of_first_error_message = 1 lsl exponent) ; unit -let get_endorsement client = +let get_attestation client = let* _ = RPC.Client.call client @@ RPC.get_chain_block_operations_validation_pass @@ -341,8 +341,8 @@ let check_metadata_query_string = let* () = metadata_is_available ~metadata_query_string:Always client 14 in (* The metadata should not be returned even if stored. *) let* () = metadata_is_pruned client in - (* Check that endorsements can still be queried. *) - let* () = get_endorsement client in + (* Check that attestations can still be queried. *) + let* () = get_attestation client in unit let register ~protocols = diff --git a/tezt/tests/precheck.ml b/tezt/tests/precheck.ml index b9c41b80e313..9663acfbe897 100644 --- a/tezt/tests/precheck.ml +++ b/tezt/tests/precheck.ml @@ -133,7 +133,7 @@ let forge_block ?client node ~key ~with_op = in let* () = (* We want an empty block, in tenderbake, we can simply propose - so that there is no endorsement operations. *) + so that there is no attestation operations. *) Client.propose_for ~key:[key] ~force:true client2 in let* shell = -- GitLab