From d7a6babe2d44d44ccf76fb167be1b87c58a5b112 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 11 Oct 2023 10:31:40 +0200 Subject: [PATCH 1/4] Revert "alpha/lib_client: use operation encoding with attestation in pretty" This reverts commit 0d61b8a1828ff7fc740902c088f34b86c6906d4f. --- src/proto_alpha/lib_client/client_proto_utils.ml | 2 +- src/proto_alpha/lib_client/injection.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_client/client_proto_utils.ml b/src/proto_alpha/lib_client/client_proto_utils.ml index 897103203366..aac91ab80b72 100644 --- a/src/proto_alpha/lib_client/client_proto_utils.ml +++ b/src/proto_alpha/lib_client/client_proto_utils.ml @@ -32,7 +32,7 @@ let to_json_and_bytes branch message = ( Environment.Operation.{branch}, Contents_list (Single (Failing_noop message)) ) in - let encoding = Operation.unsigned_encoding in + let encoding = Operation.unsigned_encoding_with_legacy_attestation_name in ( Data_encoding.Json.construct encoding op, Data_encoding.Binary.to_bytes_exn encoding op ) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 4d72ecc0a4b5..2afcd0220cf4 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -226,7 +226,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name ({branch}, Contents_list contents) in item (fun ppf () -> -- GitLab From 74f9d66ed580682f58806c0556047ede38fdb480 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 11 Oct 2023 10:31:54 +0200 Subject: [PATCH 2/4] Revert "alpha/baker: external operations should use attestation in JSON" This reverts commit d2c700c92cb6a0851fe80dfed349f5404e14d156. --- src/proto_alpha/lib_delegate/baking_actions.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index c95b6dbed252..91248110df0c 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -37,7 +37,8 @@ module Operations_source = struct } let operations_encoding = - Data_encoding.(list (dynamic_size Operation.encoding)) + Data_encoding.( + list (dynamic_size Operation.encoding_with_legacy_attestation_name)) let retrieve = let open Lwt_result_syntax in -- GitLab From 57e020b661da408509cfd4e586b6d4f9b0a9184c Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 11 Oct 2023 10:33:00 +0200 Subject: [PATCH 3/4] Revert "alpha: use binary balance updates encoding" This reverts commit 88c16e8994ba16f8a9146672eeb1b44390e889e4. --- .../lib_protocol/apply_internal_results.ml | 15 +- src/proto_alpha/lib_protocol/apply_results.ml | 128 ++++++++++++++---- .../lib_protocol/migration_repr.ml | 6 +- src/proto_alpha/lib_protocol/storage.ml | 3 +- .../lib_protocol/test/unit/test_receipt.ml | 8 +- 5 files changed, 127 insertions(+), 33 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply_internal_results.ml b/src/proto_alpha/lib_protocol/apply_internal_results.ml index ca82d86267f2..3c188af0d33c 100644 --- a/src/proto_alpha/lib_protocol/apply_internal_results.ml +++ b/src/proto_alpha/lib_protocol/apply_internal_results.ml @@ -241,7 +241,10 @@ module Internal_operation = struct (Tag 0) (obj9 (opt "storage" Script.expr_encoding) - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "ticket_receipt" Ticket_receipt.encoding []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) @@ -568,7 +571,10 @@ module Internal_operation_result = struct ~op_case:Internal_operation.origination_case ~encoding: (obj6 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "storage_size" z Z.zero) @@ -624,7 +630,10 @@ module Internal_operation_result = struct Data_encoding.( obj2 (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) - (dft "balance_updates" Receipt.balance_updates_encoding [])) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + [])) ~select:(function | Successful_internal_operation_result (IDelegation_result _ as op) -> Some op diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index d4203a3bc8fd..4c43948711b7 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -284,7 +284,10 @@ module Manager_result = struct (Tag 0) (obj9 (opt "storage" Script.expr_encoding) - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "ticket_updates" Ticket_receipt.encoding []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) @@ -368,7 +371,10 @@ module Manager_result = struct ~op_case:Operation.Encoding.Manager_operations.origination_case ~encoding: (obj6 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "storage_size" z Z.zero) @@ -422,7 +428,10 @@ module Manager_result = struct Operation.Encoding.Manager_operations.register_global_constant_case ~encoding: (obj4 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "storage_size" z Z.zero) (req "global_address" Script_expr_hash.encoding)) @@ -447,7 +456,10 @@ module Manager_result = struct Data_encoding.( obj2 (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) - (dft "balance_updates" Receipt.balance_updates_encoding [])) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + [])) ~select:(function | Successful_manager_result (Delegation_result _ as op) -> Some op | _ -> None) @@ -479,7 +491,10 @@ module Manager_result = struct ~encoding: Data_encoding.( obj2 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero)) ~select:(function | Successful_manager_result (Increase_paid_storage_result _ as op) -> @@ -498,7 +513,9 @@ module Manager_result = struct ~encoding: Data_encoding.( obj4 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (req "ticket_updates" Ticket_receipt.encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "paid_storage_size_diff" z Z.zero)) @@ -556,7 +573,9 @@ module Manager_result = struct ~encoding: Data_encoding.( obj4 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (req "originated_zk_rollup" Zk_rollup.Address.encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "size" z)) @@ -581,7 +600,9 @@ module Manager_result = struct ~encoding: Data_encoding.( obj3 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "size" z)) ~select:(function @@ -603,7 +624,9 @@ module Manager_result = struct ~encoding: Data_encoding.( obj3 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "paid_storage_size_diff" z Z.zero)) ~select:(function @@ -623,7 +646,9 @@ module Manager_result = struct ~op_case:Operation.Encoding.Manager_operations.sc_rollup_originate_case ~encoding: (obj5 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (req "address" Sc_rollup.Address.encoding) (req "genesis_commitment_hash" Sc_rollup.Commitment.Hash.encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) @@ -703,7 +728,9 @@ module Manager_result = struct (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "staked_hash" Sc_rollup.Commitment.Hash.encoding) (req "published_at_level" Raw_level.encoding) - (req "balance_updates" Receipt.balance_updates_encoding)) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name)) ~select:(function | Successful_manager_result (Sc_rollup_publish_result _ as op) -> Some op @@ -726,7 +753,9 @@ module Manager_result = struct obj3 (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "game_status" Sc_rollup.Game.status_encoding) - (req "balance_updates" Receipt.balance_updates_encoding)) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name)) ~select:(function | Successful_manager_result (Sc_rollup_refute_result _ as op) -> Some op | _ -> None) @@ -745,7 +774,9 @@ module Manager_result = struct (obj3 (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "game_status" Sc_rollup.Game.status_encoding) - (req "balance_updates" Receipt.balance_updates_encoding)) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name)) ~select:(function | Successful_manager_result (Sc_rollup_timeout_result _ as op) -> Some op @@ -766,7 +797,9 @@ module Manager_result = struct ~encoding: Data_encoding.( obj5 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (req "ticket_updates" Ticket_receipt.encoding) (opt "whitelist_update" Sc_rollup.Whitelist.update_encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) @@ -812,7 +845,9 @@ module Manager_result = struct ~encoding: Data_encoding.( obj2 - (req "balance_updates" Receipt.balance_updates_encoding) + (req + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero)) ~select:(function | Successful_manager_result (Sc_rollup_recover_bond_result _ as op) -> @@ -992,7 +1027,10 @@ module Encoding = struct let consensus_result_encoding power_name = let open Data_encoding in obj4 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (req "delegate" Signature.Public_key_hash.encoding) (req (Format.asprintf "%s_power" power_name) int31) (req "consensus_key" Signature.Public_key_hash.encoding) @@ -1141,7 +1179,11 @@ module Encoding = struct { op_case = Operation.Encoding.seed_nonce_revelation_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Seed_nonce_revelation_result _ as op) -> Some op @@ -1160,7 +1202,11 @@ module Encoding = struct { op_case = Operation.Encoding.vdf_revelation_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Vdf_revelation_result _ as op) -> Some op @@ -1178,7 +1224,11 @@ module Encoding = struct { op_case = Operation.Encoding.double_endorsement_evidence_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Double_attestation_evidence_result _ as op) -> @@ -1198,7 +1248,11 @@ module Encoding = struct { op_case = Operation.Encoding.double_attestation_evidence_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Double_attestation_evidence_result _ as op) -> @@ -1218,7 +1272,11 @@ module Encoding = struct { op_case = Operation.Encoding.double_preendorsement_evidence_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Double_preattestation_evidence_result _ as op) -> @@ -1239,7 +1297,11 @@ module Encoding = struct { op_case = Operation.Encoding.double_preattestation_evidence_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Double_preattestation_evidence_result _ as op) -> @@ -1260,7 +1322,11 @@ module Encoding = struct { op_case = Operation.Encoding.double_baking_evidence_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Double_baking_evidence_result _ as op) -> Some op @@ -1279,7 +1345,11 @@ module Encoding = struct { op_case = Operation.Encoding.activate_account_case; encoding = - obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); + obj1 + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []); select = (function | Contents_result (Activate_account_result _ as op) -> Some op @@ -1332,7 +1402,10 @@ module Encoding = struct encoding = Data_encoding.( obj2 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (dft "allocated_destination_contract" bool false)); select = (function @@ -1362,7 +1435,10 @@ module Encoding = struct op_case = Operation.Encoding.Case op_case; encoding = obj3 - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + Receipt.balance_updates_encoding_with_legacy_attestation_name + []) (req "operation_result" res_case.t) (dft "internal_operation_results" diff --git a/src/proto_alpha/lib_protocol/migration_repr.ml b/src/proto_alpha/lib_protocol/migration_repr.ml index 0008eed3f778..c8a5508de791 100644 --- a/src/proto_alpha/lib_protocol/migration_repr.ml +++ b/src/proto_alpha/lib_protocol/migration_repr.ml @@ -56,7 +56,11 @@ let origination_result_list_encoding = paid_storage_size_diff; }) (obj4 - (dft "balance_updates" Receipt_repr.balance_updates_encoding []) + (dft + "balance_updates" + Receipt_repr + .balance_updates_encoding_with_legacy_attestation_name + []) (dft "originated_contracts" (list Contract_repr.originated_encoding) diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 77f3e5b9f3d4..99dd523ce12d 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1649,7 +1649,8 @@ module Pending_migration = struct (struct type t = Receipt_repr.balance_updates - let encoding = Receipt_repr.balance_updates_encoding + let encoding = + Receipt_repr.balance_updates_encoding_with_legacy_attestation_name end) module Operation_results = diff --git a/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml b/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml index 1e6b245a389b..aa5fc487c604 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml @@ -54,10 +54,14 @@ let test_encodings balance = let r8 = Receipt.(balance, Credited am, Block_application) in let coded = Json.construct - Receipt.balance_updates_encoding + Receipt.balance_updates_encoding_with_legacy_attestation_name [r1; r2; r3; r4; r5; r6; r7; r8] in - let decoded = Json.destruct Receipt.balance_updates_encoding coded in + let decoded = + Json.destruct + Receipt.balance_updates_encoding_with_legacy_attestation_name + coded + in match decoded with | [r1'; r2'; r3'; r4'; r5'; r6'; r7'; r8'] -> assert ( -- GitLab From c005b8974cf66dd22936c23cb0b6d944473dd649 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 11 Oct 2023 10:35:31 +0200 Subject: [PATCH 4/4] Revert "alpha: use binary operation encoding with attestation name" This reverts commit 46aabd7d856b77f9d45e0c596d78d82463873a5c. --- src/proto_alpha/lib_client/injection.ml | 16 +++++++---- .../client_proto_context_commands.ml | 3 +- .../client_proto_stresstest_commands.ml | 6 ++-- .../lib_delegate/baking_actions.ml | 10 ++++--- src/proto_alpha/lib_delegate/baking_state.ml | 18 ++++++++---- src/proto_alpha/lib_delegate/block_forge.ml | 3 +- src/proto_alpha/lib_delegate/node_rpc.ml | 6 ++-- .../lib_delegate/operation_pool.ml | 28 ++++++++++++++----- .../lib_delegate/operation_selection.ml | 14 ++++++++-- src/proto_alpha/lib_plugin/RPC.ml | 4 +-- src/proto_alpha/lib_plugin/mempool.ml | 4 ++- .../lib_protocol/mempool_validation.ml | 4 ++- .../lib_protocol/test/helpers/block.ml | 4 ++- .../lib_protocol/test/helpers/incremental.ml | 6 +++- .../lib_protocol/test/helpers/op.ml | 2 +- .../test/unit/test_operation_repr.ml | 4 +-- .../lib_sc_rollup_node/batcher_constants.ml | 2 +- .../lib_sc_rollup_node/sc_rollup_injector.ml | 14 +++++++--- 18 files changed, 104 insertions(+), 44 deletions(-) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 2afcd0220cf4..d82472539d74 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -241,7 +241,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let* _chain_id, branch = get_branch cctxt ~chain ~block branch in let bytes = Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name ({branch}, Contents_list contents) in let* signature = @@ -270,7 +270,11 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let packed_op = {shell = {branch}; protocol_data = Operation_data {contents; signature}} in - let size = Data_encoding.Binary.length Operation.encoding packed_op in + let size = + Data_encoding.Binary.length + Operation.encoding_with_legacy_attestation_name + packed_op + in let*! () = match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size @@ -791,12 +795,12 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) @@ Data_encoding.Binary.fixed_length Tezos_base.Operation.shell_header_encoding) + Data_encoding.Binary.length - Operation.contents_encoding + Operation.contents_encoding_with_legacy_attestation_name (Contents op) + signature_size_of_algo signature_algo else Data_encoding.Binary.length - Operation.contents_encoding + Operation.contents_encoding_with_legacy_attestation_name (Contents op) in let minimal_fees_in_nanotez = @@ -1060,7 +1064,9 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations if force then return_unit else Lwt.return res in let bytes = - Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) + Data_encoding.Binary.to_bytes_exn + Operation.encoding_with_legacy_attestation_name + (Operation.pack op) in if dry_run || simulation then let oph = Operation_hash.hash_bytes [bytes] in diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 1fc86d33ce71..93f8575e610d 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -817,7 +817,8 @@ let commands_ro () = "%a" Data_encoding.Binary_schema.pp (Data_encoding.Binary.describe - Alpha_context.Operation.unsigned_encoding) + Alpha_context.Operation + .unsigned_encoding_with_legacy_attestation_name) in return_unit); ] diff --git a/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml index d5e33b91cb58..b1e114f7f075 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml @@ -494,7 +494,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block let inject_contents (cctxt : Protocol_client_context.full) branch sk contents = let bytes = Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name ({branch}, Contents_list contents) in let signature = @@ -504,7 +504,9 @@ let inject_contents (cctxt : Protocol_client_context.full) branch sk contents = {shell = {branch}; protocol_data = {contents; signature}} in let bytes = - Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) + Data_encoding.Binary.to_bytes_exn + Operation.encoding_with_legacy_attestation_name + (Operation.pack op) in Shell_services.Injection.operation cctxt bytes diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index 91248110df0c..328a23bc86f7 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -476,7 +476,7 @@ let inject_preattestations state ~preattestations = in let unsigned_operation_bytes = Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name unsigned_operation in Client_keys.sign cctxt ~watermark sk_uri unsigned_operation_bytes @@ -571,7 +571,7 @@ let sign_attestations state attestations = let unsigned_operation = (shell, Contents_list contents) in let unsigned_operation_bytes = Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name unsigned_operation in Client_keys.sign cctxt ~watermark sk_uri unsigned_operation_bytes @@ -611,7 +611,7 @@ let sign_dal_attestations state attestations = let unsigned_operation = (shell, Contents_list contents) in let unsigned_operation_bytes = Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name unsigned_operation in let*! signature = @@ -672,7 +672,9 @@ let inject_dal_attestations state attestations = (attestation : Dal.Attestation.t), published_level ) -> let encoded_op = - Data_encoding.Binary.to_bytes_exn Operation.encoding signed_operation + Data_encoding.Binary.to_bytes_exn + Operation.encoding_with_legacy_attestation_name + signed_operation in let* oph = Shell_services.Injection.operation diff --git a/src/proto_alpha/lib_delegate/baking_state.ml b/src/proto_alpha/lib_delegate/baking_state.ml index 3f46c0dbb1d6..1207ba806458 100644 --- a/src/proto_alpha/lib_delegate/baking_state.ml +++ b/src/proto_alpha/lib_delegate/baking_state.ml @@ -157,7 +157,9 @@ let prequorum_encoding = (req "level" int32) (req "round" Round.encoding) (req "block_payload_hash" Block_payload_hash.encoding) - (req "preattestations" (list (dynamic_size Operation.encoding)))) + (req + "preattestations" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name)))) let block_info_encoding = let open Data_encoding in @@ -210,8 +212,12 @@ let block_info_encoding = (req "payload_round" Round.encoding) (req "round" Round.encoding) (req "prequorum" (option prequorum_encoding)) - (req "quorum" (list (dynamic_size Operation.encoding))) - (req "dal_attestations" (list (dynamic_size Operation.encoding))) + (req + "quorum" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (req + "dal_attestations" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) (req "payload" Operation_pool.payload_encoding)) let round_of_shell_header shell_header = @@ -437,7 +443,8 @@ let event_encoding = (tup3 (constant "Prequorum_reached") Operation_worker.candidate_encoding - (Data_encoding.list (dynamic_size Operation.encoding))) + (Data_encoding.list + (dynamic_size Operation.encoding_with_legacy_attestation_name))) (function | Prequorum_reached (candidate, ops) -> Some ((), candidate, List.map Operation.pack ops) @@ -451,7 +458,8 @@ let event_encoding = (tup3 (constant "Quorum_reached") Operation_worker.candidate_encoding - (Data_encoding.list (dynamic_size Operation.encoding))) + (Data_encoding.list + (dynamic_size Operation.encoding_with_legacy_attestation_name))) (function | Quorum_reached (candidate, ops) -> Some ((), candidate, List.map Operation.pack ops) diff --git a/src/proto_alpha/lib_delegate/block_forge.ml b/src/proto_alpha/lib_delegate/block_forge.ml index 19137cf3f57c..0d232cc20934 100644 --- a/src/proto_alpha/lib_delegate/block_forge.ml +++ b/src/proto_alpha/lib_delegate/block_forge.ml @@ -70,7 +70,8 @@ let convert_operation (op : packed_operation) : Tezos_base.Operation.t = shell = op.shell; proto = Data_encoding.Binary.to_bytes_exn - Alpha_context.Operation.protocol_data_encoding + Alpha_context.Operation + .protocol_data_encoding_with_legacy_attestation_name op.protocol_data; } diff --git a/src/proto_alpha/lib_delegate/node_rpc.ml b/src/proto_alpha/lib_delegate/node_rpc.ml index 7c9bb71b5e59..f43a7ef34fbb 100644 --- a/src/proto_alpha/lib_delegate/node_rpc.ml +++ b/src/proto_alpha/lib_delegate/node_rpc.ml @@ -44,7 +44,9 @@ let inject_block cctxt ?(force = false) ~chain signed_block_header operations = let inject_operation cctxt ~chain operation = let encoded_op = - Data_encoding.Binary.to_bytes_exn Operation.encoding operation + Data_encoding.Binary.to_bytes_exn + Operation.encoding_with_legacy_attestation_name + operation in Shell_services.Injection.operation cctxt ~async:true ~chain encoded_op @@ -155,7 +157,7 @@ let compute_block_info cctxt ~in_protocol ?operations ~chain block_hash let parse_op (raw_op : Tezos_base.Operation.t) = let protocol_data = Data_encoding.Binary.of_bytes_exn - Operation.protocol_data_encoding + Operation.protocol_data_encoding_with_legacy_attestation_name raw_op.proto in {shell = raw_op.shell; protocol_data} diff --git a/src/proto_alpha/lib_delegate/operation_pool.ml b/src/proto_alpha/lib_delegate/operation_pool.ml index 47dbc1ac8bab..7d9ca75987de 100644 --- a/src/proto_alpha/lib_delegate/operation_pool.ml +++ b/src/proto_alpha/lib_delegate/operation_pool.ml @@ -97,10 +97,18 @@ let ordered_pool_encoding = (fun (consensus, votes, anonymous, managers) -> {consensus; votes; anonymous; managers}) (obj4 - (req "ordered_consensus" (list (dynamic_size Operation.encoding))) - (req "ordered_votes" (list (dynamic_size Operation.encoding))) - (req "ordered_anonymouns" (list (dynamic_size Operation.encoding))) - (req "ordered_managers" (list (dynamic_size Operation.encoding)))) + (req + "ordered_consensus" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (req + "ordered_votes" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (req + "ordered_anonymouns" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (req + "ordered_managers" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name)))) type payload = { votes_payload : packed_operation list; @@ -119,9 +127,15 @@ let payload_encoding = (fun (votes_payload, anonymous_payload, managers_payload) -> {votes_payload; anonymous_payload; managers_payload}) (obj3 - (req "votes_payload" (list (dynamic_size Operation.encoding))) - (req "anonymous_payload" (list (dynamic_size Operation.encoding))) - (req "managers_payload" (list (dynamic_size Operation.encoding)))) + (req + "votes_payload" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (req + "anonymous_payload" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (req + "managers_payload" + (list (dynamic_size Operation.encoding_with_legacy_attestation_name)))) let pp_payload fmt {votes_payload; anonymous_payload; managers_payload} = Format.fprintf diff --git a/src/proto_alpha/lib_delegate/operation_selection.ml b/src/proto_alpha/lib_delegate/operation_selection.ml index 8df12bcd93d0..8fb78aac43b3 100644 --- a/src/proto_alpha/lib_delegate/operation_selection.ml +++ b/src/proto_alpha/lib_delegate/operation_selection.ml @@ -108,7 +108,11 @@ let prioritize_manager ~max_size ~hard_gas_limit_per_block ~minimal_fees | Ok (Some source, Some counter, fee, gas) -> if Tez.(fee < minimal_fees) then None else - let size = Data_encoding.Binary.length Operation.encoding op in + let size = + Data_encoding.Binary.length + Operation.encoding_with_legacy_attestation_name + op + in let size_f = Q.of_int size in let gas_f = Q.of_bigint (Gas.Arith.integral_to_z gas) in let fee_f = Q.of_int64 (Tez.to_mutez fee) in @@ -207,7 +211,9 @@ let filter_valid_operations_up_to_quota inc (ops, quota) = List.fold_left_s (fun (inc, curr_size, nb_ops, acc) op -> let op_size = - Data_encoding.Binary.length Alpha_context.Operation.encoding op + Data_encoding.Binary.length + Alpha_context.Operation.encoding_with_legacy_attestation_name + op in let new_size = curr_size + op_size in if new_size > max_size then return (inc, curr_size, nb_ops, acc) @@ -302,7 +308,9 @@ let filter_valid_operations_up_to_quota_without_simulation (ops, quota) = List.fold_left (fun (curr_size, nb_ops, acc) op -> let op_size = - Data_encoding.Binary.length Alpha_context.Operation.encoding op + Data_encoding.Binary.length + Alpha_context.Operation.encoding_with_legacy_attestation_name + op in let new_size = curr_size + op_size in if new_size > max_size then (curr_size, nb_ops, acc) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 12bc0eb3456b..2b1a9bd15344 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -2969,7 +2969,7 @@ module Forge = struct (fun () operation -> return (Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name operation)) ; Registration.register0_noctxt ~chunked:true @@ -3206,7 +3206,7 @@ module Parse = struct let open Result_syntax in match Data_encoding.Binary.of_bytes_opt - Operation.protocol_data_encoding + Operation.protocol_data_encoding_with_legacy_attestation_name op.proto with | Some protocol_data -> return {shell = op.shell; protocol_data} diff --git a/src/proto_alpha/lib_plugin/mempool.ml b/src/proto_alpha/lib_plugin/mempool.ml index 6e7674ac814c..b672a841d4b7 100644 --- a/src/proto_alpha/lib_plugin/mempool.ml +++ b/src/proto_alpha/lib_plugin/mempool.ml @@ -246,7 +246,9 @@ let size_of_operation op = (WithExceptions.Option.get ~loc:__LOC__ @@ Data_encoding.Binary.fixed_length Tezos_base.Operation.shell_header_encoding) - + Data_encoding.Binary.length Operation.protocol_data_encoding op + + Data_encoding.Binary.length + Operation.protocol_data_encoding_with_legacy_attestation_name + op (** Returns the weight and resources consumption of an operation. The weight corresponds to the one implemented by the baker, to decide which operations diff --git a/src/proto_alpha/lib_protocol/mempool_validation.ml b/src/proto_alpha/lib_protocol/mempool_validation.ml index c8041e9c30e9..e816542c8086 100644 --- a/src/proto_alpha/lib_protocol/mempool_validation.ml +++ b/src/proto_alpha/lib_protocol/mempool_validation.ml @@ -62,7 +62,9 @@ let encoding : t Data_encoding.t = (req "operations" (Operation_hash.Map.encoding - (dynamic_size ~kind:`Uint30 Operation.encoding))) + (dynamic_size + ~kind:`Uint30 + Operation.encoding_with_legacy_attestation_name))) let init ctxt chain_id ~predecessor_level ~predecessor_round ~predecessor_hash : validation_info * t = diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 860aca667afd..bed215ecfc2d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -852,7 +852,9 @@ let apply_with_metadata ?(policy = By_round 0) ?(check_size = true) ~baking_mode (fun vstate op -> (if check_size then let operation_size = - Data_encoding.Binary.length Operation.encoding op + Data_encoding.Binary.length + Operation.encoding_with_legacy_attestation_name + op in if operation_size > Constants_repr.max_operation_data_length then raise diff --git a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml index a66aad2eff26..697e2d5961d4 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml @@ -188,7 +188,11 @@ let detect_script_failure : let check_operation_size ?(check_size = true) op = if check_size then - let operation_size = Data_encoding.Binary.length Operation.encoding op in + let operation_size = + Data_encoding.Binary.length + Operation.encoding_with_legacy_attestation_name + op + in if operation_size > Constants_repr.max_operation_data_length then raise (invalid_arg diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index f762a97b4134..751ba0581bf2 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -34,7 +34,7 @@ let pack_operation ctxt signature contents = let sign ?(watermark = Signature.Generic_operation) sk branch contents = let unsigned = Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding + Operation.unsigned_encoding_with_legacy_attestation_name ({branch}, Contents_list contents) in let signature = Some (Signature.sign ~watermark sk unsigned) in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml b/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml index c6467d773628..2153116adbe1 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_operation_repr.ml @@ -106,7 +106,7 @@ module Test_operation_repr = struct let test_split_signatures error assemble = let op_bytes = Data_encoding.Binary.to_bytes_exn - Operation_repr.contents_encoding + Operation_repr.contents_encoding_with_legacy_attestation_name (Contents (Failing_noop "")) in let prefix, suffix = zero_bls in @@ -115,7 +115,7 @@ module Test_operation_repr = struct in match Data_encoding.Binary.of_bytes - Operation_repr.protocol_data_encoding + Operation_repr.protocol_data_encoding_with_legacy_attestation_name protocol_data_bytes with | Ok _ -> failwith "Should have failed with %s" error diff --git a/src/proto_alpha/lib_sc_rollup_node/batcher_constants.ml b/src/proto_alpha/lib_sc_rollup_node/batcher_constants.ml index edfa3ea32f00..c18ba0722bac 100644 --- a/src/proto_alpha/lib_sc_rollup_node/batcher_constants.ml +++ b/src/proto_alpha/lib_sc_rollup_node/batcher_constants.ml @@ -52,5 +52,5 @@ let protocol_max_batch_size = in Protocol.Constants_repr.max_operation_data_length - Data_encoding.Binary.length - Operation.encoding + Operation.encoding_with_legacy_attestation_name (Operation.pack empty_message_op) 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 5d6dee6bd1f5..9fd478da5222 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 @@ -122,7 +122,9 @@ module Proto_client = struct storage_limit = Z.zero; } in - Data_encoding.Binary.length Operation.contents_encoding (Contents contents) + Data_encoding.Binary.length + Operation.contents_encoding_with_legacy_attestation_name + (Contents contents) let operation_size op = manager_operation_size (injector_operation_to_manager op) @@ -153,7 +155,7 @@ module Proto_client = struct in let dummy_size = Data_encoding.Binary.length - Operation.contents_encoding + Operation.contents_encoding_with_legacy_attestation_name (Contents dummy_contents) in dummy_size - manager_operation_size (Manager dummy_operation) @@ -350,7 +352,9 @@ module Proto_client = struct ((shell, Contents_list contents) as unsigned_op) = let open Lwt_result_syntax in let unsigned_bytes = - Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding unsigned_op + Data_encoding.Binary.to_bytes_exn + Operation.unsigned_encoding_with_legacy_attestation_name + unsigned_op in let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) @@ -368,7 +372,9 @@ module Proto_client = struct protocol_data = Operation_data {contents; signature = Some signature}; } in - Data_encoding.Binary.to_bytes_exn Operation.encoding op + Data_encoding.Binary.to_bytes_exn + Operation.encoding_with_legacy_attestation_name + op let time_until_next_block {Injector.minimal_block_delay; delay_increment_per_round; _} -- GitLab