JoinColony / colonySDK

:rocket: Get started with Colony quickly
https://github.com/JoinColony/colonyJS/tree/main/packages/sdk
GNU General Public License v3.0
63 stars 28 forks source link

How best to store multisig data for later use #72

Closed fuguefoundation closed 2 years ago

fuguefoundation commented 5 years ago

Description

In colony-starter-basic, you employ a mock database to temporarily store multisig data such as this.

{"nonce":2,"payload":{"data":"0x6aaf4a7700000000000000000000000000000000000000000000000000000000000000010000000000000000000000005adb2d997aa9d5a6b8b0bae48b38f0c6856dbaab000000000000000000000000000000000000000000000000000000000000000a","inputValues":{"taskId":1,"token":"0x5aDb2D997Aa9D5A6B8B0BAE48B38f0C6856DBAab","amount":"a"},"destinationAddress":"0xEc46E0d7208FF021CDb5B9D47196adb8bbe07a3D","sourceAddress":"0xEc46E0d7208FF021CDb5B9D47196adb8bbe07a3D","value":0},"signers":{}}

// The global database object will act as a mock database where we will store
// our pending multisig operations so that we can restore the operations when
// we need to sign them from another account.
DATABASE = {
  operations: {},
};

What is the best, decentralized way of storing this value in a real project, given that this value will likely not be set at the same time or in the same browser window as when the other person in the multisig would need it? Any examples, docs, or projects you recommend?

ryanchristo commented 5 years ago

This will depend on the stack that the project is built with, which is why we use a mock database in the colonyStarter packages. The mock database in colony-starter-basic only stores data for the duration of the script and colony-starter-react stores data in the browser using local storage.

In the dApp, we store multisignature operations using IPFS via OrbitDB. This provides a decentralized database solution, which we chose to do in the spirit of being fully decentralized. We are polishing off this implementation and plan to share more information soon.

We will keep this issue open until we have documentation that explains this implementation and/or we have created a colonyStarter package that demonstrates how this works.

In the meantime, if you are using Node, a simple approach would be spinning up an Express server that connects to a MongoDB database (or another database of your choosing). If I recall correctly, you also have experience using Google Firebase, which could be another potential solution.

fuguefoundation commented 5 years ago

Thanks @ryanchristo, mostly looking for ideas and best practices. I am currently using (in local development) an Express db backend for the multisig, but that's not going to cut muster as it stands.

Correct me if I'm wrong, and fully recognizing that "it depends", but for this particular piece of a dapp, a decentralized backend is not entirely necessary, since for the multisig to work it will only accept a value already encoded in the blockchain. Thus storing the first multisig value in Firebase or Mongo or some other centralized system, although subject to the various pros/cons of such a solution, would only result in - at worst - the second part of the multisig operation failing if the data were corrupted. Just thinking out loud here, but I'll look into OrbitDB in the meantime.

ryanchristo commented 5 years ago

a decentralized backend is not entirely necessary

Yup, this is true. This is something that we chose to do in the spirit of being fully decentralized.