Notification-based block pinning (#13157)

* Worker

* Reorganize and unpin onnotification drop

* Pin in state-db, pass block number

* Pin blocks in blockchain db

* Switch to reference counted LRU

* Disable pinning when we keep all blocks

* Fix pinning hint for state-db

* Remove pinning from backend layer

* Improve readability

* Add justifications to test

* Fix justification behaviour

* Remove debug prints

* Convert channels to tracing_unbounded

* Add comments to the test

* Documentation and Cleanup

* Move task start to client

* Simplify cache

* Improve test, remove unwanted log

* Add tracing logs, remove expect for block number

* Cleanup

* Add conversion method for unpin handle to Finalitynotification

* Revert unwanted changes

* Improve naming

* Make clippy happy

* Fix docs

Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>

* Use `NumberFor` instead of u64 in API

* Hand over weak reference to unpin worker task

* Unwanted

* &Hash -> Hash

* Remove number from interface, rename `_unpin_handle`, LOG_TARGET

* Move RwLock one layer up

* Apply code style suggestions

* Improve comments

* Replace lru crate by schnellru

* Only insert values for pinned items + better docs

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

* Improve comments, log target and test

Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Sebastian Kunert
2023-01-19 16:13:16 +01:00
committed by GitHub
parent 7a1958ca4e
commit 9be655701a
11 changed files with 962 additions and 107 deletions
+41 -11
View File
@@ -137,6 +137,18 @@ dependencies = [
"version_check",
]
[[package]]
name = "ahash"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107"
dependencies = [
"cfg-if",
"getrandom 0.2.8",
"once_cell",
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.20"
@@ -1836,7 +1848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6"
dependencies = [
"curve25519-dalek 3.2.0",
"hashbrown",
"hashbrown 0.12.3",
"hex",
"rand_core 0.6.4",
"sha2 0.9.9",
@@ -2806,9 +2818,15 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash",
"ahash 0.7.6",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
[[package]]
name = "heck"
version = "0.4.0"
@@ -3122,7 +3140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [
"autocfg",
"hashbrown",
"hashbrown 0.12.3",
"serde",
]
@@ -4172,7 +4190,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909"
dependencies = [
"hashbrown",
"hashbrown 0.12.3",
]
[[package]]
@@ -4310,7 +4328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66"
dependencies = [
"hash-db",
"hashbrown",
"hashbrown 0.12.3",
]
[[package]]
@@ -5085,7 +5103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
dependencies = [
"crc32fast",
"hashbrown",
"hashbrown 0.12.3",
"indexmap",
"memchr",
]
@@ -7991,6 +8009,7 @@ dependencies = [
"rand 0.8.5",
"sc-client-api",
"sc-state-db",
"schnellru",
"sp-arithmetic",
"sp-blockchain",
"sp-core",
@@ -8334,7 +8353,7 @@ dependencies = [
name = "sc-finality-grandpa"
version = "0.10.0-dev"
dependencies = [
"ahash",
"ahash 0.7.6",
"array-bytes",
"assert_matches",
"async-trait",
@@ -8534,7 +8553,7 @@ dependencies = [
name = "sc-network-gossip"
version = "0.10.0-dev"
dependencies = [
"ahash",
"ahash 0.7.6",
"futures",
"futures-timer",
"libp2p",
@@ -9132,6 +9151,17 @@ dependencies = [
"windows-sys 0.36.1",
]
[[package]]
name = "schnellru"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d"
dependencies = [
"ahash 0.8.2",
"cfg-if",
"hashbrown 0.13.2",
]
[[package]]
name = "schnorrkel"
version = "0.9.1"
@@ -10275,11 +10305,11 @@ dependencies = [
name = "sp-trie"
version = "7.0.0"
dependencies = [
"ahash",
"ahash 0.7.6",
"array-bytes",
"criterion",
"hash-db",
"hashbrown",
"hashbrown 0.12.3",
"lazy_static",
"lru",
"memory-db",
@@ -11279,7 +11309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908"
dependencies = [
"hash-db",
"hashbrown",
"hashbrown 0.12.3",
"log",
"rustc-hex",
"smallvec",