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>
This commit is contained in:
Alexander Theißen
2020-06-23 11:17:53 +02:00
committed by GitHub
parent 6aa8965f33
commit bb2df2122e
16 changed files with 1383 additions and 532 deletions
+20 -8
View File
@@ -819,7 +819,7 @@ dependencies = [
"clap",
"criterion-plot 0.3.1",
"csv",
"itertools",
"itertools 0.8.2",
"lazy_static",
"libc",
"num-traits 0.2.11",
@@ -846,7 +846,7 @@ dependencies = [
"clap",
"criterion-plot 0.4.1",
"csv",
"itertools",
"itertools 0.8.2",
"lazy_static",
"num-traits 0.2.11",
"oorandom",
@@ -868,7 +868,7 @@ checksum = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e"
dependencies = [
"byteorder",
"cast",
"itertools",
"itertools 0.8.2",
]
[[package]]
@@ -878,7 +878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545"
dependencies = [
"cast",
"itertools",
"itertools 0.8.2",
]
[[package]]
@@ -2294,6 +2294,15 @@ dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "0.4.5"
@@ -5186,7 +5195,7 @@ checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26"
dependencies = [
"bytes 0.5.4",
"heck",
"itertools",
"itertools 0.8.2",
"log",
"multimap",
"petgraph",
@@ -5203,7 +5212,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72"
dependencies = [
"anyhow",
"itertools",
"itertools 0.8.2",
"proc-macro2",
"quote 1.0.6",
"syn 1.0.17",
@@ -7828,11 +7837,14 @@ version = "0.8.0-rc3"
dependencies = [
"hash-db",
"hex-literal",
"itertools 0.9.0",
"log",
"num-traits 0.2.11",
"parity-scale-codec",
"parking_lot 0.10.2",
"pretty_assertions",
"rand 0.7.3",
"smallvec 1.4.0",
"sp-core",
"sp-externalities",
"sp-panic-handler",
@@ -8072,7 +8084,7 @@ dependencies = [
"hex",
"hex-literal",
"hyper 0.12.35",
"itertools",
"itertools 0.8.2",
"jsonrpc-core-client",
"libp2p",
"node-primitives",
@@ -8301,7 +8313,7 @@ dependencies = [
"build-helper",
"cargo_metadata",
"fs2",
"itertools",
"itertools 0.8.2",
"tempfile",
"toml",
"walkdir",