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
+4
View File
@@ -8,8 +8,11 @@ repository = "https://github.com/paritytech/substrate"
description = "RPC for the BEEFY Client gadget for substrate"
[dependencies]
derive_more = "0.99"
futures = "0.3.16"
log = "0.4"
parking_lot = "0.11"
thiserror = "1.0"
serde = { version = "1.0.132", features = ["derive"] }
jsonrpc-core = "18.0.0"
@@ -20,6 +23,7 @@ jsonrpc-pubsub = "18.0.0"
codec = { version = "2.2.0", package = "parity-scale-codec", features = ["derive"] }
sc-rpc = { version = "4.0.0-dev", path = "../../rpc" }
sc-utils = { version = "4.0.0-dev", path = "../../utils" }
sp-core = { version = "4.1.0-dev", path = "../../../primitives/core" }
sp-runtime = { version = "4.0.0", path = "../../../primitives/runtime" }