From 398896d2ab74d2184a1afbbf7d13056bc7d4a933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Tue, 4 Jun 2019 13:41:20 +0200 Subject: [PATCH] Leftovers: Miner --> Staker, MiningAdjudicator --> Adjudicator, etc. --- nucypher/blockchain/eth/actors.py | 4 ++-- nucypher/blockchain/eth/deployers.py | 10 +++++----- nucypher/characters/lawful.py | 2 +- nucypher/cli/config.py | 4 ++-- nucypher/utilities/sandbox/blockchain.py | 8 ++++---- nucypher/utilities/sandbox/constants.py | 4 ++-- scripts/deploy_then_stake.sh | 3 ++- .../staking_escrow/{test_mining.py => test_staking.py} | 0 tests/blockchain/eth/entities/actors/test_deployer.py | 8 ++++---- .../entities/actors/{test_miner.py => test_staker.py} | 0 ...er_escrow_agent.py => test_staking_escrow_agent.py} | 2 +- ...row_deployer.py => test_staking_escrow_deployer.py} | 0 tests/cli/test_mixed_configurations.py | 4 ++-- 13 files changed, 25 insertions(+), 24 deletions(-) rename tests/blockchain/eth/contracts/main/staking_escrow/{test_mining.py => test_staking.py} (100%) rename tests/blockchain/eth/entities/actors/{test_miner.py => test_staker.py} (100%) rename tests/blockchain/eth/entities/agents/{test_miner_escrow_agent.py => test_staking_escrow_agent.py} (99%) rename tests/blockchain/eth/entities/deployers/{test_miner_escrow_deployer.py => test_staking_escrow_deployer.py} (100%) diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index bc7bb6ced..897616be8 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -30,7 +30,7 @@ from constant_sorrow.constants import ( UNKNOWN_STAKES, NOT_STAKING, NO_STAKES, - STRANGER_MINER + STRANGER_STAKER ) from eth_tester.exceptions import TransactionFailed from twisted.internet import task, reactor @@ -382,7 +382,7 @@ class Staker(NucypherTokenActor): self._staking_task = task.LoopingCall(self.heartbeat) else: - self.token_agent = STRANGER_MINER + self.token_agent = STRANGER_STAKER self.staking_agent = StakingEscrow(blockchain=self.blockchain) diff --git a/nucypher/blockchain/eth/deployers.py b/nucypher/blockchain/eth/deployers.py index 13dda5f58..9da761542 100644 --- a/nucypher/blockchain/eth/deployers.py +++ b/nucypher/blockchain/eth/deployers.py @@ -761,18 +761,18 @@ class AdjudicatorDeployer(ContractDeployer): deployer_address=self.deployer_address, bare=True) - mining_adjudicator_contract, deploy_txhash = self.blockchain.interface.deploy_contract(self.contract_name, - self.staking_agent.contract_address, - *self.__economics.deployment_parameters) + adjudicator_contract, deploy_txhash = self.blockchain.interface.deploy_contract(self.contract_name, + self.staking_agent.contract_address, + *self.__economics.deployment_parameters) - upgrade_tx_hash = proxy_deployer.retarget(new_target=mining_adjudicator_contract.address, + upgrade_tx_hash = proxy_deployer.retarget(new_target=adjudicator_contract.address, existing_secret_plaintext=existing_secret_plaintext, new_secret_hash=new_secret_hash) _upgrade_receipt = self.blockchain.wait_for_receipt(upgrade_tx_hash) # Wrap the escrow contract wrapped_adjudicator_contract = self.blockchain.interface._wrap_contract(proxy_deployer.contract, - target_contract=mining_adjudicator_contract) + target_contract=adjudicator_contract) # Switch the contract for the wrapped one policy_manager_contract = wrapped_adjudicator_contract diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index 7a5fd6004..489bee173 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -234,7 +234,7 @@ class Alice(Character, PolicyAuthor): duration = calculate_period_duration(future_time=expiration) else: duration = duration or self.duration - expiration = datetime_at_period(self.miner_agent.get_current_period() + duration) + expiration = datetime_at_period(self.staking_agent.get_current_period() + duration) if not value and not rate: value = int(self.rate * duration) diff --git a/nucypher/cli/config.py b/nucypher/cli/config.py index 07b9bb0ae..c88b045e9 100644 --- a/nucypher/cli/config.py +++ b/nucypher/cli/config.py @@ -148,10 +148,10 @@ class NucypherDeployerClickConfig(NucypherClickConfig): def collect_deployment_secrets(self) -> Secrets: # Deployment Environment Variables - self.staking_escrow_deployment_secret = os.environ.get("NUCYPHER_MINERS_ESCROW_SECRET") + self.staking_escrow_deployment_secret = os.environ.get("NUCYPHER_STAKING_ESCROW_SECRET") self.policy_manager_deployment_secret = os.environ.get("NUCYPHER_POLICY_MANAGER_SECRET") self.user_escrow_proxy_deployment_secret = os.environ.get("NUCYPHER_USER_ESCROW_PROXY_SECRET") - self.adjudicator_deployment_secret = os.environ.get("NUCYPHER_MINING_ADJUDICATOR_SECRET") + self.adjudicator_deployment_secret = os.environ.get("NUCYPHER_ADJUDICATOR_SECRET") if not self.staking_escrow_deployment_secret: diff --git a/nucypher/utilities/sandbox/blockchain.py b/nucypher/utilities/sandbox/blockchain.py index 11b6bcb0f..11c2ffdd8 100644 --- a/nucypher/utilities/sandbox/blockchain.py +++ b/nucypher/utilities/sandbox/blockchain.py @@ -39,9 +39,9 @@ from nucypher.utilities.sandbox.constants import ( NUMBER_OF_URSULAS_IN_BLOCKCHAIN_TESTS, NUMBER_OF_ETH_TEST_ACCOUNTS, DEVELOPMENT_ETH_AIRDROP_AMOUNT, - MINERS_ESCROW_DEPLOYMENT_SECRET, + STAKING_ESCROW_DEPLOYMENT_SECRET, POLICY_MANAGER_DEPLOYMENT_SECRET, - MINING_ADJUDICATOR_DEPLOYMENT_SECRET, + ADJUDICATOR_DEPLOYMENT_SECRET, USER_ESCROW_PROXY_DEPLOYMENT_SECRET ) @@ -219,9 +219,9 @@ class TesterBlockchain(Blockchain): origin = testerchain.interface.w3.eth.accounts[0] deployer = Deployer(blockchain=testerchain, deployer_address=origin, bare=True) - _txhashes, agents = deployer.deploy_network_contracts(staker_secret=MINERS_ESCROW_DEPLOYMENT_SECRET, + _txhashes, agents = deployer.deploy_network_contracts(staker_secret=STAKING_ESCROW_DEPLOYMENT_SECRET, policy_secret=POLICY_MANAGER_DEPLOYMENT_SECRET, - adjudicator_secret=MINING_ADJUDICATOR_DEPLOYMENT_SECRET, + adjudicator_secret=ADJUDICATOR_DEPLOYMENT_SECRET, user_escrow_proxy_secret=USER_ESCROW_PROXY_DEPLOYMENT_SECRET) return testerchain, agents diff --git a/nucypher/utilities/sandbox/constants.py b/nucypher/utilities/sandbox/constants.py index ec85eac94..c5182dfa0 100644 --- a/nucypher/utilities/sandbox/constants.py +++ b/nucypher/utilities/sandbox/constants.py @@ -89,13 +89,13 @@ NUMBER_OF_ALLOCATIONS_IN_TESTS = 100 # TODO: Move to constants INSECURE_DEVELOPMENT_PASSWORD = ''.join(SystemRandom().choice(ascii_uppercase + digits) for _ in range(16)) -MINERS_ESCROW_DEPLOYMENT_SECRET = INSECURE_DEVELOPMENT_PASSWORD + str(os.urandom(16)) +STAKING_ESCROW_DEPLOYMENT_SECRET = INSECURE_DEVELOPMENT_PASSWORD + str(os.urandom(16)) POLICY_MANAGER_DEPLOYMENT_SECRET = INSECURE_DEVELOPMENT_PASSWORD + str(os.urandom(16)) USER_ESCROW_PROXY_DEPLOYMENT_SECRET = INSECURE_DEVELOPMENT_PASSWORD + str(os.urandom(16)) -MINING_ADJUDICATOR_DEPLOYMENT_SECRET = INSECURE_DEVELOPMENT_PASSWORD + str(os.urandom(16)) +ADJUDICATOR_DEPLOYMENT_SECRET = INSECURE_DEVELOPMENT_PASSWORD + str(os.urandom(16)) # diff --git a/scripts/deploy_then_stake.sh b/scripts/deploy_then_stake.sh index 51f40ea6b..9f583e926 100755 --- a/scripts/deploy_then_stake.sh +++ b/scripts/deploy_then_stake.sh @@ -3,9 +3,10 @@ rm -rf ~/.local/share/nucypher # Set Upgrade Secrets -export NUCYPHER_MINER_ESCROW_SECRET='debuggerdebugger' +export NUCYPHER_STAKING_ESCROW_SECRET='debuggerdebugger' export NUCYPHER_POLICY_MANAGER_SECRET='debuggerdebugger' export NUCYPHER_USER_ESCROW_PROXY_SECRET='debuggerdebugger' +export NUCYPHER_ADJUDICATOR_SECRET='debuggerdebugger' # Deploy Main Contracts nucypher-deploy contracts --provider-uri ipc:///tmp/geth.ipc --poa diff --git a/tests/blockchain/eth/contracts/main/staking_escrow/test_mining.py b/tests/blockchain/eth/contracts/main/staking_escrow/test_staking.py similarity index 100% rename from tests/blockchain/eth/contracts/main/staking_escrow/test_mining.py rename to tests/blockchain/eth/contracts/main/staking_escrow/test_staking.py diff --git a/tests/blockchain/eth/entities/actors/test_deployer.py b/tests/blockchain/eth/entities/actors/test_deployer.py index a1c885fdb..3582abe6e 100644 --- a/tests/blockchain/eth/entities/actors/test_deployer.py +++ b/tests/blockchain/eth/entities/actors/test_deployer.py @@ -30,9 +30,9 @@ from nucypher.utilities.sandbox.blockchain import TesterBlockchain as _TesterBlo from nucypher.utilities.sandbox.constants import ( ONE_YEAR_IN_SECONDS, USER_ESCROW_PROXY_DEPLOYMENT_SECRET, - MINING_ADJUDICATOR_DEPLOYMENT_SECRET, + ADJUDICATOR_DEPLOYMENT_SECRET, POLICY_MANAGER_DEPLOYMENT_SECRET, - MINERS_ESCROW_DEPLOYMENT_SECRET, + STAKING_ESCROW_DEPLOYMENT_SECRET, NUMBER_OF_ALLOCATIONS_IN_TESTS, TEST_PROVIDER_URI) @@ -53,9 +53,9 @@ def test_rapid_deployment(token_economics): # The Big Three (+ Dispatchers) # Deploy User Escrow, too (+ Linker) - deployer.deploy_network_contracts(staker_secret=MINERS_ESCROW_DEPLOYMENT_SECRET, + deployer.deploy_network_contracts(staker_secret=STAKING_ESCROW_DEPLOYMENT_SECRET, policy_secret=POLICY_MANAGER_DEPLOYMENT_SECRET, - adjudicator_secret=MINING_ADJUDICATOR_DEPLOYMENT_SECRET, + adjudicator_secret=ADJUDICATOR_DEPLOYMENT_SECRET, user_escrow_proxy_secret=USER_ESCROW_PROXY_DEPLOYMENT_SECRET) all_yall = blockchain.unassigned_accounts diff --git a/tests/blockchain/eth/entities/actors/test_miner.py b/tests/blockchain/eth/entities/actors/test_staker.py similarity index 100% rename from tests/blockchain/eth/entities/actors/test_miner.py rename to tests/blockchain/eth/entities/actors/test_staker.py diff --git a/tests/blockchain/eth/entities/agents/test_miner_escrow_agent.py b/tests/blockchain/eth/entities/agents/test_staking_escrow_agent.py similarity index 99% rename from tests/blockchain/eth/entities/agents/test_miner_escrow_agent.py rename to tests/blockchain/eth/entities/agents/test_staking_escrow_agent.py index 670a0a629..b1216b377 100644 --- a/tests/blockchain/eth/entities/agents/test_miner_escrow_agent.py +++ b/tests/blockchain/eth/entities/agents/test_staking_escrow_agent.py @@ -52,7 +52,7 @@ def test_deposit_tokens(testerchain, agency, token_economics): testerchain.time_travel(periods=1) balance = token_agent.get_balance(address=someone) assert balance == locked_tokens - assert agent.get_locked_tokens(miner_address=someone) == locked_tokens + assert agent.get_locked_tokens(staker_address=someone) == locked_tokens @pytest.mark.slow() diff --git a/tests/blockchain/eth/entities/deployers/test_miner_escrow_deployer.py b/tests/blockchain/eth/entities/deployers/test_staking_escrow_deployer.py similarity index 100% rename from tests/blockchain/eth/entities/deployers/test_miner_escrow_deployer.py rename to tests/blockchain/eth/entities/deployers/test_staking_escrow_deployer.py diff --git a/tests/cli/test_mixed_configurations.py b/tests/cli/test_mixed_configurations.py index db6c61277..d96073159 100644 --- a/tests/cli/test_mixed_configurations.py +++ b/tests/cli/test_mixed_configurations.py @@ -26,9 +26,9 @@ def test_coexisting_configurations(click_runner, envvars = {'NUCYPHER_KEYRING_PASSWORD': INSECURE_DEVELOPMENT_PASSWORD, # Upgradeable Contracts - 'NUCYPHER_MINERS_ESCROW_SECRET': INSECURE_DEVELOPMENT_PASSWORD, + 'NUCYPHER_STAKING_ESCROW_SECRET': INSECURE_DEVELOPMENT_PASSWORD, 'NUCYPHER_POLICY_MANAGER_SECRET': INSECURE_DEVELOPMENT_PASSWORD, - 'NUCYPHER_MINING_ADJUDICATOR_SECRET': INSECURE_DEVELOPMENT_PASSWORD, + 'NUCYPHER_ADJUDICATOR_SECRET': INSECURE_DEVELOPMENT_PASSWORD, 'NUCYPHER_USER_ESCROW_PROXY_SECRET': INSECURE_DEVELOPMENT_PASSWORD, # Auxiliary