From de121d518692e565fb4b1efa9b7aeee846b19342 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 27 May 2024 17:34:55 +0200 Subject: [PATCH 1/4] alpha: remove balance_updates_encoding_with_legacy_attestation_name encoding --- .../lib_protocol/alpha_context.mli | 3 -- src/proto_alpha/lib_protocol/apply_results.ml | 7 +-- src/proto_alpha/lib_protocol/receipt_repr.ml | 51 +++---------------- src/proto_alpha/lib_protocol/receipt_repr.mli | 13 +---- 4 files changed, 8 insertions(+), 66 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 8f9ef4605b3f..db6ca8e6febe 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2191,9 +2191,6 @@ module Receipt : sig type balance_updates = balance_update_item list val balance_updates_encoding : balance_updates Data_encoding.t - - val balance_updates_encoding_with_legacy_attestation_name : - balance_updates Data_encoding.t end (** This module re-exports definitions from {!Delegate_consensus_key}. *) diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index 49ff68eba509..15ae7110604b 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -2818,12 +2818,7 @@ let block_metadata_encoding ~use_legacy_attestation_name = (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" - (if use_legacy_attestation_name then - Receipt.balance_updates_encoding_with_legacy_attestation_name - else Receipt.balance_updates_encoding) - []) + (dft "balance_updates" Receipt.balance_updates_encoding []) (req "liquidity_baking_toggle_ema" Per_block_votes.Liquidity_baking_toggle_EMA.encoding) diff --git a/src/proto_alpha/lib_protocol/receipt_repr.ml b/src/proto_alpha/lib_protocol/receipt_repr.ml index 52ae13d1368d..aa38d65ba1ad 100644 --- a/src/proto_alpha/lib_protocol/receipt_repr.ml +++ b/src/proto_alpha/lib_protocol/receipt_repr.ml @@ -214,7 +214,7 @@ let staking_pseudotoken_balance_update_encoding = "change" (conv_balance_update Staking_pseudotoken_repr.balance_update_encoding)) -let balance_and_update_encoding ~use_legacy_attestation_name = +let balance_and_update_encoding = let open Data_encoding in let case = function | Tag tag -> @@ -250,10 +250,7 @@ let balance_and_update_encoding ~use_legacy_attestation_name = | _ -> None) (fun (x, update) -> Ex_token (inj x, update)) in - def - (if use_legacy_attestation_name then - "operation_metadata_with_legacy_attestation_name.alpha.balance_and_update" - else "operation_metadata.alpha.balance_and_update") + def "operation_metadata.alpha.balance_and_update" @@ union [ tez_case @@ -293,16 +290,10 @@ let balance_and_update_encoding ~use_legacy_attestation_name = https://gitlab.com/tezos/tezos/-/merge_requests/7758 *) tez_case (Tag 7) - ~title: - (if use_legacy_attestation_name then "Endorsing_rewards" - else "Attesting_rewards") + ~title:"Attesting_rewards" (obj2 (req "kind" (constant "minted")) - (req - "category" - (constant - (if use_legacy_attestation_name then "endorsing rewards" - else "attesting rewards")))) + (req "category" (constant "attesting rewards"))) (function Attesting_rewards -> Some ((), ()) | _ -> None) (fun ((), ()) -> Attesting_rewards); tez_case @@ -339,17 +330,10 @@ let balance_and_update_encoding ~use_legacy_attestation_name = (fun ((), ()) -> Double_signing_punishments); tez_case (Tag 13) - ~title: - (if use_legacy_attestation_name then "Lost_endorsing_rewards" - else "Lost_attesting_rewards") + ~title:"Lost_attesting_rewards" (obj5 (req "kind" (constant "burned")) - (req - "category" - (constant - (if use_legacy_attestation_name then - "lost endorsing rewards" - else "lost attesting rewards"))) + (req "category" (constant "lost attesting rewards")) (req "delegate" Signature.Public_key_hash.encoding) (req "participation" Data_encoding.bool) (req "revelation" Data_encoding.bool)) @@ -479,12 +463,6 @@ let balance_and_update_encoding ~use_legacy_attestation_name = (fun ((), (), delegate) -> Staking_delegate_denominator {delegate}); ] -let balance_and_update_encoding_with_legacy_attestation_name = - balance_and_update_encoding ~use_legacy_attestation_name:true - -let balance_and_update_encoding = - balance_and_update_encoding ~use_legacy_attestation_name:false - type update_origin = | Block_application | Protocol_migration @@ -558,18 +536,6 @@ type balance_update_item = let item balance balance_update update_origin = Balance_update_item (balance, balance_update, update_origin) -let item_encoding_with_legacy_attestation_name = - let open Data_encoding in - conv - (function - | Balance_update_item (balance, balance_update, update_origin) -> - (Ex_token (balance, balance_update), update_origin)) - (fun (Ex_token (balance, balance_update), update_origin) -> - Balance_update_item (balance, balance_update, update_origin)) - (merge_objs - balance_and_update_encoding_with_legacy_attestation_name - update_origin_encoding) - let item_encoding = let open Data_encoding in conv @@ -582,11 +548,6 @@ let item_encoding = type balance_updates = balance_update_item 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 item_encoding_with_legacy_attestation_name - let balance_updates_encoding = let open Data_encoding in def "operation_metadata.alpha.balance_updates" @@ list item_encoding diff --git a/src/proto_alpha/lib_protocol/receipt_repr.mli b/src/proto_alpha/lib_protocol/receipt_repr.mli index e78286e144aa..893729602fdc 100644 --- a/src/proto_alpha/lib_protocol/receipt_repr.mli +++ b/src/proto_alpha/lib_protocol/receipt_repr.mli @@ -98,7 +98,7 @@ type update_origin = (** Compares two origins. *) val compare_update_origin : update_origin -> update_origin -> int -(** An item in a list of balance updates. +(** An item in a list of balance updates. An item of the form [(Rewards (b,c), Credited am, ...)] indicates that the balance of frozen rewards has been increased by [am] for baker [b] and cycle [c]. *) @@ -123,16 +123,5 @@ type balance_updates = balance_update_item 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 -- GitLab From d3d61827c14309da911ef94621c6b7c1fa6ebcee Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 27 May 2024 17:35:13 +0200 Subject: [PATCH 2/4] alpha/test: update test documentation --- .../test/integration/consensus/test_frozen_deposits.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml index 6942bd3b74f8..8f3aa5698f90 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml @@ -478,7 +478,7 @@ let test_cannot_bake_with_zero_deposits_limit () = (* N.B. there is no non-zero frozen deposits value for which one cannot bake: even with a small deposit one can still bake, though with a smaller probability (because the frozen deposits value impacts the active stake and the active - stake is the one used to determine baking/endorsing rights. *) + stake is the one used to determine baking/attesting rights. *) let* operation = Op.set_deposits_limit (B genesis) contract1 (Some Tez.zero) in -- GitLab From 31b057eaf22e7bff01d798fda13d85797e840946 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 28 Jun 2024 13:50:53 +0200 Subject: [PATCH 3/4] alpha/test: update balance update encoding test --- .../test/pbt/test_balance_updates_encoding.ml | 23 ------------------- 1 file changed, 23 deletions(-) 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 index 9a9b165ea5fc..86d48c9228a6 100644 --- 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 @@ -173,16 +173,6 @@ 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 @@ -192,17 +182,4 @@ let () = ( "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 4b553e3fe9b6a123e82045ff08ce49134327d528 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 27 May 2024 17:35:30 +0200 Subject: [PATCH 4/4] changes: add entry in alpha changelog for the removal of balance_updates_encoding_with_legacy_attestation_name --- docs/protocols/alpha.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index a0c048ff4871..61c10cd079ad 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -134,3 +134,6 @@ Minor Changes Internal -------- + +- ``balance_update_encoding_with_legacy_attestation_name`` has been removed. + (MR :gl:`!13461`) -- GitLab