Skip to content

24/Service registry#28

Draft
tahpot wants to merge 23 commits into
developfrom
feature/24-service-registry
Draft

24/Service registry#28
tahpot wants to merge 23 commits into
developfrom
feature/24-service-registry

Conversation

@tahpot
Copy link
Copy Markdown
Member

@tahpot tahpot commented May 15, 2022

Closes #24 .

Initial MVP of service registry.

ITStar10 and others added 4 commits May 9, 2022 14:57
Remaining:
	node-test/getlogs_*.js
BytesLib.sol
	Removed unnecessary functions
VeridaDIDRegistry.sol
	Update function modifiers from 'public' to 'external'
@tahpot tahpot added the enhancement New feature or request label May 15, 2022
@tahpot tahpot requested a review from pranavburnwal May 15, 2022 07:21
@tahpot tahpot marked this pull request as draft May 15, 2022 07:31
@tahpot tahpot requested a review from ITStar10 May 15, 2022 07:31
@BlockchainCrazy95 BlockchainCrazy95 marked this pull request as ready for review May 18, 2022 23:22
- Add comments in the body of functions
- Add discoverService() function
@BlockchainCrazy95 BlockchainCrazy95 force-pushed the feature/24-service-registry branch from 6830a7a to 326e631 Compare May 19, 2022 08:38
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol
bool isRegistered = registeredIds[identity].contains(serviceId);
require(!isRegistered, "Service has already registered!");
registeredIds[identity].add(serviceId);
AccountInfo storage _account = accountInfos[identity];
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

First check the account exists?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yes

Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/test/index.ts Outdated
Comment thread VDA-Service-Registry/test/index.ts Outdated
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/.env.example
@pranavburnwal
Copy link
Copy Markdown
Contributor

pranavburnwal commented May 23, 2022

@BlockchainCrazy95 The comments are not quite in good order, can you please format function comments in this way.

/**
 * @dev Returns x raised to the n-th power.
 *
 * @param {number} x The number to raise.
 * @param {number} n The power, must be a natural number.
 * @return {number} x raised to the n-th power.
 */
function pow(x, n) {
  ...
}

Refer to this if you need some more understanding: https://javascript.info/comments
Ref: https://en.wikipedia.org/wiki/JSDoc

Comment thread VDA-Service-Registry/scripts/deploy.ts Outdated

const tokenFactory = await ethers.getContractFactory("MockVDA");
const tokenContract = await tokenFactory.deploy();
await tokenContract.deployed();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a condition that this doesn't deploy the same(VDA) in mainnet (ETH or MATIC)

Also, add the part that we can feed in the 'actual' VDA token address for mainnet launches.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure what you mean. Can you kindly explain more about it?
It's a sample token for test. I won't deploy the Verida Token.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Testnet and mainnet deployment.

Comment thread VDA-Service-Registry/test/index.ts
Comment thread VDA-Service-Registry/test/index.ts
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
@pranavburnwal
Copy link
Copy Markdown
Contributor

Have one test case failing @ITStar10

image

@BlockchainCrazy95
Copy link
Copy Markdown

BlockchainCrazy95 commented May 24, 2022

Slither

Run slither and it showed below issues.

There were two high level severity issues and fixed.

  • ServiceRegistry._addCredit(address,uint256,address) ignores return value by vdaToken.transferFrom(sender,address(this), numCredit)
  • ServiceRegistry._removeCredit(address,uint256,address) ignores return value by vdaToken.transfer(sender,numCredit)

@BlockchainCrazy95
Copy link
Copy Markdown

BlockchainCrazy95 commented May 24, 2022

Mythril

No issues were detected.

BlockchainCrazy95 and others added 4 commits May 25, 2022 10:29
Update public methods to external
Added comment in NatSpec
Updated configuration : using .env
@BlockchainCrazy95
Copy link
Copy Markdown

Have one test case failing @ITStar10

image

Please kindly explain about how the process of updating service will work. In case of decreasing the maxAccounts.

Remaining:
	node-test/getlogs_*.js
ITStar10 and others added 6 commits May 27, 2022 20:44
BytesLib.sol
	Removed unnecessary functions
VeridaDIDRegistry.sol
	Update function modifiers from 'public' to 'external'
Added comment in NatSpec
Updated configuration : using .env
- Add comments in the body of functions
- Add discoverService() function
struct AccountInfo {
address identity;
uint256 creditAmount;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need AccountInfo.

/**
* did => AccountInfo
*/
mapping (address => AccountInfo) accountInfos;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to use AccountInfo struct.

uint256 maxAccounts,
uint256 pricePerAccount,
bytes calldata signature
) public onlyVerifiedSignature(identity, signature) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Need to check out status of service.

address identity,
bytes32 serviceId,
bytes calldata signature
) external onlyVerifiedSignature(identity, signature) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Need to check service status.

Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Copy link
Copy Markdown
Collaborator

@ITStar10 ITStar10 left a comment

Choose a reason for hiding this comment

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

  • Need updates for credit. Or it can be resolved while implementing treasury.
  • Need service status check in functions

Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Comment thread VDA-Service-Registry/contracts/ServiceRegistry.sol Outdated
Copy link
Copy Markdown
Collaborator

@ITStar10 ITStar10 left a comment

Choose a reason for hiding this comment

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

  • Consolidate unnecessary functions.
  • Remove unnecessary checks on token transfer.

@tahpot tahpot marked this pull request as draft June 13, 2022 01:53
ITStar10 added 2 commits June 21, 2022 16:30
Remaining:
	CheckServiceAvailability for user
	User disconnect problem
	And other stuffs
…chain-contracts into feature/24-service-registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement service registry contract

5 participants