Skip to content

Commit 411d9bb

Browse files
acatangiutomusdrw
andauthored
Implement Lean BEEFY (paritytech#10882)
Simplified BEEFY worker logic based on the invariant that GRANDPA will always finalize 1st block of each new session, meaning BEEFY worker is guaranteed to receive finality notification for the BEEFY mandatory blocks. Under these conditions the current design is as follows: - session changes are detected based on BEEFY Digest present in BEEFY mandatory blocks, - on each new session new `Rounds` of voting is created, with old rounds being dropped (for gossip rounds, last 3 are still alive so votes are still being gossiped), - after processing finality for a block, the worker votes if a new voting target has become available as a result of said block finality processing, - incoming votes as well as self-created votes are processed and signed commitments are created for completed BEEFY voting rounds, - the worker votes if a new voting target becomes available once a round successfully completes. On worker startup, the current validator set is retrieved from the BEEFY pallet. If it is the genesis validator set, worker starts voting right away considering Block #1 as session start. Otherwise (not genesis), the worker will vote starting with mandatory block of the next session. Later on when we add the BEEFY initial-sync (catch-up) logic, the worker will sync all past mandatory blocks Signed Commitments and will be able to start voting right away. BEEFY mandatory block is the block with header containing the BEEFY `AuthoritiesChange` Digest, this block is guaranteed to be finalized by GRANDPA. This session-boundary block is signed by the ending-session's validator set. Next blocks will be signed by the new session's validator set. This behavior is consistent with what GRANDPA does as well. Also drop the limit N on active gossip rounds. In an adversarial network, a bad actor could create and gossip N invalid votes with round numbers larger than the current correct round number. This would lead to votes for correct rounds to no longer be gossiped. Add unit-tests for all components, including full voter consensus tests. Signed-off-by: Adrian Catangiu <[email protected]> Co-authored-by: Tomasz Drwięga <[email protected]> Co-authored-by: David Salami <Wizdave97>
1 parent 318dea3 commit 411d9bb

File tree

12 files changed

+1815
-568
lines changed

12 files changed

+1815
-568
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/beefy/Cargo.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ description = "BEEFY Client gadget for substrate"
1010
[dependencies]
1111
fnv = "1.0.6"
1212
futures = "0.3"
13+
futures-timer = "3.0.1"
1314
hex = "0.4.2"
1415
log = "0.4"
1516
parking_lot = "0.12.0"
@@ -23,22 +24,31 @@ sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
2324
sp-application-crypto = { version = "6.0.0", path = "../../primitives/application-crypto" }
2425
sp-arithmetic = { version = "5.0.0", path = "../../primitives/arithmetic" }
2526
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
27+
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
2628
sp-core = { version = "6.0.0", path = "../../primitives/core" }
2729
sp-keystore = { version = "0.12.0", path = "../../primitives/keystore" }
2830
sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" }
2931

3032
sc-chain-spec = { version = "4.0.0-dev", path = "../../client/chain-spec" }
31-
sc-utils = { version = "4.0.0-dev", path = "../utils" }
3233
sc-client-api = { version = "4.0.0-dev", path = "../api" }
34+
sc-finality-grandpa = { version = "0.10.0-dev", path = "../../client/finality-grandpa" }
3335
sc-keystore = { version = "4.0.0-dev", path = "../keystore" }
3436
sc-network = { version = "0.10.0-dev", path = "../network" }
3537
sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" }
38+
sc-utils = { version = "4.0.0-dev", path = "../utils" }
3639

3740
beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy" }
3841

3942
[dev-dependencies]
40-
sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
43+
sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
4144
sc-network-test = { version = "0.8.0", path = "../network/test" }
4245

46+
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
47+
sp-keyring = { version = "6.0.0", path = "../../primitives/keyring" }
48+
sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
49+
substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" }
50+
4351
serde = "1.0.136"
4452
strum = { version = "0.23", features = ["derive"] }
53+
tokio = "1.15"
54+
tempfile = "3.1.0"

0 commit comments

Comments
 (0)