Rename detach-worker -> unbond-worker

pull/1959/head
vzotova 2020-05-11 15:07:16 +03:00
parent c228c388c3
commit 66ac1acb1d
10 changed files with 42 additions and 42 deletions

View File

@ -56,7 +56,7 @@ All staking-related operations done by Staker are performed through the ``nucyph
+----------------------+-------------------------------------------------------------------------------+
| ``bond-worker`` | Bond a worker to a staker |
+----------------------+-------------------------------------------------------------------------------+
| ``detach-worker`` | Detach worker currently bonded to a staker |
| ``unbond-worker`` | Unbond worker currently bonded to a staker |
+----------------------+-------------------------------------------------------------------------------+
| ``collect-reward`` | Withdraw staking compensation from the contract to your wallet |
+----------------------+-------------------------------------------------------------------------------+
@ -418,7 +418,7 @@ There is a 1:1 relationship between the roles: A Staker may have multiple Stakes
.. note:: The Worker cannot be changed for a minimum of 2 periods once bonded.
.. note:: Stakers without a worker bonded will be highlighted in yellow (sometimes called "Detached" or "Headless").
.. note:: Stakers without a worker bonded will be highlighted in yellow (sometimes called "Unbonded" or "Headless").
.. code:: bash

View File

@ -1091,7 +1091,7 @@ class Staker(NucypherTokenActor):
@only_me
@save_receipt
def detach_worker(self) -> dict:
def unbond_worker(self) -> dict:
if self.is_contract:
receipt = self.preallocation_escrow_agent.release_worker()
else:
@ -1230,7 +1230,7 @@ class Worker(NucypherTokenActor):
class WorkerError(NucypherTokenActor.ActorError):
pass
class DetachedWorker(WorkerError):
class UnbondedWorker(WorkerError):
"""Raised when the Worker is not bonded to a Staker in the StakingEscrow contract."""
def __init__(self,
@ -1316,7 +1316,7 @@ class Worker(NucypherTokenActor):
delta = now - start
if delta.total_seconds() >= timeout:
if staking_address == NULL_ADDRESS:
raise self.DetachedWorker(f"Worker {self.__worker_address} not bonded after waiting {timeout} seconds.")
raise self.UnbondedWorker(f"Worker {self.__worker_address} not bonded after waiting {timeout} seconds.")
elif not ether_balance:
raise RuntimeError(f"Worker {self.__worker_address} has no ether after waiting {timeout} seconds.")

View File

@ -510,7 +510,7 @@ contract StakingEscrow is Issuer, IERC900History {
stakerFromWorker[_worker] = msg.sender;
}
// Bond new worker (or detach if _worker == address(0))
// Bond new worker (or unbond if _worker == address(0))
info.worker = _worker;
info.workerStartPeriod = currentPeriod;
emit WorkerBonded(msg.sender, _worker, currentPeriod);

View File

@ -373,18 +373,18 @@ def bond_worker(general_config, transacting_staker_options, config_file, force,
chain_name=blockchain.client.chain_name,
transaction_type='bond_worker')
emitter.echo(f"Bonded at period #{current_period} ({bonded_date})", color='green')
emitter.echo(f"This worker can be replaced or detached after period "
emitter.echo(f"This worker can be replaced or unbonded after period "
f"#{release_period} ({release_date})", color='green')
@stake.command('detach-worker')
@stake.command('unbond-worker')
@group_transacting_staker_options
@option_config_file
@option_force
@group_general_config
def detach_worker(general_config, transacting_staker_options, config_file, force):
def unbond_worker(general_config, transacting_staker_options, config_file, force):
"""
Detach worker currently bonded to a staker.
Unbond worker currently bonded to a staker.
"""
emitter = _setup_emitter(general_config)
@ -407,18 +407,18 @@ def detach_worker(general_config, transacting_staker_options, config_file, force
password = transacting_staker_options.get_password(blockchain, client_account)
STAKEHOLDER.assimilate(checksum_address=client_account, password=password)
receipt = STAKEHOLDER.detach_worker()
receipt = STAKEHOLDER.unbond_worker()
# TODO: Double-check dates
current_period = STAKEHOLDER.staking_agent.get_current_period()
bonded_date = datetime_at_period(period=current_period, seconds_per_period=economics.seconds_per_period)
emitter.echo(f"Successfully detached worker {worker_address} from staker {staking_address}", color='green')
emitter.echo(f"Successfully unbonded worker {worker_address} from staker {staking_address}", color='green')
paint_receipt_summary(emitter=emitter,
receipt=receipt,
chain_name=blockchain.client.chain_name,
transaction_type='detach_worker')
emitter.echo(f"Detached at period #{current_period} ({bonded_date})", color='green')
transaction_type='unbond_worker')
emitter.echo(f"Unbonded at period #{current_period} ({bonded_date})", color='green')
@stake.command()

View File

@ -903,7 +903,7 @@ class Learner:
self.log.warn(f'Verification Failed - '
f'{sprout} has an invalid wallet signature for {sprout.decentralized_identity_evidence}')
except sprout.DetachedWorker:
except sprout.UnbondedWorker:
self.log.warn(f'Verification Failed - '
f'{sprout} is not bonded to a Staker.')
@ -995,7 +995,7 @@ class Teacher:
class NotStaking(InvalidStamp):
"""Raised when a node fails verification because it is not currently staking"""
class DetachedWorker(InvalidNode):
class UnbondedWorker(InvalidNode):
"""Raised when a node fails verification because it is not bonded to a Staker"""
class WrongMode(TypeError):
@ -1097,7 +1097,7 @@ class Teacher:
staker_address = staking_agent.get_staker_from_worker(worker_address=self.worker_address)
if staker_address == NULL_ADDRESS:
raise self.DetachedWorker(f"Worker {self.worker_address} is detached")
raise self.UnbondedWorker(f"Worker {self.worker_address} is not bonded")
return staker_address == self.checksum_address
def _staker_is_really_staking(self, registry: BaseContractRegistry) -> bool:
@ -1145,7 +1145,7 @@ class Teacher:
if not self._worker_is_bonded_to_staker(registry=registry): # <-- Blockchain CALL
message = f"Worker {self.worker_address} is not bonded to staker {self.checksum_address}"
self.log.debug(message)
raise self.DetachedWorker(message)
raise self.UnbondedWorker(message)
if self._staker_is_really_staking(registry=registry): # <-- Blockchain CALL
self.verified_worker = True
@ -1207,7 +1207,7 @@ class Teacher:
# This is both the stamp's client signature and interface metadata check; May raise InvalidNode
try:
self.validate_metadata(registry=registry)
except self.DetachedWorker:
except self.UnbondedWorker:
self.verified_node = False
return False

View File

@ -651,12 +651,12 @@ def test_worker(testerchain, token, escrow_contract, deploy_contract):
tx = intermediary1.functions.bondWorker(worker2).transact({'from': ursula1})
testerchain.wait_for_receipt(tx)
# She can't detach her worker too, until enough time has passed
# She can't unbond her worker too, until enough time has passed
with pytest.raises((TransactionFailed, ValueError)):
tx = intermediary1.functions.bondWorker(NULL_ADDRESS).transact({'from': ursula1})
testerchain.wait_for_receipt(tx)
# Let's advance one period and detach the worker
# Let's advance one period and unbond the worker
testerchain.time_travel(hours=1)
tx = intermediary1.functions.bondWorker(NULL_ADDRESS).transact({'from': ursula1})
testerchain.wait_for_receipt(tx)
@ -667,7 +667,7 @@ def test_worker(testerchain, token, escrow_contract, deploy_contract):
assert number_of_events == len(events)
event_args = events[-1]['args']
assert intermediary1.address == event_args['staker']
# Now the worker has been detached ...
# Now the worker has been unbonded ...
assert NULL_ADDRESS == event_args['worker']
# ... with a new starting period.
assert escrow.functions.getCurrentPeriod().call() == event_args['startPeriod']

View File

@ -170,7 +170,7 @@ def test_coexisting_configurations(click_runner,
Worker.BONDING_POLL_RATE = 1
Worker.BONDING_TIMEOUT = 1
with pytest.raises(Teacher.DetachedWorker):
with pytest.raises(Teacher.UnbondedWorker):
# Worker init success, but not bonded.
result = click_runner.invoke(nucypher_cli, run_args, input=user_input, catch_exceptions=False)
assert result.exit_code == 0

View File

@ -160,7 +160,7 @@ def test_persistent_node_storage_integration(click_runner,
'--teacher', teacher_uri)
Worker.BONDING_TIMEOUT = 1
with pytest.raises(Teacher.DetachedWorker):
with pytest.raises(Teacher.UnbondedWorker):
# Worker init success, but not bonded.
result = yield threads.deferToThread(click_runner.invoke,
nucypher_cli, run_args,
@ -176,7 +176,7 @@ def test_persistent_node_storage_integration(click_runner,
'--interactive',
'--config-file', another_ursula_configuration_file_location)
with pytest.raises(Teacher.DetachedWorker):
with pytest.raises(Teacher.UnbondedWorker):
# Worker init success, but not bonded.
result = yield threads.deferToThread(click_runner.invoke,
nucypher_cli, run_args,

View File

@ -200,13 +200,13 @@ def test_stake_via_contract(click_runner,
assert stake.duration == token_economics.minimum_locked_periods
def test_stake_set_worker(click_runner,
beneficiary,
mock_allocation_registry,
agency_local_registry,
manual_worker,
individual_allocation,
stakeholder_configuration_file_location):
def test_stake_bond_worker(click_runner,
beneficiary,
mock_allocation_registry,
agency_local_registry,
manual_worker,
individual_allocation,
stakeholder_configuration_file_location):
init_args = ('stake', 'bond-worker',
'--config-file', stakeholder_configuration_file_location,
@ -229,7 +229,7 @@ def test_stake_set_worker(click_runner,
assert staker.worker_address == manual_worker
def test_stake_detach_worker(click_runner,
def test_stake_unbond_worker(click_runner,
testerchain,
token_economics,
beneficiary,
@ -247,7 +247,7 @@ def test_stake_detach_worker(click_runner,
testerchain.time_travel(periods=token_economics.minimum_worker_periods)
init_args = ('stake', 'detach-worker',
init_args = ('stake', 'unbond-worker',
'--config-file', stakeholder_configuration_file_location,
'--allocation-filepath', MOCK_INDIVIDUAL_ALLOCATION_FILEPATH,
'--force')

View File

@ -204,12 +204,12 @@ def test_stake_prolong(click_runner,
assert new_termination == old_termination + 1
def test_stake_set_worker(click_runner,
testerchain,
agency_local_registry,
manual_staker,
manual_worker,
stakeholder_configuration_file_location):
def test_stake_bond_worker(click_runner,
testerchain,
agency_local_registry,
manual_staker,
manual_worker,
stakeholder_configuration_file_location):
init_args = ('stake', 'bond-worker',
'--config-file', stakeholder_configuration_file_location,
@ -572,7 +572,7 @@ def test_collect_rewards_integration(click_runner,
assert staker.token_agent.get_balance(address=staker_address) >= balance_before_collecting
def test_stake_detach_worker(click_runner,
def test_stake_unbond_worker(click_runner,
testerchain,
manual_staker,
manual_worker,
@ -585,7 +585,7 @@ def test_stake_detach_worker(click_runner,
assert staker.worker_address == manual_worker
init_args = ('stake', 'detach-worker',
init_args = ('stake', 'unbond-worker',
'--config-file', stakeholder_configuration_file_location,
'--staking-address', manual_staker,
)