Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

adding workerregistry and workorderregistry for the proxy model #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Amxx
Copy link
Contributor

@Amxx Amxx commented Sep 13, 2019

Signed-off-by: Hadrien Croubois [email protected]

bytes32 _requesterID,
bytes memory _workOrderRequest,
address _verifier,
bytes32 _salt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_verifier and _salt is not mentioned in EEA spec in section 6.2.1 Submitting a New Work Order. Could you add function comment with the details of parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a PR on the specs that explains that

Copy link
Contributor

@manojgop manojgop Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you share the link of the PR for reference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't access this link. Seems it's a private repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, adding "salt" here is for the uniqueness

Copy link
Contributor

@reckeyzhang reckeyzhang Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to request eea admin to get the access, I think Eugene can help you on that

Copy link
Contributor

@manojgop manojgop Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll check with @EugeneYYY . Existing spec has workOrderId as input parameter in workOrderSubmit function. So was workOrderId used for uniqueness instead of salt ?

function workOrderSubmit( bytes32 workOrderId, bytes32 workerId, bytes32 requesterId, string workOrderRequest) public returns uint32 errorCode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR removes workOrderId has an input parameter. It is not clearly defined how this should be computed beforehand and it causes issues: what if the value provided is already used ? How to prevent race conditions ?

The solution (which is the PR) is for the requester to provide the parameters (and a random salt). The contract will then generate the workOrderId itself, which is very unlikely to collide.

Without the salt a colision would happen if a requester asks the same computation twice (same parameters) ... if we add a random salt generated on the requester's side we remove this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have a secret spec? Why cannot the spec be publicly accessible?

wo.requesterID = _requesterID;
wo.request = _workOrderRequest;
wo.verifier = _verifier;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we persist the new workOrder in storage using m_workorders[workOrderID] = wo;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is already what's happening. Look at line 80!
I'm using storage, not memory so all changes to wo are 'saved'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

@manojgop manojgop Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workOrderId is calculated inside this function. Section 6.2.1 in EEA spec mentions workOrderId as an input parameter for workOrderSubmit function
function workOrderSubmit( bytes32 workOrderId, bytes32 workerId, bytes32 requesterId, string workOrderRequest) public returns uint32 errorCode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my reply above about: workerorder should not be an input but produced by the smartcontract (need to avoid colisions)

emit workOrderSubmitted(
workOrderID,
_workerID,
_requesterID);
Copy link
Contributor

@manojgop manojgop Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there are changes made to spec. Publicly released spec mentions workOrderNew event is emitted by workOrderSubmit .
event workOrderNew (bytes32 indexed workOrderId, bytes32 indexed workerId, bytes32 indexed requesterId, string workOrderRequest, uint32 errorCode, address senderAddress, byte4 version)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, part of the spec change was about improving name consistency

{
uint256 constant public TIMEOUT = 1 days;

enum WorkOrderStatus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work order status has pending and processing as per the spec -https://entethalliance.github.io/trusted-computing/spec.html#work-order-status-payload
Where are those status are captured?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These status assume a communication/report from the worker. This is part of the direct model but not in the proxy model. Smart contracts only know about the current state of "consensus" and the next step it expects. Smart contracts cannot say anything about any ongoing work.


event workOrderTimedout(
bytes32 indexed workOrderID);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EEA spec talk about 4 events for work order. 1. New Work Order Event 2. Work Order Done Event 3. Encryption Key Set Event 4. Encryption Key Start Event. Please use same name as in spec eg. newWorkOrderEvent, workOrderDoneEvnet, etc
Are you planning to add encryption ket set and encryption key start event?

_requesterID,
_workOrderRequest,
_verifier,
_salt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments about salt parameter description.

return 0;
}

function workOrderTimeout(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the description about this function. This function is not there in EEA spec.

WorkOrder storage wo = m_workorders[_workOrderID];
return (
wo.status,
wo.timestamp,
Copy link
Contributor

@Ram-srini Ram-srini Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add description about timestamp and verifier parameters in the function comments.

mapping(bytes32 => Worker) private m_workers;

// workerType → organizationId → appTypeId → WorkerID[]
mapping(uint256 => mapping(bytes32 => mapping(bytes32 => bytes32[]))) m_workersDB;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this complex map structure? Can't we use one in simple map as it line 39?
Does it for lookup optimization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what key-value do you propose and how would you maintain it?

uint256 newLookupTag,
bytes32[] memory ids
) {
bytes32[] storage matchs = m_workersDB[workerType][organizationId][appTypeId];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Worker must match all input parameters (AND mode) to be included in the list and All input parameters are optional and can be provided in any combination to select Workers. Does it covers all the conditions of lookup function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what to tell you but to read the code. Also, optional input parameters are not a thing in solidity, so you need to be creative about it (cf line 64 to 78).


pragma solidity ^0.5.0;

contract IERC1271
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the description of IERC1271 in the comments.


pragma solidity ^0.5.0;

contract IERC734
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add description about IERC734 in comments.


pragma solidity ^0.5.0;

library Set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is Set solidity module being used?

// WorkerID → Worker
mapping(bytes32 => Worker) private m_workers;

// workerType → organizationId → appTypeId → WorkerID[]
Copy link
Contributor

@danintel danintel Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/appTypeId/appTypeIds/

(I see no appTypeId here, only appTypeIds)

uint256 public constant MANAGEMENT_KEY = 1;
// 2: ACTION keys, which perform actions in this identities name (signing, logins, transactions, etc.)
uint256 public constant ACTION_KEY = 2;
// 3: CLAIM signer keys, used to sign claims on other identities which need to be revokable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/revokable/revocable/

@danintel
Copy link
Contributor

danintel commented Oct 8, 2019

Apparently this PR was abondonded and a new PR filed, PR #123

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants