diff --git a/devtools/yes_wallet/yes_wallet.ml b/devtools/yes_wallet/yes_wallet.ml index 7c68785bf4a825d57c3d3974f72042d869a1313f..98f9c1aee5a3e1ab9660fe1a5a8fe5d8cfbaccb0 100644 --- a/devtools/yes_wallet/yes_wallet.ml +++ b/devtools/yes_wallet/yes_wallet.ml @@ -28,8 +28,7 @@ type error = Overwrite_forbiden of string | File_not_found of string (* We need to exit Lwt + tzResult context from Yes_wallet. *) let run_load_bakers_public_keys ?staking_share_opt ?network_opt ?level base_dir - ~override_with_consensus_key ~active_bakers_only alias_pkh_pk_list - other_accounts_pkh = + ~active_bakers_only alias_pkh_pk_list other_accounts_pkh = let open Yes_wallet_lib in let open Tezos_error_monad in match @@ -39,7 +38,6 @@ let run_load_bakers_public_keys ?staking_share_opt ?network_opt ?level base_dir ?network_opt ?level base_dir - ~override_with_consensus_key ~active_bakers_only alias_pkh_pk_list other_accounts_pkh) @@ -62,8 +60,7 @@ let run_load_contracts ?dump_contracts ?network_opt ?level base_dir = exit 1 let run_build_yes_wallet ?staking_share_opt ?network_opt base_dir - ~override_with_consensus_key ~active_bakers_only ~aliases - ~other_accounts_pkh = + ~active_bakers_only ~aliases ~other_accounts_pkh = let open Yes_wallet_lib in let open Tezos_error_monad in match @@ -72,7 +69,6 @@ let run_build_yes_wallet ?staking_share_opt ?network_opt base_dir ?staking_share_opt ?network_opt base_dir - ~override_with_consensus_key ~active_bakers_only ~aliases ~other_accounts_pkh) @@ -146,8 +142,7 @@ let convert_wallet ~replace wallet_dir target_dir = "Warning: cannot produce yes-wallet, the file %s does not exist@." pk_source -let populate_wallet ~replace ~override_with_consensus_key yes_wallet_dir - alias_pkh_pk_list = +let populate_wallet ~replace yes_wallet_dir alias_pkh_pk_list = let pkh_filename = Filename.concat yes_wallet_dir "public_key_hashs" in let pk_filename = Filename.concat yes_wallet_dir "public_keys" in let sk_filename = Filename.concat yes_wallet_dir "secret_keys" in @@ -168,10 +163,7 @@ let populate_wallet ~replace ~override_with_consensus_key yes_wallet_dir sk_filename ; false) else ( - Yes_wallet_lib.write_yes_wallet - ~write_consensus_keys:override_with_consensus_key - yes_wallet_dir - alias_pkh_pk_list ; + Yes_wallet_lib.write_yes_wallet yes_wallet_dir alias_pkh_pk_list ; true) let alias_file_opt_name = "--aliases" @@ -190,8 +182,6 @@ let level_opt_name = "--level" let other_accounts_opt_name = "--other-accounts" -let consensus_key_override = "--consensus-key-override" - let supported_networks = List.map fst Yes_wallet_lib.supported_networks let force = ref false @@ -216,7 +206,9 @@ let usage () = @[> create from context in [%s] [%s \ ] [%s <%a>]@,\ creates a yes-wallet with all delegates in the head block of the context \ - in and store it in @,\ + in and store it in . By default, it also \ + outputs a consensus_keys_mapping file that associates every consensus key \ + to its actual delegate@,\ if %s is used the deactivated bakers are filtered out@,\ if %s is used, the first largest bakers that have an accumulated \ stake of at least percent of the total stake are kept@,\ @@ -224,10 +216,7 @@ let usage () = parameter (default is mainnet) @,\ if %s is used, the generated wallet will also contain the \ addresses for the given list of space separated pkh. Consensus keys are \ - not supported for this parameter @,\ - if %s is used, there will be an override of delegate's public key and \ - public key hash by, respectively, it's consensus public key and public \ - key hash@]@]@,\ + not supported for this parameter @]@]@,\ @[@[> compute total supply from [in ]@,\ computes the total supply form all contracts and commitments. result is \ printed in stantdard output, optionally informations on all read \ @@ -254,7 +243,6 @@ let usage () = pp_print_string) supported_networks other_accounts_opt_name - consensus_key_override alias_file_opt_name force_opt_name @@ -355,9 +343,6 @@ let () = let active_bakers_only = List.exists (fun opt -> opt = active_bakers_only_opt_name) options in - let override_with_consensus_key = - List.exists (fun opt -> opt = consensus_key_override) options - in force := List.exists (fun opt -> opt = force_opt_name) options ; let unknown_options = let rec filter args = @@ -380,7 +365,6 @@ let () = | opt :: net :: t when opt = network_opt_name && is_supported_network net -> filter t - | opt :: t when opt = consensus_key_override -> filter t | h :: t -> h :: filter t in filter options @@ -411,7 +395,6 @@ let () = ?staking_share_opt ?network_opt base_dir - ~override_with_consensus_key ~active_bakers_only ~aliases ~other_accounts_pkh @@ -419,13 +402,8 @@ let () = Format.printf "@[Number of keys to export:@;<3 0>%d@]@." (List.length yes_alias_list) ; - if - populate_wallet - ~replace:!force - ~override_with_consensus_key - yes_wallet_dir - yes_alias_list - then Format.printf "@[Exported path:@;<14 0>%s@]@." yes_wallet_dir + if populate_wallet ~replace:!force yes_wallet_dir yes_alias_list then + Format.printf "@[Exported path:@;<14 0>%s@]@." yes_wallet_dir | [_; "convert"; "wallet"; base_dir; "in"; target_dir] -> convert_wallet ~replace:!force base_dir target_dir ; Format.printf @@ -491,7 +469,6 @@ let () = ?network_opt ?level:level_opt base_dir - ~override_with_consensus_key ~active_bakers_only aliases other_accounts_pkh diff --git a/devtools/yes_wallet/yes_wallet_lib.ml b/devtools/yes_wallet/yes_wallet_lib.ml index 78f6eb095b3b2392d5a83ff37d4b2bb023a2f225..1594e601de112c6324db39cdc41b76816c1b1b3a 100644 --- a/devtools/yes_wallet/yes_wallet_lib.ml +++ b/devtools/yes_wallet/yes_wallet_lib.ml @@ -158,7 +158,7 @@ let load_alias_file chn = (* Create a yes-wallet in [dest] using the alias list [alias_pkh_pk_ck_list]. If [write_consensus_keys] is true, the consensus key mapping file will be written, even if it is an empty list. *) -let write_yes_wallet ~write_consensus_keys dest alias_pkh_pk_ck_list = +let write_yes_wallet dest alias_pkh_pk_ck_list = let pkh_filename = Filename.concat dest "public_key_hashs" in let pk_filename = Filename.concat dest "public_keys" in let sk_filename = Filename.concat dest "secret_keys" in @@ -167,8 +167,7 @@ let write_yes_wallet ~write_consensus_keys dest alias_pkh_pk_ck_list = json_to_file (pkh_list_json alias_pkh_pk_ck_list) pkh_filename ; json_to_file (pk_list_json alias_pkh_pk_ck_list) pk_filename ; json_to_file (sk_list_json alias_pkh_pk_ck_list) sk_filename ; - if write_consensus_keys then - json_to_file (ck_list_json alias_pkh_pk_ck_list) ck_filename + json_to_file (ck_list_json alias_pkh_pk_ck_list) ck_filename (** Assuming that the [keys_list] is sorted in descending order, the function extracts the first keys until reaching the limit of @@ -206,9 +205,9 @@ let filter_up_to_staking_share share total_stake to_mutez keys_list = in loop ([], 0L) keys_list |> fst |> List.rev -let get_delegates_and_accounts (module P : Sigs.PROTOCOL) - ~override_with_consensus_key context (header : Block_header.shell_header) - active_bakers_only staking_share_opt accounts_pkh_lists = +let get_delegates_and_accounts (module P : Sigs.PROTOCOL) context + (header : Block_header.shell_header) active_bakers_only staking_share_opt + accounts_pkh_lists = let open Lwt_result_syntax in let level = header.Block_header.level in let predecessor_timestamp = header.timestamp in @@ -239,20 +238,18 @@ let get_delegates_and_accounts (module P : Sigs.PROTOCOL) ~f:(fun pkh acc -> let* pk = P.Delegate.pubkey ctxt pkh in let* ck = - if override_with_consensus_key then - let* cpk = P.Delegate.consensus_key ctxt pkh in - if - Tezos_crypto.Signature.Public_key.equal - (P.Signature.To_latest.public_key pk) + let* cpk = P.Delegate.consensus_key ctxt pkh in + if + Tezos_crypto.Signature.Public_key.equal + (P.Signature.To_latest.public_key pk) + (P.Signature.To_latest.public_key cpk) + then return_none + else + let cpkh = + Tezos_crypto.Signature.Public_key.hash (P.Signature.To_latest.public_key cpk) - then return_none - else - let cpkh = - Tezos_crypto.Signature.Public_key.hash - (P.Signature.To_latest.public_key cpk) - in - return_some (cpkh, P.Signature.To_latest.public_key cpk) - else return_none + in + return_some (cpkh, P.Signature.To_latest.public_key cpk) in let*? key_list_acc, staking_balance_acc = acc in let* staking_balance = P.Delegate.staking_balance ctxt pkh in @@ -557,19 +554,18 @@ let get_context ?level ~network_opt base_dir = return (protocol_hash, context, header, store) (** [load_bakers_public_keys ?staking_share_opt ?network_opt ?level - ~active_backers_only ~override_with_consensus_key base_dir - alias_phk_pk_list] checkouts the head context at the given [base_dir] and - computes a list of [(alias, pkh, pk, stake, frozen_deposits, - unstake_frozen_deposits)] corresponding to all delegates in that context. - The [alias] for the delegates are gathered from [alias_pkh_pk_list]). + ~active_backers_only base_dir alias_phk_pk_list] checkouts the head context + at the given [base_dir] and computes a list of [(alias, pkh, pk, stake, + frozen_deposits, unstake_frozen_deposits)] corresponding to all delegates in + that context. The [alias] for the delegates are gathered from + [alias_pkh_pk_list]). if [active_bakers_only] then the deactivated delegates are filtered out of the list. if an optional [level] is given, use the context from this level instead of head, if it exists. *) let load_bakers_public_keys ?staking_share_opt ?(network_opt = "mainnet") ?level - ~active_bakers_only ~override_with_consensus_key base_dir alias_pkh_pk_list - other_accounts_pkh = + ~active_bakers_only base_dir alias_pkh_pk_list other_accounts_pkh = let open Lwt_result_syntax in let* protocol_hash, context, header, store = get_context ?level ~network_opt base_dir @@ -616,7 +612,6 @@ let load_bakers_public_keys ?staking_share_opt ?(network_opt = "mainnet") ?level pp_protocol protocol ; get_delegates_and_accounts - ~override_with_consensus_key protocol context header @@ -718,14 +713,12 @@ let load_contracts ?dump_contracts ?(network_opt = "mainnet") ?level base_dir = return contracts let build_yes_wallet ?staking_share_opt ?network_opt base_dir - ~override_with_consensus_key ~active_bakers_only ~aliases - ~other_accounts_pkh = + ~active_bakers_only ~aliases ~other_accounts_pkh = let open Lwt_result_syntax in let+ bakers, other_accounts = load_bakers_public_keys ?staking_share_opt ?network_opt - ~override_with_consensus_key base_dir ~active_bakers_only aliases