Refactor Beefy MMR and remove parachain specific implementations (#10664)

* refactor beefy mmr

* use plain vector of bytes for leaf extra

* update comment

* update comments

* remove unused vars

* Use sp_std::vec::Vec

Co-authored-by: Adrian Catangiu <adrian@parity.io>

* make extra data generic

* fix tests

* refactor beefy-mmr

* Update frame/beefy-mmr/src/lib.rs

* minor fix

* fmt

* Update frame/beefy-mmr/src/lib.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
David Salami
2022-04-01 09:50:11 +01:00
committed by GitHub
parent c2d3d488b8
commit 2d3ee74805
4 changed files with 52 additions and 65 deletions
+7 -11
View File
@@ -71,7 +71,7 @@ fn should_contain_mmr_digest() {
assert_eq!(
System::digest().logs,
vec![beefy_log(ConsensusLog::MmrRoot(
hex!("969d516e5279540ef38e4a710fb0645cab4c3b01e528be7285b85ec9c5fb55c8").into()
hex!("fa0275b19b2565089f7e2377ee73b9050e8d53bce108ef722a3251fd9d371d4b").into()
))]
);
@@ -82,13 +82,13 @@ fn should_contain_mmr_digest() {
System::digest().logs,
vec![
beefy_log(ConsensusLog::MmrRoot(
hex!("969d516e5279540ef38e4a710fb0645cab4c3b01e528be7285b85ec9c5fb55c8").into()
hex!("fa0275b19b2565089f7e2377ee73b9050e8d53bce108ef722a3251fd9d371d4b").into()
)),
beefy_log(ConsensusLog::AuthoritiesChange(
ValidatorSet::new(vec![mock_beefy_id(3), mock_beefy_id(4),], 1,).unwrap()
)),
beefy_log(ConsensusLog::MmrRoot(
hex!("8c42b7b040d262f7f2e26abeb61ab0c3c448f60c7f2f19e6ca0035d9bb3ae7e2").into()
hex!("85554fa7d4e863cce3cdce668c1ae82c0174ad37f8d1399284018bec9f9971c3").into()
)),
]
);
@@ -114,10 +114,8 @@ fn should_contain_valid_leaf_data() {
root: hex!("176e73f1bf656478b728e28dd1a7733c98621b8acf830bff585949763dca7a96")
.into(),
},
parachain_heads: hex!(
"ed893c8f8cc87195a5d4d2805b011506322036bcace79642aa3e94ab431e442e"
)
.into(),
leaf_extra: hex!("55b8e9e1cc9f0db7776fac0ca66318ef8acfb8ec26db11e373120583e07ee648")
.to_vec(),
}
);
@@ -138,10 +136,8 @@ fn should_contain_valid_leaf_data() {
root: hex!("9c6b2c1b0d0b25a008e6c882cc7b415f309965c72ad2b944ac0931048ca31cd5")
.into(),
},
parachain_heads: hex!(
"ed893c8f8cc87195a5d4d2805b011506322036bcace79642aa3e94ab431e442e"
)
.into(),
leaf_extra: hex!("55b8e9e1cc9f0db7776fac0ca66318ef8acfb8ec26db11e373120583e07ee648")
.to_vec()
}
);
}