From 05e2dcc2c2c7432778e70c8a85a9516029cb6387 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 17 Aug 2023 11:18:27 +0200 Subject: [PATCH 1/5] alpha: use binary operation encoding with attestation name --- src/proto_alpha/lib_client/injection.ml | 16 ++++------- .../client_proto_context_commands.ml | 3 +- .../client_proto_stresstest_commands.ml | 6 ++-- src/proto_alpha/lib_delegate/baking_state.ml | 14 +++------- 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 +++------- 17 files changed, 39 insertions(+), 95 deletions(-) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 96bbaa97fe06..102da7c8f0f1 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_with_legacy_attestation_name + Operation.unsigned_encoding ({branch}, Contents_list contents) in let* signature = @@ -270,11 +270,7 @@ 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_with_legacy_attestation_name - packed_op - in + let size = Data_encoding.Binary.length Operation.encoding packed_op in let*! () = match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size @@ -798,12 +794,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_with_legacy_attestation_name + Operation.contents_encoding (Contents op) + signature_size_of_algo signature_algo else Data_encoding.Binary.length - Operation.contents_encoding_with_legacy_attestation_name + Operation.contents_encoding (Contents op) in let minimal_fees_in_nanotez = @@ -1071,9 +1067,7 @@ 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_with_legacy_attestation_name - (Operation.pack op) + Data_encoding.Binary.to_bytes_exn Operation.encoding (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 15303fe07692..7f63e4bb6f22 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,8 +817,7 @@ let commands_ro () = "%a" Data_encoding.Binary_schema.pp (Data_encoding.Binary.describe - Alpha_context.Operation - .unsigned_encoding_with_legacy_attestation_name) + Alpha_context.Operation.unsigned_encoding) in return_unit); command 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 3ca38cb6b692..a058c4c30f15 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_with_legacy_attestation_name + Operation.unsigned_encoding ({branch}, Contents_list contents) in let signature = @@ -504,9 +504,7 @@ 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_with_legacy_attestation_name - (Operation.pack op) + Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in Shell_services.Injection.operation cctxt bytes diff --git a/src/proto_alpha/lib_delegate/baking_state.ml b/src/proto_alpha/lib_delegate/baking_state.ml index a9705c23dbf1..1b3161b58b5f 100644 --- a/src/proto_alpha/lib_delegate/baking_state.ml +++ b/src/proto_alpha/lib_delegate/baking_state.ml @@ -155,9 +155,7 @@ 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_with_legacy_attestation_name)))) + (req "preattestations" (list (dynamic_size Operation.encoding)))) let block_info_encoding = let open Data_encoding in @@ -205,9 +203,7 @@ 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_with_legacy_attestation_name))) + (req "quorum" (list (dynamic_size Operation.encoding))) (req "payload" Operation_pool.payload_encoding)) let round_of_shell_header shell_header = @@ -443,8 +439,7 @@ let event_encoding = (tup3 (constant "Prequorum_reached") Operation_worker.candidate_encoding - (Data_encoding.list - (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (Data_encoding.list (dynamic_size Operation.encoding))) (function | Prequorum_reached (candidate, ops) -> Some ((), candidate, List.map Operation.pack ops) @@ -458,8 +453,7 @@ let event_encoding = (tup3 (constant "Quorum_reached") Operation_worker.candidate_encoding - (Data_encoding.list - (dynamic_size Operation.encoding_with_legacy_attestation_name))) + (Data_encoding.list (dynamic_size Operation.encoding))) (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 e6d6d62675dc..7338ce67d0db 100644 --- a/src/proto_alpha/lib_delegate/block_forge.ml +++ b/src/proto_alpha/lib_delegate/block_forge.ml @@ -68,8 +68,7 @@ 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_with_legacy_attestation_name + Alpha_context.Operation.protocol_data_encoding op.protocol_data; } diff --git a/src/proto_alpha/lib_delegate/node_rpc.ml b/src/proto_alpha/lib_delegate/node_rpc.ml index fc9608f62ef9..9e9da81a51f3 100644 --- a/src/proto_alpha/lib_delegate/node_rpc.ml +++ b/src/proto_alpha/lib_delegate/node_rpc.ml @@ -44,9 +44,7 @@ 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_with_legacy_attestation_name - operation + Data_encoding.Binary.to_bytes_exn Operation.encoding operation in Shell_services.Injection.operation cctxt ~async:true ~chain encoded_op @@ -150,7 +148,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_with_legacy_attestation_name + Operation.protocol_data_encoding 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 42fcc2a4efd1..c6cf50c36bbe 100644 --- a/src/proto_alpha/lib_delegate/operation_pool.ml +++ b/src/proto_alpha/lib_delegate/operation_pool.ml @@ -97,18 +97,10 @@ let ordered_pool_encoding = (fun (consensus, votes, anonymous, managers) -> {consensus; votes; anonymous; managers}) (obj4 - (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)))) + (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)))) type payload = { votes_payload : packed_operation list; @@ -127,15 +119,9 @@ 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_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)))) + (req "votes_payload" (list (dynamic_size Operation.encoding))) + (req "anonymous_payload" (list (dynamic_size Operation.encoding))) + (req "managers_payload" (list (dynamic_size Operation.encoding)))) 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 32c47f8e8b55..d83f7c55369a 100644 --- a/src/proto_alpha/lib_delegate/operation_selection.ml +++ b/src/proto_alpha/lib_delegate/operation_selection.ml @@ -108,11 +108,7 @@ 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_with_legacy_attestation_name - op - in + let size = Data_encoding.Binary.length Operation.encoding 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 @@ -211,9 +207,7 @@ 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_with_legacy_attestation_name - op + Data_encoding.Binary.length Alpha_context.Operation.encoding op in let new_size = curr_size + op_size in if new_size > max_size then return (inc, curr_size, nb_ops, acc) @@ -347,9 +341,7 @@ 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_with_legacy_attestation_name - op + Data_encoding.Binary.length Alpha_context.Operation.encoding 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 3c46a35f2f66..aa2a40100595 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -3242,7 +3242,7 @@ module Forge = struct (fun () operation -> return (Data_encoding.Binary.to_bytes_exn - Operation.unsigned_encoding_with_legacy_attestation_name + Operation.unsigned_encoding operation)) ; Registration.register0_noctxt ~chunked:true @@ -3479,7 +3479,7 @@ module Parse = struct let open Result_syntax in match Data_encoding.Binary.of_bytes_opt - Operation.protocol_data_encoding_with_legacy_attestation_name + Operation.protocol_data_encoding 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 6f5a0fc72074..69361cf3b9d4 100644 --- a/src/proto_alpha/lib_plugin/mempool.ml +++ b/src/proto_alpha/lib_plugin/mempool.ml @@ -246,9 +246,7 @@ 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_with_legacy_attestation_name - op + + Data_encoding.Binary.length Operation.protocol_data_encoding 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 3978dd6d2dba..67dd1fbeaf76 100644 --- a/src/proto_alpha/lib_protocol/mempool_validation.ml +++ b/src/proto_alpha/lib_protocol/mempool_validation.ml @@ -62,9 +62,7 @@ let encoding : t Data_encoding.t = (req "operations" (Operation_hash.Map.encoding - (dynamic_size - ~kind:`Uint30 - Operation.encoding_with_legacy_attestation_name))) + (dynamic_size ~kind:`Uint30 Operation.encoding))) 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 36b85fd6921e..a84f6f4cbe38 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -866,9 +866,7 @@ let apply_with_metadata ?(policy = By_round 0) ?(check_size = true) (fun (vstate, contents_result) op -> (if check_size then let operation_size = - Data_encoding.Binary.length - Operation.encoding_with_legacy_attestation_name - op + Data_encoding.Binary.length Operation.encoding 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 13524daac17f..decfedcbf6da 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml @@ -188,11 +188,7 @@ 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_with_legacy_attestation_name - op - in + let operation_size = Data_encoding.Binary.length Operation.encoding 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 152bd16a0bfb..229c722639ed 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_with_legacy_attestation_name + Operation.unsigned_encoding ({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 d3d97aa26b59..688e77036497 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 @@ -108,7 +108,7 @@ module Test_operation_repr = struct let open Lwt_result_syntax in let op_bytes = Data_encoding.Binary.to_bytes_exn - Operation_repr.contents_encoding_with_legacy_attestation_name + Operation_repr.contents_encoding (Contents (Failing_noop "")) in let prefix, suffix = zero_bls in @@ -117,7 +117,7 @@ module Test_operation_repr = struct in match Data_encoding.Binary.of_bytes - Operation_repr.protocol_data_encoding_with_legacy_attestation_name + Operation_repr.protocol_data_encoding 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 c18ba0722bac..edfa3ea32f00 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_with_legacy_attestation_name + Operation.encoding (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 46460a9ad19b..da2fa6e81978 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 @@ -123,9 +123,7 @@ module Proto_client = struct storage_limit = Z.zero; } in - Data_encoding.Binary.length - Operation.contents_encoding_with_legacy_attestation_name - (Contents contents) + Data_encoding.Binary.length Operation.contents_encoding (Contents contents) let operation_size op = manager_operation_size (injector_operation_to_manager op) @@ -156,7 +154,7 @@ module Proto_client = struct in let dummy_size = Data_encoding.Binary.length - Operation.contents_encoding_with_legacy_attestation_name + Operation.contents_encoding (Contents dummy_contents) in dummy_size - manager_operation_size (Manager dummy_operation) @@ -355,9 +353,7 @@ 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_with_legacy_attestation_name - unsigned_op + Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding unsigned_op in let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) @@ -375,9 +371,7 @@ module Proto_client = struct protocol_data = Operation_data {contents; signature = Some signature}; } in - Data_encoding.Binary.to_bytes_exn - Operation.encoding_with_legacy_attestation_name - op + Data_encoding.Binary.to_bytes_exn Operation.encoding op let time_until_next_block {Injector.minimal_block_delay; delay_increment_per_round; _} -- GitLab From 54e9ce4e956001e984a794dc5741d9d2cd80217f Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 17 Aug 2023 11:43:33 +0200 Subject: [PATCH 2/5] alpha: use binary balance updates encoding --- .../lib_protocol/apply_internal_results.ml | 15 +-- src/proto_alpha/lib_protocol/apply_results.ml | 123 ++++-------------- .../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, 33 insertions(+), 122 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply_internal_results.ml b/src/proto_alpha/lib_protocol/apply_internal_results.ml index 850a38250d0c..9f5989e5eb69 100644 --- a/src/proto_alpha/lib_protocol/apply_internal_results.ml +++ b/src/proto_alpha/lib_protocol/apply_internal_results.ml @@ -241,10 +241,7 @@ module Internal_operation = struct (Tag 0) (obj9 (opt "storage" Script.expr_encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "ticket_receipt" Ticket_receipt.encoding []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) @@ -571,10 +568,7 @@ module Internal_operation_result = struct ~op_case:Internal_operation.origination_case ~encoding: (obj6 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "storage_size" z Z.zero) @@ -630,10 +624,7 @@ 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_with_legacy_attestation_name - [])) + (dft "balance_updates" Receipt.balance_updates_encoding [])) ~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 9901c0ddeaa1..06bc0928ba31 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -288,10 +288,7 @@ module Manager_result = struct (Tag 0) (obj9 (opt "storage" Script.expr_encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "ticket_updates" Ticket_receipt.encoding []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) @@ -375,10 +372,7 @@ module Manager_result = struct ~op_case:Operation.Encoding.Manager_operations.origination_case ~encoding: (obj6 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "originated_contracts" (list Contract.originated_encoding) []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "storage_size" z Z.zero) @@ -432,10 +426,7 @@ module Manager_result = struct Operation.Encoding.Manager_operations.register_global_constant_case ~encoding: (obj4 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "storage_size" z Z.zero) (req "global_address" Script_expr_hash.encoding)) @@ -460,10 +451,7 @@ 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_with_legacy_attestation_name - [])) + (dft "balance_updates" Receipt.balance_updates_encoding [])) ~select:(function | Successful_manager_result (Delegation_result _ as op) -> Some op | _ -> None) @@ -510,10 +498,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj2 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero)) ~select:(function | Successful_manager_result (Increase_paid_storage_result _ as op) -> @@ -532,9 +517,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj4 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (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)) @@ -592,9 +575,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj4 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (req "originated_zk_rollup" Zk_rollup.Address.encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "size" z)) @@ -619,9 +600,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj3 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "size" z)) ~select:(function @@ -643,9 +622,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj3 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (dft "paid_storage_size_diff" z Z.zero)) ~select:(function @@ -665,9 +642,7 @@ module Manager_result = struct ~op_case:Operation.Encoding.Manager_operations.sc_rollup_originate_case ~encoding: (obj5 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (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) @@ -747,9 +722,7 @@ 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_with_legacy_attestation_name)) + (req "balance_updates" Receipt.balance_updates_encoding)) ~select:(function | Successful_manager_result (Sc_rollup_publish_result _ as op) -> Some op @@ -772,9 +745,7 @@ 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_with_legacy_attestation_name)) + (req "balance_updates" Receipt.balance_updates_encoding)) ~select:(function | Successful_manager_result (Sc_rollup_refute_result _ as op) -> Some op | _ -> None) @@ -793,9 +764,7 @@ 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_with_legacy_attestation_name)) + (req "balance_updates" Receipt.balance_updates_encoding)) ~select:(function | Successful_manager_result (Sc_rollup_timeout_result _ as op) -> Some op @@ -816,9 +785,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj5 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (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) @@ -864,9 +831,7 @@ module Manager_result = struct ~encoding: Data_encoding.( obj2 - (req - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name) + (req "balance_updates" Receipt.balance_updates_encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero)) ~select:(function | Successful_manager_result (Sc_rollup_recover_bond_result _ as op) -> @@ -1057,10 +1022,7 @@ module Encoding = struct let consensus_result_encoding power_name = let open Data_encoding in obj4 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (req "delegate" Signature.Public_key_hash.encoding) (req (Format.asprintf "%s_power" power_name) int31) (req "consensus_key" Signature.Public_key_hash.encoding) @@ -1263,11 +1225,7 @@ module Encoding = struct { op_case = Operation.Encoding.seed_nonce_revelation_case; encoding = - obj1 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Seed_nonce_revelation_result _ as op) -> Some op @@ -1286,11 +1244,7 @@ module Encoding = struct { op_case = Operation.Encoding.vdf_revelation_case; encoding = - obj1 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Vdf_revelation_result _ as op) -> Some op @@ -1310,10 +1264,7 @@ module Encoding = struct encoding = obj2 (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Double_attestation_evidence_result _ as op) -> @@ -1341,10 +1292,7 @@ module Encoding = struct encoding = obj2 (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Double_attestation_evidence_result _ as op) -> @@ -1372,10 +1320,7 @@ module Encoding = struct encoding = obj2 (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Double_preattestation_evidence_result _ as op) -> @@ -1404,10 +1349,7 @@ module Encoding = struct encoding = obj2 (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Double_preattestation_evidence_result _ as op) -> @@ -1436,10 +1378,7 @@ module Encoding = struct encoding = obj2 (opt "forbidden_delegate" Signature.Public_key_hash.encoding) - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Double_baking_evidence_result _ as op) -> Some op @@ -1463,11 +1402,7 @@ module Encoding = struct { op_case = Operation.Encoding.activate_account_case; encoding = - obj1 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []); + obj1 (dft "balance_updates" Receipt.balance_updates_encoding []); select = (function | Contents_result (Activate_account_result _ as op) -> Some op @@ -1520,10 +1455,7 @@ module Encoding = struct encoding = Data_encoding.( obj2 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (dft "allocated_destination_contract" bool false)); select = (function @@ -1553,10 +1485,7 @@ module Encoding = struct op_case = Operation.Encoding.Case op_case; encoding = obj3 - (dft - "balance_updates" - Receipt.balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (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 c8a5508de791..0008eed3f778 100644 --- a/src/proto_alpha/lib_protocol/migration_repr.ml +++ b/src/proto_alpha/lib_protocol/migration_repr.ml @@ -56,11 +56,7 @@ let origination_result_list_encoding = paid_storage_size_diff; }) (obj4 - (dft - "balance_updates" - Receipt_repr - .balance_updates_encoding_with_legacy_attestation_name - []) + (dft "balance_updates" Receipt_repr.balance_updates_encoding []) (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 8a4764b4002c..5db19a08d24e 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1602,8 +1602,7 @@ module Pending_migration = struct (struct type t = Receipt_repr.balance_updates - let encoding = - Receipt_repr.balance_updates_encoding_with_legacy_attestation_name + let encoding = Receipt_repr.balance_updates_encoding 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 9022a52ae707..37f109b28994 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml @@ -55,14 +55,10 @@ let test_encodings balance = let r8 = Receipt.item balance (Credited am) Block_application in let coded = Json.construct - Receipt.balance_updates_encoding_with_legacy_attestation_name + Receipt.balance_updates_encoding [r1; r2; r3; r4; r5; r6; r7; r8] in - let decoded = - Json.destruct - Receipt.balance_updates_encoding_with_legacy_attestation_name - coded - in + let decoded = Json.destruct Receipt.balance_updates_encoding coded in match decoded with | [r1'; r2'; r3'; r4'; r5'; r6'; r7'; r8'] -> assert ( -- GitLab From 6a374e0a06874aef7d2f8427bc1a68e6dcaf214b Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 17 Aug 2023 12:03:42 +0200 Subject: [PATCH 3/5] alpha/baker: external operations should use attestation in JSON --- src/proto_alpha/lib_delegate/baking_actions.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index 61b325680da9..d925c1414921 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -37,8 +37,7 @@ module Operations_source = struct } let operations_encoding = - Data_encoding.( - list (dynamic_size Operation.encoding_with_legacy_attestation_name)) + Data_encoding.(list (dynamic_size Operation.encoding)) let retrieve = let open Lwt_result_syntax in -- GitLab From b4e13c6fc10ba9a07c15943e281cc1030b6d537c Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 17 Aug 2023 12:00:20 +0200 Subject: [PATCH 4/5] alpha/lib_client: use operation encoding with attestation in pretty printer and messages --- 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 aac91ab80b72..897103203366 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_with_legacy_attestation_name in + let encoding = Operation.unsigned_encoding 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 102da7c8f0f1..de3bff19d7a8 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_with_legacy_attestation_name + Operation.unsigned_encoding ({branch}, Contents_list contents) in item (fun ppf () -> -- GitLab From 914dd6746ee4ce50fc8b5fed67fd100c506c7a47 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Tue, 6 Feb 2024 15:23:09 +0100 Subject: [PATCH 5/5] alpha/lib_injector: use operation encoding with attestation --- src/proto_alpha/lib_injector/injector_plugin.ml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/proto_alpha/lib_injector/injector_plugin.ml b/src/proto_alpha/lib_injector/injector_plugin.ml index 7c0077d85e67..33b9d8111a4c 100644 --- a/src/proto_alpha/lib_injector/injector_plugin.ml +++ b/src/proto_alpha/lib_injector/injector_plugin.ml @@ -102,9 +102,7 @@ module Proto_client = struct storage_limit = Z.zero; } in - Data_encoding.Binary.length - Operation.contents_encoding_with_legacy_attestation_name - (Contents contents) + Data_encoding.Binary.length Operation.contents_encoding (Contents contents) let operation_size op = manager_operation_size (to_manager_operation op) @@ -134,7 +132,7 @@ module Proto_client = struct in let dummy_size = Data_encoding.Binary.length - Operation.contents_encoding_with_legacy_attestation_name + Operation.contents_encoding (Contents dummy_contents) in dummy_size - manager_operation_size (Manager dummy_operation) @@ -333,9 +331,7 @@ 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_with_legacy_attestation_name - unsigned_op + Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding unsigned_op in let cctxt = new Protocol_client_context.wrap_full (cctxt :> Client_context.full) @@ -353,9 +349,7 @@ module Proto_client = struct protocol_data = Operation_data {contents; signature = Some signature}; } in - Data_encoding.Binary.to_bytes_exn - Operation.encoding_with_legacy_attestation_name - op + Data_encoding.Binary.to_bytes_exn Operation.encoding op let time_until_next_block {minimal_block_delay; delay_increment_per_round; _} (header : Tezos_base.Block_header.shell_header option) = -- GitLab