-
Notifications
You must be signed in to change notification settings - Fork 694
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
Offchain DB should be fork aware #1125
Comments
https://github.com/paritytech/substrate/blob/6e740bc89d097a38d922d5619b55e0c7e8664a6c/primitives/core/src/offchain/mod.rs#L75 is a placeholder for it (I did implement that in the past but code/design was too complex or just bad :) Today, if I wanted a quick implementation, I would just reuse the current merkelized state code (bad perf), to do properly I would probably target primary support at parity-db level (not trivial but related to a design I got in mind for faster state storage and no rocksdb support). |
I don't think we need all the complexity of state db. Unlike state db, the data from offchain db doesn't have to keep state-per-block. I see it as single offchain global state. For example say wdyt? |
yes you can have a offchain worker db that is synched with the head of the chain and do not allow querying historical states. |
I don't think it will, not as is at least. state-db was designed to manages trie node references, and to make sure the node is removed from the db when all states that reference it are discarded (because of re-orgs or pruning). It assumes that values are preimages. I.e. two different blocks can't insert different value (trie node) under the same key. |
Indeed. That 's quite some impl then (similar to ethereum state snapshot). |
One issue with maintaining a "global canonical" offchain DB state is that it needs to be synced with the canonical blockchain state. You don't want a race condition when the offchain DB view is updated a bit after the main DB imports or reorgs to a new block. |
No longer a priority (or maybe even necessary - no sure if should close). In MMR we fixed it through paritytech/substrate#11594 |
closing this as not planned/required.. |
252df12a5a4 Adds runtime tests (#1114) 3b17d2a89d2 Refactoring Inbound fixture (paritytech#1125) git-subtree-dir: bridges/snowbridge git-subtree-split: 252df12a5a451a03df6fefeec44ac60ea9c7cb0b
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
…itytech#1125) * add some missing tests to encode_call * fix tests
* add some missing tests to encode_call * fix tests
Pallets that are using data in offchain DB saved with keys derived from block numbers end up with data collisions caused by forks.
Working around this issue by using keys derived from fork-unique properties like block hashes can easily lead to complicated user-facing APIs. Example of such issue is the case of
pallet-mmr
.The best future-looking solution would be to enhance the offchain DB to handle forks transparently. That way all pallets potentially facing this issue don't have to worry about it.
The proposal is to enhance the Indexing API with fork-specific overlays that get committed to permanent DB on finality. On finality. non-canonical overlays get pruned/discarded.
The text was updated successfully, but these errors were encountered: