From bbe9e963f2e15926777871ab1adf67e3f5a2413a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 3 Jul 2023 16:04:09 +0200 Subject: [PATCH 1/4] alpha: rename double_preendorsement_evidence in contents type --- .../lib_client/operation_result.ml | 2 +- src/proto_alpha/lib_plugin/RPC.ml | 2 +- src/proto_alpha/lib_plugin/mempool.ml | 4 +-- .../lib_protocol/alpha_context.mli | 2 +- src/proto_alpha/lib_protocol/apply.ml | 4 +-- src/proto_alpha/lib_protocol/apply_results.ml | 8 ++--- .../lib_protocol/operation_repr.ml | 32 +++++++++---------- .../lib_protocol/operation_repr.mli | 8 ++--- .../lib_protocol/test/helpers/op.ml | 2 +- .../test/helpers/operation_generator.ml | 2 +- .../validate/generator_descriptors.ml | 2 +- .../test/integration/validate/test_sanity.ml | 4 +-- src/proto_alpha/lib_protocol/validate.ml | 18 +++++------ 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 169968b89c24..8dc60abce8f2 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -926,7 +926,7 @@ let pp_contents_and_result : (Operation.hash op2) pp_balance_updates bus - | ( Double_preendorsement_evidence {op1; op2}, + | ( Double_preattestation_evidence {op1; op2}, Double_preendorsement_evidence_result bus ) -> Format.fprintf ppf diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 9dff9734bbbb..d642826cc496 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -2954,7 +2954,7 @@ module Forge = struct operation ctxt block ~branch (Double_endorsement_evidence {op1; op2}) let double_preendorsement_evidence ctxt block ~branch ~op1 ~op2 () = - operation ctxt block ~branch (Double_preendorsement_evidence {op1; op2}) + operation ctxt block ~branch (Double_preattestation_evidence {op1; op2}) let empty_proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '\000' diff --git a/src/proto_alpha/lib_plugin/mempool.ml b/src/proto_alpha/lib_plugin/mempool.ml index bd939bf6d5dd..2b4892c655a1 100644 --- a/src/proto_alpha/lib_plugin/mempool.ml +++ b/src/proto_alpha/lib_plugin/mempool.ml @@ -545,7 +545,7 @@ let pre_filter filter_info config [Environment.wrap_tzerror Consensus_operation_in_far_future]) | Single (Dal_attestation _) | Single (Seed_nonce_revelation _) - | Single (Double_preendorsement_evidence _) + | Single (Double_preattestation_evidence _) | Single (Double_endorsement_evidence _) | Single (Double_baking_evidence _) | Single (Activate_account _) @@ -681,7 +681,7 @@ let find_manager {shell = _; protocol_data = Operation_data {contents; _}} = | Single ( Preattestation _ | Endorsement _ | Dal_attestation _ | Proposals _ | Ballot _ | Seed_nonce_revelation _ | Vdf_revelation _ - | Double_baking_evidence _ | Double_preendorsement_evidence _ + | Double_baking_evidence _ | Double_preattestation_evidence _ | Double_endorsement_evidence _ | Activate_account _ | Drain_delegate _ | Failing_noop _ ) -> None diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 22148dd2c9a8..1a234925c0cc 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -4170,7 +4170,7 @@ and _ contents = solution : Seed.vdf_solution; } -> Kind.vdf_revelation contents - | Double_preendorsement_evidence : { + | Double_preattestation_evidence : { op1 : Kind.preattestation operation; op2 : Kind.preattestation operation; } diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index b611fbb92d4d..eccb7ba1adcb 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1983,7 +1983,7 @@ let record_operation (type kind) ctxt hash (operation : kind operation) : | Single ( Failing_noop _ | Proposals _ | Ballot _ | Seed_nonce_revelation _ | Vdf_revelation _ | Double_endorsement_evidence _ - | Double_preendorsement_evidence _ | Double_baking_evidence _ + | Double_preattestation_evidence _ | Double_baking_evidence _ | Activate_account _ | Drain_delegate _ | Manager_operation _ ) | Cons (Manager_operation _, _) -> record_non_consensus_operation_hash ctxt hash @@ -2219,7 +2219,7 @@ let apply_contents_list (type kind) ctxt chain_id (mode : mode) tip >|=? fun (ctxt, balance_updates) -> (ctxt, Single_result (Vdf_revelation_result balance_updates)) - | Single (Double_preendorsement_evidence {op1; op2 = _}) -> + | Single (Double_preattestation_evidence {op1; op2 = _}) -> punish_double_endorsement_or_preattestation ctxt ~op1 ~payload_producer | Single (Double_endorsement_evidence {op1; op2 = _}) -> punish_double_endorsement_or_preattestation ctxt ~op1 ~payload_producer diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index b7b34a4ac44c..df3aaf50d805 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -1220,7 +1220,7 @@ module Encoding = struct | _ -> None); mselect = (function - | Contents_and_result ((Double_preendorsement_evidence _ as op), res) + | Contents_and_result ((Double_preattestation_evidence _ as op), res) -> Some (op, res) | _ -> None); @@ -1241,7 +1241,7 @@ module Encoding = struct | _ -> None); mselect = (function - | Contents_and_result ((Double_preendorsement_evidence _ as op), res) + | Contents_and_result ((Double_preattestation_evidence _ as op), res) -> Some (op, res) | _ -> None); @@ -1904,9 +1904,9 @@ let kind_equal : | Seed_nonce_revelation _, _ -> None | Vdf_revelation _, Vdf_revelation_result _ -> Some Eq | Vdf_revelation _, _ -> None - | Double_preendorsement_evidence _, Double_preendorsement_evidence_result _ -> + | Double_preattestation_evidence _, Double_preendorsement_evidence_result _ -> Some Eq - | Double_preendorsement_evidence _, _ -> None + | Double_preattestation_evidence _, _ -> None | Double_endorsement_evidence _, Double_endorsement_evidence_result _ -> Some Eq | Double_endorsement_evidence _, _ -> None diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 66cf94c26831..38e7b97ece83 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -248,7 +248,7 @@ and _ contents = solution : Seed_repr.vdf_solution; } -> Kind.vdf_revelation contents - | Double_preendorsement_evidence : { + | Double_preattestation_evidence : { op1 : Kind.preattestation operation; op2 : Kind.preattestation operation; } @@ -1219,10 +1219,10 @@ module Encoding = struct (req "op2" (dynamic_size preendorsement_encoding)); select = (function - | Contents (Double_preendorsement_evidence _ as op) -> Some op + | Contents (Double_preattestation_evidence _ as op) -> Some op | _ -> None); - proj = (fun (Double_preendorsement_evidence {op1; op2}) -> (op1, op2)); - inj = (fun (op1, op2) -> Double_preendorsement_evidence {op1; op2}); + proj = (fun (Double_preattestation_evidence {op1; op2}) -> (op1, op2)); + inj = (fun (op1, op2) -> Double_preattestation_evidence {op1; op2}); } let double_preattestation_evidence_case : @@ -1237,10 +1237,10 @@ module Encoding = struct (req "op2" (dynamic_size preattestation_encoding)); select = (function - | Contents (Double_preendorsement_evidence _ as op) -> Some op + | Contents (Double_preattestation_evidence _ as op) -> Some op | _ -> None); - proj = (fun (Double_preendorsement_evidence {op1; op2}) -> (op1, op2)); - inj = (fun (op1, op2) -> Double_preendorsement_evidence {op1; op2}); + proj = (fun (Double_preattestation_evidence {op1; op2}) -> (op1, op2)); + inj = (fun (op1, op2) -> Double_preattestation_evidence {op1; op2}); } let double_endorsement_evidence_case : Kind.double_attestation_evidence case = @@ -1854,7 +1854,7 @@ let acceptable_pass (op : packed_operation) = | Single (Seed_nonce_revelation _) -> Some anonymous_pass | Single (Vdf_revelation _) -> Some anonymous_pass | Single (Double_endorsement_evidence _) -> Some anonymous_pass - | Single (Double_preendorsement_evidence _) -> Some anonymous_pass + | Single (Double_preattestation_evidence _) -> Some anonymous_pass | Single (Double_baking_evidence _) -> Some anonymous_pass | Single (Activate_account _) -> Some anonymous_pass | Single (Drain_delegate _) -> Some anonymous_pass @@ -1942,7 +1942,7 @@ let check_signature (type kind) key chain_id (op : kind operation) = | Single ( Failing_noop _ | Proposals _ | Ballot _ | Seed_nonce_revelation _ | Vdf_revelation _ | Double_endorsement_evidence _ - | Double_preendorsement_evidence _ | Double_baking_evidence _ + | Double_preattestation_evidence _ | Double_baking_evidence _ | Activate_account _ | Drain_delegate _ | Manager_operation _ ) -> Generic_operation | Cons (Manager_operation _, _ops) -> Generic_operation @@ -2029,9 +2029,9 @@ let equal_contents_kind : type a b. a contents -> b contents -> (a, b) eq option | Vdf_revelation _, _ -> None | Double_endorsement_evidence _, Double_endorsement_evidence _ -> Some Eq | Double_endorsement_evidence _, _ -> None - | Double_preendorsement_evidence _, Double_preendorsement_evidence _ -> + | Double_preattestation_evidence _, Double_preattestation_evidence _ -> Some Eq - | Double_preendorsement_evidence _, _ -> None + | Double_preattestation_evidence _, _ -> None | Double_baking_evidence _, Double_baking_evidence _ -> Some Eq | Double_baking_evidence _, _ -> None | Activate_account _, Activate_account _ -> Some Eq @@ -2203,7 +2203,7 @@ let consensus_infos_and_hash_from_block_header (bh : Block_header_repr.t) = The [weight] of a {!Seed_nonce_revelation} depends on its [level] converted in {!int32}. - The [weight] of a {!Double_preendorsement} or + The [weight] of a {!Double_preattestation} or {!Double_endorsement} depends on the [level] and [round] of their first denounciated operations. The [level] and [round] are wrapped in a {!round_infos}. @@ -2348,7 +2348,7 @@ let weight_of : packed_operation -> operation_weight = ( Anonymous, Weight_double_endorsement (round_infos_from_consensus_content consensus_content) )) - | Single (Double_preendorsement_evidence {op1; _}) -> ( + | Single (Double_preattestation_evidence {op1; _}) -> ( match op1.protocol_data.contents with | Single (Preattestation consensus_content) -> W @@ -2413,7 +2413,7 @@ let compare_round_infos infos1 infos2 = (infos2.level, infos2.round) (** When comparing {!Endorsement} to {!Preattestation} or - {!Double_endorsement_evidence} to {!Double_preendorsement}, in case + {!Double_endorsement_evidence} to {!Double_preattestation}, in case of {!round_infos} equality, the position is relevant to compute the order. *) type prioritized_position = Nopos | Fstpos | Sndpos @@ -2528,7 +2528,7 @@ let compare_vote_weight w1 w2 = (** {5 Comparison of valid anonymous operations} *) (** Comparing two {!Double_endorsement_evidence}, or two - {!Double_preendorsement_evidence}, or comparing them to each other + {!Double_preattestation_evidence}, or comparing them to each other is comparing their {!round_infos}, see {!compare_round_infos} for more details. @@ -2543,7 +2543,7 @@ let compare_vote_weight w1 w2 = Two {!Activate_account} are compared as their [id]. When comparing different kind of anonymous operations, the order is - as follows: {!Double_preendorsement_evidence} > + as follows: {!Double_preattestation_evidence} > {!Double_endorsement_evidence} > {!Double_baking_evidence} > {!Vdf_revelation} > {!Seed_nonce_revelation} > {!Activate_account}. *) diff --git a/src/proto_alpha/lib_protocol/operation_repr.mli b/src/proto_alpha/lib_protocol/operation_repr.mli index ed9075b52ec6..3667efd5473e 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/operation_repr.mli @@ -255,18 +255,18 @@ and _ contents = solution : Seed_repr.vdf_solution; } -> Kind.vdf_revelation contents - (* Double_preendorsement_evidence: Double-preendorsement is a + (* Double_preattestation_evidence: Double-preattestation is a kind of malicious attack where a byzantine attempts to fork the chain by preendorsing blocks with different contents (at the same level and same round) twice. This behavior may be reported and the byzantine will have its security deposit forfeited. *) - | Double_preendorsement_evidence : { + | Double_preattestation_evidence : { op1 : Kind.preattestation operation; op2 : Kind.preattestation operation; } -> Kind.double_preattestation_evidence contents - (* Double_endorsement_evidence: Similar to double-preendorsement but + (* Double_endorsement_evidence: Similar to double-preattestation but for endorsements. *) | Double_endorsement_evidence : { op1 : Kind.attestation operation; @@ -595,7 +595,7 @@ val compare_by_passes : packed_operation -> packed_operation -> int The global order is as follows: {!Endorsement} and {!Preattestation} > {!Dal_attestation} > - {!Proposals} > {!Ballot} > {!Double_preendorsement_evidence} > + {!Proposals} > {!Ballot} > {!Double_preattestation_evidence} > {!Double_endorsement_evidence} > {!Double_baking_evidence} > {!Vdf_revelation} > {!Seed_nonce_revelation} > {!Activate_account} > {!Drain_delegate} > {!Manager_operation}. diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index e729ab74f6bd..866693595cac 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -647,7 +647,7 @@ let double_endorsement ctxt op1 op2 = } let double_preendorsement ctxt op1 op2 = - let contents = Single (Double_preendorsement_evidence {op1; op2}) in + let contents = Single (Double_preattestation_evidence {op1; op2}) in let branch = Context.branch ctxt in { shell = {branch}; diff --git a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml index d049ee52e515..09adbbaa5655 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml @@ -409,7 +409,7 @@ let generate_double_preendorsement = let open QCheck2.Gen in let* op1 = generate_op generate_preendorsement in let+ op2 = generate_op generate_preendorsement in - Double_preendorsement_evidence {op1; op2} + Double_preattestation_evidence {op1; op2} let generate_double_endorsement = let open QCheck2.Gen in 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 682a7a769eb0..dc2434190c59 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 @@ -842,7 +842,7 @@ let op_kind_of_packed_operation op = | Single (Seed_nonce_revelation _) -> KNonce | Single (Vdf_revelation _) -> KVdf | Single (Double_endorsement_evidence _) -> KDbl_consensus - | Single (Double_preendorsement_evidence _) -> KDbl_consensus + | Single (Double_preattestation_evidence _) -> KDbl_consensus | Single (Double_baking_evidence _) -> KDbl_baking | Single (Activate_account _) -> KActivate | Single (Proposals _) -> KProposals 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 eee04bcceff3..d20629c37492 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 @@ -131,9 +131,9 @@ let covalidation_sanity () = | Single (Double_endorsement_evidence _), KDbl_consensus -> return_unit | Single (Double_endorsement_evidence _), _ -> assert false - | Single (Double_preendorsement_evidence _), KDbl_consensus -> + | Single (Double_preattestation_evidence _), KDbl_consensus -> return_unit - | Single (Double_preendorsement_evidence _), _ -> assert false + | Single (Double_preattestation_evidence _), _ -> assert false | Single (Double_baking_evidence _), KDbl_baking -> return_unit | Single (Double_baking_evidence _), _ -> assert false | Single (Activate_account _), KActivate -> return_unit diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index 13f1c73de486..4934c3ae4caa 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -1406,7 +1406,7 @@ module Anonymous = struct let check_double_preendorsement_evidence vi (operation : Kind.double_preattestation_evidence operation) = - let (Single (Double_preendorsement_evidence {op1; op2})) = + let (Single (Double_preattestation_evidence {op1; op2})) = operation.protocol_data.contents in check_double_endorsing_evidence @@ -1437,7 +1437,7 @@ module Anonymous = struct let check_double_preendorsement_evidence_conflict vs oph (operation : Kind.double_preattestation_evidence operation) = - let (Single (Double_preendorsement_evidence {op1; _})) = + let (Single (Double_preattestation_evidence {op1; _})) = operation.protocol_data.contents in check_double_endorsing_evidence_conflict vs oph op1 @@ -1478,7 +1478,7 @@ module Anonymous = struct let add_double_preendorsement_evidence vs oph (operation : Kind.double_preattestation_evidence operation) = - let (Single (Double_preendorsement_evidence {op1; _})) = + let (Single (Double_preattestation_evidence {op1; _})) = operation.protocol_data.contents in add_double_endorsing_evidence vs oph op1 @@ -1499,7 +1499,7 @@ module Anonymous = struct let remove_double_preendorsement_evidence vs (operation : Kind.double_preattestation_evidence operation) = - let (Single (Double_preendorsement_evidence {op1; _})) = + let (Single (Double_preattestation_evidence {op1; _})) = operation.protocol_data.contents in remove_double_endorsing_evidence vs op1 @@ -2463,7 +2463,7 @@ let check_operation ?(check_signature = true) info (type kind) | Single (Ballot _) -> Voting.check_ballot info ~check_signature operation | Single (Activate_account _) -> Anonymous.check_activate_account info operation - | Single (Double_preendorsement_evidence _) -> + | Single (Double_preattestation_evidence _) -> Anonymous.check_double_preendorsement_evidence info operation | Single (Double_endorsement_evidence _) -> Anonymous.check_double_endorsement_evidence info operation @@ -2527,7 +2527,7 @@ let check_operation_conflict (type kind) operation_conflict_state oph operation_conflict_state oph operation - | Single (Double_preendorsement_evidence _) -> + | Single (Double_preattestation_evidence _) -> Anonymous.check_double_preendorsement_evidence_conflict operation_conflict_state oph @@ -2581,7 +2581,7 @@ let add_valid_operation operation_conflict_state oph (type kind) Voting.add_ballot operation_conflict_state oph operation | Single (Activate_account _) -> Anonymous.add_activate_account operation_conflict_state oph operation - | Single (Double_preendorsement_evidence _) -> + | Single (Double_preattestation_evidence _) -> Anonymous.add_double_preendorsement_evidence operation_conflict_state oph @@ -2625,7 +2625,7 @@ let remove_operation operation_conflict_state (type kind) | Single (Ballot _) -> Voting.remove_ballot operation_conflict_state operation | Single (Activate_account _) -> Anonymous.remove_activate_account operation_conflict_state operation - | Single (Double_preendorsement_evidence _) -> + | Single (Double_preattestation_evidence _) -> Anonymous.remove_double_preendorsement_evidence operation_conflict_state operation @@ -2756,7 +2756,7 @@ let validate_operation ?(check_signature = true) add_activate_account operation_state oph operation in return {info; operation_state; block_state} - | Single (Double_preendorsement_evidence _) -> + | Single (Double_preattestation_evidence _) -> let open Anonymous in let* () = check_double_preendorsement_evidence info operation in let*? () = -- GitLab From 46d818cd009e3a12529148a07817d9795a6b349c Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 3 Jul 2023 16:05:57 +0200 Subject: [PATCH 2/4] alpha: rename double_preendorsement_evidence in operation weight --- src/proto_alpha/lib_protocol/operation_repr.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 38e7b97ece83..72732a088314 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -2235,7 +2235,7 @@ type _ weight = -> voting_pass_type weight | Weight_seed_nonce_revelation : int32 -> anonymous_pass_type weight | Weight_vdf_revelation : Seed_repr.vdf_solution -> anonymous_pass_type weight - | Weight_double_preendorsement : round_infos -> anonymous_pass_type weight + | Weight_double_preattestation : round_infos -> anonymous_pass_type weight | Weight_double_endorsement : round_infos -> anonymous_pass_type weight | Weight_double_baking : double_baking_infos -> anonymous_pass_type weight | Weight_activate_account : @@ -2353,7 +2353,7 @@ let weight_of : packed_operation -> operation_weight = | Single (Preattestation consensus_content) -> W ( Anonymous, - Weight_double_preendorsement + Weight_double_preattestation (round_infos_from_consensus_content consensus_content) )) | Single (Double_baking_evidence {bh1; _}) -> let double_baking_infos = @@ -2549,14 +2549,14 @@ let compare_vote_weight w1 w2 = *) let compare_anonymous_weight w1 w2 = match (w1, w2) with - | Weight_double_preendorsement infos1, Weight_double_preendorsement infos2 -> + | Weight_double_preattestation infos1, Weight_double_preattestation infos2 -> compare_round_infos infos1 infos2 - | Weight_double_preendorsement infos1, Weight_double_endorsement infos2 -> + | Weight_double_preattestation infos1, Weight_double_endorsement infos2 -> compare_round_infos_with_prioritized_position ~prioritized_position:Fstpos infos1 infos2 - | Weight_double_endorsement infos1, Weight_double_preendorsement infos2 -> + | Weight_double_endorsement infos1, Weight_double_preattestation infos2 -> compare_round_infos_with_prioritized_position ~prioritized_position:Sndpos infos1 @@ -2566,9 +2566,9 @@ let compare_anonymous_weight w1 w2 = | ( ( Weight_double_baking _ | Weight_seed_nonce_revelation _ | Weight_vdf_revelation _ | Weight_activate_account _ | Weight_drain_delegate _ ), - (Weight_double_preendorsement _ | Weight_double_endorsement _) ) -> + (Weight_double_preattestation _ | Weight_double_endorsement _) ) -> -1 - | ( (Weight_double_preendorsement _ | Weight_double_endorsement _), + | ( (Weight_double_preattestation _ | Weight_double_endorsement _), ( Weight_double_baking _ | Weight_seed_nonce_revelation _ | Weight_vdf_revelation _ | Weight_activate_account _ | Weight_drain_delegate _ ) ) -> -- GitLab From 190d49145f324b08d0fc7a31552a517aedd8d3c0 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 3 Jul 2023 16:07:45 +0200 Subject: [PATCH 3/4] alpha: rename double_preendorsement_evidence in validate --- src/proto_alpha/lib_protocol/validate.ml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_protocol/validate.ml b/src/proto_alpha/lib_protocol/validate.ml index 4934c3ae4caa..f0f6113e0fae 100644 --- a/src/proto_alpha/lib_protocol/validate.ml +++ b/src/proto_alpha/lib_protocol/validate.ml @@ -1404,7 +1404,7 @@ module Anonymous = struct let*? () = Operation.check_signature delegate_pk vi.chain_id op2 in return_unit - let check_double_preendorsement_evidence vi + let check_double_preattestation_evidence vi (operation : Kind.double_preattestation_evidence operation) = let (Single (Double_preattestation_evidence {op1; op2})) = operation.protocol_data.contents @@ -1435,7 +1435,7 @@ module Anonymous = struct | Some existing -> Error (Operation_conflict {existing; new_operation = oph})) - let check_double_preendorsement_evidence_conflict vs oph + let check_double_preattestation_evidence_conflict vs oph (operation : Kind.double_preattestation_evidence operation) = let (Single (Double_preattestation_evidence {op1; _})) = operation.protocol_data.contents @@ -1476,7 +1476,7 @@ module Anonymous = struct in add_double_endorsing_evidence vs oph op1 - let add_double_preendorsement_evidence vs oph + let add_double_preattestation_evidence vs oph (operation : Kind.double_preattestation_evidence operation) = let (Single (Double_preattestation_evidence {op1; _})) = operation.protocol_data.contents @@ -1497,7 +1497,7 @@ module Anonymous = struct in {vs with anonymous_state} - let remove_double_preendorsement_evidence vs + let remove_double_preattestation_evidence vs (operation : Kind.double_preattestation_evidence operation) = let (Single (Double_preattestation_evidence {op1; _})) = operation.protocol_data.contents @@ -2464,7 +2464,7 @@ let check_operation ?(check_signature = true) info (type kind) | Single (Activate_account _) -> Anonymous.check_activate_account info operation | Single (Double_preattestation_evidence _) -> - Anonymous.check_double_preendorsement_evidence info operation + Anonymous.check_double_preattestation_evidence info operation | Single (Double_endorsement_evidence _) -> Anonymous.check_double_endorsement_evidence info operation | Single (Double_baking_evidence _) -> @@ -2528,7 +2528,7 @@ let check_operation_conflict (type kind) operation_conflict_state oph oph operation | Single (Double_preattestation_evidence _) -> - Anonymous.check_double_preendorsement_evidence_conflict + Anonymous.check_double_preattestation_evidence_conflict operation_conflict_state oph operation @@ -2582,7 +2582,7 @@ let add_valid_operation operation_conflict_state oph (type kind) | Single (Activate_account _) -> Anonymous.add_activate_account operation_conflict_state oph operation | Single (Double_preattestation_evidence _) -> - Anonymous.add_double_preendorsement_evidence + Anonymous.add_double_preattestation_evidence operation_conflict_state oph operation @@ -2626,7 +2626,7 @@ let remove_operation operation_conflict_state (type kind) | Single (Activate_account _) -> Anonymous.remove_activate_account operation_conflict_state operation | Single (Double_preattestation_evidence _) -> - Anonymous.remove_double_preendorsement_evidence + Anonymous.remove_double_preattestation_evidence operation_conflict_state operation | Single (Double_endorsement_evidence _) -> @@ -2758,16 +2758,16 @@ let validate_operation ?(check_signature = true) return {info; operation_state; block_state} | Single (Double_preattestation_evidence _) -> let open Anonymous in - let* () = check_double_preendorsement_evidence info operation in + let* () = check_double_preattestation_evidence info operation in let*? () = - check_double_preendorsement_evidence_conflict + check_double_preattestation_evidence_conflict operation_state oph operation |> wrap_denunciation_conflict Preattestation in let operation_state = - add_double_preendorsement_evidence operation_state oph operation + add_double_preattestation_evidence operation_state oph operation in return {info; operation_state; block_state} | Single (Double_endorsement_evidence _) -> @@ -2893,7 +2893,7 @@ let check_fitness_locked_round bs fitness_locked_round = before the block's round, and that their total power is high enough. Note that this function does not check whether the block actually - contains preendorments when they are mandatory. This is checked by + contains preattestations when they are mandatory. This is checked by {!check_fitness_locked_round} instead. *) let check_preattestation_round_and_power vi vs round = let open Result_syntax in -- GitLab From 8868a24370f153ea67584dca739484827f9464ae Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 3 Jul 2023 16:10:16 +0200 Subject: [PATCH 4/4] alpha: rename double_preendorsement_evidence in apply_results --- src/proto_alpha/lib_client/operation_result.ml | 2 +- src/proto_alpha/lib_protocol/apply.ml | 2 +- src/proto_alpha/lib_protocol/apply_results.ml | 18 +++++++++--------- src/proto_alpha/lib_protocol/apply_results.mli | 2 +- .../lib_sc_rollup_node/sc_rollup_injector.ml | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 8dc60abce8f2..32e0fb40c1f4 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -927,7 +927,7 @@ let pp_contents_and_result : pp_balance_updates bus | ( Double_preattestation_evidence {op1; op2}, - Double_preendorsement_evidence_result bus ) -> + Double_preattestation_evidence_result bus ) -> Format.fprintf ppf "@[Double preattestation evidence:@,\ diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index eccb7ba1adcb..0037b73e1236 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -2135,7 +2135,7 @@ let punish_double_endorsement_or_preattestation (type kind) ctxt kind Kind.double_consensus_operation_evidence contents_result = match op1.protocol_data.contents with | Single (Preattestation _) -> - Double_preendorsement_evidence_result balance_updates + Double_preattestation_evidence_result balance_updates | Single (Endorsement _) -> Double_endorsement_evidence_result balance_updates in diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index df3aaf50d805..50992174b725 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -877,7 +877,7 @@ type 'kind contents_result = | Double_endorsement_evidence_result : Receipt.balance_updates -> Kind.double_attestation_evidence contents_result - | Double_preendorsement_evidence_result : + | Double_preattestation_evidence_result : Receipt.balance_updates -> Kind.double_preattestation_evidence contents_result | Double_baking_evidence_result : @@ -1215,7 +1215,7 @@ module Encoding = struct obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function - | Contents_result (Double_preendorsement_evidence_result _ as op) -> + | Contents_result (Double_preattestation_evidence_result _ as op) -> Some op | _ -> None); mselect = @@ -1224,8 +1224,8 @@ module Encoding = struct -> Some (op, res) | _ -> None); - proj = (fun (Double_preendorsement_evidence_result bus) -> bus); - inj = (fun bus -> Double_preendorsement_evidence_result bus); + proj = (fun (Double_preattestation_evidence_result bus) -> bus); + inj = (fun bus -> Double_preattestation_evidence_result bus); } let double_preattestation_evidence_case = @@ -1236,7 +1236,7 @@ module Encoding = struct obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function - | Contents_result (Double_preendorsement_evidence_result _ as op) -> + | Contents_result (Double_preattestation_evidence_result _ as op) -> Some op | _ -> None); mselect = @@ -1245,8 +1245,8 @@ module Encoding = struct -> Some (op, res) | _ -> None); - proj = (fun (Double_preendorsement_evidence_result bus) -> bus); - inj = (fun bus -> Double_preendorsement_evidence_result bus); + proj = (fun (Double_preattestation_evidence_result bus) -> bus); + inj = (fun bus -> Double_preattestation_evidence_result bus); } let double_baking_evidence_case = @@ -1407,7 +1407,7 @@ module Encoding = struct | Contents_result (Seed_nonce_revelation_result _) -> None | Contents_result (Vdf_revelation_result _) -> None | Contents_result (Double_endorsement_evidence_result _) -> None - | Contents_result (Double_preendorsement_evidence_result _) -> None + | Contents_result (Double_preattestation_evidence_result _) -> None | Contents_result (Double_baking_evidence_result _) -> None | Contents_result (Activate_account_result _) -> None | Contents_result (Drain_delegate_result _) -> None @@ -1904,7 +1904,7 @@ let kind_equal : | Seed_nonce_revelation _, _ -> None | Vdf_revelation _, Vdf_revelation_result _ -> Some Eq | Vdf_revelation _, _ -> None - | Double_preattestation_evidence _, Double_preendorsement_evidence_result _ -> + | Double_preattestation_evidence _, Double_preattestation_evidence_result _ -> Some Eq | Double_preattestation_evidence _, _ -> None | Double_endorsement_evidence _, Double_endorsement_evidence_result _ -> diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index b5365624ab9e..bf9ee06d8b22 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -85,7 +85,7 @@ and 'kind contents_result = | Double_endorsement_evidence_result : Receipt.balance_updates -> Kind.double_attestation_evidence contents_result - | Double_preendorsement_evidence_result : + | Double_preattestation_evidence_result : Receipt.balance_updates -> Kind.double_preattestation_evidence contents_result | Double_baking_evidence_result : diff --git a/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml b/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml index 5e2dec4b6526..72278a9be064 100644 --- a/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml +++ b/src/proto_alpha/lib_sc_rollup_node/sc_rollup_injector.ml @@ -163,7 +163,7 @@ module Proto_client = struct | Seed_nonce_revelation_result _ -> Successful | Vdf_revelation_result _ -> Successful | Double_endorsement_evidence_result _ -> Successful - | Double_preendorsement_evidence_result _ -> Successful + | Double_preattestation_evidence_result _ -> Successful | Double_baking_evidence_result _ -> Successful | Activate_account_result _ -> Successful | Proposals_result -> Successful -- GitLab