From 391e44d45244657b3c6d93f6f3fe5bcc7ca6a2c8 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 14 Apr 2022 11:48:30 +0200 Subject: [PATCH 1/4] Proto: move Origination_nonce before Contract_hash --- src/proto_alpha/lib_protocol/TEZOS_PROTOCOL | 2 +- src/proto_alpha/lib_protocol/dune.inc | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index eb644ef194d0..72597091ad41 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -9,10 +9,10 @@ "State_hash", "Nonce_hash", "Script_expr_hash", + "Origination_nonce", "Contract_hash", "Blinded_public_key_hash", "Block_payload_hash", - "Origination_nonce", "Tx_rollup_prefixes", "Merkle_list", "Bitset", diff --git a/src/proto_alpha/lib_protocol/dune.inc b/src/proto_alpha/lib_protocol/dune.inc index b2cb4c95ff94..c2a5f6a6ff2f 100644 --- a/src/proto_alpha/lib_protocol/dune.inc +++ b/src/proto_alpha/lib_protocol/dune.inc @@ -35,10 +35,10 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end state_hash.mli state_hash.ml nonce_hash.mli nonce_hash.ml script_expr_hash.mli script_expr_hash.ml + origination_nonce.mli origination_nonce.ml contract_hash.mli contract_hash.ml blinded_public_key_hash.mli blinded_public_key_hash.ml block_payload_hash.mli block_payload_hash.ml - origination_nonce.mli origination_nonce.ml tx_rollup_prefixes.mli tx_rollup_prefixes.ml merkle_list.mli merkle_list.ml bitset.mli bitset.ml @@ -225,10 +225,10 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end state_hash.mli state_hash.ml nonce_hash.mli nonce_hash.ml script_expr_hash.mli script_expr_hash.ml + origination_nonce.mli origination_nonce.ml contract_hash.mli contract_hash.ml blinded_public_key_hash.mli blinded_public_key_hash.ml block_payload_hash.mli block_payload_hash.ml - origination_nonce.mli origination_nonce.ml tx_rollup_prefixes.mli tx_rollup_prefixes.ml merkle_list.mli merkle_list.ml bitset.mli bitset.ml @@ -415,10 +415,10 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end state_hash.mli state_hash.ml nonce_hash.mli nonce_hash.ml script_expr_hash.mli script_expr_hash.ml + origination_nonce.mli origination_nonce.ml contract_hash.mli contract_hash.ml blinded_public_key_hash.mli blinded_public_key_hash.ml block_payload_hash.mli block_payload_hash.ml - origination_nonce.mli origination_nonce.ml tx_rollup_prefixes.mli tx_rollup_prefixes.ml merkle_list.mli merkle_list.ml bitset.mli bitset.ml @@ -627,10 +627,10 @@ include Tezos_raw_protocol_alpha.Main State_hash Nonce_hash Script_expr_hash + Origination_nonce Contract_hash Blinded_public_key_hash Block_payload_hash - Origination_nonce Tx_rollup_prefixes Merkle_list Bitset @@ -858,10 +858,10 @@ include Tezos_raw_protocol_alpha.Main state_hash.mli state_hash.ml nonce_hash.mli nonce_hash.ml script_expr_hash.mli script_expr_hash.ml + origination_nonce.mli origination_nonce.ml contract_hash.mli contract_hash.ml blinded_public_key_hash.mli blinded_public_key_hash.ml block_payload_hash.mli block_payload_hash.ml - origination_nonce.mli origination_nonce.ml tx_rollup_prefixes.mli tx_rollup_prefixes.ml merkle_list.mli merkle_list.ml bitset.mli bitset.ml -- GitLab From 82cd1fdca837f371538abfd57ef45301efd51350 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 14 Apr 2022 11:50:44 +0200 Subject: [PATCH 2/4] Proto: move Contract_hash computation --- src/proto_alpha/lib_protocol/contract_hash.ml | 6 ++++++ src/proto_alpha/lib_protocol/contract_hash.mli | 3 +++ src/proto_alpha/lib_protocol/contract_repr.ml | 6 +----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/proto_alpha/lib_protocol/contract_hash.ml b/src/proto_alpha/lib_protocol/contract_hash.ml index c232a80278df..8583c1839303 100644 --- a/src/proto_alpha/lib_protocol/contract_hash.ml +++ b/src/proto_alpha/lib_protocol/contract_hash.ml @@ -43,3 +43,9 @@ include H include Path_encoding.Make_hex (H) let () = Base58.check_encoded_prefix b58check_encoding "KT1" 36 + +let of_nonce nonce = + let data = + Data_encoding.Binary.to_bytes_exn Origination_nonce.encoding nonce + in + hash_bytes [data] diff --git a/src/proto_alpha/lib_protocol/contract_hash.mli b/src/proto_alpha/lib_protocol/contract_hash.mli index 1cbc424150af..45a9f23cdf32 100644 --- a/src/proto_alpha/lib_protocol/contract_hash.mli +++ b/src/proto_alpha/lib_protocol/contract_hash.mli @@ -27,3 +27,6 @@ (** A specialized Blake2B implementation for hashing contract identifiers. *) include S.HASH + +(** [of_nonce nonce] is the contract address originated from [nonce]. *) +val of_nonce : Origination_nonce.t -> t diff --git a/src/proto_alpha/lib_protocol/contract_repr.ml b/src/proto_alpha/lib_protocol/contract_repr.ml index 3f4dc97444d6..b1cfe042a292 100644 --- a/src/proto_alpha/lib_protocol/contract_repr.ml +++ b/src/proto_alpha/lib_protocol/contract_repr.ml @@ -181,11 +181,7 @@ let () = (function Invalid_contract_notation loc -> Some loc | _ -> None) (fun loc -> Invalid_contract_notation loc) -let originated_contract nonce = - let data = - Data_encoding.Binary.to_bytes_exn Origination_nonce.encoding nonce - in - Originated (Contract_hash.hash_bytes [data]) +let originated_contract nonce = Originated (Contract_hash.of_nonce nonce) let originated_contracts ~since: -- GitLab From 70e10fe72fc763a11aa6975b86e311cf5efff4b6 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 14 Apr 2022 16:32:01 +0200 Subject: [PATCH 3/4] Proto: fresh_contract_from_current_nonce returns a contract hash --- src/proto_alpha/lib_plugin/plugin.ml | 5 ++-- .../lib_protocol/alpha_context.mli | 3 ++- src/proto_alpha/lib_protocol/apply.ml | 3 ++- .../lib_protocol/bootstrap_storage.ml | 3 ++- .../lib_protocol/contract_storage.ml | 2 +- .../lib_protocol/contract_storage.mli | 2 +- .../liquidity_baking_migration.ml | 23 +++++++++++-------- .../lib_protocol/script_interpreter_defs.ml | 4 +++- 8 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/proto_alpha/lib_plugin/plugin.ml b/src/proto_alpha/lib_plugin/plugin.ml index eee1d35ef3d2..e6ec2daf2091 100644 --- a/src/proto_alpha/lib_plugin/plugin.ml +++ b/src/proto_alpha/lib_plugin/plugin.ml @@ -2427,8 +2427,9 @@ module RPC = struct let register () = let originate_dummy_contract ctxt script balance = let ctxt = Origination_nonce.init ctxt Operation_hash.zero in - Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) - >>=? fun (ctxt, dummy_contract) -> + Contract.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, dummy_contract_hash) -> + let dummy_contract = Contract.Originated dummy_contract_hash in Contract.raw_originate ctxt ~prepaid_bootstrap_storage:false diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index eb9ca6c4b6c3..5fc840225e68 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1520,7 +1520,8 @@ module Contract : sig val get_balance_carbonated : context -> t -> (context * Tez.t) tzresult Lwt.t - val fresh_contract_from_current_nonce : context -> (context * t) tzresult + val fresh_contract_from_current_nonce : + context -> (context * Contract_hash.t) tzresult val originated_from_current_nonce : since:context -> until:context -> t list tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 6265f3a43bd4..566dcf349b10 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1414,7 +1414,8 @@ let apply_external_manager_operation_content : so that the script can use it immediately. The address of external originations is generated here. *) Contract.fresh_contract_from_current_nonce ctxt - >>?= fun (ctxt, contract) -> + >>?= fun (ctxt, contract_hash) -> + let contract = Contract.Originated contract_hash in Script.force_decode_in_context ~consume_deserialization_gas ctxt diff --git a/src/proto_alpha/lib_protocol/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/bootstrap_storage.ml index df398aca79c9..a5f9715e5a6b 100644 --- a/src/proto_alpha/lib_protocol/bootstrap_storage.ml +++ b/src/proto_alpha/lib_protocol/bootstrap_storage.ml @@ -47,7 +47,8 @@ let init_account (ctxt, balance_updates) let init_contract ~typecheck (ctxt, balance_updates) ({delegate; amount; script} : Parameters_repr.bootstrap_contract) = Contract_storage.fresh_contract_from_current_nonce ctxt - >>?= fun (ctxt, contract) -> + >>?= fun (ctxt, contract_hash) -> + let contract = Contract_repr.Originated contract_hash in typecheck ctxt script >>=? fun (script, ctxt) -> Contract_storage.raw_originate ctxt diff --git a/src/proto_alpha/lib_protocol/contract_storage.ml b/src/proto_alpha/lib_protocol/contract_storage.ml index ac00a29e514f..6e06ef64ad23 100644 --- a/src/proto_alpha/lib_protocol/contract_storage.ml +++ b/src/proto_alpha/lib_protocol/contract_storage.ml @@ -502,7 +502,7 @@ let list c = Storage.Contract.list c let fresh_contract_from_current_nonce c = Raw_context.increment_origination_nonce c >|? fun (c, nonce) -> - (c, Contract_repr.originated_contract nonce) + (c, Contract_hash.of_nonce nonce) let originated_from_current_nonce ~since:ctxt_since ~until:ctxt_until = Raw_context.get_origination_nonce ctxt_since >>?= fun since -> diff --git a/src/proto_alpha/lib_protocol/contract_storage.mli b/src/proto_alpha/lib_protocol/contract_storage.mli index 48421c4a1619..344e1409caa4 100644 --- a/src/proto_alpha/lib_protocol/contract_storage.mli +++ b/src/proto_alpha/lib_protocol/contract_storage.mli @@ -150,7 +150,7 @@ val raw_originate : Raw_context.t tzresult Lwt.t val fresh_contract_from_current_nonce : - Raw_context.t -> (Raw_context.t * Contract_repr.t) tzresult + Raw_context.t -> (Raw_context.t * Contract_hash.t) tzresult val originated_from_current_nonce : since:Raw_context.t -> diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml b/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml index ad3717117a3c..3093115c0b5c 100644 --- a/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml +++ b/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml @@ -53,7 +53,8 @@ let null_address = Bytes.of_string "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" -let mainnet_tzBTC_address = "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" +let mainnet_tzBTC_address = + Contract_hash.of_b58check_exn "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" (** If token_pool, xtz_pool, or lqt_total are ever zero the CPMM will be permanently broken. Therefore, we initialize it with the null address @@ -110,7 +111,8 @@ let test_fa12_init_storage manager = ], [] ))) -let originate ctxt address ~balance script = +let originate ctxt address_hash ~balance script = + let address = Contract_repr.Originated address_hash in Contract_storage.raw_originate ctxt ~prepaid_bootstrap_storage:true @@ -174,11 +176,11 @@ let first_bootstrap_account = "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav") let check_tzBTC ~typecheck current_level ctxt f = - Contract_repr.of_b58check mainnet_tzBTC_address >>?= fun tzBTC -> - Contract_storage.exists ctxt tzBTC >>= function + Contract_storage.exists ctxt (Contract_repr.Originated mainnet_tzBTC_address) + >>= function | true -> (* If tzBTC exists, we're on mainnet and we use it as the token address in the CPMM. *) - f ctxt tzBTC [] + f ctxt mainnet_tzBTC_address [] | false -> (* If the tzBTC contract does not exist, we originate a test FA1.2 contract using the same script as the LQT. This is so that we can test the contracts after performing the same protocol migration that will be done on mainnet. @@ -204,7 +206,10 @@ let init ctxt ~typecheck = >>?= fun (ctxt, cpmm_address) -> Contract_storage.fresh_contract_from_current_nonce ctxt >>?= fun (ctxt, lqt_address) -> - Storage.Liquidity_baking.Cpmm_address.init ctxt cpmm_address >>=? fun ctxt -> + Storage.Liquidity_baking.Cpmm_address.init + ctxt + (Contract_repr.Originated cpmm_address) + >>=? fun ctxt -> check_tzBTC ~typecheck current_level @@ -216,8 +221,8 @@ let init ctxt ~typecheck = code = Script_repr.lazy_expr Liquidity_baking_cpmm.script; storage = cpmm_init_storage - ~token_address:(Contract_repr.to_b58check token_address) - ~lqt_address:(Contract_repr.to_b58check lqt_address); + ~token_address:(Contract_hash.to_b58check token_address) + ~lqt_address:(Contract_hash.to_b58check lqt_address); } in typecheck ctxt cpmm_script >>=? fun (cpmm_script, ctxt) -> @@ -225,7 +230,7 @@ let init ctxt ~typecheck = Script_repr. { code = Script_repr.lazy_expr Liquidity_baking_lqt.script; - storage = lqt_init_storage (Contract_repr.to_b58check cpmm_address); + storage = lqt_init_storage (Contract_hash.to_b58check cpmm_address); } in typecheck ctxt lqt_script >>=? fun (lqt_script, ctxt) -> diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index 44c0f255b918..91aca747c5ca 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -646,7 +646,9 @@ let create_contract (ctxt, sc) gas storage_type code delegate credit init = unparse_data ctxt Optimized storage_type init >>=? fun (storage, ctxt) -> Gas.consume ctxt (Script.strip_locations_cost storage) >>?= fun ctxt -> let storage = Micheline.strip_locations storage in - Contract.fresh_contract_from_current_nonce ctxt >>?= fun (ctxt, contract) -> + Contract.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, contract_hash) -> + let contract = Contract.Originated contract_hash in let origination = { credit; -- GitLab From 4c3027e8905e35e4cfe5c3725ba044bdd2bbac26 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 14 Apr 2022 11:45:41 +0200 Subject: [PATCH 4/4] Proto/LB: store CPMM address as contract hash --- src/proto_alpha/lib_protocol/alpha_context.mli | 6 ++++-- src/proto_alpha/lib_protocol/alpha_services.ml | 2 +- src/proto_alpha/lib_protocol/alpha_services.mli | 4 +--- src/proto_alpha/lib_protocol/apply.ml | 5 ++++- src/proto_alpha/lib_protocol/liquidity_baking_migration.ml | 5 +---- src/proto_alpha/lib_protocol/liquidity_baking_storage.ml | 3 ++- src/proto_alpha/lib_protocol/liquidity_baking_storage.mli | 4 ++-- src/proto_alpha/lib_protocol/storage.ml | 7 ++++++- src/proto_alpha/lib_protocol/storage.mli | 2 +- src/proto_alpha/lib_protocol/test/helpers/context.ml | 1 + 10 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 5fc840225e68..8256832fb6dd 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1479,6 +1479,8 @@ module Contract : sig include BASIC_DATA with type t := t + val originated_encoding : Contract_hash.t Data_encoding.t + val in_memory_size : t -> Cache_memory_helpers.sint val rpc_arg : t RPC_arg.arg @@ -3501,7 +3503,7 @@ module Liquidity_baking : sig val liquidity_baking_toggle_vote_encoding : liquidity_baking_toggle_vote Data_encoding.encoding - val get_cpmm_address : context -> Contract.t tzresult Lwt.t + val get_cpmm_address : context -> Contract_hash.t tzresult Lwt.t module Toggle_EMA : sig type t @@ -3516,7 +3518,7 @@ module Liquidity_baking : sig val on_subsidy_allowed : context -> toggle_vote:liquidity_baking_toggle_vote -> - (context -> Contract.t -> (context * 'a list) tzresult Lwt.t) -> + (context -> Contract_hash.t -> (context * 'a list) tzresult Lwt.t) -> (context * 'a list * Toggle_EMA.t) tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/alpha_services.ml b/src/proto_alpha/lib_protocol/alpha_services.ml index a75da8eb8b12..6c8161d4cae1 100644 --- a/src/proto_alpha/lib_protocol/alpha_services.ml +++ b/src/proto_alpha/lib_protocol/alpha_services.ml @@ -178,7 +178,7 @@ module Liquidity_baking = struct RPC_service.get_service ~description:"Liquidity baking CPMM address" ~query:RPC_query.empty - ~output:Alpha_context.Contract.encoding + ~output:Alpha_context.Contract.originated_encoding RPC_path.(custom_root / "context" / "liquidity_baking" / "cpmm_address") end diff --git a/src/proto_alpha/lib_protocol/alpha_services.mli b/src/proto_alpha/lib_protocol/alpha_services.mli index 468c0241e44e..25a22c348773 100644 --- a/src/proto_alpha/lib_protocol/alpha_services.mli +++ b/src/proto_alpha/lib_protocol/alpha_services.mli @@ -63,9 +63,7 @@ module Sapling = Sapling_services module Liquidity_baking : sig val get_cpmm_address : - 'a #RPC_context.simple -> - 'a -> - Alpha_context.Contract.t shell_tzresult Lwt.t + 'a #RPC_context.simple -> 'a -> Contract_hash.t shell_tzresult Lwt.t end module Cache : sig diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 566dcf349b10..cb7a1cd95d45 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -3108,7 +3108,10 @@ let apply_liquidity_baking_subsidy ctxt ~toggle_vote = Liquidity_baking.on_subsidy_allowed ctxt ~toggle_vote - (fun ctxt liquidity_baking_cpmm_contract -> + (fun ctxt liquidity_baking_cpmm_contract_hash -> + let liquidity_baking_cpmm_contract = + Contract.Originated liquidity_baking_cpmm_contract_hash + in let ctxt = (* We set a gas limit of 1/20th the block limit, which is ~10x actual usage here in Granada. Gas consumed is reported in diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml b/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml index 3093115c0b5c..8e773910ffb2 100644 --- a/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml +++ b/src/proto_alpha/lib_protocol/liquidity_baking_migration.ml @@ -206,10 +206,7 @@ let init ctxt ~typecheck = >>?= fun (ctxt, cpmm_address) -> Contract_storage.fresh_contract_from_current_nonce ctxt >>?= fun (ctxt, lqt_address) -> - Storage.Liquidity_baking.Cpmm_address.init - ctxt - (Contract_repr.Originated cpmm_address) - >>=? fun ctxt -> + Storage.Liquidity_baking.Cpmm_address.init ctxt cpmm_address >>=? fun ctxt -> check_tzBTC ~typecheck current_level diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml b/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml index 2c78115b223a..0202241484b9 100644 --- a/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml +++ b/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml @@ -34,7 +34,8 @@ let get_toggle_ema ctxt = let on_cpmm_exists ctxt f = get_cpmm_address ctxt >>=? fun cpmm_contract -> - Contract_storage.exists ctxt cpmm_contract >>= function + Contract_storage.exists ctxt (Contract_repr.Originated cpmm_contract) + >>= function | false -> (* do nothing if the cpmm is not found *) return (ctxt, []) diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli b/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli index a22a03927bfa..4db50c0a2536 100644 --- a/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli +++ b/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli @@ -26,7 +26,7 @@ (** Get the address of the Constant-Product Market Maker receiving the Liquidity Baking subsidy *) -val get_cpmm_address : Raw_context.t -> Contract_repr.t tzresult Lwt.t +val get_cpmm_address : Raw_context.t -> Contract_hash.t tzresult Lwt.t (** [on_subsidy_allowed ctxt ~toggle_vote f] updates the toggle EMA according to [toggle_vote]. Then the callback function [f] is called if the following @@ -40,5 +40,5 @@ val get_cpmm_address : Raw_context.t -> Contract_repr.t tzresult Lwt.t val on_subsidy_allowed : Raw_context.t -> toggle_vote:Liquidity_baking_repr.liquidity_baking_toggle_vote -> - (Raw_context.t -> Contract_repr.t -> (Raw_context.t * 'a list) tzresult Lwt.t) -> + (Raw_context.t -> Contract_hash.t -> (Raw_context.t * 'a list) tzresult Lwt.t) -> (Raw_context.t * 'a list * Liquidity_baking_repr.Toggle_EMA.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 7d178652fa40..d4b0e00d6e39 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1366,7 +1366,12 @@ module Liquidity_baking = struct (struct let name = ["liquidity_baking_cpmm_address"] end) - (Contract_repr) + (struct + type t = Contract_hash.t + + (* Keeping contract-compatible encoding to avoid migrating this. *) + let encoding = Contract_repr.originated_encoding + end) end module Ticket_balance = struct diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 21565d0e3f31..e97d724f49b9 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -548,7 +548,7 @@ module Liquidity_baking : sig module Cpmm_address : Single_data_storage with type t := Raw_context.t - and type value = Contract_repr.t + and type value = Contract_hash.t end (** A map of [Script_repr.expr] values, indexed by their hash ([Script_expr_hash.t]). diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index e08f29d45aa3..d4649b4d09a0 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -215,6 +215,7 @@ let get_liquidity_baking_subsidy ctxt = let get_liquidity_baking_cpmm_address ctxt = Alpha_services.Liquidity_baking.get_cpmm_address rpc_ctxt ctxt + >|=? fun hash -> Contract.Originated hash (* Voting *) -- GitLab