diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index 28bc2cb3d..b78287e1d 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -28,7 +28,6 @@ from web3.types import TxReceipt from nucypher.acumen.nicknames import Nickname from nucypher.blockchain.eth.agents import ( - AdjudicatorAgent, ContractAgency, CoordinatorAgent, NucypherTokenAgent, @@ -37,7 +36,7 @@ from nucypher.blockchain.eth.agents import ( ) from nucypher.blockchain.eth.clients import PUBLIC_CHAINS from nucypher.blockchain.eth.constants import NULL_ADDRESS -from nucypher.blockchain.eth.decorators import save_receipt, validate_checksum_address +from nucypher.blockchain.eth.decorators import validate_checksum_address from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory from nucypher.blockchain.eth.registry import ( BaseContractRegistry, @@ -756,24 +755,3 @@ class PolicyAuthor(NucypherTokenActor): blockchain_policy = Policy(publisher=self, *args, **kwargs) return blockchain_policy - - -class Investigator(NucypherTokenActor): - """ - Actor that reports incorrect CFrags to the Adjudicator contract. - In most cases, Bob will act as investigator, but the actor is generic enough than - anyone can report CFrags. - """ - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.adjudicator_agent = ContractAgency.get_agent(AdjudicatorAgent, registry=self.registry) - - @save_receipt - def request_evaluation(self, evidence) -> dict: - receipt = self.adjudicator_agent.evaluate_cfrag(evidence=evidence, transacting_power=self.transacting_power) - return receipt - - def was_this_evidence_evaluated(self, evidence) -> bool: - result = self.adjudicator_agent.was_this_evidence_evaluated(evidence=evidence) - return result diff --git a/nucypher/blockchain/eth/agents.py b/nucypher/blockchain/eth/agents.py index 8a2e93031..f2ff4343f 100644 --- a/nucypher/blockchain/eth/agents.py +++ b/nucypher/blockchain/eth/agents.py @@ -38,8 +38,6 @@ from web3.types import Timestamp, TxParams, TxReceipt, Wei from nucypher import types from nucypher.blockchain.eth import events from nucypher.blockchain.eth.constants import ( - ADJUDICATOR_CONTRACT_NAME, - DISPATCHER_CONTRACT_NAME, ETH_ADDRESS_BYTE_LENGTH, NUCYPHER_TOKEN_CONTRACT_NAME, NULL_ADDRESS, @@ -57,7 +55,6 @@ from nucypher.config.constants import ( NUCYPHER_ENVVAR_STAKING_PROVIDERS_PAGINATION_SIZE_LIGHT_NODE, ) from nucypher.crypto.powers import TransactingPower -from nucypher.crypto.utils import sha256_digest from nucypher.utilities.logging import Logger # type: ignore @@ -252,8 +249,6 @@ class NucypherTokenAgent(EthereumContractAgent): class SubscriptionManagerAgent(EthereumContractAgent): contract_name: str = SUBSCRIPTION_MANAGER_CONTRACT_NAME - # TODO: A future deployment of SubscriptionManager may have a proxy. - # _proxy_name: str = DISPATCHER_CONTRACT_NAME class PolicyInfo(NamedTuple): sponsor: ChecksumAddress @@ -318,78 +313,6 @@ class SubscriptionManagerAgent(EthereumContractAgent): return receipt -class AdjudicatorAgent(EthereumContractAgent): - - contract_name: str = ADJUDICATOR_CONTRACT_NAME - _proxy_name: str = DISPATCHER_CONTRACT_NAME - - @contract_api(TRANSACTION) - def evaluate_cfrag(self, evidence, transacting_power: TransactingPower) -> TxReceipt: - """Submits proof that a worker created wrong CFrag""" - payload: TxParams = {'gas': Wei(500_000)} # TODO TransactionFails unless gas is provided. - contract_function: ContractFunction = self.contract.functions.evaluateCFrag(*evidence.evaluation_arguments()) - receipt = self.blockchain.send_transaction(contract_function=contract_function, - transacting_power=transacting_power, - payload=payload) - return receipt - - @contract_api(CONTRACT_CALL) - def was_this_evidence_evaluated(self, evidence) -> bool: - data_hash: bytes = sha256_digest(evidence.task.capsule, evidence.task.cfrag) - result: bool = self.contract.functions.evaluatedCFrags(data_hash).call() - return result - - @property # type: ignore - @contract_api(CONTRACT_ATTRIBUTE) - def staking_escrow_contract(self) -> ChecksumAddress: - return self.contract.functions.escrow().call() - - @property # type: ignore - @contract_api(CONTRACT_ATTRIBUTE) - def hash_algorithm(self) -> int: - return self.contract.functions.hashAlgorithm().call() - - @property # type: ignore - @contract_api(CONTRACT_ATTRIBUTE) - def base_penalty(self) -> int: - return self.contract.functions.basePenalty().call() - - @property # type: ignore - @contract_api(CONTRACT_ATTRIBUTE) - def penalty_history_coefficient(self) -> int: - return self.contract.functions.penaltyHistoryCoefficient().call() - - @property # type: ignore - @contract_api(CONTRACT_ATTRIBUTE) - def percentage_penalty_coefficient(self) -> int: - return self.contract.functions.percentagePenaltyCoefficient().call() - - @property # type: ignore - @contract_api(CONTRACT_ATTRIBUTE) - def reward_coefficient(self) -> int: - return self.contract.functions.rewardCoefficient().call() - - @contract_api(CONTRACT_CALL) - def penalty_history(self, staker_address: str) -> int: - return self.contract.functions.penaltyHistory(staker_address).call() - - @contract_api(CONTRACT_CALL) - def slashing_parameters(self) -> Tuple[int, ...]: - parameter_signatures = ( - 'hashAlgorithm', # Hashing algorithm - 'basePenalty', # Base for the penalty calculation - 'penaltyHistoryCoefficient', # Coefficient for calculating the penalty depending on the history - 'percentagePenaltyCoefficient', # Coefficient for calculating the percentage penalty - 'rewardCoefficient', # Coefficient for calculating the reward - ) - - def _call_function_by_name(name: str) -> int: - return getattr(self.contract.functions, name)().call() - - staking_parameters = tuple(map(_call_function_by_name, parameter_signatures)) - return staking_parameters - - class TACoChildApplicationAgent(EthereumContractAgent): contract_name: str = TACO_CHILD_APPLICATION_CONTRACT_NAME diff --git a/nucypher/blockchain/eth/constants.py b/nucypher/blockchain/eth/constants.py index 588ee3f77..476a63b74 100644 --- a/nucypher/blockchain/eth/constants.py +++ b/nucypher/blockchain/eth/constants.py @@ -4,11 +4,9 @@ # Contract Names # -DISPATCHER_CONTRACT_NAME = "Dispatcher" NUCYPHER_TOKEN_CONTRACT_NAME = "NuCypherToken" STAKING_ESCROW_CONTRACT_NAME = "StakingEscrow" STAKING_ESCROW_STUB_CONTRACT_NAME = "StakingEscrowStub" -ADJUDICATOR_CONTRACT_NAME = "Adjudicator" TACO_APPLICATION_CONTRACT_NAME = "TACoApplication" TACO_CHILD_APPLICATION_CONTRACT_NAME = "TACoChildApplication" SUBSCRIPTION_MANAGER_CONTRACT_NAME = "SubscriptionManager" @@ -16,8 +14,6 @@ SUBSCRIPTION_MANAGER_CONTRACT_NAME = "SubscriptionManager" NUCYPHER_CONTRACT_NAMES = ( NUCYPHER_TOKEN_CONTRACT_NAME, STAKING_ESCROW_CONTRACT_NAME, - ADJUDICATOR_CONTRACT_NAME, - DISPATCHER_CONTRACT_NAME, TACO_APPLICATION_CONTRACT_NAME, SUBSCRIPTION_MANAGER_CONTRACT_NAME ) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 37ae39214..8b08838de 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -7,7 +7,6 @@ from eth_account.account import Account from nucypher.blockchain.eth.actors import Operator from nucypher.blockchain.eth.agents import ( - AdjudicatorAgent, ContractAgency, CoordinatorAgent, StakingProvidersReservoir, @@ -84,13 +83,6 @@ def mock_taco_child_application_agent(testerchain, mock_contract_agency): mock_agent.reset() -@pytest.fixture(scope="function", autouse=True) -def mock_adjudicator_agent(testerchain, mock_contract_agency): - mock_agent = mock_contract_agency.get_agent(AdjudicatorAgent) - yield mock_agent - mock_agent.reset() - - @pytest.fixture(scope="function", autouse=True) def mock_coordinator_agent(testerchain, mock_contract_agency): from tests.mock.coordinator import MockCoordinatorAgent