From e58cba5e0b16c455c247775e8ef411b7d41676bb Mon Sep 17 00:00:00 2001 From: Michal Zander Date: Tue, 17 Dec 2024 14:41:01 +0000 Subject: [PATCH] Adjust genesis weights and weight_threshold for genesis accounts --- libraries/protocol/forward_keyauths.cpp | 18 ++++++++++++------ .../include/hive/protocol/forward_keyauths.hpp | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libraries/protocol/forward_keyauths.cpp b/libraries/protocol/forward_keyauths.cpp index b66268f001..b67fc0f9d3 100644 --- a/libraries/protocol/forward_keyauths.cpp +++ b/libraries/protocol/forward_keyauths.cpp @@ -135,9 +135,9 @@ struct keyauth_collector void collect_pow(const account_name_type& worker_account_name, const public_key_type& worker_key) { - collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::OWNER, 0, true, worker_key, {}, 0}); - collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::ACTIVE, 0, true, worker_key, {}, 0}); - collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::POSTING, 0, true, worker_key, {}, 0}); + collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::OWNER, 1, true, worker_key, {}, 1}); + collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::ACTIVE, 1, true, worker_key, {}, 1}); + collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::POSTING, 1, true, worker_key, {}, 1}); collected_keyauths.emplace_back(collected_keyauth_t{worker_account_name, hive::app::key_t::MEMO, 0, true, worker_key, {}, 0}); } @@ -271,17 +271,23 @@ collected_keyauth_collection_t operation_get_genesis_keyauths() keyauth_collector collector; // Common key types for genesis accounts - std::vector genesis_key_types = {key_t::OWNER, key_t::ACTIVE, key_t::POSTING, key_t::MEMO}; + std::vector genesis_key_types = {key_t::OWNER, key_t::ACTIVE, key_t::POSTING}; // 'steem' account auto STEEM_PUBLIC_KEY = public_key_type( HIVE_STEEM_PUBLIC_KEY_STR ); collected_keyauth_t steem_item {"steem", key_t::OWNER, 1, true, STEEM_PUBLIC_KEY, {}, 1}; add_key_authorizations(collector, steem_item, genesis_key_types); + add_key_authorizations(collector, steem_item, {key_t::MEMO}); // 'initminer' account auto INITMINER_KEY = public_key_type(HIVE_INIT_PUBLIC_KEY_STR); - collected_keyauth_t initminer_item {"initminer", key_t::OWNER, 0, true, INITMINER_KEY, {}, 0}; + collected_keyauth_t initminer_item {"initminer", key_t::OWNER, 1, true, INITMINER_KEY, {}, 1}; add_key_authorizations(collector, initminer_item, genesis_key_types); + add_key_authorizations(collector, initminer_item, {key_t::MEMO}); + + // 'temp' account + collected_keyauth_t temp_item {"temp", key_t::OWNER, 0, true, public_key_type(), {}, 0, false}; + add_key_authorizations(collector, temp_item, genesis_key_types); // Other genesis accounts - only MEMO std::vector other_accounts = {HIVE_MINER_ACCOUNT, HIVE_NULL_ACCOUNT, HIVE_TEMP_ACCOUNT}; @@ -319,7 +325,7 @@ collected_keyauth_collection_t lock_account( const std::string& account_name ) for (const auto& key_type : key_types) { - collected_keyauth_t default_item {account_name, key_type, 0, key_type == key_t::MEMO, {}, {}, 0, key_type != key_t::MEMO/*lock_account_mode*/}; + collected_keyauth_t default_item {account_name, key_type, 0, key_type == key_t::MEMO, {}, {}, 0, true, key_type != key_t::MEMO/*lock_account_mode*/}; add_key_authorizations(collector, default_item, {key_type}); } diff --git a/libraries/protocol/include/hive/protocol/forward_keyauths.hpp b/libraries/protocol/include/hive/protocol/forward_keyauths.hpp index a9c133f6f4..a427f919f4 100644 --- a/libraries/protocol/include/hive/protocol/forward_keyauths.hpp +++ b/libraries/protocol/include/hive/protocol/forward_keyauths.hpp @@ -26,12 +26,12 @@ struct collected_keyauth_t fc::ecc::public_key_data key_auth; std::string account_auth; hive::protocol::weight_type w = 0; - + bool key_exists = true; bool lock_account_mode = false; bool allow_null_in_key_auth() const { - return lock_account_mode || !keyauth_variant; + return lock_account_mode || !keyauth_variant || !key_exists; } bool allow_null_in_account_auth() const