Add BEEFY latestFinalized RPC and deduplicate code between BEEFY and GRANDPA (#10568)

* beefy: add dummy latest_finalized() RPC

* beefy: rpc latest_best_beefy() using shared mem

* beefy: rpc populate latest_best_beefy()

* beefy: rpc handle readiness

* beefy: best block over channel - wip

Not working because channel can't be simply opened and receiver passed
to `rpc_extensions_builder` because `rpc_extensions_builder` has to be
`Fn` and not `FnOnce`... and and Receiver side of mpsc can't be cloned

yay!..

* beefy: make notification channels payload-agnostic

* beefy: use notification mechanism instead of custom channel

* beefy: add tracing key to notif channels

* sc-utils: add notification channel - wip

* beefy: use sc-utils generic notification channel

* grandpa: use sc-utils generic notification channel

* fix grumbles

* beefy-rpc: get best block header instead of number

* beefy-rpc: rename to `beefy_getFinalizedHead`

* fix nitpicks

* client-rpc-notifications: move generic Error from struct to fn

* beefy: use header from notification instead of getting from database

* beefy-rpc: get best block hash instead of header

* beefy-rpc: fix and improve latestHead test

* beefy-rpc: bubble up errors from rpc-handler instantiation

* update lockfile

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* fix errors and warnings

* fix nit

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Adrian Catangiu
2022-01-06 15:43:11 +02:00
committed by GitHub
parent 4ca4df644e
commit fe8d2bc7f4
12 changed files with 447 additions and 193 deletions
+40
View File
@@ -323,6 +323,27 @@ dependencies = [
"trust-dns-resolver",
]
[[package]]
name = "async-stream"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625"
dependencies = [
"async-stream-impl",
"futures-core",
]
[[package]]
name = "async-stream-impl"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "async-task"
version = "4.0.3"
@@ -508,6 +529,7 @@ version = "4.0.0-dev"
dependencies = [
"beefy-gadget",
"beefy-primitives",
"derive_more",
"futures 0.3.16",
"jsonrpc-core",
"jsonrpc-core-client",
@@ -515,12 +537,15 @@ dependencies = [
"jsonrpc-pubsub",
"log 0.4.14",
"parity-scale-codec",
"parking_lot 0.11.2",
"sc-rpc",
"sc-utils",
"serde",
"serde_json",
"sp-core",
"sp-runtime",
"substrate-test-runtime-client",
"thiserror",
]
[[package]]
@@ -8743,7 +8768,9 @@ dependencies = [
"futures 0.3.16",
"futures-timer",
"lazy_static",
"parking_lot 0.11.2",
"prometheus",
"tokio-test",
]
[[package]]
@@ -10745,6 +10772,19 @@ dependencies = [
"tokio-reactor",
]
[[package]]
name = "tokio-test"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53474327ae5e166530d17f2d956afcb4f8a004de581b3cae10f12006bc8163e3"
dependencies = [
"async-stream",
"bytes 1.1.0",
"futures-core",
"tokio",
"tokio-stream",
]
[[package]]
name = "tokio-tls"
version = "0.2.1"