Skip to content

Commit

Permalink
drop deprecated authentication_public_key from pool config (#17959)
Browse files Browse the repository at this point in the history
* introduce early exit to dedent for-loop

* remove deprecated authentication_public_key from pool-config
  • Loading branch information
arvidn authored May 4, 2024
1 parent 1661ce2 commit fdb87e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 37 deletions.
4 changes: 1 addition & 3 deletions chia/farmer/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from chia.daemon.keychain_proxy import KeychainProxy, connect_to_keychain_and_validate, wrap_local_keychain
from chia.plot_sync.delta import Delta
from chia.plot_sync.receiver import Receiver
from chia.pools.pool_config import PoolWalletConfig, add_auth_key, load_pool_config, update_pool_url
from chia.pools.pool_config import PoolWalletConfig, load_pool_config, update_pool_url
from chia.protocols import farmer_protocol, harvester_protocol
from chia.protocols.pool_protocol import (
AuthenticationPayload,
Expand Down Expand Up @@ -531,8 +531,6 @@ async def update_pool_state(self) -> None:
self.log.error(f"Could not find authentication sk for {p2_singleton_puzzle_hash}")
continue

add_auth_key(self._root_path, pool_config, authentication_sk.get_g1())

if p2_singleton_puzzle_hash not in self.pool_state:
self.pool_state[p2_singleton_puzzle_hash] = {
"p2_singleton_puzzle_hash": p2_singleton_puzzle_hash.hex(),
Expand Down
47 changes: 13 additions & 34 deletions chia/pools/pool_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,6 @@ def load_pool_config(root_path: Path) -> List[PoolWalletConfig]:
return ret_list


# TODO: remove this a few versions after 1.3, since authentication_public_key is deprecated. This is here to support
# downgrading to versions older than 1.3.
def add_auth_key(root_path: Path, pool_wallet_config: PoolWalletConfig, auth_key: G1Element) -> None:
def update_auth_pub_key_for_entry(config_entry: Dict[str, Any]) -> bool:
auth_key_hex = bytes(auth_key).hex()
if config_entry.get("authentication_public_key", "") != auth_key_hex:
config_entry["authentication_public_key"] = auth_key_hex

return True

return False

update_pool_config_entry(
root_path=root_path,
pool_wallet_config=pool_wallet_config,
update_closure=update_auth_pub_key_for_entry,
update_log_message=f"Updating pool config for auth key: {auth_key}",
)


def update_pool_url(root_path: Path, pool_wallet_config: PoolWalletConfig, pool_url: str) -> None:
def update_pool_url_for_entry(config_entry: Dict[str, Any]) -> bool:
if config_entry.get("pool_url", "") != pool_url:
Expand All @@ -107,21 +87,20 @@ def update_pool_config_entry(
) -> None:
with lock_and_load_config(root_path, "config.yaml") as config:
pool_list = config["pool"].get("pool_list", [])
if pool_list is None:
return
updated = False
if pool_list is not None:
for pool_config_dict in pool_list:
try:
if hexstr_to_bytes(pool_config_dict["owner_public_key"]) == bytes(
pool_wallet_config.owner_public_key
):
if update_closure(pool_config_dict):
updated = True
except Exception as e:
log.error(f"Exception updating config: {pool_config_dict} {e}")
if updated:
log.info(update_log_message)
config["pool"]["pool_list"] = pool_list
save_config(root_path, "config.yaml", config)
for pool_config_dict in pool_list:
try:
if hexstr_to_bytes(pool_config_dict["owner_public_key"]) == bytes(pool_wallet_config.owner_public_key):
if update_closure(pool_config_dict):
updated = True
except Exception as e:
log.error(f"Exception updating config: {pool_config_dict} {e}")
if updated:
log.info(update_log_message)
config["pool"]["pool_list"] = pool_list
save_config(root_path, "config.yaml", config)


async def update_pool_config(root_path: Path, pool_config_list: List[PoolWalletConfig]) -> None:
Expand Down

0 comments on commit fdb87e6

Please sign in to comment.