pallet-beefy-mmr: add API for BEEFY Authority Sets (#11406)
* pallet-beefy: add Config::OnNewValidatorSet type
Add a hook to pallet-beefy for doing specific work when
BEEFY validator set changes.
For example, this can be used by pallet-beefy-mmr to cache
a lightweight MMR root over validators and make it available
to light clients.
* pallet-beefy-mmr: implement OnNewValidatorSet
Implement pallet-beefy::OnNewValidatorSet to be notified of BEEFY
validator set changes. Use the notifications to compute and cache
a light weight 'BEEFY authority set' which is an MMR root over
BEEFY validator set plus some extra info.
Previously, pallet-beefy-mmr was interogating pallet-beefy about
validator set id on every block to find out when it needs to recompute
the authority set.
By using the event-driven approach in this commit, we also save one
extra state interogation per block.
* pallet-beefy-mmr: add new authority_set() API
Expose current and next BEEFY authority sets through runtime API.
These can be directly used by light clients to avoid having them
compute them themselves based on BEEFY validator sets.
Signed-off-by:
acatangiu <adrian@parity.io>
* rename BeefyMmr exposed runtime api
Showing
- substrate/Cargo.lock 3 additions, 0 deletionssubstrate/Cargo.lock
- substrate/frame/beefy-mmr/primitives/Cargo.toml 7 additions, 1 deletionsubstrate/frame/beefy-mmr/primitives/Cargo.toml
- substrate/frame/beefy-mmr/primitives/src/lib.rs 17 additions, 0 deletionssubstrate/frame/beefy-mmr/primitives/src/lib.rs
- substrate/frame/beefy-mmr/src/lib.rs 48 additions, 19 deletionssubstrate/frame/beefy-mmr/src/lib.rs
- substrate/frame/beefy-mmr/src/mock.rs 1 addition, 0 deletionssubstrate/frame/beefy-mmr/src/mock.rs
- substrate/frame/beefy-mmr/src/tests.rs 50 additions, 0 deletionssubstrate/frame/beefy-mmr/src/tests.rs
- substrate/frame/beefy/src/lib.rs 41 additions, 10 deletionssubstrate/frame/beefy/src/lib.rs
- substrate/frame/beefy/src/mock.rs 1 addition, 0 deletionssubstrate/frame/beefy/src/mock.rs
- substrate/primitives/beefy/src/lib.rs 14 additions, 0 deletionssubstrate/primitives/beefy/src/lib.rs
- substrate/primitives/beefy/src/mmr.rs 8 additions, 5 deletionssubstrate/primitives/beefy/src/mmr.rs
- substrate/test-utils/runtime/Cargo.toml 2 additions, 0 deletionssubstrate/test-utils/runtime/Cargo.toml
- substrate/test-utils/runtime/src/lib.rs 10 additions, 0 deletionssubstrate/test-utils/runtime/src/lib.rs
Please register or sign in to comment