mirror of https://github.com/nucypher/nucypher.git
First version of AdjudicatorAgent and Investigator actor. Closes #931
parent
5b530430dd
commit
05a7a78c49
|
@ -632,3 +632,25 @@ class PolicyAuthor(NucypherTokenActor):
|
|||
from nucypher.blockchain.eth.policies import BlockchainPolicy
|
||||
blockchain_policy = BlockchainPolicy(alice=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,
|
||||
checksum_address: str,
|
||||
*args, **kwargs) -> None:
|
||||
|
||||
super().__init__(checksum_address=checksum_address, *args, **kwargs)
|
||||
|
||||
self.adjudicator_agent = AdjudicatorAgent(blockchain=self.blockchain)
|
||||
|
||||
def request_evaluation(self, evidence):
|
||||
receipt = self.adjudicator_agent.evaluate_cfrag(evidence=evidence,
|
||||
sender_address=self.checksum_address)
|
||||
self._transaction_cache.append((datetime.utcnow(), receipt))
|
||||
return receipt
|
||||
|
|
|
@ -499,46 +499,17 @@ class UserEscrowAgent(EthereumContractAgent):
|
|||
|
||||
|
||||
class AdjudicatorAgent(EthereumContractAgent, metaclass=Agency):
|
||||
"""TODO Issue #931"""
|
||||
|
||||
registry_contract_name = "Adjudicator"
|
||||
_proxy_name = "Dispatcher"
|
||||
|
||||
def evaluate_cfrag(self,
|
||||
capsule_bytes: bytes,
|
||||
capsule_signature_by_requester: bytes,
|
||||
capsule_signature_by_requester_and_staker: bytes,
|
||||
cfrag_bytes: bytes,
|
||||
cfrag_signature_by_staker: bytes,
|
||||
requester_public_key: bytes,
|
||||
staker_public_key: bytes,
|
||||
staker_public_key_signature: bytes,
|
||||
precomputed_data: bytes):
|
||||
def evaluate_cfrag(self, evidence, sender_address: str):
|
||||
"""
|
||||
|
||||
From Contract Source:
|
||||
|
||||
function evaluateCFrag(
|
||||
bytes memory _capsuleBytes,
|
||||
bytes memory _capsuleSignatureByRequester,
|
||||
bytes memory _capsuleSignatureByRequesterAndStaker,
|
||||
bytes memory _cFragBytes,
|
||||
bytes memory _cFragSignatureByStaker,
|
||||
bytes memory _requesterPublicKey,
|
||||
bytes memory _stakerPublicKey,
|
||||
bytes memory _stakerPublicKeySignature,
|
||||
bytes memory _preComputedData
|
||||
)
|
||||
|
||||
:param capsule:
|
||||
:param capsule_signature_by_requester:
|
||||
:param capsule_signature_by_requester_and_staker:
|
||||
:param cfrag:
|
||||
:param cfrag_signature_by_staker:
|
||||
:param requester_public_key:
|
||||
:param staker_public_key:
|
||||
:param staker_piblc_key_signature:
|
||||
:param precomputed_data:
|
||||
Submits proof that a worker created wrong CFrag
|
||||
:param evidence:
|
||||
:param sender_address:
|
||||
:return:
|
||||
"""
|
||||
# TODO: #931 - Challenge Agent and Actor - "Investigator"
|
||||
contract_function = self.contract.functions.evaluateCFrag(evidence.evaluation_arguments())
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=sender_address)
|
||||
return receipt
|
||||
|
|
|
@ -72,15 +72,15 @@ contract Adjudicator is Upgradeable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @notice Submit proof that staker created wrong CFrag
|
||||
* @notice Submit proof that a worker created wrong CFrag
|
||||
* @param _capsuleBytes Serialized capsule
|
||||
* @param _cFragBytes Serialized CFrag
|
||||
* @param _cFragSignature Signature of CFrag by staker
|
||||
* @param _cFragSignature Signature of CFrag by worker
|
||||
* @param _taskSignature Signature of task specification by Bob
|
||||
* @param _requesterPublicKey Requester's public key that was used to sign Capsule
|
||||
* @param _workerPublicKey Staker's public key that was used to sign Capsule and CFrag
|
||||
* @param _requesterPublicKey Bob's signing public key, also known as "stamp"
|
||||
* @param _workerPublicKey Worker's signing public key, also known as "stamp"
|
||||
* @param _workerIdentityEvidence Signature of worker's public key by worker's eth-key
|
||||
* @param _preComputedData Pre computed data for CFrag correctness verification
|
||||
* @param _preComputedData Additional pre-computed data for CFrag correctness verification
|
||||
**/
|
||||
function evaluateCFrag(
|
||||
bytes memory _capsuleBytes,
|
||||
|
|
Loading…
Reference in New Issue