{"action":"created","issue":{"url":"https://api.github.com/repos/paritytech/parity-common/issues/182","repository_url":"https://api.github.com/repos/paritytech/parity-common","labels_url":"https://api.github.com/repos/paritytech/parity-common/issues/182/labels{/name}","comments_url":"https://api.github.com/repos/paritytech/parity-common/issues/182/comments","events_url":"https://api.github.com/repos/paritytech/parity-common/issues/182/events","html_url":"https://github.com/paritytech/parity-common/issues/182","id":460597602,"node_id":"MDU6SXNzdWU0NjA1OTc2MDI=","number":182,"title":"Add an implementation of kvdb on top of IndexedDB","user":{"login":"tomaka","id":1412254,"node_id":"MDQ6VXNlcjE0MTIyNTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1412254?v=4","gravatar_id":"","url":"https://api.github.com/users/tomaka","html_url":"https://github.com/tomaka","followers_url":"https://api.github.com/users/tomaka/followers","following_url":"https://api.github.com/users/tomaka/following{/other_user}","gists_url":"https://api.github.com/users/tomaka/gists{/gist_id}","starred_url":"https://api.github.com/users/tomaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomaka/subscriptions","organizations_url":"https://api.github.com/users/tomaka/orgs","repos_url":"https://api.github.com/users/tomaka/repos","events_url":"https://api.github.com/users/tomaka/events{/privacy}","received_events_url":"https://api.github.com/users/tomaka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ordian","id":4211399,"node_id":"MDQ6VXNlcjQyMTEzOTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4211399?v=4","gravatar_id":"","url":"https://api.github.com/users/ordian","html_url":"https://github.com/ordian","followers_url":"https://api.github.com/users/ordian/followers","following_url":"https://api.github.com/users/ordian/following{/other_user}","gists_url":"https://api.github.com/users/ordian/gists{/gist_id}","starred_url":"https://api.github.com/users/ordian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ordian/subscriptions","organizations_url":"https://api.github.com/users/ordian/orgs","repos_url":"https://api.github.com/users/ordian/repos","events_url":"https://api.github.com/users/ordian/events{/privacy}","received_events_url":"https://api.github.com/users/ordian/received_events","type":"User","site_admin":false},"assignees":[{"login":"ordian","id":4211399,"node_id":"MDQ6VXNlcjQyMTEzOTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4211399?v=4","gravatar_id":"","url":"https://api.github.com/users/ordian","html_url":"https://github.com/ordian","followers_url":"https://api.github.com/users/ordian/followers","following_url":"https://api.github.com/users/ordian/following{/other_user}","gists_url":"https://api.github.com/users/ordian/gists{/gist_id}","starred_url":"https://api.github.com/users/ordian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ordian/subscriptions","organizations_url":"https://api.github.com/users/ordian/orgs","repos_url":"https://api.github.com/users/ordian/repos","events_url":"https://api.github.com/users/ordian/events{/privacy}","received_events_url":"https://api.github.com/users/ordian/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2019-06-25T19:22:45Z","updated_at":"2019-08-02T13:28:09Z","closed_at":null,"author_association":"MEMBER","body":"Add an implementation of the `kvdb` traits on top of the Web IndexedDB API: https://developer.mozilla.org/fr/docs/Web/API/API_IndexedDB\r\n\r\nThe bindings to IndexedDB are already present in the `web_sys` crate (https://docs.rs/web-sys/0.3.24/web_sys/struct.IdbFactory.html?search=Idb), and we should use this crate to access IndexedDB.\r\n\r\nThe use-case for this is running Substrate (or parity-ethereum?) from within a browser.\r\n\r\nI'm personally not very familiar with neither `kvdb` nor IndexedDB, so there might or might not be problems that I can't think of.\r\n"},"comment":{"url":"https://api.github.com/repos/paritytech/parity-common/issues/comments/517700656","html_url":"https://github.com/paritytech/parity-common/issues/182#issuecomment-517700656","issue_url":"https://api.github.com/repos/paritytech/parity-common/issues/182","id":517700656,"node_id":"MDEyOklzc3VlQ29tbWVudDUxNzcwMDY1Ng==","user":{"login":"ordian","id":4211399,"node_id":"MDQ6VXNlcjQyMTEzOTk=","avatar_url":"https://avatars1.githubusercontent.com/u/4211399?v=4","gravatar_id":"","url":"https://api.github.com/users/ordian","html_url":"https://github.com/ordian","followers_url":"https://api.github.com/users/ordian/followers","following_url":"https://api.github.com/users/ordian/following{/other_user}","gists_url":"https://api.github.com/users/ordian/gists{/gist_id}","starred_url":"https://api.github.com/users/ordian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ordian/subscriptions","organizations_url":"https://api.github.com/users/ordian/orgs","repos_url":"https://api.github.com/users/ordian/repos","events_url":"https://api.github.com/users/ordian/events{/privacy}","received_events_url":"https://api.github.com/users/ordian/received_events","type":"User","site_admin":false},"created_at":"2019-08-02T13:28:09Z","updated_at":"2019-08-02T13:28:09Z","author_association":"MEMBER","body":"While trying to make this work, I've encountered a bunch of issues:\r\n\r\n#### Some problems of localStorage:\r\n- The API allows you to use only JS string (UTF-16) as keys and values\r\n- It usually has a limit of 10MB (https://arty.name/localstorage.html)\r\n- localStorage API is not available in WebWorkers, meaning it's not possible to save a serialized version in a background thread.\r\n\r\n#### IndexDB API is not ready yet\r\n- one can access low-level API via `web_sys`, but it's really ugly \r\n- Hopefully this will be resolved by https://github.com/rustwasm/gloo/issues/68\r\n\r\nI'm not sure what is the expected size of of the substrate light client db, but we could implement it with localStorage first and migrate to IndexDB  later (I imagine having an in-memory hashmap in both cases, reading the whole db into the memory on startup and writing async in case of indexdb).\r\n\r\n#### wasm-bindgen limitations\r\n- it doesn't (and probably won't) support lifetimes in returned values (https://github.com/rustwasm/wasm-bindgen/issues/423) (we have `iter` and `iter_from_prefix` methods on `KeyValueDB`)\r\n- only supports c-style enums (we have a rusty enum `DBOp` in kvdb)\r\n- [minor] wasm-bindgen provides a proc macro to generate all the js shims, which means it can't be used as an optional dependency on kvdb due to https://github.com/rust-lang/rust/issues/29642, unless I'm missing something?\r\n\r\nThis means that kvdb `KeyValueDB` interface would need some breaking changes. Alternatively, we could create another (async?) interface just for the browser use-case."}}
{"actor":{"display_login":"ordian"}}