diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 61c10cd079ada6576112428b5f822841b4864ce6..ba5769c753622a3451dc317170a7356ba43991db 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -137,3 +137,6 @@ Internal - ``balance_update_encoding_with_legacy_attestation_name`` has been removed. (MR :gl:`!13461`) + +- Encoding that supports ``endorsement`` kind in apply_result JSON has been + removed. (MR :gl:`!13974`) diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index 15ae7110604bcadca7534fb3f163db53a6d2fd26..77a991147f5ae70a248028926da72cc512bf26e6 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -1020,9 +1020,6 @@ module Encoding = struct (req (Format.asprintf "%s_power" power_name) int31) (req "consensus_key" Signature.Public_key_hash.encoding) - let consensus_result_encoding_legacy power_name = - consensus_result_encoding power_name - let consensus_result_encoding = consensus_result_encoding "consensus" type case = @@ -1047,30 +1044,6 @@ module Encoding = struct (fun x -> match proj x with None -> None | Some x -> Some ((), x)) (fun ((), x) -> inj x) - let preendorsement_case = - Case - { - op_case = Operation.Encoding.preendorsement_case; - encoding = consensus_result_encoding_legacy "preendorsement"; - select = - (function - | Contents_result (Preattestation_result _ as op) -> Some op - | _ -> None); - mselect = - (function - | Contents_and_result ((Preattestation _ as op), res) -> Some (op, res) - | _ -> None); - proj = - (function - | Preattestation_result - {balance_updates; delegate; consensus_key; consensus_power} -> - (balance_updates, delegate, consensus_power, consensus_key)); - inj = - (fun (balance_updates, delegate, consensus_power, consensus_key) -> - Preattestation_result - {balance_updates; delegate; consensus_key; consensus_power}); - } - let preattestation_case = Case { @@ -1095,31 +1068,6 @@ module Encoding = struct {balance_updates; delegate; consensus_key; consensus_power}); } - let endorsement_case = - Case - { - op_case = Operation.Encoding.endorsement_case; - encoding = consensus_result_encoding_legacy "endorsement"; - select = - (function - | Contents_result (Attestation_result _ as op) -> Some op | _ -> None); - mselect = - (function - | Contents_and_result - ((Attestation {dal_content = None; _} as op), res) -> - Some (op, res) - | _ -> None); - proj = - (function - | Attestation_result - {balance_updates; delegate; consensus_key; consensus_power} -> - (balance_updates, delegate, consensus_power, consensus_key)); - inj = - (fun (balance_updates, delegate, consensus_power, consensus_key) -> - Attestation_result - {balance_updates; delegate; consensus_key; consensus_power}); - } - let attestation_case = Case { @@ -1145,31 +1093,6 @@ module Encoding = struct {balance_updates; delegate; consensus_key; consensus_power}); } - let endorsement_with_dal_case = - Case - { - op_case = Operation.Encoding.endorsement_with_dal_case; - encoding = consensus_result_encoding_legacy "endorsement"; - select = - (function - | Contents_result (Attestation_result _ as op) -> Some op | _ -> None); - mselect = - (function - | Contents_and_result - ((Attestation {dal_content = Some _; _} as op), res) -> - Some (op, res) - | _ -> None); - proj = - (function - | Attestation_result - {balance_updates; delegate; consensus_key; consensus_power} -> - (balance_updates, delegate, consensus_power, consensus_key)); - inj = - (fun (balance_updates, delegate, consensus_power, consensus_key) -> - Attestation_result - {balance_updates; delegate; consensus_key; consensus_power}); - } - let attestation_with_dal_case = Case { @@ -1232,34 +1155,6 @@ module Encoding = struct inj = (fun bus -> Vdf_revelation_result bus); } - let double_endorsement_evidence_case = - Case - { - op_case = Operation.Encoding.double_endorsement_evidence_case; - encoding = - obj2 - (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft "balance_updates" Receipt.balance_updates_encoding []); - select = - (function - | Contents_result (Double_attestation_evidence_result _ as op) -> - Some op - | _ -> None); - mselect = - (function - | Contents_and_result ((Double_attestation_evidence _ as op), res) -> - Some (op, res) - | _ -> None); - proj = - (fun (Double_attestation_evidence_result - {forbidden_delegate; balance_updates}) -> - (forbidden_delegate, balance_updates)); - inj = - (fun (forbidden_delegate, balance_updates) -> - Double_attestation_evidence_result - {forbidden_delegate; balance_updates}); - } - let double_attestation_evidence_case = Case { @@ -1288,35 +1183,6 @@ module Encoding = struct {forbidden_delegate; balance_updates}); } - let double_preendorsement_evidence_case = - Case - { - op_case = Operation.Encoding.double_preendorsement_evidence_case; - encoding = - obj2 - (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft "balance_updates" Receipt.balance_updates_encoding []); - select = - (function - | Contents_result (Double_preattestation_evidence_result _ as op) -> - Some op - | _ -> None); - mselect = - (function - | Contents_and_result ((Double_preattestation_evidence _ as op), res) - -> - Some (op, res) - | _ -> None); - proj = - (fun (Double_preattestation_evidence_result - {forbidden_delegate; balance_updates}) -> - (forbidden_delegate, balance_updates)); - inj = - (fun (forbidden_delegate, balance_updates) -> - Double_preattestation_evidence_result - {forbidden_delegate; balance_updates}); - } - let double_preattestation_evidence_case = Case { @@ -1803,12 +1669,6 @@ let contents_cases = :: double_attestation_evidence_case :: double_preattestation_evidence_case :: common_cases -let contents_cases_with_legacy_attestation_name = - let open Encoding in - endorsement_case :: endorsement_with_dal_case :: preendorsement_case - :: double_endorsement_evidence_case :: double_preendorsement_evidence_case - :: common_cases - let make_contents_result (Encoding.Case { @@ -1827,13 +1687,6 @@ let contents_result_encoding = def "operation.alpha.contents_result" @@ union (List.map make_contents_result contents_cases) -let contents_result_encoding_with_legacy_attestation_name = - def "operation_with_legacy_attestation_name.alpha.contents_result" - @@ union - (List.map - make_contents_result - contents_cases_with_legacy_attestation_name) - let make_contents_and_result (Encoding.Case { @@ -1857,14 +1710,6 @@ let contents_and_result_encoding = def "operation.alpha.operation_contents_and_result" @@ union (List.map make_contents_and_result contents_cases) -let contents_and_result_encoding_with_legacy_attestation_name = - def - "operation_with_legacy_attestation_name.alpha.operation_contents_and_result" - @@ union - (List.map - make_contents_and_result - contents_cases_with_legacy_attestation_name) - type 'kind contents_result_list = | Single_result : 'kind contents_result -> 'kind contents_result_list | Cons_result : @@ -1903,11 +1748,6 @@ let contents_result_list_encoding = def "operation.alpha.contents_list_result" @@ contents_result_list_conv_with_guard (list contents_result_encoding) -let contents_result_list_encoding_with_legacy_attestation_name = - def "operation_with_legacy_attestation_name.alpha.contents_list_result" - @@ contents_result_list_conv_with_guard - (list contents_result_encoding_with_legacy_attestation_name) - type 'kind contents_and_result_list = | Single_and_result : 'kind Alpha_context.contents * 'kind contents_result @@ -1950,10 +1790,6 @@ let contents_and_result_list_encoding = contents_and_result_conv_with_guard (Variable.list contents_and_result_encoding) -let contents_and_result_list_encoding_with_legacy_attestation_name = - contents_and_result_conv_with_guard - (Variable.list contents_and_result_encoding_with_legacy_attestation_name) - type 'kind operation_metadata = {contents : 'kind contents_result_list} type packed_operation_metadata = @@ -1982,28 +1818,6 @@ let operation_metadata_encoding = (fun () -> No_operation_metadata); ] -let operation_metadata_encoding_with_legacy_attestation_name = - def "operation_with_legacy_attestation_name.alpha.result" - @@ union - [ - case - (Tag 0) - ~title:"Operation_metadata" - contents_result_list_encoding_with_legacy_attestation_name - (function - | Operation_metadata {contents} -> - Some (Contents_result_list contents) - | _ -> None) - (fun (Contents_result_list contents) -> - Operation_metadata {contents}); - case - (Tag 1) - ~title:"No_operation_metadata" - empty - (function No_operation_metadata -> Some () | _ -> None) - (fun () -> No_operation_metadata); - ] - let kind_equal : type kind kind2. kind contents -> kind2 contents_result -> (kind, kind2) eq option = @@ -2679,53 +2493,6 @@ let operation_data_and_metadata_encoding = (Operation_data {contents; signature}, No_operation_metadata)); ] -let operation_data_and_metadata_encoding_with_legacy_attestation_name = - def "operation_with_legacy_attestation_name.alpha.operation_with_metadata" - @@ union - [ - case - (Tag 0) - ~title:"Operation_with_metadata" - (obj2 - (req - "contents" - (dynamic_size - contents_and_result_list_encoding_with_legacy_attestation_name)) - (opt "signature" Signature.encoding)) - (function - | Operation_data _, No_operation_metadata -> None - | Operation_data op, Operation_metadata res -> ( - match kind_equal_list op.contents res.contents with - | None -> - Pervasives.failwith - "cannot decode inconsistent combined operation result" - | Some Eq -> - Some - ( Contents_and_result_list - (pack_contents_list op.contents res.contents), - op.signature ))) - (fun (Contents_and_result_list contents, signature) -> - let op_contents, res_contents = unpack_contents_list contents in - ( Operation_data {contents = op_contents; signature}, - Operation_metadata {contents = res_contents} )); - case - (Tag 1) - ~title:"Operation_without_metadata" - (obj2 - (req - "contents" - (dynamic_size - Operation - .contents_list_encoding_with_legacy_attestation_name)) - (opt "signature" Signature.encoding)) - (function - | Operation_data op, No_operation_metadata -> - Some (Contents_list op.contents, op.signature) - | Operation_data _, Operation_metadata _ -> None) - (fun (Contents_list contents, signature) -> - (Operation_data {contents; signature}, No_operation_metadata)); - ] - type block_metadata = { proposer : Consensus_key.t; baker : Consensus_key.t; @@ -2742,12 +2509,9 @@ type block_metadata = { dal_attestation : Dal.Attestation.t; } -let block_metadata_encoding ~use_legacy_attestation_name = +let block_metadata_encoding = let open Data_encoding in - def - (if use_legacy_attestation_name then - "block_header.alpha.metadata_with_legacy_attestation_name" - else "block_header.alpha.metadata") + def "block_header.alpha.metadata" @@ conv (fun { proposer = @@ -2834,9 +2598,3 @@ let block_metadata_encoding ~use_legacy_attestation_name = (req "baker_consensus_key" Signature.Public_key_hash.encoding) (req "consumed_milligas" Gas.Arith.n_fp_encoding) (req "dal_attestation" Dal.Attestation.encoding))) - -let block_metadata_encoding_with_legacy_attestation_name = - block_metadata_encoding ~use_legacy_attestation_name:true - -let block_metadata_encoding = - block_metadata_encoding ~use_legacy_attestation_name:false diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index b0a09087030c1e44d1c52d463da6300f662a3bc7..36bd8e59790d4b16d3b0c61ef29f304301aea6fb 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -274,31 +274,9 @@ val pack_migration_operation_results : (** Serializer for {!packed_operation_result}. *) val operation_metadata_encoding : packed_operation_metadata Data_encoding.t -(** Operation metadata encoding that accepts legacy attestation name : - `endorsement` (and preendorsement, double__evidence) in JSON - - https://gitlab.com/tezos/tezos/-/issues/5531 - - This encoding is temporary and should be removed when the protocol no longer - accepts JSON endorsements kinds -*) -val operation_metadata_encoding_with_legacy_attestation_name : - packed_operation_metadata Data_encoding.t - val operation_data_and_metadata_encoding : (Operation.packed_protocol_data * packed_operation_metadata) Data_encoding.t -(** Operation data and metadata encoding that accepts legacy attestation name : - `endorsement` (and preendorsement, double__evidence) in JSON - - https://gitlab.com/tezos/tezos/-/issues/5531 - - This encoding is temporary and should be removed when the protocol no longer - accepts JSON endorsements kinds -*) -val operation_data_and_metadata_encoding_with_legacy_attestation_name : - (Operation.packed_protocol_data * packed_operation_metadata) Data_encoding.t - type 'kind contents_and_result_list = | Single_and_result : 'kind Alpha_context.contents * 'kind contents_result @@ -317,9 +295,6 @@ type packed_contents_and_result_list = val contents_and_result_list_encoding : packed_contents_and_result_list Data_encoding.t -val contents_and_result_list_encoding_with_legacy_attestation_name : - packed_contents_and_result_list Data_encoding.t - val pack_contents_list : 'kind contents_list -> 'kind contents_result_list -> @@ -354,7 +329,4 @@ type block_metadata = { dal_attestation : Dal.Attestation.t; } -val block_metadata_encoding_with_legacy_attestation_name : - block_metadata Data_encoding.encoding - val block_metadata_encoding : block_metadata Data_encoding.encoding diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index c24f7b14790879f94cb2d5871765002642a0a3f9..a927b7f6b8eff7be128d4e635679e89113f3bc0e 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -38,7 +38,7 @@ let block_header_data_encoding = type block_header_metadata = Apply_results.block_metadata let block_header_metadata_encoding_with_legacy_attestation_name = - Apply_results.block_metadata_encoding_with_legacy_attestation_name + Apply_results.block_metadata_encoding let block_header_metadata_encoding = Apply_results.block_metadata_encoding @@ -61,14 +61,13 @@ type operation_receipt = Apply_results.packed_operation_metadata = let operation_receipt_encoding = Apply_results.operation_metadata_encoding let operation_receipt_encoding_with_legacy_attestation_name = - Apply_results.operation_metadata_encoding_with_legacy_attestation_name + Apply_results.operation_metadata_encoding let operation_data_and_receipt_encoding = Apply_results.operation_data_and_metadata_encoding let operation_data_and_receipt_encoding_with_legacy_attestation_name = - Apply_results - .operation_data_and_metadata_encoding_with_legacy_attestation_name + Apply_results.operation_data_and_metadata_encoding type operation = Alpha_context.packed_operation = { shell : Operation.shell_header;