Implement nested storage transactions (#6269)
* Add transactional storage functionality to OverlayChanges A collection already has a natural None state. No need to wrap it with an option. * Add storage transactions runtime interface * Add frame support for transactions * Fix committed typo * Rename 'changes' variable to 'overlay' * Fix renaming change * Fixed strange line break * Rename clear to clear_where * Add comment regarding delete value on mutation * Add comment which changes are covered by a transaction * Do force the arg to with_transaction return a Result * Use rust doc comments on every documentable place * Fix wording of insert_diry doc * Improve doc on start_transaction * Rename value to overlayed in close_transaction * Inline negation * Improve wording of close_transaction comments * Get rid of an expect by using get_or_insert_with * Remove trailing whitespace * Rename should to expected in tests * Rolling back a transaction must mark the overlay as dirty * Protect client initiated storage tx from being droped by runtime * Review nits * Return Err when entering or exiting runtime fails * Documentation fixup * Remove close type * Move enter/exit runtime to excute_aux in the state-machine * Rename Discard -> Rollback * Move child changeset creation to constructor * Move child spawning into the closure * Apply suggestions from code review Co-authored-by:Bastian Köcher <bkchr@users.noreply.github.com> * Fixup for code suggestion * Unify re-exports * Rename overlay_changes to mod.rs and move into subdir * Change proof wording * Adapt a new test from master to storage-tx * Suggestions from the latest round of review * Fix warning message Co-authored-by:
Bastian Köcher <bkchr@users.noreply.github.com>
Showing
- substrate/Cargo.lock 20 additions, 8 deletionssubstrate/Cargo.lock
- substrate/frame/support/src/storage/mod.rs 27 additions, 0 deletionssubstrate/frame/support/src/storage/mod.rs
- substrate/frame/support/test/tests/storage_transaction.rs 159 additions, 0 deletionssubstrate/frame/support/test/tests/storage_transaction.rs
- substrate/primitives/api/proc-macro/src/impl_runtime_apis.rs 11 additions, 2 deletionssubstrate/primitives/api/proc-macro/src/impl_runtime_apis.rs
- substrate/primitives/externalities/src/lib.rs 23 additions, 0 deletionssubstrate/primitives/externalities/src/lib.rs
- substrate/primitives/io/src/lib.rs 40 additions, 0 deletionssubstrate/primitives/io/src/lib.rs
- substrate/primitives/runtime-interface/test/src/lib.rs 0 additions, 1 deletionsubstrate/primitives/runtime-interface/test/src/lib.rs
- substrate/primitives/state-machine/Cargo.toml 3 additions, 0 deletionssubstrate/primitives/state-machine/Cargo.toml
- substrate/primitives/state-machine/src/basic.rs 12 additions, 0 deletionssubstrate/primitives/state-machine/src/basic.rs
- substrate/primitives/state-machine/src/changes_trie/build.rs 20 additions, 21 deletionssubstrate/primitives/state-machine/src/changes_trie/build.rs
- substrate/primitives/state-machine/src/ext.rs 34 additions, 14 deletionssubstrate/primitives/state-machine/src/ext.rs
- substrate/primitives/state-machine/src/lib.rs 27 additions, 14 deletionssubstrate/primitives/state-machine/src/lib.rs
- substrate/primitives/state-machine/src/overlayed_changes/changeset.rs 752 additions, 0 deletions...imitives/state-machine/src/overlayed_changes/changeset.rs
- substrate/primitives/state-machine/src/overlayed_changes/mod.rs 245 additions, 474 deletions...ate/primitives/state-machine/src/overlayed_changes/mod.rs
- substrate/primitives/state-machine/src/read_only.rs 12 additions, 0 deletionssubstrate/primitives/state-machine/src/read_only.rs
- substrate/primitives/state-machine/src/testing.rs 3 additions, 3 deletionssubstrate/primitives/state-machine/src/testing.rs
Please register or sign in to comment