From d762160acd26577c47f525060aa16c8bdbfff4cd Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 22 Jun 2023 16:50:00 +0200 Subject: [PATCH 1/7] proto_alpha: add a new encoding for balance updates with legacy attestation name --- .../lib_protocol/alpha_context.mli | 3 + .../lib_protocol/apply_internal_results.ml | 15 +- src/proto_alpha/lib_protocol/apply_results.ml | 148 ++++++++++++++---- .../lib_protocol/apply_results.mli | 3 + .../lib_protocol/migration_repr.ml | 6 +- src/proto_alpha/lib_protocol/receipt_repr.ml | 49 +++++- src/proto_alpha/lib_protocol/receipt_repr.mli | 11 ++ src/proto_alpha/lib_protocol/storage.ml | 3 +- .../lib_protocol/test/unit/test_receipt.ml | 8 +- 9 files changed, 204 insertions(+), 42 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 1a234925c0cc..b05a7975d442 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2070,6 +2070,9 @@ module Receipt : sig val balance_updates_encoding : balance_updates Data_encoding.t + val balance_updates_encoding_with_legacy_attestation_name : + balance_updates Data_encoding.t + val group_balance_updates : balance_updates -> balance_updates tzresult end 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 50992174b725..0a7bf4733212 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -283,7 +283,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) @@ -367,7 +370,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) @@ -421,7 +427,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)) @@ -446,7 +455,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) @@ -478,7 +490,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) -> @@ -497,7 +512,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)) @@ -555,7 +572,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)) @@ -580,7 +599,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 @@ -602,7 +623,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 @@ -622,7 +645,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) @@ -702,7 +727,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 @@ -725,7 +752,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) @@ -744,7 +773,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 @@ -765,7 +796,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)) @@ -806,7 +839,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) -> @@ -986,7 +1021,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) @@ -1135,7 +1173,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 @@ -1154,7 +1196,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 @@ -1172,7 +1218,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_endorsement_evidence_result _ as op) -> @@ -1192,7 +1242,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_endorsement_evidence_result _ as op) -> @@ -1212,7 +1266,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) -> @@ -1233,7 +1291,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) -> @@ -1254,7 +1316,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 @@ -1273,7 +1339,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 @@ -1326,7 +1396,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 @@ -1356,7 +1429,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" @@ -2605,9 +2681,12 @@ type block_metadata = { dal_attestation : Dal.Attestation.t option; } -let block_metadata_encoding = +let block_metadata_encoding ~use_legacy_attestation_name = let open Data_encoding in - def "block_header.alpha.metadata" + def + (if use_legacy_attestation_name then + "block_header.alpha.metadata_with_legacy_attestation_name" + else "block_header.alpha.metadata") @@ conv (fun { proposer = @@ -2678,7 +2757,12 @@ let block_metadata_encoding = (req "voting_period_info" Voting_period.info_encoding) (req "nonce_hash" (option Nonce_hash.encoding)) (req "deactivated" (list Signature.Public_key_hash.encoding)) - (dft "balance_updates" Receipt.balance_updates_encoding []) + (dft + "balance_updates" + (if use_legacy_attestation_name then + Receipt.balance_updates_encoding_with_legacy_attestation_name + else Receipt.balance_updates_encoding) + []) (req "liquidity_baking_toggle_ema" Per_block_votes.Liquidity_baking_toggle_EMA.encoding) @@ -2698,3 +2782,9 @@ let block_metadata_encoding = flag. This should be replaced by a required field once the feature flag will be activated. *) (varopt "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 bf9ee06d8b22..477be4ae2891 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -346,4 +346,7 @@ type block_metadata = { dal_attestation : Dal.Attestation.t option; } +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/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/receipt_repr.ml b/src/proto_alpha/lib_protocol/receipt_repr.ml index 87c604a29ccd..4002d8917097 100644 --- a/src/proto_alpha/lib_protocol/receipt_repr.ml +++ b/src/proto_alpha/lib_protocol/receipt_repr.ml @@ -47,7 +47,7 @@ type balance = | Sc_rollup_refutation_punishments | Sc_rollup_refutation_rewards -let balance_encoding = +let balance_encoding ~use_legacy_attestation_name = let open Data_encoding in let case = function | Tag tag -> @@ -59,7 +59,10 @@ let balance_encoding = case (Tag tag) | _ as c -> case c in - def "operation_metadata.alpha.balance" + def + (if use_legacy_attestation_name then + "operation_metadata_with_legacy_attestation_name.alpha.balance" + else "operation_metadata.alpha.balance") @@ union [ case @@ -99,10 +102,16 @@ let balance_encoding = https://gitlab.com/tezos/tezos/-/merge_requests/7758 *) case (Tag 7) - ~title:"Endorsing_rewards" + ~title: + (if use_legacy_attestation_name then "Endorsing_rewards" + else "Attesting_rewards") (obj2 (req "kind" (constant "minted")) - (req "category" (constant "endorsing rewards"))) + (req + "category" + (constant + (if use_legacy_attestation_name then "endorsing rewards" + else "attesting rewards")))) (function Endorsing_rewards -> Some ((), ()) | _ -> None) (fun ((), ()) -> Endorsing_rewards); case @@ -139,10 +148,17 @@ let balance_encoding = (fun ((), ()) -> Double_signing_punishments); case (Tag 13) - ~title:"Lost_endorsing_rewards" + ~title: + (if use_legacy_attestation_name then "Lost_endorsing_rewards" + else "Lost_attesting_rewards") (obj5 (req "kind" (constant "burned")) - (req "category" (constant "lost endorsing rewards")) + (req + "category" + (constant + (if use_legacy_attestation_name then + "lost endorsing rewards" + else "lost attesting rewards"))) (req "delegate" Signature.Public_key_hash.encoding) (req "participation" Data_encoding.bool) (req "revelation" Data_encoding.bool)) @@ -248,6 +264,11 @@ let balance_encoding = (fun ((), (), d, c) -> Unstaked_deposits (d, c)); ] +let balance_encoding_with_legacy_attestation_name = + balance_encoding ~use_legacy_attestation_name:true + +let balance_encoding = balance_encoding ~use_legacy_attestation_name:false + let is_not_zero c = not (Compare.Int.equal c 0) let compare_balance ba bb = @@ -372,6 +393,22 @@ let update_origin_encoding = type balance_updates = (balance * balance_update * update_origin) list +let balance_updates_encoding_with_legacy_attestation_name = + let open Data_encoding in + def "operation_metadata_with_legacy_attestation_name.alpha.balance_updates" + @@ list + (conv + (function + | balance, balance_update, update_origin -> + ((balance, balance_update), update_origin)) + (fun ((balance, balance_update), update_origin) -> + (balance, balance_update, update_origin)) + (merge_objs + (merge_objs + balance_encoding_with_legacy_attestation_name + balance_update_encoding) + update_origin_encoding)) + let balance_updates_encoding = let open Data_encoding in def "operation_metadata.alpha.balance_updates" diff --git a/src/proto_alpha/lib_protocol/receipt_repr.mli b/src/proto_alpha/lib_protocol/receipt_repr.mli index 11dff7c3e9a6..6a312891527f 100644 --- a/src/proto_alpha/lib_protocol/receipt_repr.mli +++ b/src/proto_alpha/lib_protocol/receipt_repr.mli @@ -76,5 +76,16 @@ type balance_updates = (balance * balance_update * update_origin) list [balance_update] [(_ Tez_repr.zero)] always decodes into [(Credited Tez_repr.zero)]. *) val balance_updates_encoding : balance_updates Data_encoding.t +(** Balance updates encoding that uses legacy attestation name : `endorsing + right` and `lost endorsing right` when encoding to JSON + + https://gitlab.com/tezos/tezos/-/issues/5529 + + This encoding is temporary and should be removed when the endorsements kinds + in JSON will not be accepted any more by the protocol. +*) +val balance_updates_encoding_with_legacy_attestation_name : + balance_updates Data_encoding.t + (** Group updates by (balance x origin), and remove zero-valued balances. *) val group_balance_updates : balance_updates -> balance_updates tzresult diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index c4f2554a1f11..9e370ef0ef68 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1609,7 +1609,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 bb89605dc412..42f1f9686ddd 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 3f5cf01c79046b6343dd26a896587eadc9a1d69e Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 22 Jun 2023 16:54:32 +0200 Subject: [PATCH 2/7] environment: introduce new balance_updates_encoding that supports legacy attestation name --- src/lib_protocol_environment/environment_V3.ml | 3 +++ src/lib_protocol_environment/environment_V4.ml | 3 +++ src/lib_protocol_environment/environment_V5.ml | 3 +++ src/lib_protocol_environment/environment_V6.ml | 3 +++ src/lib_protocol_environment/environment_V7.ml | 3 +++ src/lib_protocol_environment/environment_V8.ml | 3 +++ src/lib_protocol_environment/environment_V9.ml | 3 +++ src/lib_protocol_environment/environment_protocol_T.ml | 3 +++ src/lib_protocol_environment/environment_protocol_T_V10.ml | 3 +++ src/lib_protocol_environment/environment_protocol_T_test.ml | 3 +++ src/lib_protocol_environment/sigs/v10.ml | 5 +++++ src/lib_protocol_environment/sigs/v10/updater.mli | 5 +++++ src/proto_alpha/lib_protocol/main.ml | 3 +++ src/proto_demo_counter/lib_protocol/main.ml | 3 +++ src/proto_demo_noops/lib_protocol/main.ml | 3 +++ 15 files changed, 49 insertions(+) diff --git a/src/lib_protocol_environment/environment_V3.ml b/src/lib_protocol_environment/environment_V3.ml index 1194e7f4f905..360e490704c9 100644 --- a/src/lib_protocol_environment/environment_V3.ml +++ b/src/lib_protocol_environment/environment_V3.ml @@ -1044,6 +1044,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_V4.ml b/src/lib_protocol_environment/environment_V4.ml index f399cfbde17b..ed770f9a98e8 100644 --- a/src/lib_protocol_environment/environment_V4.ml +++ b/src/lib_protocol_environment/environment_V4.ml @@ -1061,6 +1061,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_V5.ml b/src/lib_protocol_environment/environment_V5.ml index 2810f3269a02..43dddd2cfc18 100644 --- a/src/lib_protocol_environment/environment_V5.ml +++ b/src/lib_protocol_environment/environment_V5.ml @@ -1038,6 +1038,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_V6.ml b/src/lib_protocol_environment/environment_V6.ml index 96c477845739..6b021941c143 100644 --- a/src/lib_protocol_environment/environment_V6.ml +++ b/src/lib_protocol_environment/environment_V6.ml @@ -1128,6 +1128,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_V7.ml b/src/lib_protocol_environment/environment_V7.ml index fd4bb1daccc2..60df5f376f19 100644 --- a/src/lib_protocol_environment/environment_V7.ml +++ b/src/lib_protocol_environment/environment_V7.ml @@ -1110,6 +1110,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_V8.ml b/src/lib_protocol_environment/environment_V8.ml index a418d0daf486..50361f4fc33d 100644 --- a/src/lib_protocol_environment/environment_V8.ml +++ b/src/lib_protocol_environment/environment_V8.ml @@ -1156,6 +1156,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_V9.ml b/src/lib_protocol_environment/environment_V9.ml index 6395c37103cb..264320800d8a 100644 --- a/src/lib_protocol_environment/environment_V9.ml +++ b/src/lib_protocol_environment/environment_V9.ml @@ -1156,6 +1156,9 @@ struct include P + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_protocol_T.ml b/src/lib_protocol_environment/environment_protocol_T.ml index f3947ab058ff..c7ca0e0cd831 100644 --- a/src/lib_protocol_environment/environment_protocol_T.ml +++ b/src/lib_protocol_environment/environment_protocol_T.ml @@ -80,6 +80,9 @@ module V0toV10 and type cache_value = Context.Cache.value = struct include E + let block_header_metadata_encoding_with_legacy_attestation_name = + block_header_metadata_encoding + let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding diff --git a/src/lib_protocol_environment/environment_protocol_T_V10.ml b/src/lib_protocol_environment/environment_protocol_T_V10.ml index de815bec7a8f..80b3dba1b925 100644 --- a/src/lib_protocol_environment/environment_protocol_T_V10.ml +++ b/src/lib_protocol_environment/environment_protocol_T_V10.ml @@ -57,6 +57,9 @@ module type T = sig type block_header_metadata + val block_header_metadata_encoding_with_legacy_attestation_name : + block_header_metadata Data_encoding.t + val block_header_metadata_encoding : block_header_metadata Data_encoding.t type operation_data diff --git a/src/lib_protocol_environment/environment_protocol_T_test.ml b/src/lib_protocol_environment/environment_protocol_T_test.ml index c79fddeb4421..f71431a53de2 100644 --- a/src/lib_protocol_environment/environment_protocol_T_test.ml +++ b/src/lib_protocol_environment/environment_protocol_T_test.ml @@ -111,6 +111,9 @@ module Mock_all_unit : let operation_data_encoding_with_legacy_attestation_name = operation_data_encoding + let block_header_metadata_encoding_with_legacy_attestation_name = + Data_encoding.unit + let block_header_metadata_encoding = Data_encoding.unit let block_header_data_encoding = Data_encoding.unit diff --git a/src/lib_protocol_environment/sigs/v10.ml b/src/lib_protocol_environment/sigs/v10.ml index 7d9bb634f39b..4462553c5345 100644 --- a/src/lib_protocol_environment/sigs/v10.ml +++ b/src/lib_protocol_environment/sigs/v10.ml @@ -11411,6 +11411,11 @@ module type PROTOCOL = sig validation. *) type block_header_metadata + (** Encoding for economic protocol-specific block metadata. This encoding uses + the attestation legacy name: endorsement. *) + val block_header_metadata_encoding_with_legacy_attestation_name : + block_header_metadata Data_encoding.t + (** Encoding for economic protocol-specific block metadata. *) val block_header_metadata_encoding : block_header_metadata Data_encoding.t diff --git a/src/lib_protocol_environment/sigs/v10/updater.mli b/src/lib_protocol_environment/sigs/v10/updater.mli index 5a7089ab7f1e..e394c22b9b62 100644 --- a/src/lib_protocol_environment/sigs/v10/updater.mli +++ b/src/lib_protocol_environment/sigs/v10/updater.mli @@ -97,6 +97,11 @@ module type PROTOCOL = sig validation. *) type block_header_metadata + (** Encoding for economic protocol-specific block metadata. This encoding uses + the attestation legacy name: endorsement. *) + val block_header_metadata_encoding_with_legacy_attestation_name : + block_header_metadata Data_encoding.t + (** Encoding for economic protocol-specific block metadata. *) val block_header_metadata_encoding : block_header_metadata Data_encoding.t diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index e1e5bd9387f1..918ba6539849 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -37,6 +37,9 @@ 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 + let block_header_metadata_encoding = Apply_results.block_metadata_encoding type operation_data = Alpha_context.packed_protocol_data = diff --git a/src/proto_demo_counter/lib_protocol/main.ml b/src/proto_demo_counter/lib_protocol/main.ml index 904c62b5f56c..c76e3b59ab95 100644 --- a/src/proto_demo_counter/lib_protocol/main.ml +++ b/src/proto_demo_counter/lib_protocol/main.ml @@ -42,6 +42,9 @@ let block_header_data_encoding = Header.encoding type block_header_metadata = State.t +let block_header_metadata_encoding_with_legacy_attestation_name = + State.encoding + let block_header_metadata_encoding = State.encoding type operation_data = Proto_operation.t diff --git a/src/proto_demo_noops/lib_protocol/main.ml b/src/proto_demo_noops/lib_protocol/main.ml index 1857c867d73d..b6c1c4df8a9f 100644 --- a/src/proto_demo_noops/lib_protocol/main.ml +++ b/src/proto_demo_noops/lib_protocol/main.ml @@ -43,6 +43,9 @@ type block_header = { type block_header_metadata = unit +let block_header_metadata_encoding_with_legacy_attestation_name = + Data_encoding.unit + let block_header_metadata_encoding = Data_encoding.unit type operation_data = unit -- GitLab From 493531396c16c3fa8af07d19279b8e54443d7211 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Tue, 11 Jul 2023 11:39:35 +0200 Subject: [PATCH 3/7] node: use legacy block_header_metadata_encoding everywhere outside of the protocol --- src/bin_node/node_replay_command.ml | 6 ++++-- src/lib_shell/block_directory.ml | 2 +- src/lib_shell_services/block_services.ml | 8 +++++--- src/lib_shell_services/block_services.mli | 3 ++- src/lib_store/unix/test/alpha_utils.ml | 2 +- src/lib_validation/block_validation.ml | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/bin_node/node_replay_command.ml b/src/bin_node/node_replay_command.ml index fe8dd992eb04..a2deae5b735f 100644 --- a/src/bin_node/node_replay_command.ml +++ b/src/bin_node/node_replay_command.ml @@ -299,9 +299,11 @@ let replay_one_block strict main_chain_store validator_process block = (not (Bytes.equal expected_block_receipt_bytes block_metadata_bytes)) (fun () -> let to_json block = - Data_encoding.Json.construct Proto.block_header_metadata_encoding + Data_encoding.Json.construct + Proto.block_header_metadata_encoding_with_legacy_attestation_name @@ Data_encoding.Binary.of_bytes_exn - Proto.block_header_metadata_encoding + Proto + .block_header_metadata_encoding_with_legacy_attestation_name block in let exp = to_json expected_block_receipt_bytes in diff --git a/src/lib_shell/block_directory.ml b/src/lib_shell/block_directory.ml index 47be17da83ce..5c87e91331f7 100644 --- a/src/lib_shell/block_directory.ml +++ b/src/lib_shell/block_directory.ml @@ -197,7 +197,7 @@ let build_raw_rpc_directory (module Proto : Block_services.PROTO) let* metadata = Store.Block.get_block_metadata chain_store block in let protocol_data = Data_encoding.Binary.of_bytes_exn - Proto.block_header_metadata_encoding + Proto.block_header_metadata_encoding_with_legacy_attestation_name (Store.Block.block_metadata metadata) in let* test_chain_status, _ = diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 9cdaca082833..5dab39ab142c 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -466,7 +466,8 @@ module type PROTO = sig type block_header_metadata - val block_header_metadata_encoding : block_header_metadata Data_encoding.t + val block_header_metadata_encoding_with_legacy_attestation_name : + block_header_metadata Data_encoding.t type operation_data @@ -603,7 +604,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (req "max_operation_list_length" (dynamic_size (list operation_list_quota_encoding)))) - Proto.block_header_metadata_encoding) + Proto.block_header_metadata_encoding_with_legacy_attestation_name) let next_operation_encoding_with_legacy_attestation_name = let open Data_encoding in @@ -2143,7 +2144,8 @@ module Fake_protocol = struct type block_header_metadata = unit - let block_header_metadata_encoding = Data_encoding.empty + let block_header_metadata_encoding_with_legacy_attestation_name = + Data_encoding.empty type operation_data = unit diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index f79febd8139b..268671812190 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -101,7 +101,8 @@ module type PROTO = sig type block_header_metadata - val block_header_metadata_encoding : block_header_metadata Data_encoding.t + val block_header_metadata_encoding_with_legacy_attestation_name : + block_header_metadata Data_encoding.t type operation_data diff --git a/src/lib_store/unix/test/alpha_utils.ml b/src/lib_store/unix/test/alpha_utils.ml index 65b172ec1be5..e460d202c56b 100644 --- a/src/lib_store/unix/test/alpha_utils.ml +++ b/src/lib_store/unix/test/alpha_utils.ml @@ -605,7 +605,7 @@ let apply pred_resulting_ctxt chain_id ~policy ?(operations = empty_operations) in let block_header_metadata = Data_encoding.Binary.to_bytes_exn - Main.block_header_metadata_encoding + Main.block_header_metadata_encoding_with_legacy_attestation_name block_header_metadata in let payload_hash = diff --git a/src/lib_validation/block_validation.ml b/src/lib_validation/block_validation.ml index bf47859a25e4..4b4c72be3cc2 100644 --- a/src/lib_validation/block_validation.ml +++ b/src/lib_validation/block_validation.ml @@ -499,7 +499,7 @@ module Make (Proto : Registered_protocol.T) = struct let block_metadata = let metadata = Data_encoding.Binary.to_bytes_exn - Proto.block_header_metadata_encoding + Proto.block_header_metadata_encoding_with_legacy_attestation_name block_data in let metadata_hash_opt = -- GitLab From e233272b4733f8bc4756b31736d89190079714f2 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 30 Jun 2023 16:50:38 +0200 Subject: [PATCH 4/7] lib_test: add test_roundtrip_through_binary in qcheck_helpers this function use 2 different encodings in binary roundtrip to ensure that these encodings produce compatible binaries --- src/lib_test/qcheck2_helpers.ml | 37 ++++++++++++++++++++++++++++++++ src/lib_test/qcheck2_helpers.mli | 10 +++++++++ src/lib_test/roundtrip.ml | 5 +++++ 3 files changed, 52 insertions(+) diff --git a/src/lib_test/qcheck2_helpers.ml b/src/lib_test/qcheck2_helpers.ml index b8df1033b893..a561a83add01 100644 --- a/src/lib_test/qcheck2_helpers.ml +++ b/src/lib_test/qcheck2_helpers.ml @@ -337,3 +337,40 @@ let test_roundtrip ~count ~title ~gen ~eq encoding = test Roundtrip.binary input ; test Roundtrip.json input ; true) + +let test_roundtrip_through_binary ~count ~title ~gen ~eq encoding1 encoding2 = + let pp fmt x = + Data_encoding.Json.construct encoding1 x + |> Data_encoding.Json.to_string |> Format.pp_print_string fmt + in + let test encoding1 encoding2 rdt input = + let output = + try Roundtrip.make_with_2_encoding encoding1 encoding2 rdt input + with exn -> + QCheck2.Test.fail_reportf + "%s %s roundtrip error: error %s on %a" + title + (Roundtrip.target rdt) + (Printexc.to_string exn) + pp + input + in + let success = eq input output in + if not success then + QCheck2.Test.fail_reportf + "%s %s roundtrip error: %a became %a" + title + (Roundtrip.target rdt) + pp + input + pp + output + in + QCheck2.Test.make + ~count + ~name:(Format.asprintf "roundtrip through binary %s" title) + gen + (fun input -> + test encoding1 encoding2 Roundtrip.binary input ; + test encoding2 encoding1 Roundtrip.binary input ; + true) diff --git a/src/lib_test/qcheck2_helpers.mli b/src/lib_test/qcheck2_helpers.mli index 411a8eeed06b..684fec43ab06 100644 --- a/src/lib_test/qcheck2_helpers.mli +++ b/src/lib_test/qcheck2_helpers.mli @@ -249,3 +249,13 @@ val test_roundtrip : eq:('a -> 'a -> bool) -> 'a Data_encoding.t -> QCheck2.Test.t + +(** Test the roundtripness of two encodings in binary formats. *) +val test_roundtrip_through_binary : + count:int -> + title:string -> + gen:'a QCheck2.Gen.t -> + eq:('a -> 'a -> bool) -> + 'a Data_encoding.t -> + 'a Data_encoding.t -> + QCheck2.Test.t diff --git a/src/lib_test/roundtrip.ml b/src/lib_test/roundtrip.ml index 87516e3bfcaa..4c3c8be194f0 100644 --- a/src/lib_test/roundtrip.ml +++ b/src/lib_test/roundtrip.ml @@ -41,6 +41,11 @@ let make : type a. a Data_encoding.t -> t -> a -> a = fun encoding (module R : ROUNDTRIP) input -> R.of_input encoding input |> R.to_input encoding +let make_with_2_encoding : + type a. a Data_encoding.t -> a Data_encoding.t -> t -> a -> a = + fun encoding1 encoding2 (module R : ROUNDTRIP) input -> + R.of_input encoding1 input |> R.to_input encoding2 + let binary : t = (module struct type output = bytes -- GitLab From 4fd88222318c9fc9c330d18520c4189798c66fab Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 30 Jun 2023 16:52:33 +0200 Subject: [PATCH 5/7] proto_alpha/test: add balance_updates encoding tests --- manifest/main.ml | 1 + src/proto_alpha/lib_protocol/test/pbt/dune | 1 + .../test/pbt/test_balance_updates_encoding.ml | 165 ++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml diff --git a/manifest/main.ml b/manifest/main.ml index 68c8f7e45df5..1584748ca344 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4847,6 +4847,7 @@ end = struct (3, "test_dal_slot_proof", N.(number >= 016)); (3, "test_compare_operations", N.(number >= 015)); (3, "test_operation_encoding", N.(number >= 016)); + (3, "test_balance_updates_encoding", N.(number >= 018)); (3, "test_bytes_conversion", N.(number >= 016)); ] |> List.filter_map (fun (i, n, b) -> if b then Some (i, n) else None) diff --git a/src/proto_alpha/lib_protocol/test/pbt/dune b/src/proto_alpha/lib_protocol/test/pbt/dune index 2de7189dbcf1..b919d1a987a4 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/dune +++ b/src/proto_alpha/lib_protocol/test/pbt/dune @@ -58,6 +58,7 @@ test_dal_slot_proof test_compare_operations test_operation_encoding + test_balance_updates_encoding test_bytes_conversion)) (executable diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml b/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml new file mode 100644 index 000000000000..2b25380efe14 --- /dev/null +++ b/src/proto_alpha/lib_protocol/test/pbt/test_balance_updates_encoding.ml @@ -0,0 +1,165 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Testing + ------- + Component: Protocol Library + Invocation: dune exec src/proto_alpha/lib_protocol/test/pbt/main.exe \ + -- --file test_balance_updates_encoding.ml + Subject: Encoding for balance_updates +*) + +open Protocol +open QCheck2 +open Qcheck2_helpers + +(** {2 Generators} *) +let contract = + let pkh, _, _ = Signature.generate_key () in + Receipt_repr.Contract (Contract_repr.Implicit pkh) + +let deposits = + let pkh, _, _ = Signature.generate_key () in + Receipt_repr.Deposits pkh + +let lost_endorsing_rewards = + let pkh, _, _ = Signature.generate_key () in + Receipt_repr.Lost_endorsing_rewards (pkh, false, false) + +let unstaked_deposits = + let pkh, _, _ = Signature.generate_key () in + Receipt_repr.Unstaked_deposits (pkh, Cycle_repr.root) + +let commitments = Receipt_repr.Commitments Blinded_public_key_hash.zero + +let frozen_bonds = + let pkh, _, _ = Signature.generate_key () in + let bond_id = + Bond_id_repr.Sc_rollup_bond_id + (Sc_rollup_repr.Address.of_b58check_exn + "sr1JPVatbbPoGp4vb6VfQ1jzEPMrYFcKq6VG") + in + Receipt_repr.Frozen_bonds (Contract_repr.Implicit pkh, bond_id) + +let generate_balance = + let open Gen in + let open Receipt_repr in + oneofl + [ + contract; + Block_fees; + deposits; + unstaked_deposits; + Nonce_revelation_rewards; + Endorsing_rewards; + Baking_rewards; + Baking_bonuses; + Storage_fees; + Double_signing_punishments; + lost_endorsing_rewards; + Liquidity_baking_subsidies; + Burned; + commitments; + Bootstrap; + Invoice; + Initial_commitments; + Minted; + frozen_bonds; + Sc_rollup_refutation_punishments; + Sc_rollup_refutation_rewards; + ] + +let generate_balance_update = + let open Gen in + let open Receipt_repr in + let* i = big_nat in + let tez = Tez_repr.of_mutez_exn (Int64.of_int i) in + oneofl [Debited tez; Credited tez] + +let generate_update_origin = + let open Gen in + let open Receipt_repr in + oneofl [Block_application; Protocol_migration; Subsidy; Simulation] + +let generate_balance_updates : Receipt_repr.balance_updates Gen.t = + Gen.list + (Gen.tup3 generate_balance generate_balance_update generate_update_origin) + +(** {2 Tests} *) +let eq balance_updates1 balance_updates2 = + let open Receipt_repr in + let res = + List.for_all2 + ~when_different_lengths:() + (fun (b1, bu1, uo1) (b2, bu2, uo2) -> + compare b1 b2 = 0 + && (match (bu1, bu2) with + | Debited tz1, Debited tz2 | Credited tz1, Credited tz2 -> + Tez_repr.equal tz1 tz2 + | Debited tz1, Credited tz2 | Credited tz1, Debited tz2 -> + Tez_repr.(equal tz1 zero) && Tez_repr.(equal tz2 zero)) + && compare_update_origin uo1 uo2 = 0) + balance_updates1 + balance_updates2 + in + match res with Ok b -> b | Error _ -> false + +let test_balance_updates encoding = + let gen = generate_balance_updates in + test_roundtrip ~count:2000 ~title:"Balance_updates" ~gen ~eq encoding + +let test_binary_balance_updates encoding1 encoding2 = + let gen = generate_balance_updates in + test_roundtrip_through_binary + ~count:2000 + ~title:"Balance_updates" + ~gen + ~eq + encoding1 + encoding2 + +let () = + let qcheck_wrap = qcheck_wrap ~rand:(Random.State.make_self_init ()) in + Alcotest.run + ~__FILE__ + (Protocol.name ^ ": Operation_encoding") + [ + ( "roundtrip", + qcheck_wrap [test_balance_updates Receipt_repr.balance_updates_encoding] + ); + ( "legacy : roundtrip", + qcheck_wrap + [ + test_balance_updates + Receipt_repr.balance_updates_encoding_with_legacy_attestation_name; + ] ); + ( "roundtrip 2 encodings", + qcheck_wrap + [ + test_binary_balance_updates + Receipt_repr.balance_updates_encoding + Receipt_repr.balance_updates_encoding_with_legacy_attestation_name; + ] ); + ] -- GitLab From dd27c9f0fd162b1011874c731007328385d4330b Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 3 Jul 2023 13:28:39 +0200 Subject: [PATCH 6/7] bin_client: add legacy block_header_metadata_encoding --- src/bin_client/test/proto_test_injection/main.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bin_client/test/proto_test_injection/main.ml b/src/bin_client/test/proto_test_injection/main.ml index 6c4237ef6cd1..8d6fb9fbdc77 100644 --- a/src/bin_client/test/proto_test_injection/main.ml +++ b/src/bin_client/test/proto_test_injection/main.ml @@ -37,6 +37,9 @@ type block_header_metadata = unit let block_header_metadata_encoding = Data_encoding.unit +let block_header_metadata_encoding_with_legacy_attestation_name = + Data_encoding.unit + type operation_data = unit let operation_data_encoding = Data_encoding.unit -- GitLab From 05f20731a95c2056a75cb0804d62582bfd908d0c Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 22 Jun 2023 17:18:50 +0200 Subject: [PATCH 7/7] changes/alpha: add entry for legacy balance_updates encoding --- docs/protocols/alpha.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 627287fcdd6d..6e2a80183e6d 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -245,3 +245,9 @@ Internal - ``version_value`` moved from ``raw_context.ml`` to ``constants_repr.ml``. (MR :gl:`!8867`) - Transaction rollup: removed left parameters (:gl:`!8700`) + +- ``balance_update_encoding`` now output ``attesting rewards`` and ``lost + attesting rewards`` in JSON. + ``balance_update_encoding_with_legacy_attestation_name`` has been added and + output legacy ``endorsing rewards`` and ``lost endorsing rewards``. (MR + :gl:`!9251`) -- GitLab