dashpay / platform

L2 solution for seriously fast decentralized applications for the Dash network
https://dashplatform.readme.io/docs/introduction-what-is-dash-platform
MIT License
67 stars 40 forks source link

Cache wallet data during core chain sync #119

Closed thephez closed 5 days ago

thephez commented 3 years ago

When using the SDK with a mnemonic, cache wallet account information so it is accessible immediately the next time the wallet account is used.

Expected Behavior

After initial sync for a particular wallet (mnemonic), future syncs would generally use locally cached data rather than syncing the entire chain again.

Current Behavior

Currently, the libraries underlying the SDK don't provide an option to cache wallet info locally so the entire core chain has to be synced when things like getWalletAccount() are run. This is problematic as it can take 5+ minutes on testnet.

Possible Solution

Get wallet-lib's persistence adapter working in conjunction with the SDK and other libraries (dapi-client?)

Alternatives Considered

Open to suggestions :slightly_smiling_face:

Additional Context

Many of the Readme portal tutorials take 5+ minutes to run on testnet due to syncing the chain on each run (e.g. https://dashplatform.readme.io/docs/tutorial-register-an-identity).

Opening this issue for tracking purposes

monachilada commented 3 years ago

This also occurs when broadcasting any changes to documents within a contract. Is that also expected?

thephez commented 3 years ago

This also occurs when broadcasting any changes to documents within a contract. Is that also expected?

Yes, all changes are signed by the identity's private key. The broadcast logic includes getWalletAccount() as part of that process.

monachilada commented 3 years ago

Right, I guess that makes sense. What I'm wondering is how this might effect usage in the browser? Even if the SDK is patched to cache the results after the first fetch, will it not still be a hard requirement to synchronise at least once before any transactions can be broadcast, wallet operations made etc? And if so, will this problem not compound even further on main net? Am I simply wrong in assuming the SDK should also be useable directly in the browser without requiring a server in the background?

Aside: I've seen mention of a light client in blog posts and documentation, and I might have just been clumsy in overlooking it, but as yet haven't been able to dig up much on it which I assume is designed for exactly this use case. Is there anything in terms of repos or documentation you could point to that might help shed some light on this for me?

shumkov commented 5 days ago

Storage adapter is implemented