Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a batch of dids? #210

Closed
thomas-tran opened this issue Jun 23, 2021 · 9 comments
Closed

How to create a batch of dids? #210

thomas-tran opened this issue Jun 23, 2021 · 9 comments

Comments

@thomas-tran
Copy link

In your Q & A section,
Each newly created ID will pay a transaction fee?
With ION can fit 10,000 ID operations in a single bitcoin transaction.

Can you explain more detail on this? Assume that the company requires to create 1000 DIDs for IOT devices. Does it cost only a single bitcoin transaction or 1000 transactions? How can I do create them in a batch?

Thanks

@henkvancann
Copy link
Contributor

henkvancann commented Jun 23, 2021

To create 1000 DIDs for IOT devices, you wouldn't need 1000 BTC transactions, but only a fraction. Furthermore costs can be shared among many users. e.g. ION is able to bundle thousands of pluriform identifier events in a Merkletree-like structure and only the root hash will be anchored on the bitcoin blockchain. In your specific question, it depends whether you're able to batch the inception events of the IoT identifiers or not. A batch of 1000 identifiers requires 1 BTC transaction and there's even more room in that ION batch. 1000 consecutive inception events over of period of time, could require 1000 BTC transactions, but of course a single identifier event in one anchoring ION BTC transaction should not have to pay for the total fee. The fee can be shared and divided by the number of participating controllers in that specific ION anchoring BTC transaction.

How can I do create them in a batch? -> Use a Sidetree based solution like ION or ORB. A more detailed answer on the exact technical approach to batch them in either environment should come from another community member, I don't have that knowledge.

@thomas-tran
Copy link
Author

@henkvancann Thanks for the explanation.
@csuwildcat Do you have any idea how to batch the request for thousand of identities in ION technically?

@csuwildcat
Copy link
Member

@thomas-tran pretty sure the node already ships set to batch requests, so if you wanted to batch then write, you'd use the API to send your running node N number of ops, then it will batch them up for you and anchor them (assuming you attach a funded wallet that can do txns). There's one big caveat: anchoring thousand of ION ops is going to require you to have enough in the wallet to lock an escrow-like proof of fee, which uses a relative timelock that will freeze a large amount of Bitcoin for roughly 30 days. It's a form of spam protection for the network. You can so 100 ops in a Bitcoin txn without any proof of fee value lock. @thehenrytsai please confirm

@csuwildcat
Copy link
Member

@thomas-tran this doc explains the value locking proof of fee requirement the nodes all enforce: https://github.com/decentralized-identity/ion/blob/master/docs/design.md#value-locking-algorithm

@thomas-tran
Copy link
Author

thomas-tran commented Jun 24, 2021

@thomas-tran pretty sure the node already ships set to batch requests, so if you wanted to batch then write, you'd use the API to send your running node N number of ops, then it will batch them up for you and anchor them (assuming you attach a funded wallet that can do txns). There's one big caveat: anchoring thousand of ION ops is going to require you to have enough in the wallet to lock an escrow-like proof of fee, which uses a relative timelock that will freeze a large amount of Bitcoin for roughly 30 days. It's a form of spam protection for the network. You can so 100 ops in a Bitcoin txn without any proof of fee value lock. @thehenrytsai please confirm

@csuwildcat can you point me to the right API or source code that allow to batch no of create operations e.g. I need to create 100 dids at once.

I've checked the source code and I found this information. However, I assume that this only handle 1 did create request at the time.

https://github.com/decentralized-identity/ion/blob/master/src/core.ts
const router = new Router();
router.post('/operations', async (ctx, _next) => {
const response = await sidetreeCore.handleOperationRequest(ctx.body);
setKoaResponse(response, ctx.response);
});

@thehenrytsai
Copy link
Collaborator

@thomas-tran, assuming you are running your own node, you simply need to submit 100 create operations to your node (ie. http://localhost:3000/operations) before your batch writer kicks in every 10 minutes by default, the batch writer will batch all 100 operations into 1 bitcoin transaction thus you'll pay fee for just one transaction to the minor.

The technical spec for constructing a create request can be found in Sidetree API spec, but if you know TypeScript, you are better off using the ion-sdk directly, it will save you a lot of time.

@thomas-tran
Copy link
Author

@thehenrytsai Thanks for the explanation. Where is the configuration to change batch writer waiting time in the node?

@thehenrytsai
Copy link
Collaborator

Assuming you are running against mainnet using the setup guide:

mainnet-core-config.json -> batchingIntervalInSeconds

@thomas-tran
Copy link
Author

Thank you @thehenrytsai @csuwildcat

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

No branches or pull requests

4 participants