diff --git a/nucypher/blockchain/eth/clients.py b/nucypher/blockchain/eth/clients.py index b44ab0e53..c619c3144 100644 --- a/nucypher/blockchain/eth/clients.py +++ b/nucypher/blockchain/eth/clients.py @@ -322,8 +322,17 @@ class GethClient(Web3Client): # Geth --dev accounts are unlocked by default. return True debug_message = f"Unlocking account {address}" + + if duration is None: + debug_message += f" for 5 minutes" + elif duration == 0: + debug_message += f" indefinitely" + elif duration > 0: + debug_message += f" for {duration} seconds" + if password is None: debug_message += " with no password." + self.log.debug(debug_message) return self.w3.geth.personal.unlockAccount(address, password, duration) diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index bd52aa883..ac15eee02 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -1390,6 +1390,7 @@ class StakeHolder(Staker): self.__get_accounts() if checksum_address not in self: raise self.UnknownAccount + # TODO: What if cached TransactingPower is wrongly initialized? See issue #1385 try: transacting_power = self.__transacting_powers[checksum_address] except KeyError: @@ -1433,17 +1434,27 @@ class StakeHolder(Staker): @validate_checksum_address def assimilate(self, checksum_address: str, password: str = None) -> None: + if self.is_contract: + original_form = f"{self.beneficiary_address[0:8]} (contract {self.checksum_address[0:8]})" + else: + original_form = self.checksum_address + # This handles both regular staking and staking via a contract staking_contract_address = self.check_if_staking_via_contract(checksum_address) staking_address = staking_contract_address or checksum_address self.wallet.activate_account(checksum_address=checksum_address, password=password) - original_form = self.checksum_address self.checksum_address = staking_address self.stakes = StakeList(registry=self.registry, checksum_address=staking_address) self.stakes.refresh() # TODO: Not sure how to log all this new info (i.e. old or new address may be via contract) - self.log.info(f"Resistance is futile - Assimilating Staker {original_form} -> {checksum_address}.") + + if self.is_contract: + new_form = f"{self.beneficiary_address[0:8]} (contract {self.checksum_address[0:8]})" + else: + new_form = self.checksum_address + + self.log.info(f"Resistance is futile - Assimilating Staker {original_form} -> {new_form}.") @property def all_stakes(self) -> list: diff --git a/nucypher/cli/characters/stake.py b/nucypher/cli/characters/stake.py index 9cd2e71d8..ad37376a0 100644 --- a/nucypher/cli/characters/stake.py +++ b/nucypher/cli/characters/stake.py @@ -166,8 +166,10 @@ def stake(click_config, allocation_registry = None initial_address = staking_address + dummy_password = "Look Away, I'm Hideous" # TODO: See #1385 STAKEHOLDER = stakeholder_config.produce(initial_address=initial_address, - allocation_registry=allocation_registry) + allocation_registry=allocation_registry, + password=dummy_password) blockchain = BlockchainInterfaceFactory.get_interface(provider_uri=provider_uri) # Eager connection economics = STAKEHOLDER.economics diff --git a/nucypher/crypto/powers.py b/nucypher/crypto/powers.py index 33c1fe4e5..0a177b15b 100644 --- a/nucypher/crypto/powers.py +++ b/nucypher/crypto/powers.py @@ -123,7 +123,7 @@ class TransactingPower(CryptoPowerUp): self.blockchain = BlockchainInterfaceFactory.get_or_create_interface(provider_uri=provider_uri) self.__account = account - # TODO: Is there a better way to design this Flag? + # TODO: Is there a better way to design this Flag? See #1385 self.device = True if not password else False self.__password = password